| 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 | 53 |
| 54 namespace { | 54 namespace { |
| 55 | 55 |
| 56 MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct, | 56 MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct, |
| 57 Handle<Object> target, | 57 Handle<Object> target, |
| 58 Handle<Object> receiver, int argc, | 58 Handle<Object> receiver, int argc, |
| 59 Handle<Object> args[], | 59 Handle<Object> args[], |
| 60 Handle<Object> new_target) { | 60 Handle<Object> new_target) { |
| 61 DCHECK(!receiver->IsGlobalObject()); | 61 DCHECK(!receiver->IsJSGlobalObject()); |
| 62 | 62 |
| 63 // Entering JavaScript. | 63 // Entering JavaScript. |
| 64 VMState<JS> state(isolate); | 64 VMState<JS> state(isolate); |
| 65 CHECK(AllowJavascriptExecution::IsAllowed(isolate)); | 65 CHECK(AllowJavascriptExecution::IsAllowed(isolate)); |
| 66 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) { | 66 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) { |
| 67 isolate->ThrowIllegalOperation(); | 67 isolate->ThrowIllegalOperation(); |
| 68 isolate->ReportPendingMessages(); | 68 isolate->ReportPendingMessages(); |
| 69 return MaybeHandle<Object>(); | 69 return MaybeHandle<Object>(); |
| 70 } | 70 } |
| 71 | 71 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } // namespace | 124 } // namespace |
| 125 | 125 |
| 126 | 126 |
| 127 // static | 127 // static |
| 128 MaybeHandle<Object> Execution::Call(Isolate* isolate, Handle<Object> callable, | 128 MaybeHandle<Object> Execution::Call(Isolate* isolate, Handle<Object> callable, |
| 129 Handle<Object> receiver, int argc, | 129 Handle<Object> receiver, int argc, |
| 130 Handle<Object> argv[]) { | 130 Handle<Object> argv[]) { |
| 131 // Convert calls on global objects to be calls on the global | 131 // Convert calls on global objects to be calls on the global |
| 132 // receiver instead to avoid having a 'this' pointer which refers | 132 // receiver instead to avoid having a 'this' pointer which refers |
| 133 // directly to a global object. | 133 // directly to a global object. |
| 134 if (receiver->IsGlobalObject()) { | 134 if (receiver->IsJSGlobalObject()) { |
| 135 receiver = | 135 receiver = |
| 136 handle(Handle<GlobalObject>::cast(receiver)->global_proxy(), isolate); | 136 handle(Handle<JSGlobalObject>::cast(receiver)->global_proxy(), isolate); |
| 137 } | 137 } |
| 138 | 138 |
| 139 // api callbacks can be called directly. | 139 // api callbacks can be called directly. |
| 140 if (callable->IsJSFunction() && | 140 if (callable->IsJSFunction() && |
| 141 Handle<JSFunction>::cast(callable)->shared()->IsApiFunction()) { | 141 Handle<JSFunction>::cast(callable)->shared()->IsApiFunction()) { |
| 142 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | 142 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); |
| 143 SaveContext save(isolate); | 143 SaveContext save(isolate); |
| 144 isolate->set_context(function->context()); | 144 isolate->set_context(function->context()); |
| 145 // Do proper receiver conversion for non-strict mode api functions. | 145 // Do proper receiver conversion for non-strict mode api functions. |
| 146 if (!receiver->IsJSReceiver() && | 146 if (!receiver->IsJSReceiver() && |
| 147 is_sloppy(function->shared()->language_mode())) { | 147 is_sloppy(function->shared()->language_mode())) { |
| 148 if (receiver->IsUndefined() || receiver->IsNull()) { | 148 if (receiver->IsUndefined() || receiver->IsNull()) { |
| 149 receiver = handle(function->global_proxy(), isolate); | 149 receiver = handle(function->global_proxy(), isolate); |
| 150 } else { | 150 } else { |
| 151 ASSIGN_RETURN_ON_EXCEPTION( | 151 ASSIGN_RETURN_ON_EXCEPTION( |
| 152 isolate, receiver, Execution::ToObject(isolate, receiver), Object); | 152 isolate, receiver, Execution::ToObject(isolate, receiver), Object); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 DCHECK(function->context()->global_object()->IsGlobalObject()); | 155 DCHECK(function->context()->global_object()->IsJSGlobalObject()); |
| 156 auto value = Builtins::InvokeApiFunction(function, receiver, argc, argv); | 156 auto value = Builtins::InvokeApiFunction(function, receiver, argc, argv); |
| 157 bool has_exception = value.is_null(); | 157 bool has_exception = value.is_null(); |
| 158 DCHECK(has_exception == isolate->has_pending_exception()); | 158 DCHECK(has_exception == isolate->has_pending_exception()); |
| 159 if (has_exception) { | 159 if (has_exception) { |
| 160 isolate->ReportPendingMessages(); | 160 isolate->ReportPendingMessages(); |
| 161 return MaybeHandle<Object>(); | 161 return MaybeHandle<Object>(); |
| 162 } else { | 162 } else { |
| 163 isolate->clear_pending_message(); | 163 isolate->clear_pending_message(); |
| 164 } | 164 } |
| 165 return value; | 165 return value; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 525 |
| 526 isolate_->counters()->stack_interrupts()->Increment(); | 526 isolate_->counters()->stack_interrupts()->Increment(); |
| 527 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 527 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 528 isolate_->runtime_profiler()->OptimizeNow(); | 528 isolate_->runtime_profiler()->OptimizeNow(); |
| 529 | 529 |
| 530 return isolate_->heap()->undefined_value(); | 530 return isolate_->heap()->undefined_value(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 } // namespace internal | 533 } // namespace internal |
| 534 } // namespace v8 | 534 } // namespace v8 |
| OLD | NEW |