OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/frames.h" | 5 #include "src/frames.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 bool JavaScriptFrame::IsConstructor() const { | 742 bool JavaScriptFrame::IsConstructor() const { |
743 Address fp = caller_fp(); | 743 Address fp = caller_fp(); |
744 if (has_adapted_arguments()) { | 744 if (has_adapted_arguments()) { |
745 // Skip the arguments adaptor frame and look at the real caller. | 745 // Skip the arguments adaptor frame and look at the real caller. |
746 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); | 746 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
747 } | 747 } |
748 return IsConstructFrame(fp); | 748 return IsConstructFrame(fp); |
749 } | 749 } |
750 | 750 |
751 | 751 |
752 bool JavaScriptFrame::HasInlinedFrames() { | 752 bool JavaScriptFrame::HasInlinedFrames() const { |
753 List<JSFunction*> functions(1); | 753 List<JSFunction*> functions(1); |
754 GetFunctions(&functions); | 754 GetFunctions(&functions); |
755 return functions.length() > 1; | 755 return functions.length() > 1; |
756 } | 756 } |
757 | 757 |
758 | 758 |
759 Object* JavaScriptFrame::GetOriginalConstructor() const { | 759 Object* JavaScriptFrame::GetOriginalConstructor() const { |
| 760 DCHECK(!HasInlinedFrames()); |
760 Address fp = caller_fp(); | 761 Address fp = caller_fp(); |
761 if (has_adapted_arguments()) { | 762 if (has_adapted_arguments()) { |
762 // Skip the arguments adaptor frame and look at the real caller. | 763 // Skip the arguments adaptor frame and look at the real caller. |
763 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); | 764 fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
764 } | 765 } |
765 DCHECK(IsConstructFrame(fp)); | 766 DCHECK(IsConstructFrame(fp)); |
766 STATIC_ASSERT(ConstructFrameConstants::kOriginalConstructorOffset == | 767 STATIC_ASSERT(ConstructFrameConstants::kOriginalConstructorOffset == |
767 StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize); | 768 StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize); |
768 return GetExpression(fp, 3); | 769 return GetExpression(fp, 3); |
769 } | 770 } |
(...skipping 22 matching lines...) Expand all Loading... |
792 | 793 |
793 return function()->shared()->internal_formal_parameter_count(); | 794 return function()->shared()->internal_formal_parameter_count(); |
794 } | 795 } |
795 | 796 |
796 | 797 |
797 Address JavaScriptFrame::GetCallerStackPointer() const { | 798 Address JavaScriptFrame::GetCallerStackPointer() const { |
798 return fp() + StandardFrameConstants::kCallerSPOffset; | 799 return fp() + StandardFrameConstants::kCallerSPOffset; |
799 } | 800 } |
800 | 801 |
801 | 802 |
802 void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) { | 803 void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) const { |
803 DCHECK(functions->length() == 0); | 804 DCHECK(functions->length() == 0); |
804 functions->Add(function()); | 805 functions->Add(function()); |
805 } | 806 } |
806 | 807 |
807 | 808 |
808 void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { | 809 void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { |
809 DCHECK(functions->length() == 0); | 810 DCHECK(functions->length() == 0); |
810 Code* code_pointer = LookupCode(); | 811 Code* code_pointer = LookupCode(); |
811 int offset = static_cast<int>(pc() - code_pointer->address()); | 812 int offset = static_cast<int>(pc() - code_pointer->address()); |
812 FrameSummary summary(receiver(), | 813 FrameSummary summary(receiver(), |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 Code* code = LookupCode(); | 1035 Code* code = LookupCode(); |
1035 DCHECK(code->is_optimized_code()); | 1036 DCHECK(code->is_optimized_code()); |
1036 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 1037 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
1037 int pc_offset = static_cast<int>(pc() - code->entry()); | 1038 int pc_offset = static_cast<int>(pc() - code->entry()); |
1038 *stack_slots = code->stack_slots(); | 1039 *stack_slots = code->stack_slots(); |
1039 return table->LookupReturn(pc_offset, prediction); | 1040 return table->LookupReturn(pc_offset, prediction); |
1040 } | 1041 } |
1041 | 1042 |
1042 | 1043 |
1043 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( | 1044 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( |
1044 int* deopt_index) { | 1045 int* deopt_index) const { |
1045 DCHECK(is_optimized()); | 1046 DCHECK(is_optimized()); |
1046 | 1047 |
1047 JSFunction* opt_function = function(); | 1048 JSFunction* opt_function = function(); |
1048 Code* code = opt_function->code(); | 1049 Code* code = opt_function->code(); |
1049 | 1050 |
1050 // The code object may have been replaced by lazy deoptimization. Fall | 1051 // The code object may have been replaced by lazy deoptimization. Fall |
1051 // back to a slow search in this case to find the original optimized | 1052 // back to a slow search in this case to find the original optimized |
1052 // code object. | 1053 // code object. |
1053 if (!code->contains(pc())) { | 1054 if (!code->contains(pc())) { |
1054 code = isolate()->inner_pointer_to_code_cache()-> | 1055 code = isolate()->inner_pointer_to_code_cache()-> |
1055 GcSafeFindCodeForInnerPointer(pc()); | 1056 GcSafeFindCodeForInnerPointer(pc()); |
1056 } | 1057 } |
1057 DCHECK(code != NULL); | 1058 DCHECK(code != NULL); |
1058 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); | 1059 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
1059 | 1060 |
1060 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); | 1061 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); |
1061 *deopt_index = safepoint_entry.deoptimization_index(); | 1062 *deopt_index = safepoint_entry.deoptimization_index(); |
1062 DCHECK(*deopt_index != Safepoint::kNoDeoptimizationIndex); | 1063 DCHECK(*deopt_index != Safepoint::kNoDeoptimizationIndex); |
1063 | 1064 |
1064 return DeoptimizationInputData::cast(code->deoptimization_data()); | 1065 return DeoptimizationInputData::cast(code->deoptimization_data()); |
1065 } | 1066 } |
1066 | 1067 |
1067 | 1068 |
1068 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { | 1069 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) const { |
1069 DCHECK(functions->length() == 0); | 1070 DCHECK(functions->length() == 0); |
1070 DCHECK(is_optimized()); | 1071 DCHECK(is_optimized()); |
1071 | 1072 |
1072 // Delegate to JS frame in absence of turbofan deoptimization. | 1073 // Delegate to JS frame in absence of turbofan deoptimization. |
1073 // TODO(turbofan): Revisit once we support deoptimization across the board. | 1074 // TODO(turbofan): Revisit once we support deoptimization across the board. |
1074 if (LookupCode()->is_turbofanned() && function()->shared()->asm_function() && | 1075 if (LookupCode()->is_turbofanned() && function()->shared()->asm_function() && |
1075 !FLAG_turbo_asm_deoptimization) { | 1076 !FLAG_turbo_asm_deoptimization) { |
1076 return JavaScriptFrame::GetFunctions(functions); | 1077 return JavaScriptFrame::GetFunctions(functions); |
1077 } | 1078 } |
1078 | 1079 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1590 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1591 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1591 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1592 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1592 list.Add(frame, zone); | 1593 list.Add(frame, zone); |
1593 } | 1594 } |
1594 return list.ToVector(); | 1595 return list.ToVector(); |
1595 } | 1596 } |
1596 | 1597 |
1597 | 1598 |
1598 } // namespace internal | 1599 } // namespace internal |
1599 } // namespace v8 | 1600 } // namespace v8 |
OLD | NEW |