Chromium Code Reviews| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // directly to a global object. | 133 // directly to a global object. |
| 134 if (receiver->IsJSGlobalObject()) { | 134 if (receiver->IsJSGlobalObject()) { |
| 135 receiver = | 135 receiver = |
| 136 handle(Handle<JSGlobalObject>::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 Object* call_code = function->shared()->get_api_func_data()->call_code(); |
| 144 isolate->set_context(function->context()); | 144 if (call_code->IsCallHandlerInfo() && |
| 145 // Do proper receiver conversion for non-strict mode api functions. | 145 !CallHandlerInfo::cast(call_code)->callback()->IsCode()) { |
|
Toon Verwaest
2015/11/13 09:55:49
Don't we want the ability to stay in C++ if we are
epertoso
2015/11/13 19:06:10
Well, not necessarily. The fast callback, on the c
Benedikt Meurer
2015/11/16 04:43:55
I think there should always be a C++ backup implem
epertoso
2015/11/17 10:32:43
Done. Added a new field to CallHandlerInfo, as dis
| |
| 146 if (!receiver->IsJSReceiver() && | 146 SaveContext save(isolate); |
| 147 is_sloppy(function->shared()->language_mode())) { | 147 isolate->set_context(function->context()); |
| 148 if (receiver->IsUndefined() || receiver->IsNull()) { | 148 // Do proper receiver conversion for non-strict mode api functions. |
| 149 receiver = handle(function->global_proxy(), isolate); | 149 if (!receiver->IsJSReceiver() && |
| 150 is_sloppy(function->shared()->language_mode())) { | |
| 151 if (receiver->IsUndefined() || receiver->IsNull()) { | |
| 152 receiver = handle(function->global_proxy(), isolate); | |
| 153 } else { | |
| 154 ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver, | |
| 155 Execution::ToObject(isolate, receiver), | |
| 156 Object); | |
| 157 } | |
| 158 } | |
| 159 DCHECK(function->context()->global_object()->IsJSGlobalObject()); | |
| 160 auto value = Builtins::InvokeApiFunction(function, receiver, argc, argv); | |
| 161 bool has_exception = value.is_null(); | |
| 162 DCHECK(has_exception == isolate->has_pending_exception()); | |
| 163 if (has_exception) { | |
| 164 isolate->ReportPendingMessages(); | |
| 165 return MaybeHandle<Object>(); | |
| 150 } else { | 166 } else { |
| 151 ASSIGN_RETURN_ON_EXCEPTION( | 167 isolate->clear_pending_message(); |
| 152 isolate, receiver, Execution::ToObject(isolate, receiver), Object); | |
| 153 } | 168 } |
| 169 return value; | |
| 154 } | 170 } |
| 155 DCHECK(function->context()->global_object()->IsJSGlobalObject()); | |
| 156 auto value = Builtins::InvokeApiFunction(function, receiver, argc, argv); | |
| 157 bool has_exception = value.is_null(); | |
| 158 DCHECK(has_exception == isolate->has_pending_exception()); | |
| 159 if (has_exception) { | |
| 160 isolate->ReportPendingMessages(); | |
| 161 return MaybeHandle<Object>(); | |
| 162 } else { | |
| 163 isolate->clear_pending_message(); | |
| 164 } | |
| 165 return value; | |
| 166 } | 171 } |
| 167 return Invoke(isolate, false, callable, receiver, argc, argv, | 172 return Invoke(isolate, false, callable, receiver, argc, argv, |
| 168 isolate->factory()->undefined_value()); | 173 isolate->factory()->undefined_value()); |
| 169 } | 174 } |
| 170 | 175 |
| 171 | 176 |
| 172 // static | 177 // static |
| 173 MaybeHandle<Object> Execution::New(Handle<JSFunction> constructor, int argc, | 178 MaybeHandle<Object> Execution::New(Handle<JSFunction> constructor, int argc, |
| 174 Handle<Object> argv[]) { | 179 Handle<Object> argv[]) { |
| 175 return New(constructor->GetIsolate(), constructor, constructor, argc, argv); | 180 return New(constructor->GetIsolate(), constructor, constructor, argc, argv); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 | 530 |
| 526 isolate_->counters()->stack_interrupts()->Increment(); | 531 isolate_->counters()->stack_interrupts()->Increment(); |
| 527 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 532 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 528 isolate_->runtime_profiler()->OptimizeNow(); | 533 isolate_->runtime_profiler()->OptimizeNow(); |
| 529 | 534 |
| 530 return isolate_->heap()->undefined_value(); | 535 return isolate_->heap()->undefined_value(); |
| 531 } | 536 } |
| 532 | 537 |
| 533 } // namespace internal | 538 } // namespace internal |
| 534 } // namespace v8 | 539 } // namespace v8 |
| OLD | NEW |