| 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/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 } | 713 } |
| 714 | 714 |
| 715 Object* StandardFrame::receiver() const { | 715 Object* StandardFrame::receiver() const { |
| 716 return isolate()->heap()->undefined_value(); | 716 return isolate()->heap()->undefined_value(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 Object* StandardFrame::context() const { | 719 Object* StandardFrame::context() const { |
| 720 return isolate()->heap()->undefined_value(); | 720 return isolate()->heap()->undefined_value(); |
| 721 } | 721 } |
| 722 | 722 |
| 723 int StandardFrame::position() const { |
| 724 AbstractCode* code = AbstractCode::cast(LookupCode()); |
| 725 int code_offset = static_cast<int>(pc() - code->instruction_start()); |
| 726 return code->SourcePosition(code_offset); |
| 727 } |
| 728 |
| 723 int StandardFrame::ComputeExpressionsCount() const { | 729 int StandardFrame::ComputeExpressionsCount() const { |
| 724 Address base = GetExpressionAddress(0); | 730 Address base = GetExpressionAddress(0); |
| 725 Address limit = sp() - kPointerSize; | 731 Address limit = sp() - kPointerSize; |
| 726 DCHECK(base >= limit); // stack grows downwards | 732 DCHECK(base >= limit); // stack grows downwards |
| 727 // Include register-allocated locals in number of expressions. | 733 // Include register-allocated locals in number of expressions. |
| 728 return static_cast<int>((base - limit) / kPointerSize); | 734 return static_cast<int>((base - limit) / kPointerSize); |
| 729 } | 735 } |
| 730 | 736 |
| 731 Object* StandardFrame::GetParameter(int index) const { | 737 Object* StandardFrame::GetParameter(int index) const { |
| 732 // StandardFrame does not define any parameters. | 738 // StandardFrame does not define any parameters. |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { | 1334 int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) { |
| 1329 return StandardFrameConstants::kCallerSPOffset - | 1335 return StandardFrameConstants::kCallerSPOffset - |
| 1330 ((slot_index + 1) * kPointerSize); | 1336 ((slot_index + 1) * kPointerSize); |
| 1331 } | 1337 } |
| 1332 | 1338 |
| 1333 | 1339 |
| 1334 Object* OptimizedFrame::StackSlotAt(int index) const { | 1340 Object* OptimizedFrame::StackSlotAt(int index) const { |
| 1335 return Memory::Object_at(fp() + StackSlotOffsetRelativeToFp(index)); | 1341 return Memory::Object_at(fp() + StackSlotOffsetRelativeToFp(index)); |
| 1336 } | 1342 } |
| 1337 | 1343 |
| 1344 int InterpretedFrame::position() const { |
| 1345 AbstractCode* code = AbstractCode::cast(GetBytecodeArray()); |
| 1346 int code_offset = GetBytecodeOffset(); |
| 1347 return code->SourcePosition(code_offset); |
| 1348 } |
| 1349 |
| 1338 int InterpretedFrame::LookupExceptionHandlerInTable( | 1350 int InterpretedFrame::LookupExceptionHandlerInTable( |
| 1339 int* context_register, HandlerTable::CatchPrediction* prediction) { | 1351 int* context_register, HandlerTable::CatchPrediction* prediction) { |
| 1340 BytecodeArray* bytecode = function()->shared()->bytecode_array(); | 1352 BytecodeArray* bytecode = function()->shared()->bytecode_array(); |
| 1341 return bytecode->LookupRangeInHandlerTable(GetBytecodeOffset(), | 1353 return bytecode->LookupRangeInHandlerTable(GetBytecodeOffset(), |
| 1342 context_register, prediction); | 1354 context_register, prediction); |
| 1343 } | 1355 } |
| 1344 | 1356 |
| 1345 int InterpretedFrame::GetBytecodeOffset() const { | 1357 int InterpretedFrame::GetBytecodeOffset() const { |
| 1346 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; | 1358 const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex; |
| 1347 DCHECK_EQ( | 1359 DCHECK_EQ( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 } | 1479 } |
| 1468 | 1480 |
| 1469 uint32_t WasmFrame::function_index() const { | 1481 uint32_t WasmFrame::function_index() const { |
| 1470 FixedArray* deopt_data = LookupCode()->deoptimization_data(); | 1482 FixedArray* deopt_data = LookupCode()->deoptimization_data(); |
| 1471 DCHECK(deopt_data->length() == 2); | 1483 DCHECK(deopt_data->length() == 2); |
| 1472 return Smi::cast(deopt_data->get(1))->value(); | 1484 return Smi::cast(deopt_data->get(1))->value(); |
| 1473 } | 1485 } |
| 1474 | 1486 |
| 1475 Script* WasmFrame::script() const { | 1487 Script* WasmFrame::script() const { |
| 1476 Handle<JSObject> wasm(JSObject::cast(wasm_obj()), isolate()); | 1488 Handle<JSObject> wasm(JSObject::cast(wasm_obj()), isolate()); |
| 1489 if (wasm::WasmIsAsmJs(*wasm, isolate())) { |
| 1490 return *wasm::GetAsmWasmScript(wasm); |
| 1491 } |
| 1477 Handle<wasm::WasmDebugInfo> debug_info = wasm::GetDebugInfo(wasm); | 1492 Handle<wasm::WasmDebugInfo> debug_info = wasm::GetDebugInfo(wasm); |
| 1478 return wasm::WasmDebugInfo::GetFunctionScript(debug_info, function_index()); | 1493 return wasm::WasmDebugInfo::GetFunctionScript(debug_info, function_index()); |
| 1479 } | 1494 } |
| 1480 | 1495 |
| 1496 int WasmFrame::position() const { |
| 1497 int position = StandardFrame::position(); |
| 1498 if (wasm::WasmIsAsmJs(wasm_obj(), isolate())) { |
| 1499 Handle<JSObject> wasm(JSObject::cast(wasm_obj()), isolate()); |
| 1500 position = wasm::GetAsmWasmSourcePosition(wasm, function_index(), position); |
| 1501 } |
| 1502 return position; |
| 1503 } |
| 1504 |
| 1481 int WasmFrame::LookupExceptionHandlerInTable(int* stack_slots) { | 1505 int WasmFrame::LookupExceptionHandlerInTable(int* stack_slots) { |
| 1482 DCHECK_NOT_NULL(stack_slots); | 1506 DCHECK_NOT_NULL(stack_slots); |
| 1483 Code* code = LookupCode(); | 1507 Code* code = LookupCode(); |
| 1484 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 1508 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
| 1485 int pc_offset = static_cast<int>(pc() - code->entry()); | 1509 int pc_offset = static_cast<int>(pc() - code->entry()); |
| 1486 *stack_slots = code->stack_slots(); | 1510 *stack_slots = code->stack_slots(); |
| 1487 return table->LookupReturn(pc_offset); | 1511 return table->LookupReturn(pc_offset); |
| 1488 } | 1512 } |
| 1489 | 1513 |
| 1490 namespace { | 1514 namespace { |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1942 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1919 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1943 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1920 list.Add(frame, zone); | 1944 list.Add(frame, zone); |
| 1921 } | 1945 } |
| 1922 return list.ToVector(); | 1946 return list.ToVector(); |
| 1923 } | 1947 } |
| 1924 | 1948 |
| 1925 | 1949 |
| 1926 } // namespace internal | 1950 } // namespace internal |
| 1927 } // namespace v8 | 1951 } // namespace v8 |
| OLD | NEW |