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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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->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 bool is_callback = false; | |
Benedikt Meurer
2015/11/12 04:31:21
Please add a TODO here, that this code will need c
epertoso
2015/11/13 01:39:28
I refactored the code a bit.
I'm not sure I under
| |
140 if (callable->IsJSFunction()) { | |
141 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | |
142 if (function->shared()->IsApiFunction()) { | |
143 Object* call_code = function->shared()->get_api_func_data()->call_code(); | |
144 is_callback = call_code->IsCallHandlerInfo() && | |
145 !CallHandlerInfo::cast(call_code)->callback()->IsCode(); | |
146 } | |
147 } | |
148 | |
139 // api callbacks can be called directly. | 149 // api callbacks can be called directly. |
140 if (callable->IsJSFunction() && | 150 if (is_callback) { |
141 Handle<JSFunction>::cast(callable)->shared()->IsApiFunction()) { | |
142 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | 151 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); |
143 SaveContext save(isolate); | 152 SaveContext save(isolate); |
144 isolate->set_context(function->context()); | 153 isolate->set_context(function->context()); |
145 // Do proper receiver conversion for non-strict mode api functions. | 154 // Do proper receiver conversion for non-strict mode api functions. |
146 if (!receiver->IsJSReceiver() && | 155 if (!receiver->IsJSReceiver() && |
147 is_sloppy(function->shared()->language_mode())) { | 156 is_sloppy(function->shared()->language_mode())) { |
148 if (receiver->IsUndefined() || receiver->IsNull()) { | 157 if (receiver->IsUndefined() || receiver->IsNull()) { |
149 receiver = handle(function->global_proxy(), isolate); | 158 receiver = handle(function->global_proxy(), isolate); |
150 } else { | 159 } else { |
151 ASSIGN_RETURN_ON_EXCEPTION( | 160 ASSIGN_RETURN_ON_EXCEPTION( |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 | 534 |
526 isolate_->counters()->stack_interrupts()->Increment(); | 535 isolate_->counters()->stack_interrupts()->Increment(); |
527 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 536 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
528 isolate_->runtime_profiler()->OptimizeNow(); | 537 isolate_->runtime_profiler()->OptimizeNow(); |
529 | 538 |
530 return isolate_->heap()->undefined_value(); | 539 return isolate_->heap()->undefined_value(); |
531 } | 540 } |
532 | 541 |
533 } // namespace internal | 542 } // namespace internal |
534 } // namespace v8 | 543 } // namespace v8 |
OLD | NEW |