| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 Object* V = args[1]; | 869 Object* V = args[1]; |
| 870 while (true) { | 870 while (true) { |
| 871 Object* prototype = V->GetPrototype(); | 871 Object* prototype = V->GetPrototype(); |
| 872 if (prototype->IsNull()) return isolate->heap()->false_value(); | 872 if (prototype->IsNull()) return isolate->heap()->false_value(); |
| 873 if (O == prototype) return isolate->heap()->true_value(); | 873 if (O == prototype) return isolate->heap()->true_value(); |
| 874 V = prototype; | 874 V = prototype; |
| 875 } | 875 } |
| 876 } | 876 } |
| 877 | 877 |
| 878 | 878 |
| 879 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) { | |
| 880 NoHandleAllocation ha; | |
| 881 ASSERT(args.length() == 0); | |
| 882 JavaScriptFrameIterator it(isolate); | |
| 883 return isolate->heap()->ToBoolean(it.frame()->IsConstructor()); | |
| 884 } | |
| 885 | |
| 886 | |
| 887 // Recursively traverses hidden prototypes if property is not found | 879 // Recursively traverses hidden prototypes if property is not found |
| 888 static void GetOwnPropertyImplementation(JSObject* obj, | 880 static void GetOwnPropertyImplementation(JSObject* obj, |
| 889 String* name, | 881 String* name, |
| 890 LookupResult* result) { | 882 LookupResult* result) { |
| 891 obj->LocalLookupRealNamedProperty(name, result); | 883 obj->LocalLookupRealNamedProperty(name, result); |
| 892 | 884 |
| 893 if (!result->IsProperty()) { | 885 if (!result->IsProperty()) { |
| 894 Object* proto = obj->GetPrototype(); | 886 Object* proto = obj->GetPrototype(); |
| 895 if (proto->IsJSObject() && | 887 if (proto->IsJSObject() && |
| 896 JSObject::cast(proto)->map()->is_hidden_prototype()) | 888 JSObject::cast(proto)->map()->is_hidden_prototype()) |
| (...skipping 9811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10708 FrameInspector(JavaScriptFrame* frame, | 10700 FrameInspector(JavaScriptFrame* frame, |
| 10709 int inlined_jsframe_index, | 10701 int inlined_jsframe_index, |
| 10710 Isolate* isolate) | 10702 Isolate* isolate) |
| 10711 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { | 10703 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { |
| 10712 // Calculate the deoptimized frame. | 10704 // Calculate the deoptimized frame. |
| 10713 if (frame->is_optimized()) { | 10705 if (frame->is_optimized()) { |
| 10714 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( | 10706 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( |
| 10715 frame, inlined_jsframe_index, isolate); | 10707 frame, inlined_jsframe_index, isolate); |
| 10716 } | 10708 } |
| 10717 has_adapted_arguments_ = frame_->has_adapted_arguments(); | 10709 has_adapted_arguments_ = frame_->has_adapted_arguments(); |
| 10710 is_bottommost_ = inlined_jsframe_index == 0; |
| 10718 is_optimized_ = frame_->is_optimized(); | 10711 is_optimized_ = frame_->is_optimized(); |
| 10719 } | 10712 } |
| 10720 | 10713 |
| 10721 ~FrameInspector() { | 10714 ~FrameInspector() { |
| 10722 // Get rid of the calculated deoptimized frame if any. | 10715 // Get rid of the calculated deoptimized frame if any. |
| 10723 if (deoptimized_frame_ != NULL) { | 10716 if (deoptimized_frame_ != NULL) { |
| 10724 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, | 10717 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, |
| 10725 isolate_); | 10718 isolate_); |
| 10726 } | 10719 } |
| 10727 } | 10720 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 10745 Object* GetExpression(int index) { | 10738 Object* GetExpression(int index) { |
| 10746 return is_optimized_ | 10739 return is_optimized_ |
| 10747 ? deoptimized_frame_->GetExpression(index) | 10740 ? deoptimized_frame_->GetExpression(index) |
| 10748 : frame_->GetExpression(index); | 10741 : frame_->GetExpression(index); |
| 10749 } | 10742 } |
| 10750 Address GetPc() { | 10743 Address GetPc() { |
| 10751 return is_optimized_ | 10744 return is_optimized_ |
| 10752 ? deoptimized_frame_->GetPc() | 10745 ? deoptimized_frame_->GetPc() |
| 10753 : frame_->pc(); | 10746 : frame_->pc(); |
| 10754 } | 10747 } |
| 10748 bool IsConstructor() { |
| 10749 return is_optimized_ && !is_bottommost_ |
| 10750 ? deoptimized_frame_->HasConstructStub() |
| 10751 : frame_->IsConstructor(); |
| 10752 } |
| 10755 | 10753 |
| 10756 // To inspect all the provided arguments the frame might need to be | 10754 // To inspect all the provided arguments the frame might need to be |
| 10757 // replaced with the arguments frame. | 10755 // replaced with the arguments frame. |
| 10758 void SetArgumentsFrame(JavaScriptFrame* frame) { | 10756 void SetArgumentsFrame(JavaScriptFrame* frame) { |
| 10759 ASSERT(has_adapted_arguments_); | 10757 ASSERT(has_adapted_arguments_); |
| 10760 frame_ = frame; | 10758 frame_ = frame; |
| 10761 is_optimized_ = frame_->is_optimized(); | 10759 is_optimized_ = frame_->is_optimized(); |
| 10762 ASSERT(!is_optimized_); | 10760 ASSERT(!is_optimized_); |
| 10763 } | 10761 } |
| 10764 | 10762 |
| 10765 private: | 10763 private: |
| 10766 JavaScriptFrame* frame_; | 10764 JavaScriptFrame* frame_; |
| 10767 DeoptimizedFrameInfo* deoptimized_frame_; | 10765 DeoptimizedFrameInfo* deoptimized_frame_; |
| 10768 Isolate* isolate_; | 10766 Isolate* isolate_; |
| 10769 bool is_optimized_; | 10767 bool is_optimized_; |
| 10768 bool is_bottommost_; |
| 10770 bool has_adapted_arguments_; | 10769 bool has_adapted_arguments_; |
| 10771 | 10770 |
| 10772 DISALLOW_COPY_AND_ASSIGN(FrameInspector); | 10771 DISALLOW_COPY_AND_ASSIGN(FrameInspector); |
| 10773 }; | 10772 }; |
| 10774 | 10773 |
| 10775 | 10774 |
| 10776 static const int kFrameDetailsFrameIdIndex = 0; | 10775 static const int kFrameDetailsFrameIdIndex = 0; |
| 10777 static const int kFrameDetailsReceiverIndex = 1; | 10776 static const int kFrameDetailsReceiverIndex = 1; |
| 10778 static const int kFrameDetailsFunctionIndex = 2; | 10777 static const int kFrameDetailsFunctionIndex = 2; |
| 10779 static const int kFrameDetailsArgumentCountIndex = 3; | 10778 static const int kFrameDetailsArgumentCountIndex = 3; |
| 10780 static const int kFrameDetailsLocalCountIndex = 4; | 10779 static const int kFrameDetailsLocalCountIndex = 4; |
| 10781 static const int kFrameDetailsSourcePositionIndex = 5; | 10780 static const int kFrameDetailsSourcePositionIndex = 5; |
| 10782 static const int kFrameDetailsConstructCallIndex = 6; | 10781 static const int kFrameDetailsConstructCallIndex = 6; |
| 10783 static const int kFrameDetailsAtReturnIndex = 7; | 10782 static const int kFrameDetailsAtReturnIndex = 7; |
| 10784 static const int kFrameDetailsFlagsIndex = 8; | 10783 static const int kFrameDetailsFlagsIndex = 8; |
| 10785 static const int kFrameDetailsFirstDynamicIndex = 9; | 10784 static const int kFrameDetailsFirstDynamicIndex = 9; |
| 10786 | 10785 |
| 10787 | 10786 |
| 10788 static SaveContext* FindSavedContextForFrame(Isolate* isolate, | 10787 static SaveContext* FindSavedContextForFrame(Isolate* isolate, |
| 10789 JavaScriptFrame* frame) { | 10788 JavaScriptFrame* frame) { |
| 10790 SaveContext* save = isolate->save_context(); | 10789 SaveContext* save = isolate->save_context(); |
| 10791 while (save != NULL && !save->IsBelowFrame(frame)) { | 10790 while (save != NULL && !save->IsBelowFrame(frame)) { |
| 10792 save = save->prev(); | 10791 save = save->prev(); |
| 10793 } | 10792 } |
| 10794 ASSERT(save != NULL); | 10793 ASSERT(save != NULL); |
| 10795 return save; | 10794 return save; |
| 10796 } | 10795 } |
| 10797 | 10796 |
| 10798 | 10797 |
| 10798 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) { |
| 10799 NoHandleAllocation ha; |
| 10800 ASSERT(args.length() == 0); |
| 10801 JavaScriptFrameIterator it(isolate); |
| 10802 JavaScriptFrame* frame = it.frame(); |
| 10803 FrameInspector frame_inspector(frame, frame->GetInlineCount() - 1, isolate); |
| 10804 return isolate->heap()->ToBoolean(frame_inspector.IsConstructor()); |
| 10805 } |
| 10806 |
| 10807 |
| 10799 // Return an array with frame details | 10808 // Return an array with frame details |
| 10800 // args[0]: number: break id | 10809 // args[0]: number: break id |
| 10801 // args[1]: number: frame index | 10810 // args[1]: number: frame index |
| 10802 // | 10811 // |
| 10803 // The array returned contains the following information: | 10812 // The array returned contains the following information: |
| 10804 // 0: Frame id | 10813 // 0: Frame id |
| 10805 // 1: Receiver | 10814 // 1: Receiver |
| 10806 // 2: Function | 10815 // 2: Function |
| 10807 // 3: Argument count | 10816 // 3: Argument count |
| 10808 // 4: Local count | 10817 // 4: Local count |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10855 SaveContext* save = FindSavedContextForFrame(isolate, it.frame()); | 10864 SaveContext* save = FindSavedContextForFrame(isolate, it.frame()); |
| 10856 | 10865 |
| 10857 // Get the frame id. | 10866 // Get the frame id. |
| 10858 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); | 10867 Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate); |
| 10859 | 10868 |
| 10860 // Find source position in unoptimized code. | 10869 // Find source position in unoptimized code. |
| 10861 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 10870 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
| 10862 Handle<SharedFunctionInfo> shared(function->shared()); | 10871 Handle<SharedFunctionInfo> shared(function->shared()); |
| 10863 int position = shared->code()->SourcePosition(frame_inspector.GetPc()); | 10872 int position = shared->code()->SourcePosition(frame_inspector.GetPc()); |
| 10864 | 10873 |
| 10865 // Check for constructor frame. Inlined frames cannot be construct calls. | 10874 // Check for constructor frame. |
| 10866 bool inlined_frame = is_optimized && inlined_jsframe_index != 0; | 10875 bool constructor = frame_inspector.IsConstructor(); |
| 10867 bool constructor = !inlined_frame && it.frame()->IsConstructor(); | |
| 10868 | 10876 |
| 10869 // Get scope info and read from it for local variable information. | 10877 // Get scope info and read from it for local variable information. |
| 10870 Handle<ScopeInfo> scope_info(shared->scope_info()); | 10878 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 10871 ASSERT(*scope_info != ScopeInfo::Empty()); | 10879 ASSERT(*scope_info != ScopeInfo::Empty()); |
| 10872 | 10880 |
| 10873 // Get the locals names and values into a temporary array. | 10881 // Get the locals names and values into a temporary array. |
| 10874 // | 10882 // |
| 10875 // TODO(1240907): Hide compiler-introduced stack variables | 10883 // TODO(1240907): Hide compiler-introduced stack variables |
| 10876 // (e.g. .result)? For users of the debugger, they will probably be | 10884 // (e.g. .result)? For users of the debugger, they will probably be |
| 10877 // confusing. | 10885 // confusing. |
| (...skipping 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13649 } else { | 13657 } else { |
| 13650 // Handle last resort GC and make sure to allow future allocations | 13658 // Handle last resort GC and make sure to allow future allocations |
| 13651 // to grow the heap without causing GCs (if possible). | 13659 // to grow the heap without causing GCs (if possible). |
| 13652 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13660 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13653 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13661 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13654 } | 13662 } |
| 13655 } | 13663 } |
| 13656 | 13664 |
| 13657 | 13665 |
| 13658 } } // namespace v8::internal | 13666 } } // namespace v8::internal |
| OLD | NEW |