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 <memory> | 7 #include <memory> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 const int offset = StandardFrameConstants::kContextOffset; | 975 const int offset = StandardFrameConstants::kContextOffset; |
976 Object* maybe_result = Memory::Object_at(fp() + offset); | 976 Object* maybe_result = Memory::Object_at(fp() + offset); |
977 DCHECK(!maybe_result->IsSmi()); | 977 DCHECK(!maybe_result->IsSmi()); |
978 return maybe_result; | 978 return maybe_result; |
979 } | 979 } |
980 | 980 |
981 int JavaScriptFrame::LookupExceptionHandlerInTable( | 981 int JavaScriptFrame::LookupExceptionHandlerInTable( |
982 int* stack_depth, HandlerTable::CatchPrediction* prediction) { | 982 int* stack_depth, HandlerTable::CatchPrediction* prediction) { |
983 Code* code = LookupCode(); | 983 Code* code = LookupCode(); |
984 DCHECK(!code->is_optimized_code()); | 984 DCHECK(!code->is_optimized_code()); |
985 HandlerTable* table = HandlerTable::cast(code->handler_table()); | |
986 int pc_offset = static_cast<int>(pc() - code->entry()); | 985 int pc_offset = static_cast<int>(pc() - code->entry()); |
987 return table->LookupRange(pc_offset, stack_depth, prediction); | 986 return code->LookupRangeInHandlerTable(pc_offset, stack_depth, prediction); |
988 } | 987 } |
989 | 988 |
990 | |
991 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, | 989 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, |
992 Address pc, FILE* file, | 990 Address pc, FILE* file, |
993 bool print_line_number) { | 991 bool print_line_number) { |
994 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); | 992 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); |
995 function->PrintName(file); | 993 function->PrintName(file); |
996 int code_offset = static_cast<int>(pc - code->instruction_start()); | 994 int code_offset = static_cast<int>(pc - code->instruction_start()); |
997 PrintF(file, "+%d", code_offset); | 995 PrintF(file, "+%d", code_offset); |
998 if (print_line_number) { | 996 if (print_line_number) { |
999 SharedFunctionInfo* shared = function->shared(); | 997 SharedFunctionInfo* shared = function->shared(); |
1000 int source_pos = AbstractCode::cast(code)->SourcePosition(code_offset); | 998 int source_pos = AbstractCode::cast(code)->SourcePosition(code_offset); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 // Skip over operands to advance to the next opcode. | 1227 // Skip over operands to advance to the next opcode. |
1230 it.Skip(Translation::NumberOfOperandsFor(frame_opcode)); | 1228 it.Skip(Translation::NumberOfOperandsFor(frame_opcode)); |
1231 } | 1229 } |
1232 } | 1230 } |
1233 DCHECK(!is_constructor); | 1231 DCHECK(!is_constructor); |
1234 } | 1232 } |
1235 | 1233 |
1236 | 1234 |
1237 int OptimizedFrame::LookupExceptionHandlerInTable( | 1235 int OptimizedFrame::LookupExceptionHandlerInTable( |
1238 int* stack_slots, HandlerTable::CatchPrediction* prediction) { | 1236 int* stack_slots, HandlerTable::CatchPrediction* prediction) { |
| 1237 // We cannot perform exception prediction on optimized code. Instead, we need |
| 1238 // to use FrameSummary to find the corresponding code offset in unoptimized |
| 1239 // code to perform prediction there. |
| 1240 DCHECK_NULL(prediction); |
1239 Code* code = LookupCode(); | 1241 Code* code = LookupCode(); |
1240 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 1242 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
1241 int pc_offset = static_cast<int>(pc() - code->entry()); | 1243 int pc_offset = static_cast<int>(pc() - code->entry()); |
1242 if (stack_slots) *stack_slots = code->stack_slots(); | 1244 if (stack_slots) *stack_slots = code->stack_slots(); |
1243 return table->LookupReturn(pc_offset, prediction); | 1245 return table->LookupReturn(pc_offset); |
1244 } | 1246 } |
1245 | 1247 |
1246 | 1248 |
1247 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( | 1249 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( |
1248 int* deopt_index) const { | 1250 int* deopt_index) const { |
1249 DCHECK(is_optimized()); | 1251 DCHECK(is_optimized()); |
1250 | 1252 |
1251 JSFunction* opt_function = function(); | 1253 JSFunction* opt_function = function(); |
1252 Code* code = opt_function->code(); | 1254 Code* code = opt_function->code(); |
1253 | 1255 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 } | 1332 } |
1331 | 1333 |
1332 | 1334 |
1333 Object* OptimizedFrame::StackSlotAt(int index) const { | 1335 Object* OptimizedFrame::StackSlotAt(int index) const { |
1334 return Memory::Object_at(fp() + StackSlotOffsetRelativeToFp(index)); | 1336 return Memory::Object_at(fp() + StackSlotOffsetRelativeToFp(index)); |
1335 } | 1337 } |
1336 | 1338 |
1337 int InterpretedFrame::LookupExceptionHandlerInTable( | 1339 int InterpretedFrame::LookupExceptionHandlerInTable( |
1338 int* context_register, HandlerTable::CatchPrediction* prediction) { | 1340 int* context_register, HandlerTable::CatchPrediction* prediction) { |
1339 BytecodeArray* bytecode = function()->shared()->bytecode_array(); | 1341 BytecodeArray* bytecode = function()->shared()->bytecode_array(); |
1340 HandlerTable* table = HandlerTable::cast(bytecode->handler_table()); | 1342 return bytecode->LookupRangeInHandlerTable(GetBytecodeOffset(), |
1341 int pc_offset = GetBytecodeOffset() + 1; // Point after current bytecode. | 1343 context_register, prediction); |
1342 return table->LookupRange(pc_offset, context_register, prediction); | |
1343 } | 1344 } |
1344 | 1345 |
1345 int InterpretedFrame::GetBytecodeOffset() const { | 1346 int InterpretedFrame::GetBytecodeOffset() const { |
1346 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; | 1347 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; |
1347 DCHECK_EQ( | 1348 DCHECK_EQ( |
1348 InterpreterFrameConstants::kBytecodeOffsetFromFp, | 1349 InterpreterFrameConstants::kBytecodeOffsetFromFp, |
1349 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize); | 1350 InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize); |
1350 int raw_offset = Smi::cast(GetExpression(index))->value(); | 1351 int raw_offset = Smi::cast(GetExpression(index))->value(); |
1351 return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; | 1352 return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; |
1352 } | 1353 } |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1910 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1910 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1911 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1911 list.Add(frame, zone); | 1912 list.Add(frame, zone); |
1912 } | 1913 } |
1913 return list.ToVector(); | 1914 return list.ToVector(); |
1914 } | 1915 } |
1915 | 1916 |
1916 | 1917 |
1917 } // namespace internal | 1918 } // namespace internal |
1918 } // namespace v8 | 1919 } // namespace v8 |
OLD | NEW |