OLD | NEW |
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 Loading... |
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 | |
81 // Entering JavaScript. | 61 // Entering JavaScript. |
82 VMState<JS> state(isolate); | 62 VMState<JS> state(isolate); |
83 CHECK(AllowJavascriptExecution::IsAllowed(isolate)); | 63 CHECK(AllowJavascriptExecution::IsAllowed(isolate)); |
84 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) { | 64 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) { |
85 isolate->ThrowIllegalOperation(); | 65 isolate->ThrowIllegalOperation(); |
86 isolate->ReportPendingMessages(); | 66 isolate->ReportPendingMessages(); |
87 return MaybeHandle<Object>(); | 67 return MaybeHandle<Object>(); |
88 } | 68 } |
89 | 69 |
90 // Placeholder for return value. | 70 // Placeholder for return value. |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 } | 725 } |
746 | 726 |
747 isolate_->counters()->stack_interrupts()->Increment(); | 727 isolate_->counters()->stack_interrupts()->Increment(); |
748 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 728 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
749 isolate_->runtime_profiler()->OptimizeNow(); | 729 isolate_->runtime_profiler()->OptimizeNow(); |
750 | 730 |
751 return isolate_->heap()->undefined_value(); | 731 return isolate_->heap()->undefined_value(); |
752 } | 732 } |
753 | 733 |
754 } } // namespace v8::internal | 734 } } // namespace v8::internal |
OLD | NEW |