From: yangguo@chromium.org Date: Fri, 11 Apr 2014 10:41:09 +0000 (+0000) Subject: Return MaybeHandle from Invoke. X-Git-Tag: upstream/4.7.83~9681 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=380ae9810e6e176f1425c1e446ec64804357af15;p=platform%2Fupstream%2Fv8.git Return MaybeHandle from Invoke. R=ishell@chromium.org Review URL: https://codereview.chromium.org/231883007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20680 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/accessors.cc b/src/accessors.cc index 8f77af0..3030e5d 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -202,13 +202,12 @@ MaybeObject* Accessors::ArraySetLength(Isolate* isolate, Handle array_handle = Handle::cast(object); - bool has_exception; - Handle uint32_v = - Execution::ToUint32(isolate, value, &has_exception); - if (has_exception) return Failure::Exception(); - Handle number_v = - Execution::ToNumber(isolate, value, &has_exception); - if (has_exception) return Failure::Exception(); + Handle uint32_v; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, uint32_v, Execution::ToUint32(isolate, value)); + Handle number_v; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, number_v, Execution::ToNumber(isolate, value)); if (uint32_v->Number() == number_v->Number()) { Handle result; diff --git a/src/api.cc b/src/api.cc index 90150b0..aebb8d7 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1707,21 +1707,16 @@ Local Script::Run() { ENTER_V8(isolate); i::Logger::TimerEventScope timer_scope( isolate, i::Logger::TimerEventScope::v8_execute); - i::Object* raw_result = NULL; - { - i::HandleScope scope(isolate); - i::Handle fun = - i::Handle(i::JSFunction::cast(*obj), isolate); - EXCEPTION_PREAMBLE(isolate); - i::Handle receiver( - isolate->context()->global_proxy(), isolate); - i::Handle result = i::Execution::Call( - isolate, fun, receiver, 0, NULL, &has_pending_exception); - EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); - raw_result = *result; - } - i::Handle result(raw_result, isolate); - return Utils::ToLocal(result); + i::HandleScope scope(isolate); + i::Handle fun = i::Handle::cast(obj); + EXCEPTION_PREAMBLE(isolate); + i::Handle receiver( + isolate->context()->global_proxy(), isolate); + i::Handle result; + has_pending_exception = !i::Execution::Call( + isolate, fun, receiver, 0, NULL).ToHandle(&result); + EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); + return Utils::ToLocal(scope.CloseAndEscape(result)); } @@ -2040,11 +2035,11 @@ v8::Handle Message::GetStackTrace() const { } -static i::Handle CallV8HeapFunction(const char* name, - i::Handle recv, - int argc, - i::Handle argv[], - bool* has_pending_exception) { +MUST_USE_RESULT static i::MaybeHandle CallV8HeapFunction( + const char* name, + i::Handle recv, + int argc, + i::Handle argv[]) { i::Isolate* isolate = i::Isolate::Current(); i::Handle fmt_str = isolate->factory()->InternalizeUtf8String(name); @@ -2052,21 +2047,18 @@ static i::Handle CallV8HeapFunction(const char* name, i::GlobalObject::GetPropertyNoExceptionThrown( isolate->js_builtins_object(), fmt_str); i::Handle fun = i::Handle::cast(object_fun); - i::Handle value = i::Execution::Call( - isolate, fun, recv, argc, argv, has_pending_exception); - return value; + return i::Execution::Call(isolate, fun, recv, argc, argv); } -static i::Handle CallV8HeapFunction(const char* name, - i::Handle data, - bool* has_pending_exception) { +MUST_USE_RESULT static i::MaybeHandle CallV8HeapFunction( + const char* name, + i::Handle data) { i::Handle argv[] = { data }; return CallV8HeapFunction(name, i::Isolate::Current()->js_builtins_object(), ARRAY_SIZE(argv), - argv, - has_pending_exception); + argv); } @@ -2077,9 +2069,9 @@ int Message::GetLineNumber() const { i::HandleScope scope(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle result = CallV8HeapFunction("GetLineNumber", - Utils::OpenHandle(this), - &has_pending_exception); + i::Handle result; + has_pending_exception = !CallV8HeapFunction( + "GetLineNumber", Utils::OpenHandle(this)).ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, 0); return static_cast(result->Number()); } @@ -2111,10 +2103,9 @@ int Message::GetStartColumn() const { i::HandleScope scope(isolate); i::Handle data_obj = Utils::OpenHandle(this); EXCEPTION_PREAMBLE(isolate); - i::Handle start_col_obj = CallV8HeapFunction( - "GetPositionInLine", - data_obj, - &has_pending_exception); + i::Handle start_col_obj; + has_pending_exception = !CallV8HeapFunction( + "GetPositionInLine", data_obj).ToHandle(&start_col_obj); EXCEPTION_BAILOUT_CHECK(isolate, 0); return static_cast(start_col_obj->Number()); } @@ -2126,10 +2117,9 @@ int Message::GetEndColumn() const { i::HandleScope scope(isolate); i::Handle data_obj = Utils::OpenHandle(this); EXCEPTION_PREAMBLE(isolate); - i::Handle start_col_obj = CallV8HeapFunction( - "GetPositionInLine", - data_obj, - &has_pending_exception); + i::Handle start_col_obj; + has_pending_exception = !CallV8HeapFunction( + "GetPositionInLine", data_obj).ToHandle(&start_col_obj); EXCEPTION_BAILOUT_CHECK(isolate, 0); i::Handle message = i::Handle::cast(data_obj); @@ -2158,9 +2148,9 @@ Local Message::GetSourceLine() const { ENTER_V8(isolate); EscapableHandleScope scope(reinterpret_cast(isolate)); EXCEPTION_PREAMBLE(isolate); - i::Handle result = CallV8HeapFunction("GetSourceLine", - Utils::OpenHandle(this), - &has_pending_exception); + i::Handle result; + has_pending_exception = !CallV8HeapFunction( + "GetSourceLine", Utils::OpenHandle(this)).ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, Local()); if (result->IsString()) { return scope.Escape(Utils::ToLocal(i::Handle::cast(result))); @@ -2557,7 +2547,8 @@ Local Value::ToString() const { LOG_API(isolate, "ToString"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - str = i::Execution::ToString(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToString( + isolate, obj).ToHandle(&str); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(str); @@ -2574,7 +2565,8 @@ Local Value::ToDetailString() const { LOG_API(isolate, "ToDetailString"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToDetailString( + isolate, obj).ToHandle(&str); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(str); @@ -2591,7 +2583,8 @@ Local Value::ToObject() const { LOG_API(isolate, "ToObject"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - val = i::Execution::ToObject(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToObject( + isolate, obj).ToHandle(&val); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(val); @@ -2623,7 +2616,8 @@ Local Value::ToNumber() const { LOG_API(isolate, "ToNumber"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToNumber( + isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(num); @@ -2640,7 +2634,8 @@ Local Value::ToInteger() const { LOG_API(isolate, "ToInteger"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToInteger( + isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(num); @@ -2850,7 +2845,8 @@ double Value::NumberValue() const { LOG_API(isolate, "NumberValue"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToNumber( + isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); } return num->Number(); @@ -2867,7 +2863,8 @@ int64_t Value::IntegerValue() const { LOG_API(isolate, "IntegerValue"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToInteger( + isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, 0); } if (num->IsSmi()) { @@ -2888,7 +2885,7 @@ Local Value::ToInt32() const { LOG_API(isolate, "ToInt32"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - num = i::Execution::ToInt32(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(num); @@ -2905,7 +2902,8 @@ Local Value::ToUint32() const { LOG_API(isolate, "ToUInt32"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - num = i::Execution::ToUint32(isolate, obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToUint32( + isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, Local()); } return ToApiHandle(num); @@ -2922,8 +2920,9 @@ Local Value::ToArrayIndex() const { LOG_API(isolate, "ToArrayIndex"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle string_obj = - i::Execution::ToString(isolate, obj, &has_pending_exception); + i::Handle string_obj; + has_pending_exception = !i::Execution::ToString( + isolate, obj).ToHandle(&string_obj); EXCEPTION_BAILOUT_CHECK(isolate, Local()); i::Handle str = i::Handle::cast(string_obj); uint32_t index; @@ -2949,8 +2948,8 @@ int32_t Value::Int32Value() const { LOG_API(isolate, "Int32Value (slow)"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle num = - i::Execution::ToInt32(isolate, obj, &has_pending_exception); + i::Handle num; + has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, 0); if (num->IsSmi()) { return i::Smi::cast(*num)->value(); @@ -2980,9 +2979,9 @@ bool Value::Equals(Handle that) const { } i::Handle args[] = { other }; EXCEPTION_PREAMBLE(isolate); - i::Handle result = - CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, - &has_pending_exception); + i::Handle result; + has_pending_exception = !CallV8HeapFunction( + "EQUALS", obj, ARRAY_SIZE(args), args).ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, false); return *result == i::Smi::FromInt(i::EQUAL); } @@ -3044,8 +3043,9 @@ uint32_t Value::Uint32Value() const { LOG_API(isolate, "Uint32Value"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle num = - i::Execution::ToUint32(isolate, obj, &has_pending_exception); + i::Handle num; + has_pending_exception = !i::Execution::ToUint32( + isolate, obj).ToHandle(&num); EXCEPTION_BAILOUT_CHECK(isolate, 0); if (num->IsSmi()) { return i::Smi::cast(*num)->value(); @@ -3189,7 +3189,8 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle key) { i::Handle key_obj = Utils::OpenHandle(*key); if (!key_obj->IsName()) { EXCEPTION_PREAMBLE(isolate); - key_obj = i::Execution::ToString(isolate, key_obj, &has_pending_exception); + has_pending_exception = !i::Execution::ToString( + isolate, key_obj).ToHandle(&key_obj); EXCEPTION_BAILOUT_CHECK(isolate, static_cast(NONE)); } i::Handle key_name = i::Handle::cast(key_obj); @@ -3919,15 +3920,17 @@ Local Object::CallAsFunction(v8::Handle recv, fun = i::Handle::cast(obj); } else { EXCEPTION_PREAMBLE(isolate); - i::Handle delegate = i::Execution::TryGetFunctionDelegate( - isolate, obj, &has_pending_exception); + i::Handle delegate; + has_pending_exception = !i::Execution::TryGetFunctionDelegate( + isolate, obj).ToHandle(&delegate); EXCEPTION_BAILOUT_CHECK(isolate, Local()); fun = i::Handle::cast(delegate); recv_obj = obj; } EXCEPTION_PREAMBLE(isolate); - i::Handle returned = i::Execution::Call( - isolate, fun, recv_obj, argc, args, &has_pending_exception, true); + i::Handle returned; + has_pending_exception = !i::Execution::Call( + isolate, fun, recv_obj, argc, args, true).ToHandle(&returned); EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); return Utils::ToLocal(scope.CloseAndEscape(returned)); } @@ -3949,21 +3952,24 @@ Local Object::CallAsConstructor(int argc, if (obj->IsJSFunction()) { i::Handle fun = i::Handle::cast(obj); EXCEPTION_PREAMBLE(isolate); - i::Handle returned = - i::Execution::New(fun, argc, args, &has_pending_exception); + i::Handle returned; + has_pending_exception = !i::Execution::New( + fun, argc, args).ToHandle(&returned); EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); return Utils::ToLocal(scope.CloseAndEscape( i::Handle::cast(returned))); } EXCEPTION_PREAMBLE(isolate); - i::Handle delegate = i::Execution::TryGetConstructorDelegate( - isolate, obj, &has_pending_exception); + i::Handle delegate; + has_pending_exception = !i::Execution::TryGetConstructorDelegate( + isolate, obj).ToHandle(&delegate); EXCEPTION_BAILOUT_CHECK(isolate, Local()); if (!delegate->IsUndefined()) { i::Handle fun = i::Handle::cast(delegate); EXCEPTION_PREAMBLE(isolate); - i::Handle returned = i::Execution::Call( - isolate, fun, obj, argc, args, &has_pending_exception); + i::Handle returned; + has_pending_exception = !i::Execution::Call( + isolate, fun, obj, argc, args).ToHandle(&returned); EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); ASSERT(!delegate->IsUndefined()); return Utils::ToLocal(scope.CloseAndEscape(returned)); @@ -4004,8 +4010,9 @@ Local Function::NewInstance(int argc, STATIC_ASSERT(sizeof(v8::Handle) == sizeof(i::Object**)); i::Handle* args = reinterpret_cast*>(argv); EXCEPTION_PREAMBLE(isolate); - i::Handle returned = - i::Execution::New(function, argc, args, &has_pending_exception); + i::Handle returned; + has_pending_exception = !i::Execution::New( + function, argc, args).ToHandle(&returned); EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); return scope.Escape(Utils::ToLocal(i::Handle::cast(returned))); } @@ -4019,21 +4026,17 @@ Local Function::Call(v8::Handle recv, int argc, ENTER_V8(isolate); i::Logger::TimerEventScope timer_scope( isolate, i::Logger::TimerEventScope::v8_execute); - i::Object* raw_result = NULL; - { - i::HandleScope scope(isolate); - i::Handle fun = Utils::OpenHandle(this); - i::Handle recv_obj = Utils::OpenHandle(*recv); - STATIC_ASSERT(sizeof(v8::Handle) == sizeof(i::Object**)); - i::Handle* args = reinterpret_cast*>(argv); - EXCEPTION_PREAMBLE(isolate); - i::Handle returned = i::Execution::Call( - isolate, fun, recv_obj, argc, args, &has_pending_exception, true); - EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); - raw_result = *returned; - } - i::Handle result(raw_result, isolate); - return Utils::ToLocal(result); + i::HandleScope scope(isolate); + i::Handle fun = Utils::OpenHandle(this); + i::Handle recv_obj = Utils::OpenHandle(*recv); + STATIC_ASSERT(sizeof(v8::Handle) == sizeof(i::Object**)); + i::Handle* args = reinterpret_cast*>(argv); + EXCEPTION_PREAMBLE(isolate); + i::Handle returned; + has_pending_exception = !i::Execution::Call( + isolate, fun, recv_obj, argc, args, true).ToHandle(&returned); + EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); + return Utils::ToLocal(scope.CloseAndEscape(returned)); } @@ -5306,9 +5309,9 @@ Local ObjectTemplate::NewInstance() { LOG_API(isolate, "ObjectTemplate::NewInstance"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle obj = - i::Execution::InstantiateObject(Utils::OpenHandle(this), - &has_pending_exception); + i::Handle obj; + has_pending_exception = !i::Execution::InstantiateObject( + Utils::OpenHandle(this)).ToHandle(&obj); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(i::Handle::cast(obj)); } @@ -5321,9 +5324,9 @@ Local FunctionTemplate::GetFunction() { LOG_API(isolate, "FunctionTemplate::GetFunction"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle obj = - i::Execution::InstantiateFunction(Utils::OpenHandle(this), - &has_pending_exception); + i::Handle obj; + has_pending_exception = !i::Execution::InstantiateFunction( + Utils::OpenHandle(this)).ToHandle(&obj); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(i::Handle::cast(obj)); } @@ -5705,8 +5708,9 @@ Local v8::Date::New(Isolate* isolate, double time) { } ENTER_V8(i_isolate); EXCEPTION_PREAMBLE(i_isolate); - i::Handle obj = - i::Execution::NewDate(i_isolate, time, &has_pending_exception); + i::Handle obj; + has_pending_exception = !i::Execution::NewDate( + i_isolate, time).ToHandle(&obj); EXCEPTION_BAILOUT_CHECK(i_isolate, Local()); return Utils::ToLocal(obj); } @@ -5766,10 +5770,10 @@ Local v8::RegExp::New(Handle pattern, LOG_API(isolate, "RegExp::New"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle obj = i::Execution::NewJSRegExp( + i::Handle obj; + has_pending_exception = !i::Execution::NewJSRegExp( Utils::OpenHandle(*pattern), - RegExpFlagsToString(flags), - &has_pending_exception); + RegExpFlagsToString(flags)).ToHandle(&obj); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(i::Handle::cast(obj)); } @@ -5853,14 +5857,14 @@ bool Value::IsPromise() const { ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); i::Handle argv[] = { obj }; - i::Handle b = i::Execution::Call( + i::Handle b; + has_pending_exception = !i::Execution::Call( isolate, handle( isolate->context()->global_object()->native_context()->is_promise()), isolate->factory()->undefined_value(), ARRAY_SIZE(argv), argv, - &has_pending_exception, - false); + false).ToHandle(&b); EXCEPTION_BAILOUT_CHECK(isolate, false); return b->BooleanValue(); } @@ -5871,14 +5875,14 @@ Local Promise::Resolver::New(Isolate* v8_isolate) { LOG_API(isolate, "Promise::Resolver::New"); ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); - i::Handle result = i::Execution::Call( + i::Handle result; + has_pending_exception = !i::Execution::Call( isolate, handle(isolate->context()->global_object()->native_context()-> promise_create()), isolate->factory()->undefined_value(), 0, NULL, - &has_pending_exception, - false); + false).ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Local::Cast(Utils::ToLocal(result)); } @@ -5897,14 +5901,13 @@ void Promise::Resolver::Resolve(Handle value) { ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); i::Handle argv[] = { promise, Utils::OpenHandle(*value) }; - i::Execution::Call( + has_pending_exception = i::Execution::Call( isolate, handle(isolate->context()->global_object()->native_context()-> promise_resolve()), isolate->factory()->undefined_value(), ARRAY_SIZE(argv), argv, - &has_pending_exception, - false); + false).is_null(); EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;); } @@ -5916,14 +5919,13 @@ void Promise::Resolver::Reject(Handle value) { ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); i::Handle argv[] = { promise, Utils::OpenHandle(*value) }; - i::Execution::Call( + has_pending_exception = i::Execution::Call( isolate, handle(isolate->context()->global_object()->native_context()-> promise_reject()), isolate->factory()->undefined_value(), ARRAY_SIZE(argv), argv, - &has_pending_exception, - false); + false).is_null(); EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;); } @@ -5935,14 +5937,14 @@ Local Promise::Chain(Handle handler) { ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); i::Handle argv[] = { Utils::OpenHandle(*handler) }; - i::Handle result = i::Execution::Call( + i::Handle result; + has_pending_exception = !i::Execution::Call( isolate, handle(isolate->context()->global_object()->native_context()-> promise_chain()), promise, ARRAY_SIZE(argv), argv, - &has_pending_exception, - false); + false).ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Local::Cast(Utils::ToLocal(result)); } @@ -5955,14 +5957,14 @@ Local Promise::Catch(Handle handler) { ENTER_V8(isolate); EXCEPTION_PREAMBLE(isolate); i::Handle argv[] = { Utils::OpenHandle(*handler) }; - i::Handle result = i::Execution::Call( + i::Handle result; + has_pending_exception = !i::Execution::Call( isolate, handle(isolate->context()->global_object()->native_context()-> promise_catch()), promise, ARRAY_SIZE(argv), argv, - &has_pending_exception, - false); + false).ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Local::Cast(Utils::ToLocal(result)); } @@ -6971,17 +6973,17 @@ Local Debug::Call(v8::Handle fun, if (!isolate->IsInitialized()) return Local(); ON_BAILOUT(isolate, "v8::Debug::Call()", return Local()); ENTER_V8(isolate); - i::Handle result; + i::MaybeHandle maybe_result; EXCEPTION_PREAMBLE(isolate); if (data.IsEmpty()) { - result = isolate->debugger()->Call(Utils::OpenHandle(*fun), - isolate->factory()->undefined_value(), - &has_pending_exception); + maybe_result = isolate->debugger()->Call( + Utils::OpenHandle(*fun), isolate->factory()->undefined_value()); } else { - result = isolate->debugger()->Call(Utils::OpenHandle(*fun), - Utils::OpenHandle(*data), - &has_pending_exception); + maybe_result = isolate->debugger()->Call( + Utils::OpenHandle(*fun), Utils::OpenHandle(*data)); } + i::Handle result; + has_pending_exception = !maybe_result.ToHandle(&result); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(result); } diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 4cfebad..4e5a2a2 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1508,10 +1508,8 @@ bool Genesis::CompileScriptCached(Isolate* isolate, ? top_context->builtins() : top_context->global_object(), isolate); - bool has_pending_exception; - Execution::Call(isolate, fun, receiver, 0, NULL, &has_pending_exception); - if (has_pending_exception) return false; - return true; + return !Execution::Call( + isolate, fun, receiver, 0, NULL).is_null(); } @@ -2401,10 +2399,10 @@ bool Genesis::ConfigureApiObject(Handle object, ASSERT(FunctionTemplateInfo::cast(object_template->constructor()) ->IsTemplateFor(object->map()));; - bool pending_exception = false; - Handle obj = - Execution::InstantiateObject(object_template, &pending_exception); - if (pending_exception) { + MaybeHandle maybe_obj = + Execution::InstantiateObject(object_template); + Handle obj; + if (!maybe_obj.ToHandle(&obj)) { ASSERT(isolate()->has_pending_exception()); isolate()->clear_pending_exception(); return false; diff --git a/src/builtins.cc b/src/builtins.cc index 054963d..3f81086 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -381,14 +381,14 @@ MUST_USE_RESULT static MaybeObject* CallJsBuiltin( for (int i = 0; i < argc; ++i) { argv[i] = args.at(i + 1); } - bool pending_exception; - Handle result = Execution::Call(isolate, - function, - args.receiver(), - argc, - argv.start(), - &pending_exception); - if (pending_exception) return Failure::Exception(); + Handle result; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, result, + Execution::Call(isolate, + function, + args.receiver(), + argc, + argv.start())); return *result; } @@ -1174,15 +1174,13 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper( Handle function = args.called_function(); ASSERT(function->shared()->IsApiFunction()); - FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data(); + Handle fun_data( + function->shared()->get_api_func_data(), isolate); if (is_construct) { - Handle desc(fun_data, isolate); - bool pending_exception = false; - isolate->factory()->ConfigureInstance( - desc, Handle::cast(args.receiver()), &pending_exception); - ASSERT(isolate->has_pending_exception() == pending_exception); - if (pending_exception) return Failure::Exception(); - fun_data = *desc; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, fun_data, + isolate->factory()->ConfigureInstance( + fun_data, Handle::cast(args.receiver()))); } SharedFunctionInfo* shared = function->shared(); @@ -1194,7 +1192,7 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper( } } - Object* raw_holder = TypeCheck(heap, args.length(), &args[0], fun_data); + Object* raw_holder = TypeCheck(heap, args.length(), &args[0], *fun_data); if (raw_holder->IsNull()) { // This function cannot be called with the given receiver. Abort! diff --git a/src/debug-debugger.js b/src/debug-debugger.js index b159ae3..d759fe5 100644 --- a/src/debug-debugger.js +++ b/src/debug-debugger.js @@ -1217,31 +1217,6 @@ CompileEvent.prototype.toJSONProtocol = function() { }; -function MakeNewFunctionEvent(func) { - return new NewFunctionEvent(func); -} - - -function NewFunctionEvent(func) { - this.func = func; -} - - -NewFunctionEvent.prototype.eventType = function() { - return Debug.DebugEvent.NewFunction; -}; - - -NewFunctionEvent.prototype.name = function() { - return this.func.name; -}; - - -NewFunctionEvent.prototype.setBreakPoint = function(p) { - Debug.setBreakPoint(this.func, p || 0); -}; - - function MakeScriptCollectedEvent(exec_state, id) { return new ScriptCollectedEvent(exec_state, id); } diff --git a/src/debug.cc b/src/debug.cc index 75c7282..a1a648b 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -774,19 +774,19 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) { } // Execute the shared function in the debugger context. - bool caught_exception; Handle function = factory->NewFunctionFromSharedFunctionInfo(function_info, context); - Handle exception = + Handle exception; + MaybeHandle result = Execution::TryCall(function, Handle(context->global_object(), isolate), 0, NULL, - &caught_exception); + &exception); // Check for caught exceptions. - if (caught_exception) { + if (result.is_null()) { ASSERT(!isolate->has_pending_exception()); MessageLocation computed_location; isolate->ComputeLocation(&computed_location); @@ -1125,22 +1125,18 @@ bool Debug::CheckBreakPoint(Handle break_point_object) { Handle break_id = factory->NewNumberFromInt(Debug::break_id()); // Call HandleBreakPointx. - bool caught_exception; Handle argv[] = { break_id, break_point_object }; - Handle result = Execution::TryCall(check_break_point, - isolate_->js_builtins_object(), - ARRAY_SIZE(argv), - argv, - &caught_exception); - - // If exception or non boolean result handle as not triggered - if (caught_exception || !result->IsBoolean()) { - return false; - } + Handle result; + ASSIGN_RETURN_ON_EXCEPTION_VALUE( + isolate_, result, + Execution::TryCall(check_break_point, + isolate_->js_builtins_object(), + ARRAY_SIZE(argv), + argv), + false); // Return whether the break point is triggered. - ASSERT(!result.is_null()); - return (*result)->IsTrue(); + return result->IsTrue(); } @@ -2466,10 +2462,11 @@ void Debug::ClearMirrorCache() { Handle fun = GlobalObject::GetPropertyNoExceptionThrown( isolate_->global_object(), function_name); ASSERT(fun->IsJSFunction()); - bool caught_exception; - Execution::TryCall(Handle::cast(fun), + Execution::TryCall( + Handle::cast(fun), Handle(Debug::debug_context()->global_object()), - 0, NULL, &caught_exception); + 0, + NULL); } @@ -2590,10 +2587,10 @@ Debugger::Debugger(Isolate* isolate) Debugger::~Debugger() {} -Handle Debugger::MakeJSObject(Vector constructor_name, - int argc, - Handle argv[], - bool* caught_exception) { +MaybeHandle Debugger::MakeJSObject( + Vector constructor_name, + int argc, + Handle argv[]) { ASSERT(isolate_->context() == *isolate_->debug()->debug_context()); // Create the execution state object. @@ -2603,99 +2600,72 @@ Handle Debugger::MakeJSObject(Vector constructor_name, Handle constructor = GlobalObject::GetPropertyNoExceptionThrown( isolate_->global_object(), constructor_str); ASSERT(constructor->IsJSFunction()); - if (!constructor->IsJSFunction()) { - *caught_exception = true; - return isolate_->factory()->undefined_value(); - } - Handle js_object = Execution::TryCall( + if (!constructor->IsJSFunction()) return MaybeHandle(); + return Execution::TryCall( Handle::cast(constructor), Handle(isolate_->debug()->debug_context()->global_object()), argc, - argv, - caught_exception); - return js_object; + argv); } -Handle Debugger::MakeExecutionState(bool* caught_exception) { +MaybeHandle Debugger::MakeExecutionState() { // Create the execution state object. Handle break_id = isolate_->factory()->NewNumberFromInt( isolate_->debug()->break_id()); Handle argv[] = { break_id }; - return MakeJSObject(CStrVector("MakeExecutionState"), - ARRAY_SIZE(argv), - argv, - caught_exception); + return MakeJSObject(CStrVector("MakeExecutionState"), ARRAY_SIZE(argv), argv); } -Handle Debugger::MakeBreakEvent(Handle exec_state, - Handle break_points_hit, - bool* caught_exception) { +MaybeHandle Debugger::MakeBreakEvent(Handle break_points_hit) { + Handle exec_state; + ASSIGN_RETURN_ON_EXCEPTION( + isolate_, exec_state, MakeExecutionState(), Object); // Create the new break event object. Handle argv[] = { exec_state, break_points_hit }; - return MakeJSObject(CStrVector("MakeBreakEvent"), - ARRAY_SIZE(argv), - argv, - caught_exception); + return MakeJSObject(CStrVector("MakeBreakEvent"), ARRAY_SIZE(argv), argv); } -Handle Debugger::MakeExceptionEvent(Handle exec_state, - Handle exception, - bool uncaught, - bool* caught_exception) { - Factory* factory = isolate_->factory(); +MaybeHandle Debugger::MakeExceptionEvent(Handle exception, + bool uncaught) { + Handle exec_state; + ASSIGN_RETURN_ON_EXCEPTION( + isolate_, exec_state, MakeExecutionState(), Object); // Create the new exception event object. Handle argv[] = { exec_state, exception, - factory->ToBoolean(uncaught) }; - return MakeJSObject(CStrVector("MakeExceptionEvent"), - ARRAY_SIZE(argv), - argv, - caught_exception); -} - - -Handle Debugger::MakeNewFunctionEvent(Handle function, - bool* caught_exception) { - // Create the new function event object. - Handle argv[] = { function }; - return MakeJSObject(CStrVector("MakeNewFunctionEvent"), - ARRAY_SIZE(argv), - argv, - caught_exception); + isolate_->factory()->ToBoolean(uncaught) }; + return MakeJSObject(CStrVector("MakeExceptionEvent"), ARRAY_SIZE(argv), argv); } -Handle Debugger::MakeCompileEvent(Handle