| 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/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { | 801 void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { |
| 802 DCHECK(functions->length() == 0); | 802 DCHECK(functions->length() == 0); |
| 803 Code* code = LookupCode(); | 803 Code* code = LookupCode(); |
| 804 int offset = static_cast<int>(pc() - code->instruction_start()); | 804 int offset = static_cast<int>(pc() - code->instruction_start()); |
| 805 AbstractCode* abstract_code = AbstractCode::cast(code); | 805 AbstractCode* abstract_code = AbstractCode::cast(code); |
| 806 FrameSummary summary(receiver(), function(), abstract_code, offset, | 806 FrameSummary summary(receiver(), function(), abstract_code, offset, |
| 807 IsConstructor()); | 807 IsConstructor()); |
| 808 functions->Add(summary); | 808 functions->Add(summary); |
| 809 } | 809 } |
| 810 | 810 |
| 811 | |
| 812 int JavaScriptFrame::LookupExceptionHandlerInTable( | 811 int JavaScriptFrame::LookupExceptionHandlerInTable( |
| 813 int* stack_slots, HandlerTable::CatchPrediction* prediction) { | 812 int* stack_depth, HandlerTable::CatchPrediction* prediction) { |
| 814 Code* code = LookupCode(); | 813 Code* code = LookupCode(); |
| 815 DCHECK(!code->is_optimized_code()); | 814 DCHECK(!code->is_optimized_code()); |
| 816 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 815 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
| 817 int pc_offset = static_cast<int>(pc() - code->entry()); | 816 int pc_offset = static_cast<int>(pc() - code->entry()); |
| 818 return table->LookupRange(pc_offset, stack_slots, prediction); | 817 return table->LookupRange(pc_offset, stack_depth, prediction); |
| 819 } | 818 } |
| 820 | 819 |
| 821 | 820 |
| 822 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, | 821 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, |
| 823 Address pc, FILE* file, | 822 Address pc, FILE* file, |
| 824 bool print_line_number) { | 823 bool print_line_number) { |
| 825 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); | 824 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); |
| 826 function->PrintName(file); | 825 function->PrintName(file); |
| 827 int code_offset = static_cast<int>(pc - code->instruction_start()); | 826 int code_offset = static_cast<int>(pc - code->instruction_start()); |
| 828 PrintF(file, "+%d", code_offset); | 827 PrintF(file, "+%d", code_offset); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 DCHECK(!is_constructor); | 1034 DCHECK(!is_constructor); |
| 1036 } | 1035 } |
| 1037 | 1036 |
| 1038 | 1037 |
| 1039 int OptimizedFrame::LookupExceptionHandlerInTable( | 1038 int OptimizedFrame::LookupExceptionHandlerInTable( |
| 1040 int* stack_slots, HandlerTable::CatchPrediction* prediction) { | 1039 int* stack_slots, HandlerTable::CatchPrediction* prediction) { |
| 1041 Code* code = LookupCode(); | 1040 Code* code = LookupCode(); |
| 1042 DCHECK(code->is_optimized_code()); | 1041 DCHECK(code->is_optimized_code()); |
| 1043 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 1042 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
| 1044 int pc_offset = static_cast<int>(pc() - code->entry()); | 1043 int pc_offset = static_cast<int>(pc() - code->entry()); |
| 1045 *stack_slots = code->stack_slots(); | 1044 if (stack_slots) *stack_slots = code->stack_slots(); |
| 1046 return table->LookupReturn(pc_offset, prediction); | 1045 return table->LookupReturn(pc_offset, prediction); |
| 1047 } | 1046 } |
| 1048 | 1047 |
| 1049 | 1048 |
| 1050 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( | 1049 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( |
| 1051 int* deopt_index) const { | 1050 int* deopt_index) const { |
| 1052 DCHECK(is_optimized()); | 1051 DCHECK(is_optimized()); |
| 1053 | 1052 |
| 1054 JSFunction* opt_function = function(); | 1053 JSFunction* opt_function = function(); |
| 1055 Code* code = opt_function->code(); | 1054 Code* code = opt_function->code(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { | 1127 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { |
| 1129 return StandardFrameConstants::kCallerSPOffset - | 1128 return StandardFrameConstants::kCallerSPOffset - |
| 1130 ((slot_index + 1) * kPointerSize); | 1129 ((slot_index + 1) * kPointerSize); |
| 1131 } | 1130 } |
| 1132 | 1131 |
| 1133 | 1132 |
| 1134 Object* OptimizedFrame::StackSlotAt(int index) const { | 1133 Object* OptimizedFrame::StackSlotAt(int index) const { |
| 1135 return Memory::Object_at(fp() + StackSlotOffsetRelativeToFp(index)); | 1134 return Memory::Object_at(fp() + StackSlotOffsetRelativeToFp(index)); |
| 1136 } | 1135 } |
| 1137 | 1136 |
| 1138 | |
| 1139 int InterpretedFrame::LookupExceptionHandlerInTable( | 1137 int InterpretedFrame::LookupExceptionHandlerInTable( |
| 1140 int* stack_slots, HandlerTable::CatchPrediction* prediction) { | 1138 int* context_register, HandlerTable::CatchPrediction* prediction) { |
| 1141 BytecodeArray* bytecode = function()->shared()->bytecode_array(); | 1139 BytecodeArray* bytecode = function()->shared()->bytecode_array(); |
| 1142 HandlerTable* table = HandlerTable::cast(bytecode->handler_table()); | 1140 HandlerTable* table = HandlerTable::cast(bytecode->handler_table()); |
| 1143 int pc_offset = GetBytecodeOffset() + 1; // Point after current bytecode. | 1141 int pc_offset = GetBytecodeOffset() + 1; // Point after current bytecode. |
| 1144 return table->LookupRange(pc_offset, stack_slots, prediction); | 1142 return table->LookupRange(pc_offset, context_register, prediction); |
| 1145 } | 1143 } |
| 1146 | 1144 |
| 1147 | 1145 |
| 1148 int InterpretedFrame::GetBytecodeOffset() const { | 1146 int InterpretedFrame::GetBytecodeOffset() const { |
| 1149 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; | 1147 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; |
| 1150 DCHECK_EQ(InterpreterFrameConstants::kBytecodeOffsetFromFp, | 1148 DCHECK_EQ(InterpreterFrameConstants::kBytecodeOffsetFromFp, |
| 1151 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); | 1149 StandardFrameConstants::kExpressionsOffset - index * kPointerSize); |
| 1152 int raw_offset = Smi::cast(GetExpression(index))->value(); | 1150 int raw_offset = Smi::cast(GetExpression(index))->value(); |
| 1153 return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; | 1151 return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; |
| 1154 } | 1152 } |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1638 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1641 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1639 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1642 list.Add(frame, zone); | 1640 list.Add(frame, zone); |
| 1643 } | 1641 } |
| 1644 return list.ToVector(); | 1642 return list.ToVector(); |
| 1645 } | 1643 } |
| 1646 | 1644 |
| 1647 | 1645 |
| 1648 } // namespace internal | 1646 } // namespace internal |
| 1649 } // namespace v8 | 1647 } // namespace v8 |
| OLD | NEW |