Reviewers: Michael Achenbach,
Description:
Revert "Make v8::TryCatch able to consume natively thrown exceptions
(again)."
TBR=machenb...@chromium.org
Please review this at https://codereview.chromium.org/296133013/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+11, -73 lines):
M src/api.cc
M src/isolate.h
M src/isolate.cc
M test/cctest/test-api.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
66692b8dd9ea4e656a32d00333633e561a4e248d..c33365b931fab61d8513b050df60321fac395877
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1830,12 +1830,6 @@ v8::TryCatch::~TryCatch() {
reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
ASSERT(!isolate_->thread_local_top()->rethrowing_message_);
} else {
- if (HasCaught() && isolate_->has_scheduled_exception()) {
- // If an exception was caught but is still scheduled because no API
call
- // promoted it, then it is canceled to prevent it from being
propagated.
- // Note that this will not cancel termination exceptions.
- isolate_->CancelScheduledExceptionFromTryCatch(this);
- }
isolate_->UnregisterTryCatchHandler(this);
v8::internal::SimulatorStack::UnregisterCTryCatch();
}
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
08948fcc3fde66856a2d8ad7bd100f6281462455..9572046a40e01274aeafa9b626ed6c77b48130c7
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -908,15 +908,6 @@ void
Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) {
}
-void Isolate::CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler) {
- ASSERT(has_scheduled_exception());
- if (scheduled_exception() == handler->exception_) {
- ASSERT(scheduled_exception() != heap()->termination_exception());
- clear_scheduled_exception();
- }
-}
-
-
Object* Isolate::PromoteScheduledException() {
Object* thrown = scheduled_exception();
clear_scheduled_exception();
@@ -1222,7 +1213,8 @@ void Isolate::ReportPendingMessages() {
PropagatePendingExceptionToExternalTryCatch();
HandleScope scope(this);
- if (thread_local_top_.pending_exception_ ==
heap()->termination_exception()) {
+ if (thread_local_top_.pending_exception_ ==
+ heap()->termination_exception()) {
// Do nothing: if needed, the exception has been already propagated to
// v8::TryCatch.
} else {
@@ -1759,7 +1751,8 @@ void
Isolate::PropagatePendingExceptionToExternalTryCatch() {
if (!external_caught) return;
- if (thread_local_top_.pending_exception_ ==
heap()->termination_exception()) {
+ if (thread_local_top_.pending_exception_ ==
+ heap()->termination_exception()) {
try_catch_handler()->can_continue_ = false;
try_catch_handler()->has_terminated_ = true;
try_catch_handler()->exception_ = heap()->null_value();
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
ca2c23ea74d70f4eb697286dcc77c09e65b9567b..382cb5dbb13156ab5d8b886bbd1293bd9652dd76
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -735,8 +735,6 @@ class Isolate {
// Re-set pending message, script and positions reported to the TryCatch
// back to the TLS for re-use when rethrowing.
void RestorePendingMessageFromTryCatch(v8::TryCatch* handler);
- // Un-schedule an exception that was caught by a TryCatch handler.
- void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler);
void ReportPendingMessages();
// Return pending location if any or unfilled structure.
MessageLocation GetMessageLocation();
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
003a51134dc3fa35d9be4017fa1702171c76ee0d..e2f746209d84ae9061fae0a09ed9f4a59ad7aa76
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -5343,28 +5343,15 @@ THREADED_TEST(TryCatchAndFinally) {
}
-static void TryCatchNested1Helper(int depth) {
+static void TryCatchNestedHelper(int depth) {
if (depth > 0) {
v8::TryCatch try_catch;
try_catch.SetVerbose(true);
- TryCatchNested1Helper(depth - 1);
+ TryCatchNestedHelper(depth - 1);
CHECK(try_catch.HasCaught());
try_catch.ReThrow();
} else {
- CcTest::isolate()->ThrowException(v8_str("E1"));
- }
-}
-
-
-static void TryCatchNested2Helper(int depth) {
- if (depth > 0) {
- v8::TryCatch try_catch;
- try_catch.SetVerbose(true);
- TryCatchNested2Helper(depth - 1);
- CHECK(try_catch.HasCaught());
- try_catch.ReThrow();
- } else {
- CompileRun("throw 'E2';");
+ CcTest::isolate()->ThrowException(v8_str("back"));
}
}
@@ -5373,22 +5360,10 @@ TEST(TryCatchNested) {
v8::V8::Initialize();
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
-
- {
- // Test nested try-catch with a native throw in the end.
- v8::TryCatch try_catch;
- TryCatchNested1Helper(5);
- CHECK(try_catch.HasCaught());
- CHECK_EQ(0,
strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E1"));
- }
-
- {
- // Test nested try-catch with a JavaScript throw in the end.
- v8::TryCatch try_catch;
- TryCatchNested2Helper(5);
- CHECK(try_catch.HasCaught());
- CHECK_EQ(0,
strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E2"));
- }
+ v8::TryCatch try_catch;
+ TryCatchNestedHelper(5);
+ CHECK(try_catch.HasCaught());
+ CHECK_EQ(0,
strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back"));
}
@@ -5434,28 +5409,6 @@ TEST(TryCatchMixedNesting) {
}
-void TryCatchNativeHelper(const v8::FunctionCallbackInfo<v8::Value>& args)
{
- ApiTestFuzzer::Fuzz();
- v8::TryCatch try_catch;
- args.GetIsolate()->ThrowException(v8_str("boom"));
- CHECK(try_catch.HasCaught());
-}
-
-
-TEST(TryCatchNative) {
- v8::Isolate* isolate = CcTest::isolate();
- v8::HandleScope scope(isolate);
- v8::V8::Initialize();
- v8::TryCatch try_catch;
- Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
- templ->Set(v8_str("TryCatchNativeHelper"),
- v8::FunctionTemplate::New(isolate, TryCatchNativeHelper));
- LocalContext context(0, templ);
- CompileRun("TryCatchNativeHelper();");
- CHECK(!try_catch.HasCaught());
-}
-
-
THREADED_TEST(Equality) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.