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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/execution.h" 5 #include "src/execution.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 52
53 MUST_USE_RESULT static MaybeHandle<Object> Invoke( 53 MUST_USE_RESULT static MaybeHandle<Object> Invoke(
54 bool is_construct, 54 bool is_construct,
55 Handle<JSFunction> function, 55 Handle<JSFunction> function,
56 Handle<Object> receiver, 56 Handle<Object> receiver,
57 int argc, 57 int argc,
58 Handle<Object> args[]) { 58 Handle<Object> args[]) {
59 Isolate* isolate = function->GetIsolate(); 59 Isolate* isolate = function->GetIsolate();
60 60
61 // api callbacks can be called directly.
62 if (!is_construct && function->shared()->IsApiFunction()) {
63 SaveContext save(isolate);
64 isolate->set_context(function->context());
65 if (receiver->IsGlobalObject()) {
66 receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy());
67 }
68 DCHECK(function->context()->global_object()->IsGlobalObject());
69 auto value = Builtins::InvokeApiFunction(function, receiver, argc, args);
70 bool has_exception = value.is_null();
71 DCHECK(has_exception == isolate->has_pending_exception());
72 if (has_exception) {
73 isolate->ReportPendingMessages();
74 return MaybeHandle<Object>();
75 } else {
76 isolate->clear_pending_message();
77 }
78 return value;
79 }
80
61 // Entering JavaScript. 81 // Entering JavaScript.
62 VMState<JS> state(isolate); 82 VMState<JS> state(isolate);
63 CHECK(AllowJavascriptExecution::IsAllowed(isolate)); 83 CHECK(AllowJavascriptExecution::IsAllowed(isolate));
64 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) { 84 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) {
65 isolate->ThrowIllegalOperation(); 85 isolate->ThrowIllegalOperation();
66 isolate->ReportPendingMessages(); 86 isolate->ReportPendingMessages();
67 return MaybeHandle<Object>(); 87 return MaybeHandle<Object>();
68 } 88 }
69 89
70 // Placeholder for return value. 90 // Placeholder for return value.
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 745 }
726 746
727 isolate_->counters()->stack_interrupts()->Increment(); 747 isolate_->counters()->stack_interrupts()->Increment();
728 isolate_->counters()->runtime_profiler_ticks()->Increment(); 748 isolate_->counters()->runtime_profiler_ticks()->Increment();
729 isolate_->runtime_profiler()->OptimizeNow(); 749 isolate_->runtime_profiler()->OptimizeNow();
730 750
731 return isolate_->heap()->undefined_value(); 751 return isolate_->heap()->undefined_value();
732 } 752 }
733 753
734 } } // namespace v8::internal 754 } } // namespace v8::internal
OLDNEW
« 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