| 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/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 Handle<JSFunction>::cast(callable)->shared()->IsApiFunction()) { | 137 Handle<JSFunction>::cast(callable)->shared()->IsApiFunction()) { |
| 138 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | 138 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); |
| 139 SaveContext save(isolate); | 139 SaveContext save(isolate); |
| 140 isolate->set_context(function->context()); | 140 isolate->set_context(function->context()); |
| 141 // Do proper receiver conversion for non-strict mode api functions. | 141 // Do proper receiver conversion for non-strict mode api functions. |
| 142 if (!receiver->IsJSReceiver() && | 142 if (!receiver->IsJSReceiver() && |
| 143 is_sloppy(function->shared()->language_mode())) { | 143 is_sloppy(function->shared()->language_mode())) { |
| 144 if (receiver->IsUndefined() || receiver->IsNull()) { | 144 if (receiver->IsUndefined() || receiver->IsNull()) { |
| 145 receiver = handle(function->global_proxy(), isolate); | 145 receiver = handle(function->global_proxy(), isolate); |
| 146 } else { | 146 } else { |
| 147 ASSIGN_RETURN_ON_EXCEPTION( | 147 ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver, |
| 148 isolate, receiver, Execution::ToObject(isolate, receiver), Object); | 148 Object::ToObject(isolate, receiver), Object); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 DCHECK(function->context()->global_object()->IsJSGlobalObject()); | 151 DCHECK(function->context()->global_object()->IsJSGlobalObject()); |
| 152 auto value = Builtins::InvokeApiFunction(function, receiver, argc, argv); | 152 auto value = Builtins::InvokeApiFunction(function, receiver, argc, argv); |
| 153 bool has_exception = value.is_null(); | 153 bool has_exception = value.is_null(); |
| 154 DCHECK(has_exception == isolate->has_pending_exception()); | 154 DCHECK(has_exception == isolate->has_pending_exception()); |
| 155 if (has_exception) { | 155 if (has_exception) { |
| 156 isolate->ReportPendingMessages(); | 156 isolate->ReportPendingMessages(); |
| 157 return MaybeHandle<Object>(); | 157 return MaybeHandle<Object>(); |
| 158 } else { | 158 } else { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // You should hold the ExecutionAccess lock when you call this. | 414 // You should hold the ExecutionAccess lock when you call this. |
| 415 if (stored_limit != 0) { | 415 if (stored_limit != 0) { |
| 416 SetStackLimit(stored_limit); | 416 SetStackLimit(stored_limit); |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 | 419 |
| 420 | 420 |
| 421 // --- C a l l s t o n a t i v e s --- | 421 // --- C a l l s t o n a t i v e s --- |
| 422 | 422 |
| 423 | 423 |
| 424 MaybeHandle<JSReceiver> Execution::ToObject(Isolate* isolate, | |
| 425 Handle<Object> obj) { | |
| 426 Handle<JSReceiver> receiver; | |
| 427 if (JSReceiver::ToObject(isolate, obj).ToHandle(&receiver)) { | |
| 428 return receiver; | |
| 429 } | |
| 430 THROW_NEW_ERROR(isolate, | |
| 431 NewTypeError(MessageTemplate::kUndefinedOrNullToObject), | |
| 432 JSReceiver); | |
| 433 } | |
| 434 | |
| 435 | |
| 436 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, | 424 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, |
| 437 Handle<JSFunction> fun, | 425 Handle<JSFunction> fun, |
| 438 Handle<Object> pos, | 426 Handle<Object> pos, |
| 439 Handle<Object> is_global) { | 427 Handle<Object> is_global) { |
| 440 Isolate* isolate = fun->GetIsolate(); | 428 Isolate* isolate = fun->GetIsolate(); |
| 441 Handle<Object> args[] = { recv, fun, pos, is_global }; | 429 Handle<Object> args[] = { recv, fun, pos, is_global }; |
| 442 MaybeHandle<Object> maybe_result = | 430 MaybeHandle<Object> maybe_result = |
| 443 TryCall(isolate, isolate->get_stack_trace_line_fun(), | 431 TryCall(isolate, isolate->get_stack_trace_line_fun(), |
| 444 isolate->factory()->undefined_value(), arraysize(args), args); | 432 isolate->factory()->undefined_value(), arraysize(args), args); |
| 445 Handle<Object> result; | 433 Handle<Object> result; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 480 |
| 493 isolate_->counters()->stack_interrupts()->Increment(); | 481 isolate_->counters()->stack_interrupts()->Increment(); |
| 494 isolate_->counters()->runtime_profiler_ticks()->Increment(); | 482 isolate_->counters()->runtime_profiler_ticks()->Increment(); |
| 495 isolate_->runtime_profiler()->OptimizeNow(); | 483 isolate_->runtime_profiler()->OptimizeNow(); |
| 496 | 484 |
| 497 return isolate_->heap()->undefined_value(); | 485 return isolate_->heap()->undefined_value(); |
| 498 } | 486 } |
| 499 | 487 |
| 500 } // namespace internal | 488 } // namespace internal |
| 501 } // namespace v8 | 489 } // namespace v8 |
| OLD | NEW |