Index: src/execution.cc |
diff --git a/src/execution.cc b/src/execution.cc |
index 998afb8524e6aab5c81205e1dd3d84b75c537c8e..9f418ac5d843e0a1f300974313e5c404e28d58fb 100644 |
--- a/src/execution.cc |
+++ b/src/execution.cc |
@@ -58,6 +58,26 @@ MUST_USE_RESULT static MaybeHandle<Object> Invoke( |
Handle<Object> args[]) { |
Isolate* isolate = function->GetIsolate(); |
+ // api callbacks can be called directly. |
+ if (!is_construct && function->shared()->IsApiFunction()) { |
+ SaveContext save(isolate); |
+ isolate->set_context(function->context()); |
+ if (receiver->IsGlobalObject()) { |
+ receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy()); |
+ } |
+ DCHECK(function->context()->global_object()->IsGlobalObject()); |
+ auto value = Builtins::InvokeApiFunction(function, receiver, argc, args); |
+ bool has_exception = value.is_null(); |
+ DCHECK(has_exception == isolate->has_pending_exception()); |
+ if (has_exception) { |
+ isolate->ReportPendingMessages(); |
+ return MaybeHandle<Object>(); |
+ } else { |
+ isolate->clear_pending_message(); |
+ } |
+ return value; |
+ } |
+ |
// Entering JavaScript. |
VMState<JS> state(isolate); |
CHECK(AllowJavascriptExecution::IsAllowed(isolate)); |