diff options
Diffstat (limited to 'deps/v8/src/builtins.cc')
-rw-r--r-- | deps/v8/src/builtins.cc | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/deps/v8/src/builtins.cc b/deps/v8/src/builtins.cc index 84a0c3d19c..01e88f5593 100644 --- a/deps/v8/src/builtins.cc +++ b/deps/v8/src/builtins.cc @@ -1103,7 +1103,7 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallHelper( CustomArguments custom(isolate); v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), - isolate, data_obj, *function, raw_holder); + data_obj, *function, raw_holder); v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( custom.end(), @@ -1143,6 +1143,68 @@ BUILTIN(HandleApiCallConstruct) { } +#ifdef DEBUG + +static void VerifyTypeCheck(Handle<JSObject> object, + Handle<JSFunction> function) { + ASSERT(function->shared()->IsApiFunction()); + FunctionTemplateInfo* info = function->shared()->get_api_func_data(); + if (info->signature()->IsUndefined()) return; + SignatureInfo* signature = SignatureInfo::cast(info->signature()); + Object* receiver_type = signature->receiver(); + if (receiver_type->IsUndefined()) return; + FunctionTemplateInfo* type = FunctionTemplateInfo::cast(receiver_type); + ASSERT(object->IsInstanceOf(type)); +} + +#endif + + +BUILTIN(FastHandleApiCall) { + ASSERT(!CalledAsConstructor(isolate)); + Heap* heap = isolate->heap(); + const bool is_construct = false; + + // We expect four more arguments: callback, function, call data, and holder. + const int args_length = args.length() - 4; + ASSERT(args_length >= 0); + + Object* callback_obj = args[args_length]; + + v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( + &args[args_length + 1], + &args[0] - 1, + args_length - 1, + is_construct); + +#ifdef DEBUG + VerifyTypeCheck(Utils::OpenHandle(*new_args.Holder()), + Utils::OpenHandle(*new_args.Callee())); +#endif + HandleScope scope(isolate); + Object* result; + v8::Handle<v8::Value> value; + { + // Leaving JavaScript. + VMState state(isolate, EXTERNAL); + ExternalCallbackScope call_scope(isolate, + v8::ToCData<Address>(callback_obj)); + v8::InvocationCallback callback = + v8::ToCData<v8::InvocationCallback>(callback_obj); + + value = callback(new_args); + } + if (value.IsEmpty()) { + result = heap->undefined_value(); + } else { + result = *reinterpret_cast<Object**>(*value); + } + + RETURN_IF_SCHEDULED_EXCEPTION(isolate); + return result; +} + + // Helper function to handle calls to non-function objects created through the // API. The object can be called as either a constructor (using new) or just as // a function (without new). @@ -1181,7 +1243,7 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor( CustomArguments custom(isolate); v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), - isolate, call_data->data(), constructor, obj); + call_data->data(), constructor, obj); v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( custom.end(), &args[0] - 1, |