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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 for (int i = 0; i < local_count * 2; i++) { | 697 for (int i = 0; i < local_count * 2; i++) { |
698 details->set(details_index++, locals->get(i)); | 698 details->set(details_index++, locals->get(i)); |
699 } | 699 } |
700 | 700 |
701 // Add the value being returned. | 701 // Add the value being returned. |
702 if (at_return) { | 702 if (at_return) { |
703 details->set(details_index++, *return_value); | 703 details->set(details_index++, *return_value); |
704 } | 704 } |
705 | 705 |
706 // Add the receiver (same as in function frame). | 706 // Add the receiver (same as in function frame). |
707 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE | |
708 // THE FRAME ITERATOR TO WRAP THE RECEIVER. | |
709 Handle<Object> receiver(it.frame()->receiver(), isolate); | 707 Handle<Object> receiver(it.frame()->receiver(), isolate); |
710 DCHECK(!function->IsBuiltin()); | 708 DCHECK(!function->IsBuiltin()); |
711 if (!receiver->IsJSObject() && is_sloppy(shared->language_mode())) { | 709 if (!receiver->IsJSObject() && is_sloppy(shared->language_mode())) { |
712 // If the receiver is not a JSObject and the function is not a | 710 // If the receiver is not a JSObject and the function is not a builtin or |
713 // builtin or strict-mode we have hit an optimization where a | 711 // strict-mode we have hit an optimization where a value object is not |
714 // value object is not converted into a wrapped JS objects. To | 712 // converted into a wrapped JS objects. To hide this optimization from the |
715 // hide this optimization from the debugger, we wrap the receiver | 713 // debugger, we wrap the receiver by creating correct wrapper object based |
716 // by creating correct wrapper object based on the calling frame's | 714 // on the function's native context. |
717 // native context. | 715 // See ECMA-262 6.0, 9.2.1.2, 6 b iii. |
718 it.Advance(); | |
719 if (receiver->IsUndefined()) { | 716 if (receiver->IsUndefined()) { |
720 receiver = handle(function->global_proxy()); | 717 receiver = handle(function->global_proxy()); |
721 } else { | 718 } else { |
722 Context* context = Context::cast(it.frame()->context()); | 719 Context* context = function->context(); |
723 Handle<Context> native_context(Context::cast(context->native_context())); | 720 Handle<Context> native_context(Context::cast(context->native_context())); |
724 if (!Object::ToObject(isolate, receiver, native_context) | 721 if (!Object::ToObject(isolate, receiver, native_context) |
725 .ToHandle(&receiver)) { | 722 .ToHandle(&receiver)) { |
726 // This only happens if the receiver is forcibly set in %_CallFunction. | 723 // This only happens if the receiver is forcibly set in %_CallFunction. |
727 return heap->undefined_value(); | 724 return heap->undefined_value(); |
728 } | 725 } |
729 } | 726 } |
730 } | 727 } |
731 details->set(kFrameDetailsReceiverIndex, *receiver); | 728 details->set(kFrameDetailsReceiverIndex, *receiver); |
732 | 729 |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 return *isolate->factory()->undefined_value(); | 1711 return *isolate->factory()->undefined_value(); |
1715 } | 1712 } |
1716 | 1713 |
1717 | 1714 |
1718 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1715 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1719 UNIMPLEMENTED(); | 1716 UNIMPLEMENTED(); |
1720 return NULL; | 1717 return NULL; |
1721 } | 1718 } |
1722 } // namespace internal | 1719 } // namespace internal |
1723 } // namespace v8 | 1720 } // namespace v8 |
OLD | NEW |