Revert "Make v8::TryCatch able to consume natively thrown exceptions"

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/293123003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21432 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3d0bf69c
...@@ -883,7 +883,7 @@ void Isolate::ScheduleThrow(Object* exception) { ...@@ -883,7 +883,7 @@ void Isolate::ScheduleThrow(Object* exception) {
// When scheduling a throw we first throw the exception to get the // When scheduling a throw we first throw the exception to get the
// error reporting if it is uncaught before rescheduling it. // error reporting if it is uncaught before rescheduling it.
Throw(exception); Throw(exception);
OptionalRescheduleException(false); PropagatePendingExceptionToExternalTryCatch();
if (has_pending_exception()) { if (has_pending_exception()) {
thread_local_top()->scheduled_exception_ = pending_exception(); thread_local_top()->scheduled_exception_ = pending_exception();
thread_local_top()->external_caught_exception_ = false; thread_local_top()->external_caught_exception_ = false;
......
...@@ -5343,28 +5343,15 @@ THREADED_TEST(TryCatchAndFinally) { ...@@ -5343,28 +5343,15 @@ THREADED_TEST(TryCatchAndFinally) {
} }
static void TryCatchNested1Helper(int depth) { static void TryCatchNestedHelper(int depth) {
if (depth > 0) { if (depth > 0) {
v8::TryCatch try_catch; v8::TryCatch try_catch;
try_catch.SetVerbose(true); try_catch.SetVerbose(true);
TryCatchNested1Helper(depth - 1); TryCatchNestedHelper(depth - 1);
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
try_catch.ReThrow(); try_catch.ReThrow();
} else { } else {
CcTest::isolate()->ThrowException(v8_str("E1")); CcTest::isolate()->ThrowException(v8_str("back"));
}
}
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';");
} }
} }
...@@ -5373,22 +5360,10 @@ TEST(TryCatchNested) { ...@@ -5373,22 +5360,10 @@ TEST(TryCatchNested) {
v8::V8::Initialize(); v8::V8::Initialize();
LocalContext context; LocalContext context;
v8::HandleScope scope(context->GetIsolate()); 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; v8::TryCatch try_catch;
TryCatchNested2Helper(5); TryCatchNestedHelper(5);
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E2")); CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "back"));
}
} }
...@@ -5434,28 +5409,6 @@ TEST(TryCatchMixedNesting) { ...@@ -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) { THREADED_TEST(Equality) {
LocalContext context; LocalContext context;
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
...@@ -13010,29 +12963,22 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { ...@@ -13010,29 +12963,22 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
Local<Value> result = instance->GetRealNamedProperty(v8_str("f")); Local<Value> result = instance->GetRealNamedProperty(v8_str("f"));
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
try_catch.Reset(); try_catch.Reset();
// TODO(mstarzinger): The exception is propagated directly to the TryCatch CHECK(result.IsEmpty());
// scope and is never scheduled, because there is no real JavaScript frame
// between here and the ThrowingGetter. Fixing this will make the result a
// proper empty handle again.
CHECK(result->IsUndefined());
result = another->GetRealNamedProperty(v8_str("f")); result = another->GetRealNamedProperty(v8_str("f"));
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
try_catch.Reset(); try_catch.Reset();
// TODO(mstarzinger): Likewise. CHECK(result.IsEmpty());
CHECK(result->IsUndefined());
result = another->GetRealNamedPropertyInPrototypeChain(v8_str("f")); result = another->GetRealNamedPropertyInPrototypeChain(v8_str("f"));
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
try_catch.Reset(); try_catch.Reset();
// TODO(mstarzinger): Likewise. CHECK(result.IsEmpty());
CHECK(result->IsUndefined());
result = another->Get(v8_str("f")); result = another->Get(v8_str("f"));
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
try_catch.Reset(); try_catch.Reset();
// TODO(mstarzinger): Likewise. CHECK(result.IsEmpty());
CHECK(result->IsUndefined());
result = with_js_getter->GetRealNamedProperty(v8_str("f")); result = with_js_getter->GetRealNamedProperty(v8_str("f"));
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment