| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 61 // api callbacks can be called directly. |
| 62 if (!is_construct && function->shared()->IsApiFunction()) { | 62 if (function->shared()->IsApiFunction() && |
| 63 (!is_construct || |
| 64 !function->shared()->get_api_func_data()->remove_prototype())) { |
| 63 SaveContext save(isolate); | 65 SaveContext save(isolate); |
| 64 isolate->set_context(function->context()); | 66 isolate->set_context(function->context()); |
| 65 if (receiver->IsGlobalObject()) { | 67 if (is_construct) { |
| 68 receiver = isolate->factory()->NewJSObject(function); |
| 69 } else if (receiver->IsGlobalObject()) { |
| 66 receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy()); | 70 receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy()); |
| 67 } | 71 } |
| 68 DCHECK(function->context()->global_object()->IsGlobalObject()); | 72 DCHECK(function->context()->global_object()->IsGlobalObject()); |
| 69 auto value = Builtins::InvokeApiFunction(function, receiver, argc, args); | 73 auto value = Builtins::InvokeApiFunction(function, receiver, argc, args, |
| 74 is_construct); |
| 70 bool has_exception = value.is_null(); | 75 bool has_exception = value.is_null(); |
| 71 DCHECK(has_exception == isolate->has_pending_exception()); | 76 DCHECK(has_exception == isolate->has_pending_exception()); |
| 72 if (has_exception) { | 77 if (has_exception) { |
| 73 isolate->ReportPendingMessages(); | 78 isolate->ReportPendingMessages(); |
| 74 return MaybeHandle<Object>(); | 79 return MaybeHandle<Object>(); |
| 75 } else { | 80 } else { |
| 76 isolate->clear_pending_message(); | 81 isolate->clear_pending_message(); |
| 77 } | 82 } |
| 78 return value; | 83 return value; |
| 79 } | 84 } |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 } | 691 } |
| 687 | 692 |
| 688 isolate_->counters()->stack_interrupts()->Increment(); | 693 isolate_->counters()->stack_interrupts()->Increment(); |
| 689 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 694 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 690 isolate_->runtime_profiler()->OptimizeNow(); | 695 isolate_->runtime_profiler()->OptimizeNow(); |
| 691 | 696 |
| 692 return isolate_->heap()->undefined_value(); | 697 return isolate_->heap()->undefined_value(); |
| 693 } | 698 } |
| 694 | 699 |
| 695 } } // namespace v8::internal | 700 } } // namespace v8::internal |
| OLD | NEW |