Handle<JSArray> array_handle = Handle<JSArray>::cast(object);
- bool has_exception;
- Handle<Object> uint32_v =
- Execution::ToUint32(isolate, value, &has_exception);
- if (has_exception) return Failure::Exception();
- Handle<Object> number_v =
- Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return Failure::Exception();
+ Handle<Object> uint32_v;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, uint32_v, Execution::ToUint32(isolate, value));
+ Handle<Object> number_v;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, number_v, Execution::ToNumber(isolate, value));
if (uint32_v->Number() == number_v->Number()) {
Handle<Object> result;
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<i::JSFunction> fun =
- i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate);
- EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> receiver(
- isolate->context()->global_proxy(), isolate);
- i::Handle<i::Object> result = i::Execution::Call(
- isolate, fun, receiver, 0, NULL, &has_pending_exception);
- EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
- raw_result = *result;
- }
- i::Handle<i::Object> result(raw_result, isolate);
- return Utils::ToLocal(result);
+ i::HandleScope scope(isolate);
+ i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj);
+ EXCEPTION_PREAMBLE(isolate);
+ i::Handle<i::Object> receiver(
+ isolate->context()->global_proxy(), isolate);
+ i::Handle<i::Object> result;
+ has_pending_exception = !i::Execution::Call(
+ isolate, fun, receiver, 0, NULL).ToHandle(&result);
+ EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
+ return Utils::ToLocal(scope.CloseAndEscape(result));
}
}
-static i::Handle<i::Object> CallV8HeapFunction(const char* name,
- i::Handle<i::Object> recv,
- int argc,
- i::Handle<i::Object> argv[],
- bool* has_pending_exception) {
+MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction(
+ const char* name,
+ i::Handle<i::Object> recv,
+ int argc,
+ i::Handle<i::Object> argv[]) {
i::Isolate* isolate = i::Isolate::Current();
i::Handle<i::String> fmt_str =
isolate->factory()->InternalizeUtf8String(name);
i::GlobalObject::GetPropertyNoExceptionThrown(
isolate->js_builtins_object(), fmt_str);
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun);
- i::Handle<i::Object> 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<i::Object> CallV8HeapFunction(const char* name,
- i::Handle<i::Object> data,
- bool* has_pending_exception) {
+MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction(
+ const char* name,
+ i::Handle<i::Object> data) {
i::Handle<i::Object> argv[] = { data };
return CallV8HeapFunction(name,
i::Isolate::Current()->js_builtins_object(),
ARRAY_SIZE(argv),
- argv,
- has_pending_exception);
+ argv);
}
i::HandleScope scope(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
- Utils::OpenHandle(this),
- &has_pending_exception);
+ i::Handle<i::Object> result;
+ has_pending_exception = !CallV8HeapFunction(
+ "GetLineNumber", Utils::OpenHandle(this)).ToHandle(&result);
EXCEPTION_BAILOUT_CHECK(isolate, 0);
return static_cast<int>(result->Number());
}
i::HandleScope scope(isolate);
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
- "GetPositionInLine",
- data_obj,
- &has_pending_exception);
+ i::Handle<i::Object> start_col_obj;
+ has_pending_exception = !CallV8HeapFunction(
+ "GetPositionInLine", data_obj).ToHandle(&start_col_obj);
EXCEPTION_BAILOUT_CHECK(isolate, 0);
return static_cast<int>(start_col_obj->Number());
}
i::HandleScope scope(isolate);
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
- "GetPositionInLine",
- data_obj,
- &has_pending_exception);
+ i::Handle<i::Object> start_col_obj;
+ has_pending_exception = !CallV8HeapFunction(
+ "GetPositionInLine", data_obj).ToHandle(&start_col_obj);
EXCEPTION_BAILOUT_CHECK(isolate, 0);
i::Handle<i::JSMessageObject> message =
i::Handle<i::JSMessageObject>::cast(data_obj);
ENTER_V8(isolate);
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
- Utils::OpenHandle(this),
- &has_pending_exception);
+ i::Handle<i::Object> result;
+ has_pending_exception = !CallV8HeapFunction(
+ "GetSourceLine", Utils::OpenHandle(this)).ToHandle(&result);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>());
if (result->IsString()) {
return scope.Escape(Utils::ToLocal(i::Handle<i::String>::cast(result)));
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<String>());
}
return ToApiHandle<String>(str);
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<String>());
}
return ToApiHandle<String>(str);
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<v8::Object>());
}
return ToApiHandle<Object>(val);
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<Number>());
}
return ToApiHandle<Number>(num);
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<Integer>());
}
return ToApiHandle<Integer>(num);
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();
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()) {
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<Int32>());
}
return ToApiHandle<Int32>(num);
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<Uint32>());
}
return ToApiHandle<Uint32>(num);
LOG_API(isolate, "ToArrayIndex");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> string_obj =
- i::Execution::ToString(isolate, obj, &has_pending_exception);
+ i::Handle<i::Object> string_obj;
+ has_pending_exception = !i::Execution::ToString(
+ isolate, obj).ToHandle(&string_obj);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj);
uint32_t index;
LOG_API(isolate, "Int32Value (slow)");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> num =
- i::Execution::ToInt32(isolate, obj, &has_pending_exception);
+ i::Handle<i::Object> 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();
}
i::Handle<i::Object> args[] = { other };
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> result =
- CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args,
- &has_pending_exception);
+ i::Handle<i::Object> 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);
}
LOG_API(isolate, "Uint32Value");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> num =
- i::Execution::ToUint32(isolate, obj, &has_pending_exception);
+ i::Handle<i::Object> 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();
i::Handle<i::Object> 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<PropertyAttribute>(NONE));
}
i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
fun = i::Handle<i::JSFunction>::cast(obj);
} else {
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> delegate = i::Execution::TryGetFunctionDelegate(
- isolate, obj, &has_pending_exception);
+ i::Handle<i::Object> delegate;
+ has_pending_exception = !i::Execution::TryGetFunctionDelegate(
+ isolate, obj).ToHandle(&delegate);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
fun = i::Handle<i::JSFunction>::cast(delegate);
recv_obj = obj;
}
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> returned = i::Execution::Call(
- isolate, fun, recv_obj, argc, args, &has_pending_exception, true);
+ i::Handle<i::Object> returned;
+ has_pending_exception = !i::Execution::Call(
+ isolate, fun, recv_obj, argc, args, true).ToHandle(&returned);
EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
return Utils::ToLocal(scope.CloseAndEscape(returned));
}
if (obj->IsJSFunction()) {
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> returned =
- i::Execution::New(fun, argc, args, &has_pending_exception);
+ i::Handle<i::Object> returned;
+ has_pending_exception = !i::Execution::New(
+ fun, argc, args).ToHandle(&returned);
EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
return Utils::ToLocal(scope.CloseAndEscape(
i::Handle<i::JSObject>::cast(returned)));
}
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> delegate = i::Execution::TryGetConstructorDelegate(
- isolate, obj, &has_pending_exception);
+ i::Handle<i::Object> delegate;
+ has_pending_exception = !i::Execution::TryGetConstructorDelegate(
+ isolate, obj).ToHandle(&delegate);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
if (!delegate->IsUndefined()) {
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> returned = i::Execution::Call(
- isolate, fun, obj, argc, args, &has_pending_exception);
+ i::Handle<i::Object> returned;
+ has_pending_exception = !i::Execution::Call(
+ isolate, fun, obj, argc, args).ToHandle(&returned);
EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
ASSERT(!delegate->IsUndefined());
return Utils::ToLocal(scope.CloseAndEscape(returned));
STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> returned =
- i::Execution::New(function, argc, args, &has_pending_exception);
+ i::Handle<i::Object> returned;
+ has_pending_exception = !i::Execution::New(
+ function, argc, args).ToHandle(&returned);
EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
return scope.Escape(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned)));
}
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<i::JSFunction> fun = Utils::OpenHandle(this);
- i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
- STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
- i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
- EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> returned = i::Execution::Call(
- isolate, fun, recv_obj, argc, args, &has_pending_exception, true);
- EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>());
- raw_result = *returned;
- }
- i::Handle<i::Object> result(raw_result, isolate);
- return Utils::ToLocal(result);
+ i::HandleScope scope(isolate);
+ i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
+ i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
+ STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
+ i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
+ EXCEPTION_PREAMBLE(isolate);
+ i::Handle<i::Object> returned;
+ has_pending_exception = !i::Execution::Call(
+ isolate, fun, recv_obj, argc, args, true).ToHandle(&returned);
+ EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>());
+ return Utils::ToLocal(scope.CloseAndEscape(returned));
}
LOG_API(isolate, "ObjectTemplate::NewInstance");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> obj =
- i::Execution::InstantiateObject(Utils::OpenHandle(this),
- &has_pending_exception);
+ i::Handle<i::Object> obj;
+ has_pending_exception = !i::Execution::InstantiateObject(
+ Utils::OpenHandle(this)).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
return Utils::ToLocal(i::Handle<i::JSObject>::cast(obj));
}
LOG_API(isolate, "FunctionTemplate::GetFunction");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> obj =
- i::Execution::InstantiateFunction(Utils::OpenHandle(this),
- &has_pending_exception);
+ i::Handle<i::Object> obj;
+ has_pending_exception = !i::Execution::InstantiateFunction(
+ Utils::OpenHandle(this)).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Function>());
return Utils::ToLocal(i::Handle<i::JSFunction>::cast(obj));
}
}
ENTER_V8(i_isolate);
EXCEPTION_PREAMBLE(i_isolate);
- i::Handle<i::Object> obj =
- i::Execution::NewDate(i_isolate, time, &has_pending_exception);
+ i::Handle<i::Object> obj;
+ has_pending_exception = !i::Execution::NewDate(
+ i_isolate, time).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>());
return Utils::ToLocal(obj);
}
LOG_API(isolate, "RegExp::New");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp(
+ i::Handle<i::JSRegExp> obj;
+ has_pending_exception = !i::Execution::NewJSRegExp(
Utils::OpenHandle(*pattern),
- RegExpFlagsToString(flags),
- &has_pending_exception);
+ RegExpFlagsToString(flags)).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>());
return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj));
}
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> argv[] = { obj };
- i::Handle<i::Object> b = i::Execution::Call(
+ i::Handle<i::Object> 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();
}
LOG_API(isolate, "Promise::Resolver::New");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> result = i::Execution::Call(
+ i::Handle<i::Object> 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<Promise::Resolver>());
return Local<Promise::Resolver>::Cast(Utils::ToLocal(result));
}
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> 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 */ ;);
}
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> 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 */ ;);
}
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
- i::Handle<i::Object> result = i::Execution::Call(
+ i::Handle<i::Object> 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<Promise>());
return Local<Promise>::Cast(Utils::ToLocal(result));
}
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) };
- i::Handle<i::Object> result = i::Execution::Call(
+ i::Handle<i::Object> 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<Promise>());
return Local<Promise>::Cast(Utils::ToLocal(result));
}
if (!isolate->IsInitialized()) return Local<Value>();
ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
ENTER_V8(isolate);
- i::Handle<i::Object> result;
+ i::MaybeHandle<i::Object> 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<i::Object> result;
+ has_pending_exception = !maybe_result.ToHandle(&result);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
return Utils::ToLocal(result);
}
? 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();
}
ASSERT(FunctionTemplateInfo::cast(object_template->constructor())
->IsTemplateFor(object->map()));;
- bool pending_exception = false;
- Handle<JSObject> obj =
- Execution::InstantiateObject(object_template, &pending_exception);
- if (pending_exception) {
+ MaybeHandle<JSObject> maybe_obj =
+ Execution::InstantiateObject(object_template);
+ Handle<JSObject> obj;
+ if (!maybe_obj.ToHandle(&obj)) {
ASSERT(isolate()->has_pending_exception());
isolate()->clear_pending_exception();
return false;
for (int i = 0; i < argc; ++i) {
argv[i] = args.at<Object>(i + 1);
}
- bool pending_exception;
- Handle<Object> result = Execution::Call(isolate,
- function,
- args.receiver(),
- argc,
- argv.start(),
- &pending_exception);
- if (pending_exception) return Failure::Exception();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Execution::Call(isolate,
+ function,
+ args.receiver(),
+ argc,
+ argv.start()));
return *result;
}
Handle<JSFunction> function = args.called_function();
ASSERT(function->shared()->IsApiFunction());
- FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data();
+ Handle<FunctionTemplateInfo> fun_data(
+ function->shared()->get_api_func_data(), isolate);
if (is_construct) {
- Handle<FunctionTemplateInfo> desc(fun_data, isolate);
- bool pending_exception = false;
- isolate->factory()->ConfigureInstance(
- desc, Handle<JSObject>::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<JSObject>::cast(args.receiver())));
}
SharedFunctionInfo* shared = function->shared();
}
}
- 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!
};
-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);
}
}
// Execute the shared function in the debugger context.
- bool caught_exception;
Handle<JSFunction> function =
factory->NewFunctionFromSharedFunctionInfo(function_info, context);
- Handle<Object> exception =
+ Handle<Object> exception;
+ MaybeHandle<Object> result =
Execution::TryCall(function,
Handle<Object>(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);
Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());
// Call HandleBreakPointx.
- bool caught_exception;
Handle<Object> argv[] = { break_id, break_point_object };
- Handle<Object> 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<Object> 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();
}
Handle<Object> fun = GlobalObject::GetPropertyNoExceptionThrown(
isolate_->global_object(), function_name);
ASSERT(fun->IsJSFunction());
- bool caught_exception;
- Execution::TryCall(Handle<JSFunction>::cast(fun),
+ Execution::TryCall(
+ Handle<JSFunction>::cast(fun),
Handle<JSObject>(Debug::debug_context()->global_object()),
- 0, NULL, &caught_exception);
+ 0,
+ NULL);
}
Debugger::~Debugger() {}
-Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name,
- int argc,
- Handle<Object> argv[],
- bool* caught_exception) {
+MaybeHandle<Object> Debugger::MakeJSObject(
+ Vector<const char> constructor_name,
+ int argc,
+ Handle<Object> argv[]) {
ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
// Create the execution state object.
Handle<Object> constructor = GlobalObject::GetPropertyNoExceptionThrown(
isolate_->global_object(), constructor_str);
ASSERT(constructor->IsJSFunction());
- if (!constructor->IsJSFunction()) {
- *caught_exception = true;
- return isolate_->factory()->undefined_value();
- }
- Handle<Object> js_object = Execution::TryCall(
+ if (!constructor->IsJSFunction()) return MaybeHandle<Object>();
+ return Execution::TryCall(
Handle<JSFunction>::cast(constructor),
Handle<JSObject>(isolate_->debug()->debug_context()->global_object()),
argc,
- argv,
- caught_exception);
- return js_object;
+ argv);
}
-Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) {
+MaybeHandle<Object> Debugger::MakeExecutionState() {
// Create the execution state object.
Handle<Object> break_id = isolate_->factory()->NewNumberFromInt(
isolate_->debug()->break_id());
Handle<Object> argv[] = { break_id };
- return MakeJSObject(CStrVector("MakeExecutionState"),
- ARRAY_SIZE(argv),
- argv,
- caught_exception);
+ return MakeJSObject(CStrVector("MakeExecutionState"), ARRAY_SIZE(argv), argv);
}
-Handle<Object> Debugger::MakeBreakEvent(Handle<Object> exec_state,
- Handle<Object> break_points_hit,
- bool* caught_exception) {
+MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) {
+ Handle<Object> exec_state;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate_, exec_state, MakeExecutionState(), Object);
// Create the new break event object.
Handle<Object> 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<Object> Debugger::MakeExceptionEvent(Handle<Object> exec_state,
- Handle<Object> exception,
- bool uncaught,
- bool* caught_exception) {
- Factory* factory = isolate_->factory();
+MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception,
+ bool uncaught) {
+ Handle<Object> exec_state;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate_, exec_state, MakeExecutionState(), Object);
// Create the new exception event object.
Handle<Object> argv[] = { exec_state,
exception,
- factory->ToBoolean(uncaught) };
- return MakeJSObject(CStrVector("MakeExceptionEvent"),
- ARRAY_SIZE(argv),
- argv,
- caught_exception);
-}
-
-
-Handle<Object> Debugger::MakeNewFunctionEvent(Handle<Object> function,
- bool* caught_exception) {
- // Create the new function event object.
- Handle<Object> 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<Object> Debugger::MakeCompileEvent(Handle<Script> script,
- bool before,
- bool* caught_exception) {
+MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
+ bool before) {
Factory* factory = isolate_->factory();
// Create the compile event object.
- Handle<Object> exec_state = MakeExecutionState(caught_exception);
+ Handle<Object> exec_state;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate_, exec_state, MakeExecutionState(), Object);
Handle<Object> script_wrapper = GetScriptWrapper(script);
Handle<Object> argv[] = { exec_state,
script_wrapper,
factory->ToBoolean(before) };
- return MakeJSObject(CStrVector("MakeCompileEvent"),
- ARRAY_SIZE(argv),
- argv,
- caught_exception);
+ return MakeJSObject(CStrVector("MakeCompileEvent"), ARRAY_SIZE(argv), argv);
}
-Handle<Object> Debugger::MakeScriptCollectedEvent(int id,
- bool* caught_exception) {
+MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) {
// Create the script collected event object.
- Handle<Object> exec_state = MakeExecutionState(caught_exception);
+ Handle<Object> exec_state;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate_, exec_state, MakeExecutionState(), Object);
Handle<Object> id_object = Handle<Smi>(Smi::FromInt(id), isolate_);
Handle<Object> argv[] = { exec_state, id_object };
- return MakeJSObject(CStrVector("MakeScriptCollectedEvent"),
- ARRAY_SIZE(argv),
- argv,
- caught_exception);
+ return MakeJSObject(
+ CStrVector("MakeScriptCollectedEvent"), ARRAY_SIZE(argv), argv);
}
// Clear all current stepping setup.
debug->ClearStepping();
// Create the event data object.
- bool caught_exception = false;
- Handle<Object> exec_state = MakeExecutionState(&caught_exception);
Handle<Object> event_data;
- if (!caught_exception) {
- event_data = MakeExceptionEvent(exec_state, exception, uncaught,
- &caught_exception);
- }
// Bail out and don't call debugger if exception.
- if (caught_exception) {
- return;
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, event_data, MakeExceptionEvent(exception, uncaught),
+ /* void */ ;);
// Process debug event.
ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false);
ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
// Create the event data object.
- bool caught_exception = false;
- Handle<Object> exec_state = MakeExecutionState(&caught_exception);
Handle<Object> event_data;
- if (!caught_exception) {
- event_data = MakeBreakEvent(exec_state, break_points_hit,
- &caught_exception);
- }
// Bail out and don't call debugger if exception.
- if (caught_exception) {
- return;
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, event_data, MakeBreakEvent(break_points_hit), /* void */ ;);
// Process debug event.
ProcessDebugEvent(v8::Break,
if (debugger.FailedToEnter()) return;
// Create the event data object.
- bool caught_exception = false;
- Handle<Object> event_data = MakeCompileEvent(script, true, &caught_exception);
+ Handle<Object> event_data;
// Bail out and don't call debugger if exception.
- if (caught_exception) {
- return;
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, event_data, MakeCompileEvent(script, true), /* void */ ;);
// Process debug event.
ProcessDebugEvent(v8::BeforeCompile,
Handle<JSValue> wrapper = GetScriptWrapper(script);
// Call UpdateScriptBreakPoints expect no exceptions.
- bool caught_exception;
Handle<Object> argv[] = { wrapper };
- Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points),
- isolate_->js_builtins_object(),
- ARRAY_SIZE(argv),
- argv,
- &caught_exception);
- if (caught_exception) {
+ if (Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points),
+ isolate_->js_builtins_object(),
+ ARRAY_SIZE(argv),
+ argv).is_null()) {
return;
}
// Bail out based on state or if there is no listener for this event
if (!Debugger::EventActive(v8::AfterCompile)) return;
// Create the compile state object.
- Handle<Object> event_data = MakeCompileEvent(script,
- false,
- &caught_exception);
+ Handle<Object> event_data;
// Bail out and don't call debugger if exception.
- if (caught_exception) {
- return;
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, event_data, MakeCompileEvent(script, false), /* void */ ;);
+
// Process debug event.
- ProcessDebugEvent(v8::AfterCompile,
- Handle<JSObject>::cast(event_data),
- true);
+ ProcessDebugEvent(v8::AfterCompile, Handle<JSObject>::cast(event_data), true);
}
if (debugger.FailedToEnter()) return;
// Create the script collected state object.
- bool caught_exception = false;
- Handle<Object> event_data = MakeScriptCollectedEvent(id,
- &caught_exception);
+ Handle<Object> event_data;
// Bail out and don't call debugger if exception.
- if (caught_exception) {
- return;
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, event_data, MakeScriptCollectedEvent(id), /* void */ ;);
// Process debug event.
ProcessDebugEvent(v8::ScriptCollected,
}
// Create the execution state.
- bool caught_exception = false;
- Handle<Object> exec_state = MakeExecutionState(&caught_exception);
- if (caught_exception) {
- return;
- }
+ Handle<Object> exec_state;
+ // Bail out and don't call debugger if exception.
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, exec_state, MakeExecutionState(), /* void */ ;);
// First notify the message handler if any.
if (message_handler_ != NULL) {
NotifyMessageHandler(event,
exec_state,
event_data,
event_listener_data_ };
- bool caught_exception;
Execution::TryCall(fun,
isolate_->global_object(),
ARRAY_SIZE(argv),
- argv,
- &caught_exception);
+ argv);
// Silently ignore exceptions from debug event listeners.
}
}
-Handle<Object> Debugger::Call(Handle<JSFunction> fun,
- Handle<Object> data,
- bool* pending_exception) {
+MaybeHandle<Object> Debugger::Call(Handle<JSFunction> fun,
+ Handle<Object> data) {
// When calling functions in the debugger prevent it from beeing unloaded.
Debugger::never_unload_debugger_ = true;
}
// Create the execution state.
- bool caught_exception = false;
- Handle<Object> exec_state = MakeExecutionState(&caught_exception);
- if (caught_exception) {
- return isolate_->factory()->undefined_value();
- }
+ Handle<Object> exec_state;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, exec_state,
+ MakeExecutionState(),
+ isolate_->factory()->undefined_value());
Handle<Object> argv[] = { exec_state, data };
- Handle<Object> result = Execution::Call(
+ return Execution::Call(
isolate_,
fun,
Handle<Object>(isolate_->debug()->debug_context_->global_proxy(),
isolate_),
ARRAY_SIZE(argv),
- argv,
- pending_exception);
- return result;
+ argv);
}
v8::Handle<v8::String> MessageImpl::GetJSON() const {
- v8::EscapableHandleScope scope(
- reinterpret_cast<v8::Isolate*>(event_data_->GetIsolate()));
+ Isolate* isolate = event_data_->GetIsolate();
+ v8::EscapableHandleScope scope(reinterpret_cast<v8::Isolate*>(isolate));
if (IsEvent()) {
// Call toJSONProtocol on the debug event object.
if (!fun->IsJSFunction()) {
return v8::Handle<v8::String>();
}
- bool caught_exception;
- Handle<Object> json = Execution::TryCall(Handle<JSFunction>::cast(fun),
- event_data_,
- 0, NULL, &caught_exception);
- if (caught_exception || !json->IsString()) {
+
+ MaybeHandle<Object> maybe_json =
+ Execution::TryCall(Handle<JSFunction>::cast(fun), event_data_, 0, NULL);
+ Handle<Object> json;
+ if (!maybe_json.ToHandle(&json) || !json->IsString()) {
return v8::Handle<v8::String>();
}
return scope.Escape(v8::Utils::ToLocal(Handle<String>::cast(json)));
void DebugRequest(const uint16_t* json_request, int length);
- Handle<Object> MakeJSObject(Vector<const char> constructor_name,
- int argc,
- Handle<Object> argv[],
- bool* caught_exception);
- Handle<Object> MakeExecutionState(bool* caught_exception);
- Handle<Object> MakeBreakEvent(Handle<Object> exec_state,
- Handle<Object> break_points_hit,
- bool* caught_exception);
- Handle<Object> MakeExceptionEvent(Handle<Object> exec_state,
- Handle<Object> exception,
- bool uncaught,
- bool* caught_exception);
- Handle<Object> MakeNewFunctionEvent(Handle<Object> func,
- bool* caught_exception);
- Handle<Object> MakeCompileEvent(Handle<Script> script,
- bool before,
- bool* caught_exception);
- Handle<Object> MakeScriptCollectedEvent(int id,
- bool* caught_exception);
+ MUST_USE_RESULT MaybeHandle<Object> MakeJSObject(
+ Vector<const char> constructor_name,
+ int argc,
+ Handle<Object> argv[]);
+ MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState();
+ MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent(
+ Handle<Object> break_points_hit);
+ MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent(
+ Handle<Object> exception, bool uncaught);
+ MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent(
+ Handle<Script> script, bool before);
+ MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id);
+
void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue);
void OnException(Handle<Object> exception, bool uncaught);
void OnBeforeCompile(Handle<Script> script);
// Enqueue a debugger command to the command queue for event listeners.
void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL);
- Handle<Object> Call(Handle<JSFunction> fun,
- Handle<Object> data,
- bool* pending_exception);
+ MUST_USE_RESULT MaybeHandle<Object> Call(Handle<JSFunction> fun,
+ Handle<Object> data);
// Start the debugger agent listening on the provided port.
bool StartAgent(const char* name, int port,
}
-static Handle<Object> Invoke(bool is_construct,
- Handle<JSFunction> function,
- Handle<Object> receiver,
- int argc,
- Handle<Object> args[],
- bool* has_pending_exception) {
+MUST_USE_RESULT static MaybeHandle<Object> Invoke(
+ bool is_construct,
+ Handle<JSFunction> function,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> args[]) {
Isolate* isolate = function->GetIsolate();
// Entering JavaScript.
CHECK(AllowJavascriptExecution::IsAllowed(isolate));
if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) {
isolate->ThrowIllegalOperation();
- *has_pending_exception = true;
isolate->ReportPendingMessages();
- return Handle<Object>();
+ return MaybeHandle<Object>();
}
// Placeholder for return value.
#endif
// Update the pending exception flag and return the value.
- *has_pending_exception = value->IsException();
- ASSERT(*has_pending_exception == isolate->has_pending_exception());
- if (*has_pending_exception) {
+ bool has_exception = value->IsException();
+ ASSERT(has_exception == isolate->has_pending_exception());
+ if (has_exception) {
isolate->ReportPendingMessages();
#ifdef ENABLE_DEBUGGER_SUPPORT
// Reset stepping state when script exits with uncaught exception.
isolate->debug()->ClearStepping();
}
#endif // ENABLE_DEBUGGER_SUPPORT
- return Handle<Object>();
+ return MaybeHandle<Object>();
} else {
isolate->clear_pending_message();
}
}
-Handle<Object> Execution::Call(Isolate* isolate,
- Handle<Object> callable,
- Handle<Object> receiver,
- int argc,
- Handle<Object> argv[],
- bool* pending_exception,
- bool convert_receiver) {
- *pending_exception = false;
-
+MaybeHandle<Object> Execution::Call(Isolate* isolate,
+ Handle<Object> callable,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> argv[],
+ bool convert_receiver) {
if (!callable->IsJSFunction()) {
- callable = TryGetFunctionDelegate(isolate, callable, pending_exception);
- if (*pending_exception) return callable;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, callable, TryGetFunctionDelegate(isolate, callable), Object);
}
Handle<JSFunction> func = Handle<JSFunction>::cast(callable);
receiver = Handle<Object>(global, func->GetIsolate());
}
} else {
- receiver = ToObject(isolate, receiver, pending_exception);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, receiver, ToObject(isolate, receiver), Object);
}
- if (*pending_exception) return callable;
}
- return Invoke(false, func, receiver, argc, argv, pending_exception);
+ return Invoke(false, func, receiver, argc, argv);
}
-Handle<Object> Execution::New(Handle<JSFunction> func,
- int argc,
- Handle<Object> argv[],
- bool* pending_exception) {
- return Invoke(true, func, func->GetIsolate()->global_object(), argc, argv,
- pending_exception);
+MaybeHandle<Object> Execution::New(Handle<JSFunction> func,
+ int argc,
+ Handle<Object> argv[]) {
+ return Invoke(true, func, func->GetIsolate()->global_object(), argc, argv);
}
-Handle<Object> Execution::TryCall(Handle<JSFunction> func,
- Handle<Object> receiver,
- int argc,
- Handle<Object> args[],
- bool* caught_exception) {
+MaybeHandle<Object> Execution::TryCall(Handle<JSFunction> func,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> args[],
+ Handle<Object>* exception_out) {
// Enter a try-block while executing the JavaScript code. To avoid
// duplicate error printing it must be non-verbose. Also, to avoid
// creating message objects during stack overflow we shouldn't
v8::TryCatch catcher;
catcher.SetVerbose(false);
catcher.SetCaptureMessage(false);
- *caught_exception = false;
// Get isolate now, because handle might be persistent
// and get destroyed in the next call.
Isolate* isolate = func->GetIsolate();
- Handle<Object> result = Invoke(false, func, receiver, argc, args,
- caught_exception);
+ MaybeHandle<Object> maybe_result = Invoke(false, func, receiver, argc, args);
- if (*caught_exception) {
+ if (maybe_result.is_null()) {
ASSERT(catcher.HasCaught());
ASSERT(isolate->has_pending_exception());
ASSERT(isolate->external_caught_exception());
- if (isolate->pending_exception() ==
- isolate->heap()->termination_exception()) {
- result = isolate->factory()->termination_exception();
- } else {
- result = v8::Utils::OpenHandle(*catcher.Exception());
+ if (exception_out != NULL) {
+ if (isolate->pending_exception() ==
+ isolate->heap()->termination_exception()) {
+ *exception_out = isolate->factory()->termination_exception();
+ } else {
+ *exception_out = v8::Utils::OpenHandle(*catcher.Exception());
+ }
}
isolate->OptionalRescheduleException(true);
}
ASSERT(!isolate->has_pending_exception());
ASSERT(!isolate->external_caught_exception());
- return result;
+ return maybe_result;
}
}
-Handle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate,
- Handle<Object> object,
- bool* has_pending_exception) {
+MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate,
+ Handle<Object> object) {
ASSERT(!object->IsJSFunction());
// If object is a function proxy, get its handler. Iterate if necessary.
// throw a non-callable exception.
i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
"called_non_callable", i::HandleVector<i::Object>(&object, 1));
- isolate->Throw(*error_obj);
- *has_pending_exception = true;
- return isolate->factory()->undefined_value();
+ return isolate->Throw<Object>(error_obj);
}
}
-Handle<Object> Execution::TryGetConstructorDelegate(
- Isolate* isolate,
- Handle<Object> object,
- bool* has_pending_exception) {
+MaybeHandle<Object> Execution::TryGetConstructorDelegate(
+ Isolate* isolate, Handle<Object> object) {
ASSERT(!object->IsJSFunction());
// If you return a function from here, it will be called when an
// throw a non-callable exception.
i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
"called_non_callable", i::HandleVector<i::Object>(&object, 1));
- isolate->Throw(*error_obj);
- *has_pending_exception = true;
-
- return isolate->factory()->undefined_value();
+ return isolate->Throw<Object>(error_obj);
}
void Execution::RunMicrotasks(Isolate* isolate) {
ASSERT(isolate->microtask_pending());
- bool threw = false;
Execution::Call(
isolate,
isolate->run_microtasks(),
isolate->factory()->undefined_value(),
0,
- NULL,
- &threw);
- ASSERT(!threw);
+ NULL).Assert();
}
void Execution::EnqueueMicrotask(Isolate* isolate, Handle<Object> microtask) {
- bool threw = false;
Handle<Object> args[] = { microtask };
Execution::Call(
isolate,
isolate->enqueue_external_microtask(),
isolate->factory()->undefined_value(),
1,
- args,
- &threw);
- ASSERT(!threw);
+ args).Assert();
}
// --- C a l l s t o n a t i v e s ---
-#define RETURN_NATIVE_CALL(name, args, has_pending_exception) \
+#define RETURN_NATIVE_CALL(name, args) \
do { \
Handle<Object> argv[] = args; \
- ASSERT(has_pending_exception != NULL); \
return Call(isolate, \
isolate->name##_fun(), \
isolate->js_builtins_object(), \
- ARRAY_SIZE(argv), argv, \
- has_pending_exception); \
+ ARRAY_SIZE(argv), argv); \
} while (false)
-Handle<Object> Execution::ToNumber(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_number, { obj }, exc);
+MaybeHandle<Object> Execution::ToNumber(
+ Isolate* isolate, Handle<Object> obj) {
+ RETURN_NATIVE_CALL(to_number, { obj });
}
-Handle<Object> Execution::ToString(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_string, { obj }, exc);
+MaybeHandle<Object> Execution::ToString(
+ Isolate* isolate, Handle<Object> obj) {
+ RETURN_NATIVE_CALL(to_string, { obj });
}
-Handle<Object> Execution::ToDetailString(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_detail_string, { obj }, exc);
+MaybeHandle<Object> Execution::ToDetailString(
+ Isolate* isolate, Handle<Object> obj) {
+ RETURN_NATIVE_CALL(to_detail_string, { obj });
}
-Handle<Object> Execution::ToObject(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
+MaybeHandle<Object> Execution::ToObject(
+ Isolate* isolate, Handle<Object> obj) {
if (obj->IsSpecObject()) return obj;
- RETURN_NATIVE_CALL(to_object, { obj }, exc);
+ RETURN_NATIVE_CALL(to_object, { obj });
}
-Handle<Object> Execution::ToInteger(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_integer, { obj }, exc);
+MaybeHandle<Object> Execution::ToInteger(
+ Isolate* isolate, Handle<Object> obj) {
+ RETURN_NATIVE_CALL(to_integer, { obj });
}
-Handle<Object> Execution::ToUint32(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_uint32, { obj }, exc);
+MaybeHandle<Object> Execution::ToUint32(
+ Isolate* isolate, Handle<Object> obj) {
+ RETURN_NATIVE_CALL(to_uint32, { obj });
}
-Handle<Object> Execution::ToInt32(
- Isolate* isolate, Handle<Object> obj, bool* exc) {
- RETURN_NATIVE_CALL(to_int32, { obj }, exc);
+MaybeHandle<Object> Execution::ToInt32(
+ Isolate* isolate, Handle<Object> obj) {
+ RETURN_NATIVE_CALL(to_int32, { obj });
}
-Handle<Object> Execution::NewDate(Isolate* isolate, double time, bool* exc) {
+MaybeHandle<Object> Execution::NewDate(Isolate* isolate, double time) {
Handle<Object> time_obj = isolate->factory()->NewNumber(time);
- RETURN_NATIVE_CALL(create_date, { time_obj }, exc);
+ RETURN_NATIVE_CALL(create_date, { time_obj });
}
#undef RETURN_NATIVE_CALL
-Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
- Handle<String> flags,
- bool* exc) {
+MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
+ Handle<String> flags) {
+ Isolate* isolate = pattern->GetIsolate();
Handle<JSFunction> function = Handle<JSFunction>(
- pattern->GetIsolate()->native_context()->regexp_function());
- Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral(
- function, pattern, flags, exc);
- if (*exc) return Handle<JSRegExp>();
+ isolate->native_context()->regexp_function());
+ Handle<Object> re_obj;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, re_obj,
+ RegExpImpl::CreateRegExpLiteral(function, pattern, flags),
+ JSRegExp);
return Handle<JSRegExp>::cast(re_obj);
}
return factory->undefined_value();
}
- bool caught_exception;
Handle<Object> index_object = factory->NewNumberFromInt(int_index);
Handle<Object> index_arg[] = { index_object };
- Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at),
- string,
- ARRAY_SIZE(index_arg),
- index_arg,
- &caught_exception);
- if (caught_exception) {
- return factory->undefined_value();
- }
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, result,
+ TryCall(Handle<JSFunction>::cast(char_at),
+ string,
+ ARRAY_SIZE(index_arg),
+ index_arg),
+ factory->undefined_value());
return result;
}
-Handle<JSFunction> Execution::InstantiateFunction(
- Handle<FunctionTemplateInfo> data,
- bool* exc) {
+MaybeHandle<JSFunction> Execution::InstantiateFunction(
+ Handle<FunctionTemplateInfo> data) {
Isolate* isolate = data->GetIsolate();
if (!data->do_not_cache()) {
// Fast case: see if the function has already been instantiated
}
// The function has not yet been instantiated in this context; do it.
Handle<Object> args[] = { data };
- Handle<Object> result = Call(isolate,
- isolate->instantiate_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- exc);
- if (*exc) return Handle<JSFunction>::null();
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ Call(isolate,
+ isolate->instantiate_fun(),
+ isolate->js_builtins_object(),
+ ARRAY_SIZE(args),
+ args),
+ JSFunction);
return Handle<JSFunction>::cast(result);
}
-Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data,
- bool* exc) {
+MaybeHandle<JSObject> Execution::InstantiateObject(
+ Handle<ObjectTemplateInfo> data) {
Isolate* isolate = data->GetIsolate();
+ Handle<Object> result;
if (data->property_list()->IsUndefined() &&
!data->constructor()->IsUndefined()) {
- // Initialization to make gcc happy.
- Object* result = NULL;
- {
- HandleScope scope(isolate);
- Handle<FunctionTemplateInfo> cons_template =
- Handle<FunctionTemplateInfo>(
- FunctionTemplateInfo::cast(data->constructor()));
- Handle<JSFunction> cons = InstantiateFunction(cons_template, exc);
- if (*exc) return Handle<JSObject>::null();
- Handle<Object> value = New(cons, 0, NULL, exc);
- if (*exc) return Handle<JSObject>::null();
- result = *value;
- }
- ASSERT(!*exc);
- return Handle<JSObject>(JSObject::cast(result));
+ Handle<FunctionTemplateInfo> cons_template =
+ Handle<FunctionTemplateInfo>(
+ FunctionTemplateInfo::cast(data->constructor()));
+ Handle<JSFunction> cons;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, cons, InstantiateFunction(cons_template), JSObject);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, result, New(cons, 0, NULL), JSObject);
} else {
Handle<Object> args[] = { data };
- Handle<Object> result = Call(isolate,
- isolate->instantiate_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- exc);
- if (*exc) return Handle<JSObject>::null();
- return Handle<JSObject>::cast(result);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ Call(isolate,
+ isolate->instantiate_fun(),
+ isolate->js_builtins_object(),
+ ARRAY_SIZE(args),
+ args),
+ JSObject);
}
+ return Handle<JSObject>::cast(result);
}
-void Execution::ConfigureInstance(Isolate* isolate,
- Handle<Object> instance,
- Handle<Object> instance_template,
- bool* exc) {
+MaybeHandle<Object> Execution::ConfigureInstance(
+ Isolate* isolate,
+ Handle<Object> instance,
+ Handle<Object> instance_template) {
Handle<Object> args[] = { instance, instance_template };
- Execution::Call(isolate,
- isolate->configure_instance_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- exc);
+ return Execution::Call(isolate,
+ isolate->configure_instance_fun(),
+ isolate->js_builtins_object(),
+ ARRAY_SIZE(args),
+ args);
}
Handle<Object> is_global) {
Isolate* isolate = fun->GetIsolate();
Handle<Object> args[] = { recv, fun, pos, is_global };
- bool caught_exception;
- Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(),
- isolate->js_builtins_object(),
- ARRAY_SIZE(args),
- args,
- &caught_exception);
- if (caught_exception || !result->IsString()) {
- return isolate->factory()->empty_string();
+ MaybeHandle<Object> maybe_result =
+ TryCall(isolate->get_stack_trace_line_fun(),
+ isolate->js_builtins_object(),
+ ARRAY_SIZE(args),
+ args);
+ Handle<Object> result;
+ if (!maybe_result.ToHandle(&result) || !result->IsString()) {
+ return isolate->factory()->empty_string();
}
return Handle<String>::cast(result);
// and the function called is not in strict mode, receiver is converted to
// an object.
//
- static Handle<Object> Call(Isolate* isolate,
- Handle<Object> callable,
- Handle<Object> receiver,
- int argc,
- Handle<Object> argv[],
- bool* pending_exception,
- bool convert_receiver = false);
+ MUST_USE_RESULT static MaybeHandle<Object> Call(
+ Isolate* isolate,
+ Handle<Object> callable,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> argv[],
+ bool convert_receiver = false);
// Construct object from function, the caller supplies an array of
// arguments. Arguments are Object* type. After function returns,
// *pending_exception tells whether the invoke resulted in
// a pending exception.
//
- static Handle<Object> New(Handle<JSFunction> func,
- int argc,
- Handle<Object> argv[],
- bool* pending_exception);
+ MUST_USE_RESULT static MaybeHandle<Object> New(Handle<JSFunction> func,
+ int argc,
+ Handle<Object> argv[]);
// Call a function, just like Call(), but make sure to silently catch
// any thrown exceptions. The return value is either the result of
// calling the function (if caught exception is false) or the exception
// that occurred (if caught exception is true).
- static Handle<Object> TryCall(Handle<JSFunction> func,
- Handle<Object> receiver,
- int argc,
- Handle<Object> argv[],
- bool* caught_exception);
+ MUST_USE_RESULT static MaybeHandle<Object> TryCall(
+ Handle<JSFunction> func,
+ Handle<Object> receiver,
+ int argc,
+ Handle<Object> argv[],
+ Handle<Object>* exception_out = NULL);
// ECMA-262 9.3
- static Handle<Object> ToNumber(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToNumber(
+ Isolate* isolate, Handle<Object> obj);
// ECMA-262 9.4
- static Handle<Object> ToInteger(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToInteger(
+ Isolate* isolate, Handle<Object> obj);
// ECMA-262 9.5
- static Handle<Object> ToInt32(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToInt32(
+ Isolate* isolate, Handle<Object> obj);
// ECMA-262 9.6
- static Handle<Object> ToUint32(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToUint32(
+ Isolate* isolate, Handle<Object> obj);
// ECMA-262 9.8
- static Handle<Object> ToString(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToString(
+ Isolate* isolate, Handle<Object> obj);
// ECMA-262 9.8
- static Handle<Object> ToDetailString(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToDetailString(
+ Isolate* isolate, Handle<Object> obj);
// ECMA-262 9.9
- static Handle<Object> ToObject(
- Isolate* isolate, Handle<Object> obj, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> ToObject(
+ Isolate* isolate, Handle<Object> obj);
// Create a new date object from 'time'.
- static Handle<Object> NewDate(
- Isolate* isolate, double time, bool* exc);
+ MUST_USE_RESULT static MaybeHandle<Object> NewDate(
+ Isolate* isolate, double time);
// Create a new regular expression object from 'pattern' and 'flags'.
- static Handle<JSRegExp> NewJSRegExp(Handle<String> pattern,
- Handle<String> flags,
- bool* exc);
+ MUST_USE_RESULT static MaybeHandle<JSRegExp> NewJSRegExp(
+ Handle<String> pattern, Handle<String> flags);
// Used to implement [] notation on strings (calls JS code)
static Handle<Object> CharAt(Handle<String> str, uint32_t index);
static Handle<Object> GetFunctionFor();
- static Handle<JSFunction> InstantiateFunction(
- Handle<FunctionTemplateInfo> data, bool* exc);
- static Handle<JSObject> InstantiateObject(Handle<ObjectTemplateInfo> data,
- bool* exc);
- static void ConfigureInstance(Isolate* isolate,
- Handle<Object> instance,
- Handle<Object> data,
- bool* exc);
+ MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
+ Handle<FunctionTemplateInfo> data);
+ MUST_USE_RESULT static MaybeHandle<JSObject> InstantiateObject(
+ Handle<ObjectTemplateInfo> data);
+ MUST_USE_RESULT static MaybeHandle<Object> ConfigureInstance(
+ Isolate* isolate, Handle<Object> instance, Handle<Object> data);
static Handle<String> GetStackTraceLine(Handle<Object> recv,
Handle<JSFunction> fun,
Handle<Object> pos,
// object. Used for support calling objects as functions.
static Handle<Object> GetFunctionDelegate(Isolate* isolate,
Handle<Object> object);
- static Handle<Object> TryGetFunctionDelegate(Isolate* isolate,
- Handle<Object> object,
- bool* has_pending_exception);
+ MUST_USE_RESULT static MaybeHandle<Object> TryGetFunctionDelegate(
+ Isolate* isolate,
+ Handle<Object> object);
// Get a function delegate (or undefined) for the given non-function
// object. Used for support calling objects as constructors.
static Handle<Object> GetConstructorDelegate(Isolate* isolate,
Handle<Object> object);
- static Handle<Object> TryGetConstructorDelegate(Isolate* isolate,
- Handle<Object> object,
- bool* has_pending_exception);
+ static MaybeHandle<Object> TryGetConstructorDelegate(Isolate* isolate,
+ Handle<Object> object);
static void RunMicrotasks(Isolate* isolate);
static void EnqueueMicrotask(Isolate* isolate, Handle<Object> microtask);
// Invoke the JavaScript factory method. If an exception is thrown while
// running the factory method, use the exception as the result.
- bool caught_exception;
- Handle<Object> result = Execution::TryCall(fun,
- isolate()->js_builtins_object(),
- ARRAY_SIZE(argv),
- argv,
- &caught_exception);
+ Handle<Object> result;
+ Handle<Object> exception;
+ if (!Execution::TryCall(fun,
+ isolate()->js_builtins_object(),
+ ARRAY_SIZE(argv),
+ argv,
+ &exception).ToHandle(&result)) {
+ return exception;
+ }
return result;
}
// Invoke the JavaScript factory method. If an exception is thrown while
// running the factory method, use the exception as the result.
- bool caught_exception;
- Handle<Object> result = Execution::TryCall(fun,
- isolate()->js_builtins_object(),
- ARRAY_SIZE(argv),
- argv,
- &caught_exception);
+ Handle<Object> result;
+ Handle<Object> exception;
+ if (!Execution::TryCall(fun,
+ isolate()->js_builtins_object(),
+ ARRAY_SIZE(argv),
+ argv,
+ &exception).ToHandle(&result)) {
+ return exception;
+ }
return result;
}
-void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc,
- Handle<JSObject> instance,
- bool* pending_exception) {
+MaybeHandle<FunctionTemplateInfo> Factory::ConfigureInstance(
+ Handle<FunctionTemplateInfo> desc, Handle<JSObject> instance) {
// Configure the instance by adding the properties specified by the
// instance template.
Handle<Object> instance_template(desc->instance_template(), isolate());
if (!instance_template->IsUndefined()) {
- Execution::ConfigureInstance(isolate(),
- instance,
- instance_template,
- pending_exception);
- } else {
- *pending_exception = false;
+ RETURN_ON_EXCEPTION(
+ isolate(),
+ Execution::ConfigureInstance(isolate(), instance, instance_template),
+ FunctionTemplateInfo);
}
+ return desc;
}
// Installs interceptors on the instance. 'desc' is a function template,
// and instance is an object instance created by the function of this
// function template.
- void ConfigureInstance(Handle<FunctionTemplateInfo> desc,
- Handle<JSObject> instance,
- bool* pending_exception);
+ MUST_USE_RESULT MaybeHandle<FunctionTemplateInfo> ConfigureInstance(
+ Handle<FunctionTemplateInfo> desc, Handle<JSObject> instance);
#define ROOT_ACCESSOR(type, name, camel_name) \
inline Handle<type> name() { \
Object::GetProperty(script_wrapper, name_or_source_url_key);
ASSERT(property->IsJSFunction());
Handle<JSFunction> method = Handle<JSFunction>::cast(property);
- bool caught_exception;
- Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
- NULL, &caught_exception);
- if (caught_exception) {
- result = isolate->factory()->undefined_value();
- }
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, result,
+ Execution::TryCall(method, script_wrapper, 0, NULL),
+ isolate->factory()->undefined_value());
return result;
}
if (p->IsJSProxy()) {
Handle<JSProxy> proxy(JSProxy::cast(*p), isolate);
Handle<Object> args[] = { proxy };
- bool has_pending_exception;
- Handle<Object> names = Execution::Call(isolate,
- isolate->proxy_enumerate(),
- object,
- ARRAY_SIZE(args),
- args,
- &has_pending_exception);
- if (has_pending_exception) return MaybeHandle<FixedArray>();
+ Handle<Object> names;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, names,
+ Execution::Call(isolate,
+ isolate->proxy_enumerate(),
+ object,
+ ARRAY_SIZE(args),
+ args),
+ FixedArray);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, content,
- FixedArray::AddKeysFromJSArray(content, Handle<JSArray>::cast(names)),
+ FixedArray::AddKeysFromJSArray(
+ content, Handle<JSArray>::cast(names)),
FixedArray);
break;
}
// If we only want local properties we bail out after the first
// iteration.
- if (type == LOCAL_ONLY)
- break;
+ if (type == LOCAL_ONLY) break;
}
return content;
}
-MaybeHandle<JSArray> GetKeysFor(Handle<JSReceiver> object) {
- Isolate* isolate = object->GetIsolate();
- isolate->counters()->for_in()->Increment();
- Handle<FixedArray> elements;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, elements,
- GetKeysInFixedArrayFor(object, INCLUDE_PROTOS),
- JSArray);
- return isolate->factory()->NewJSArrayWithElements(elements);
-}
-
-
Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length) {
ASSERT(array->length() >= length);
if (array->length() == length) return array;
// Computes the enumerable keys for a JSObject. Used for implementing
// "for (n in object) { }".
MUST_USE_RESULT MaybeHandle<FixedArray> GetKeysInFixedArrayFor(
- Handle<JSReceiver> object,
- KeyCollectionType type);
-MUST_USE_RESULT MaybeHandle<JSArray> GetKeysFor(Handle<JSReceiver> object);
+ Handle<JSReceiver> object, KeyCollectionType type);
Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length);
Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
bool cache_result);
Object* builtin = isolate()->js_builtins_object()->javascript_builtin(
TokenToJSBuiltin(state.op()));
Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate());
- bool caught_exception;
- Handle<Object> result = Execution::Call(
- isolate(), function, left, 1, &right, &caught_exception);
- if (caught_exception) return Failure::Exception();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate(), result,
+ Execution::Call(isolate(), function, left, 1, &right));
// Execution::Call can execute arbitrary JavaScript, hence potentially
// update the state of this very IC, so we must update the stored state.
// before throwing as uncaught exception. Note that the pending
// exception object to be set later must not be turned into a string.
if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) {
- bool failed = false;
- exception_arg =
- Execution::ToDetailString(this, exception_arg, &failed);
- if (failed) {
+ MaybeHandle<Object> maybe_exception =
+ Execution::ToDetailString(this, exception_arg);
+ if (!maybe_exception.ToHandle(&exception_arg)) {
exception_arg = factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("exception"));
}
// Call toJSON function.
if (key->IsSmi()) key = factory_->NumberToString(key);
Handle<Object> argv[] = { key };
- bool has_exception = false;
HandleScope scope(isolate_);
- object = Execution::Call(isolate_, fun, object, 1, argv, &has_exception);
- // Return empty handle to signal an exception.
- if (has_exception) return MaybeHandle<Object>();
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate_, object,
+ Execution::Call(isolate_, fun, object, 1, argv),
+ Object);
return scope.CloseAndEscape(object);
}
GetProperty(builtins, "JSONSerializeAdapter").ToHandleChecked());
Handle<Object> argv[] = { key, object };
- bool has_exception = false;
- Handle<Object> result =
- Execution::Call(isolate_, builtin, object, 2, argv, &has_exception);
- if (has_exception) return EXCEPTION;
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, result,
+ Execution::Call(isolate_, builtin, object, 2, argv),
+ EXCEPTION);
if (result->IsUndefined()) return UNCHANGED;
if (deferred_key) {
if (key->IsSmi()) key = factory_->NumberToString(key);
BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue(
Handle<JSValue> object) {
- bool has_exception = false;
String* class_name = object->class_name();
if (class_name == isolate_->heap()->String_string()) {
- Handle<Object> value =
- Execution::ToString(isolate_, object, &has_exception);
- if (has_exception) return EXCEPTION;
+ Handle<Object> value;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, value, Execution::ToString(isolate_, object), EXCEPTION);
SerializeString(Handle<String>::cast(value));
} else if (class_name == isolate_->heap()->Number_string()) {
- Handle<Object> value =
- Execution::ToNumber(isolate_, object, &has_exception);
- if (has_exception) return EXCEPTION;
+ Handle<Object> value;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate_, value, Execution::ToNumber(isolate_, object), EXCEPTION);
if (value->IsSmi()) return SerializeSmi(Smi::cast(*value));
SerializeHeapNumber(Handle<HeapNumber>::cast(value));
} else {
namespace v8 {
namespace internal {
-Handle<Object> RegExpImpl::CreateRegExpLiteral(Handle<JSFunction> constructor,
- Handle<String> pattern,
- Handle<String> flags,
- bool* has_pending_exception) {
+MaybeHandle<Object> RegExpImpl::CreateRegExpLiteral(
+ Handle<JSFunction> constructor,
+ Handle<String> pattern,
+ Handle<String> flags) {
// Call the construct code with 2 arguments.
Handle<Object> argv[] = { pattern, flags };
- return Execution::New(constructor, ARRAY_SIZE(argv), argv,
- has_pending_exception);
+ return Execution::New(constructor, ARRAY_SIZE(argv), argv);
}
// Creates a regular expression literal in the old space.
// This function calls the garbage collector if necessary.
- static Handle<Object> CreateRegExpLiteral(Handle<JSFunction> constructor,
- Handle<String> pattern,
- Handle<String> flags,
- bool* has_pending_exception);
+ MUST_USE_RESULT static MaybeHandle<Object> CreateRegExpLiteral(
+ Handle<JSFunction> constructor,
+ Handle<String> pattern,
+ Handle<String> flags);
// Returns a string representation of a regular expression.
// Implements RegExp.prototype.toString, see ECMA-262 section 15.10.6.4.
Handle<Object> argv[] = { Handle<Object>(message->type(), isolate),
Handle<Object>(message->arguments(), isolate) };
- bool caught_exception;
- Handle<Object> result =
- Execution::TryCall(fun,
- isolate->js_builtins_object(),
- ARRAY_SIZE(argv),
- argv,
- &caught_exception);
-
- if (caught_exception || !result->IsString()) {
+ MaybeHandle<Object> maybe_result = Execution::TryCall(
+ fun, isolate->js_builtins_object(), ARRAY_SIZE(argv), argv);
+ Handle<Object> result;
+ if (!maybe_result.ToHandle(&result) || !result->IsString()) {
return factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("<error>"));
}
Handle<String> result_string = Handle<String>::cast(result);
}
#endif
- bool has_pending_exception;
- Handle<Object> result = Execution::Call(
- isolate, getter, receiver, 0, NULL, &has_pending_exception, true);
- // Check for pending exception and return the result.
- if (has_pending_exception) return MaybeHandle<Object>();
- return result;
+ return Execution::Call(isolate, getter, receiver, 0, NULL, true);
}
}
Handle<Object> args[] = { type, object, name, old_value };
int argc = name.is_null() ? 2 : old_value->IsTheHole() ? 3 : 4;
- bool threw;
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_notify_change()),
isolate->factory()->undefined_value(),
- argc, args,
- &threw);
- ASSERT(!threw);
+ argc, args).Assert();
}
}
-Handle<Object> JSReceiver::SetPropertyWithDefinedSetter(
+MaybeHandle<Object> JSReceiver::SetPropertyWithDefinedSetter(
Handle<JSReceiver> object,
Handle<JSReceiver> setter,
Handle<Object> value) {
}
#endif
- bool has_pending_exception;
Handle<Object> argv[] = { value };
- Execution::Call(
- isolate, setter, object, ARRAY_SIZE(argv), argv, &has_pending_exception);
- // Check for pending exception and return the result.
- if (has_pending_exception) return Handle<Object>();
+ RETURN_ON_EXCEPTION(
+ isolate,
+ Execution::Call(isolate, setter, object, ARRAY_SIZE(argv), argv),
+ Object);
return value;
}
}
// Emulate [[GetProperty]] semantics for proxies.
- bool has_pending_exception;
Handle<Object> argv[] = { result };
- Handle<Object> desc = Execution::Call(
- isolate, isolate->to_complete_property_descriptor(), result,
- ARRAY_SIZE(argv), argv, &has_pending_exception);
- if (has_pending_exception) return MaybeHandle<Object>();
+ Handle<Object> desc;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, desc,
+ Execution::Call(isolate,
+ isolate->to_complete_property_descriptor(),
+ result,
+ ARRAY_SIZE(argv),
+ argv),
+ Object);
// [[GetProperty]] requires to check that all properties are configurable.
Handle<String> configurable_name =
if (result->IsUndefined()) return ABSENT;
- bool has_pending_exception;
Handle<Object> argv[] = { result };
- Handle<Object> desc = Execution::Call(
- isolate, isolate->to_complete_property_descriptor(), result,
- ARRAY_SIZE(argv), argv, &has_pending_exception);
- if (has_pending_exception) return NONE;
+ Handle<Object> desc;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, desc,
+ Execution::Call(isolate,
+ isolate->to_complete_property_descriptor(),
+ result,
+ ARRAY_SIZE(argv),
+ argv),
+ NONE);
// Convert result to PropertyAttributes.
Handle<String> enum_n = isolate->factory()->InternalizeOneByteString(
trap = Handle<Object>(derived);
}
- bool threw;
- return Execution::Call(isolate, trap, handler, argc, argv, &threw);
+ return Execution::Call(isolate, trap, handler, argc, argv);
}
Handle<Object> args[] =
{ object, index_object, deleted, add_count_object };
- bool threw;
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_enqueue_splice()),
- isolate->factory()->undefined_value(), ARRAY_SIZE(args), args,
- &threw);
- ASSERT(!threw);
+ isolate->factory()->undefined_value(),
+ ARRAY_SIZE(args),
+ args).Assert();
}
HandleScope scope(isolate);
Handle<Object> args[] = { object };
- bool threw;
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_begin_perform_splice()),
- isolate->factory()->undefined_value(), ARRAY_SIZE(args), args,
- &threw);
- ASSERT(!threw);
+ isolate->factory()->undefined_value(),
+ ARRAY_SIZE(args),
+ args).Assert();
}
HandleScope scope(isolate);
Handle<Object> args[] = { object };
- bool threw;
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_end_perform_splice()),
- isolate->factory()->undefined_value(), ARRAY_SIZE(args), args,
- &threw);
- ASSERT(!threw);
+ isolate->factory()->undefined_value(),
+ ARRAY_SIZE(args),
+ args).Assert();
}
}
-Handle<Object> JSObject::SetElementWithCallback(Handle<JSObject> object,
- Handle<Object> structure,
- uint32_t index,
- Handle<Object> value,
- Handle<JSObject> holder,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSObject::SetElementWithCallback(Handle<JSObject> object,
+ Handle<Object> structure,
+ uint32_t index,
+ Handle<Object> value,
+ Handle<JSObject> holder,
+ StrictMode strict_mode) {
Isolate* isolate = object->GetIsolate();
// We should never get here to initialize a const with the hole
args.Call(call_fun,
v8::Utils::ToLocal(key),
v8::Utils::ToLocal(value));
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
return value;
}
Handle<Object> args[2] = { key, holder };
Handle<Object> error = isolate->factory()->NewTypeError(
"no_setter_in_callback", HandleVector(args, 2));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
}
if (structure->IsDeclaredAccessorInfo()) return value;
UNREACHABLE();
- return Handle<Object>();
+ return MaybeHandle<Object>();
}
if (object->HasExternalArrayElements() ||
object->HasFixedTypedArrayElements()) {
if (!value->IsNumber() && !value->IsUndefined()) {
- bool has_exception;
- Handle<Object> number =
- Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return MaybeHandle<Object>();
- value = number;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value,
+ Execution::ToNumber(isolate, value), Object);
}
}
protected:
Smi* GenerateIdentityHash();
- static Handle<Object> SetPropertyWithDefinedSetter(Handle<JSReceiver> object,
- Handle<JSReceiver> setter,
- Handle<Object> value);
+ MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter(
+ Handle<JSReceiver> object,
+ Handle<JSReceiver> setter,
+ Handle<Object> value);
private:
static PropertyAttributes GetPropertyAttributeForResult(
Handle<JSReceiver> receiver,
uint32_t index,
bool continue_search);
- static Handle<Object> SetElementWithCallback(
+ MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback(
Handle<JSObject> object,
Handle<Object> structure,
uint32_t index,
};
-MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(
- Isolate* isolate,
- Handle<JSObject> obj,
- Handle<Name> name) {
+MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
+ Handle<JSObject> obj,
+ Handle<Name> name) {
Heap* heap = isolate->heap();
Factory* factory = isolate->factory();
// Due to some WebKit tests, we want to make sure that we do not log
// more than one access failure here.
AccessCheckResult access_check_result =
CheckPropertyAccess(obj, name, v8::ACCESS_HAS);
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
switch (access_check_result) {
case ACCESS_FORBIDDEN: return factory->false_value();
case ACCESS_ALLOWED: break;
PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name);
if (attrs == ABSENT) {
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
return factory->undefined_value();
}
ASSERT(!isolate->has_scheduled_exception());
CONVERT_SMI_ARG_CHECKED(index, 1)
int offset = index * kPointerSize + HeapObject::kHeaderSize;
InstanceType type = templ->map()->instance_type();
- RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE ||
- type == OBJECT_TEMPLATE_INFO_TYPE);
+ RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE ||
+ type == OBJECT_TEMPLATE_INFO_TYPE);
RUNTIME_ASSERT(offset > 0);
if (type == FUNCTION_TEMPLATE_INFO_TYPE) {
RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize);
CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
if (!callable->IsJSFunction()) {
HandleScope scope(isolate);
- bool threw = false;
- Handle<Object> delegate = Execution::TryGetFunctionDelegate(
- isolate, Handle<JSReceiver>(callable), &threw);
- if (threw) return Failure::Exception();
+ Handle<Object> delegate;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, delegate,
+ Execution::TryGetFunctionDelegate(
+ isolate, Handle<JSReceiver>(callable)));
callable = JSFunction::cast(*delegate);
}
JSFunction* function = JSFunction::cast(callable);
if (!callable->IsJSFunction()) {
HandleScope scope(isolate);
- bool threw = false;
- Handle<Object> delegate = Execution::TryGetFunctionDelegate(
- isolate, Handle<JSReceiver>(callable), &threw);
- if (threw) return Failure::Exception();
+ Handle<Object> delegate;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, delegate,
+ Execution::TryGetFunctionDelegate(
+ isolate, Handle<JSReceiver>(callable)));
callable = JSFunction::cast(*delegate);
}
JSFunction* function = JSFunction::cast(callable);
Handle<JSFunction>(
JSFunction::NativeContextFromLiterals(*literals)->regexp_function());
// Compute the regular expression literal.
- bool has_pending_exception;
- Handle<Object> regexp =
- RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags,
- &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<Object> regexp;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, regexp,
+ RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags));
literals->set(index, *regexp);
return *regexp;
}
}
-static Handle<Name> ToName(Isolate* isolate, Handle<Object> key) {
+MUST_USE_RESULT
+static MaybeHandle<Name> ToName(Isolate* isolate, Handle<Object> key) {
if (key->IsName()) {
return Handle<Name>::cast(key);
} else {
- bool has_pending_exception = false;
- Handle<Object> converted =
- Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return Handle<Name>();
+ Handle<Object> converted;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, converted, Execution::ToString(isolate, key), Name);
return Handle<Name>::cast(converted);
}
}
}
// Convert the key to a name - possibly by calling back into JavaScript.
- Handle<Name> name = ToName(isolate, key);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, MaybeHandle<Object>());
+ Handle<Name> name;
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object);
return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name));
}
Handle<Object> key) {
if (object->IsUndefined() || object->IsNull()) {
Handle<Object> args[2] = { key, object };
- isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load",
- HandleVector(args, 2)));
- return Handle<Object>();
+ return isolate->Throw<Object>(
+ isolate->factory()->NewTypeError("non_object_property_load",
+ HandleVector(args, 2)));
}
// Check if the given key is an array index.
}
// Convert the key to a name - possibly by calling back into JavaScript.
- Handle<Name> name = ToName(isolate, key);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, Handle<Object>());
+ Handle<Name> name;
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object);
// Check if the name is trivially convertible to an index and get
// the element if so.
}
if (object->IsJSProxy()) {
- bool has_pending_exception = false;
- Handle<Object> name_object = key->IsSymbol()
- ? key : Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return MaybeHandle<Object>(); // exception
+ Handle<Object> name_object;
+ if (key->IsSymbol()) {
+ name_object = key;
+ } else {
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, name_object, Execution::ToString(isolate, key), Object);
+ }
Handle<Name> name = Handle<Name>::cast(name_object);
return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
attr,
if (js_object->HasExternalArrayElements() ||
js_object->HasFixedTypedArrayElements()) {
if (!value->IsNumber() && !value->IsUndefined()) {
- bool has_exception;
- Handle<Object> number =
- Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return MaybeHandle<Object>(); // exception
- value = number;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value, Execution::ToNumber(isolate, value), Object);
}
}
if (name->AsArrayIndex(&index)) {
if (js_object->HasExternalArrayElements()) {
if (!value->IsNumber() && !value->IsUndefined()) {
- bool has_exception;
- Handle<Object> number =
- Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return MaybeHandle<Object>(); // exception
- value = number;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value, Execution::ToNumber(isolate, value), Object);
}
}
return JSObject::SetElement(js_object, index, value, attr,
}
// Call-back into JavaScript to convert the key to a string.
- bool has_pending_exception = false;
- Handle<Object> converted =
- Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return MaybeHandle<Object>(); // exception
+ Handle<Object> converted;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, converted, Execution::ToString(isolate, key), Object);
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
}
// Call-back into JavaScript to convert the key to a string.
- bool has_pending_exception = false;
- Handle<Object> converted =
- Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return MaybeHandle<Object>(); // exception
+ Handle<Object> converted;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, converted, Execution::ToString(isolate, key), Object);
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
name = Handle<Name>::cast(key);
} else {
// Call-back into JavaScript to convert the key to a string.
- bool has_pending_exception = false;
- Handle<Object> converted = Execution::ToString(
- isolate, key, &has_pending_exception);
- if (has_pending_exception) return MaybeHandle<Object>();
+ Handle<Object> converted;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, converted, Execution::ToString(isolate, key), Object);
name = Handle<String>::cast(converted);
}
ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
Handle<JSArray> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, GetKeysFor(object));
- return *result;
+
+ isolate->counters()->for_in()->Increment();
+ Handle<FixedArray> elements;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, elements, GetKeysInFixedArrayFor(object, INCLUDE_PROTOS));
+ return *isolate->factory()->NewJSArrayWithElements(elements);
}
}
// Convert the key to a string.
- bool exception = false;
- Handle<Object> converted =
- Execution::ToString(isolate, args.at<Object>(0), &exception);
- if (exception) return Failure::Exception();
+ Handle<Object> converted;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, converted, Execution::ToString(isolate, args.at<Object>(0)));
Handle<String> key = Handle<String>::cast(converted);
// Try to convert the string key into an array index.
}
if (!bound_function->IsJSFunction()) {
- bool exception_thrown;
- bound_function = Execution::TryGetConstructorDelegate(isolate,
- bound_function,
- &exception_thrown);
- if (exception_thrown) return Failure::Exception();
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, bound_function,
+ Execution::TryGetConstructorDelegate(isolate, bound_function));
}
ASSERT(bound_function->IsJSFunction());
- bool exception = false;
- Handle<Object> result =
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
Execution::New(Handle<JSFunction>::cast(bound_function),
- total_argc, param_data.get(), &exception);
- if (exception) {
- return Failure::Exception();
- }
- ASSERT(!result.is_null());
+ total_argc, param_data.get()));
return *result;
}
argv[i] = Handle<Object>(object, isolate);
}
- bool threw;
Handle<JSReceiver> hfun(fun);
Handle<Object> hreceiver(receiver, isolate);
- Handle<Object> result = Execution::Call(
- isolate, hfun, hreceiver, argc, argv, &threw, true);
-
- if (threw) return Failure::Exception();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Execution::Call(isolate, hfun, hreceiver, argc, argv, true));
return *result;
}
Object::GetElement(isolate, arguments, offset + i));
}
- bool threw;
- Handle<Object> result = Execution::Call(
- isolate, fun, receiver, argc, argv, &threw, true);
-
- if (threw) return Failure::Exception();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Execution::Call(isolate, fun, receiver, argc, argv, true));
return *result;
}
RelocInfo::kNoPosition);
RETURN_IF_EMPTY_HANDLE(isolate, eval_fun);
- bool pending_exception;
- Handle<Object> result = Execution::Call(
- isolate, eval_fun, receiver, 0, NULL, &pending_exception);
-
- if (pending_exception) return Failure::Exception();
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Execution::Call(isolate, eval_fun, receiver, 0, NULL));
// Skip the global proxy as it has no properties and always delegates to the
// real global object.
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1);
- Handle<Object> result;
- bool pending_exception;
- {
- if (without_debugger) {
- result = Execution::Call(isolate,
- function,
- isolate->global_object(),
- 0,
- NULL,
- &pending_exception);
- } else {
- EnterDebugger enter_debugger(isolate);
- result = Execution::Call(isolate,
- function,
- isolate->global_object(),
- 0,
- NULL,
- &pending_exception);
- }
- }
- if (!pending_exception) {
- return *result;
+ MaybeHandle<Object> maybe_result;
+ if (without_debugger) {
+ maybe_result = Execution::Call(isolate,
+ function,
+ isolate->global_object(),
+ 0,
+ NULL);
} else {
- return Failure::Exception();
+ EnterDebugger enter_debugger(isolate);
+ maybe_result = Execution::Call(isolate,
+ function,
+ isolate->global_object(),
+ 0,
+ NULL);
}
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result);
+ return *result;
}
I18N::GetTemplate(isolate);
// Create an empty object wrapper.
- bool has_pending_exception = false;
- Handle<JSObject> local_object = Execution::InstantiateObject(
- date_format_template, &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<JSObject> local_object;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, local_object,
+ Execution::InstantiateObject(date_format_template));
// Set date time formatter as internal field of the resulting JS object.
icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat(
CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
- bool has_pending_exception = false;
- Handle<Object> value =
- Execution::ToNumber(isolate, date, &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<Object> value;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, value, Execution::ToNumber(isolate, date));
icu::SimpleDateFormat* date_format =
DateFormat::UnpackDateFormat(isolate, date_format_holder);
UDate date = date_format->parse(u_date, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
- bool has_pending_exception = false;
- Handle<JSDate> result = Handle<JSDate>::cast(
- Execution::NewDate(
- isolate, static_cast<double>(date), &has_pending_exception));
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Execution::NewDate(isolate, static_cast<double>(date)));
+ ASSERT(result->IsJSDate());
return *result;
}
I18N::GetTemplate(isolate);
// Create an empty object wrapper.
- bool has_pending_exception = false;
- Handle<JSObject> local_object = Execution::InstantiateObject(
- number_format_template, &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<JSObject> local_object;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, local_object,
+ Execution::InstantiateObject(number_format_template));
// Set number formatter as internal field of the resulting JS object.
icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat(
CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
- bool has_pending_exception = false;
- Handle<Object> value = Execution::ToNumber(
- isolate, number, &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<Object> value;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, value, Execution::ToNumber(isolate, number));
icu::DecimalFormat* number_format =
NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
// Create an empty object wrapper.
- bool has_pending_exception = false;
- Handle<JSObject> local_object = Execution::InstantiateObject(
- collator_template, &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<JSObject> local_object;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, local_object, Execution::InstantiateObject(collator_template));
// Set collator as internal field of the resulting JS object.
icu::Collator* collator = Collator::InitializeCollator(
I18N::GetTemplate2(isolate);
// Create an empty object wrapper.
- bool has_pending_exception = false;
- Handle<JSObject> local_object = Execution::InstantiateObject(
- break_iterator_template, &has_pending_exception);
- if (has_pending_exception) {
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ Handle<JSObject> local_object;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, local_object,
+ Execution::InstantiateObject(break_iterator_template));
// Set break iterator as internal field of the resulting JS object.
icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
isolate);
// This handle is nor shared, nor used later, so it's safe.
Handle<Object> argv[] = { key_handle };
- bool pending_exception;
- value = Execution::Call(isolate,
- factory,
- receiver,
- ARRAY_SIZE(argv),
- argv,
- &pending_exception);
- if (pending_exception) return Failure::Exception();
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, value,
+ Execution::Call(isolate, factory, receiver, ARRAY_SIZE(argv), argv));
}
#ifdef VERIFY_HEAP
RUNTIME_FUNCTION(MaybeObject*, Runtime_RunMicrotasks) {
HandleScope scope(isolate);
ASSERT(args.length() == 0);
- if (isolate->microtask_pending())
- Execution::RunMicrotasks(isolate);
+ if (isolate->microtask_pending()) Execution::RunMicrotasks(isolate);
return isolate->heap()->undefined_value();
}
Handle<JSFunction> fun = Compile(buffer.start());
if (fun.is_null()) return -1;
- bool has_pending_exception;
Handle<JSObject> global(isolate->context()->global_object());
- Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ Execution::Call(isolate, fun, global, 0, NULL).Check();
return GetGlobalProperty("result")->Number();
}
SetGlobalProperty("x", Smi::FromInt(x));
SetGlobalProperty("y", Smi::FromInt(y));
- bool has_pending_exception;
Handle<JSObject> global(isolate->context()->global_object());
- Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ Execution::Call(isolate, fun, global, 0, NULL).Check();
return GetGlobalProperty("result")->Number();
}
if (fun.is_null()) return -1;
SetGlobalProperty("x", Smi::FromInt(x));
- bool has_pending_exception;
Handle<JSObject> global(isolate->context()->global_object());
- Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ Execution::Call(isolate, fun, global, 0, NULL).Check();
return GetGlobalProperty("result")->Number();
}
if (fun.is_null()) return -1;
SetGlobalProperty("n", Smi::FromInt(n));
- bool has_pending_exception;
Handle<JSObject> global(isolate->context()->global_object());
- Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ Execution::Call(isolate, fun, global, 0, NULL).Check();
return GetGlobalProperty("result")->Number();
}
const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);";
Handle<JSFunction> fun = Compile(source);
if (fun.is_null()) return;
- bool has_pending_exception;
Handle<JSObject> global(CcTest::i_isolate()->context()->global_object());
- Execution::Call(
- CcTest::i_isolate(), fun, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ Execution::Call(CcTest::i_isolate(), fun, global, 0, NULL).Check();
}
Handle<JSFunction> fun = Compile(source);
CHECK(!fun.is_null());
- bool has_pending_exception;
Handle<JSObject> global(CcTest::i_isolate()->context()->global_object());
Execution::Call(
- CcTest::i_isolate(), fun, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ CcTest::i_isolate(), fun, global, 0, NULL).Check();
CHECK_EQ(511.0, GetGlobalProperty("r")->Number());
}
const char* source = "throw 42;";
Handle<JSFunction> fun = Compile(source);
CHECK(!fun.is_null());
- bool has_pending_exception;
Isolate* isolate = fun->GetIsolate();
Handle<JSObject> global(isolate->context()->global_object());
- Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
- CHECK(has_pending_exception);
+ CHECK(Execution::Call(isolate, fun, global, 0, NULL).is_null());
CHECK_EQ(42.0, isolate->pending_exception()->Number());
}
Isolate* isolate = fun0->GetIsolate();
// Run the generated code to populate the global object with 'foo'.
- bool has_pending_exception;
Handle<JSObject> global(isolate->context()->global_object());
- Execution::Call(
- isolate, fun0, global, 0, NULL, &has_pending_exception);
- CHECK(!has_pending_exception);
+ Execution::Call(isolate, fun0, global, 0, NULL).Check();
Handle<String> foo_string = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("foo"));
Handle<JSFunction>::cast(fun1),
global,
ARRAY_SIZE(argv),
- argv,
- &has_pending_exception);
- CHECK(!has_pending_exception);
+ argv).Check();
}
static void CheckOddball(Isolate* isolate, Object* obj, const char* string) {
CHECK(obj->IsOddball());
- bool exc;
Handle<Object> handle(obj, isolate);
Object* print_string =
- *Execution::ToString(isolate, handle, &exc);
+ *Execution::ToString(isolate, handle).ToHandleChecked();
CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
}
static void CheckSmi(Isolate* isolate, int value, const char* string) {
- bool exc;
Handle<Object> handle(Smi::FromInt(value), isolate);
Object* print_string =
- *Execution::ToString(isolate, handle, &exc);
+ *Execution::ToString(isolate, handle).ToHandleChecked();
CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
}
static void CheckNumber(Isolate* isolate, double value, const char* string) {
Object* obj = CcTest::heap()->NumberFromDouble(value)->ToObjectChecked();
CHECK(obj->IsNumber());
- bool exc;
Handle<Object> handle(obj, isolate);
Object* print_string =
- *Execution::ToString(isolate, handle, &exc);
+ *Execution::ToString(isolate, handle).ToHandleChecked();
CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
}
i::Handle<i::Object> format_fun =
i::GetProperty(builtins, "FormatMessage").ToHandleChecked();
i::Handle<i::Object> arg_handles[] = { format, args_array };
- bool has_exception = false;
i::Handle<i::Object> result = i::Execution::Call(
- isolate, format_fun, builtins, 2, arg_handles, &has_exception);
- CHECK(!has_exception);
+ isolate, format_fun, builtins, 2, arg_handles).ToHandleChecked();
CHECK(result->IsString());
for (int i = 0; i < args.length(); i++) {
i::DeleteArray(args[i]);