Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: src/execution.cc

Issue 869963002: Reland "Call directly to c callbacks in Invoke instead of transitioning to js and back out" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698