| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/debug/debug-evaluate.h" | 9 #include "src/debug/debug-evaluate.h" |
| 10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 695 } |
| 696 | 696 |
| 697 // Add the value being returned. | 697 // Add the value being returned. |
| 698 if (at_return) { | 698 if (at_return) { |
| 699 details->set(details_index++, *return_value); | 699 details->set(details_index++, *return_value); |
| 700 } | 700 } |
| 701 | 701 |
| 702 // Add the receiver (same as in function frame). | 702 // Add the receiver (same as in function frame). |
| 703 Handle<Object> receiver(it.frame()->receiver(), isolate); | 703 Handle<Object> receiver(it.frame()->receiver(), isolate); |
| 704 DCHECK(!function->shared()->IsBuiltin()); | 704 DCHECK(!function->shared()->IsBuiltin()); |
| 705 if (!receiver->IsJSObject() && is_sloppy(shared->language_mode())) { | 705 DCHECK_IMPLIES(is_sloppy(shared->language_mode()), receiver->IsJSReceiver()); |
| 706 // If the receiver is not a JSObject and the function is not a builtin or | |
| 707 // strict-mode we have hit an optimization where a value object is not | |
| 708 // converted into a wrapped JS objects. To hide this optimization from the | |
| 709 // debugger, we wrap the receiver by creating correct wrapper object based | |
| 710 // on the function's native context. | |
| 711 // See ECMA-262 6.0, 9.2.1.2, 6 b iii. | |
| 712 if (receiver->IsUndefined()) { | |
| 713 receiver = handle(function->global_proxy()); | |
| 714 } else { | |
| 715 Context* context = function->context(); | |
| 716 Handle<Context> native_context(Context::cast(context->native_context())); | |
| 717 if (!Object::ToObject(isolate, receiver, native_context) | |
| 718 .ToHandle(&receiver)) { | |
| 719 // This only happens if the receiver is forcibly set in %_CallFunction. | |
| 720 return heap->undefined_value(); | |
| 721 } | |
| 722 } | |
| 723 } | |
| 724 details->set(kFrameDetailsReceiverIndex, *receiver); | 706 details->set(kFrameDetailsReceiverIndex, *receiver); |
| 725 | 707 |
| 726 DCHECK_EQ(details_size, details_index); | 708 DCHECK_EQ(details_size, details_index); |
| 727 return *isolate->factory()->NewJSArrayWithElements(details); | 709 return *isolate->factory()->NewJSArrayWithElements(details); |
| 728 } | 710 } |
| 729 | 711 |
| 730 | 712 |
| 731 RUNTIME_FUNCTION(Runtime_GetScopeCount) { | 713 RUNTIME_FUNCTION(Runtime_GetScopeCount) { |
| 732 HandleScope scope(isolate); | 714 HandleScope scope(isolate); |
| 733 DCHECK(args.length() == 2); | 715 DCHECK(args.length() == 2); |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 return Smi::FromInt(isolate->debug()->is_active()); | 1669 return Smi::FromInt(isolate->debug()->is_active()); |
| 1688 } | 1670 } |
| 1689 | 1671 |
| 1690 | 1672 |
| 1691 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1673 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1692 UNIMPLEMENTED(); | 1674 UNIMPLEMENTED(); |
| 1693 return NULL; | 1675 return NULL; |
| 1694 } | 1676 } |
| 1695 } // namespace internal | 1677 } // namespace internal |
| 1696 } // namespace v8 | 1678 } // namespace v8 |
| OLD | NEW |