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 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 } | 1573 } |
1574 | 1574 |
1575 int WasmFrame::position() const { | 1575 int WasmFrame::position() const { |
1576 int position = StandardFrame::position(); | 1576 int position = StandardFrame::position(); |
1577 if (wasm::WasmIsAsmJs(wasm_instance(), isolate())) { | 1577 if (wasm::WasmIsAsmJs(wasm_instance(), isolate())) { |
1578 Handle<WasmCompiledModule> compiled_module( | 1578 Handle<WasmCompiledModule> compiled_module( |
1579 WasmInstanceObject::cast(wasm_instance())->get_compiled_module(), | 1579 WasmInstanceObject::cast(wasm_instance())->get_compiled_module(), |
1580 isolate()); | 1580 isolate()); |
1581 DCHECK_LE(0, position); | 1581 DCHECK_LE(0, position); |
1582 position = WasmCompiledModule::GetAsmJsSourcePosition( | 1582 position = WasmCompiledModule::GetAsmJsSourcePosition( |
1583 compiled_module, function_index(), static_cast<uint32_t>(position)); | 1583 compiled_module, function_index(), static_cast<uint32_t>(position), |
| 1584 at_to_number_conversion()); |
1584 } | 1585 } |
1585 return position; | 1586 return position; |
1586 } | 1587 } |
1587 | 1588 |
| 1589 bool WasmFrame::at_to_number_conversion() const { |
| 1590 // WasmToJsFrame::ComputeCallerState encoded this for us in the constant pool |
| 1591 // address. If there was no WasmToJsFrame above us, we just return false here, |
| 1592 // but this information is not relevant in this case anyway. |
| 1593 intptr_t addr_int = reinterpret_cast<intptr_t>(constant_pool_address()); |
| 1594 return addr_int == 1; |
| 1595 } |
| 1596 |
1588 int WasmFrame::LookupExceptionHandlerInTable(int* stack_slots) { | 1597 int WasmFrame::LookupExceptionHandlerInTable(int* stack_slots) { |
1589 DCHECK_NOT_NULL(stack_slots); | 1598 DCHECK_NOT_NULL(stack_slots); |
1590 Code* code = LookupCode(); | 1599 Code* code = LookupCode(); |
1591 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 1600 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
1592 int pc_offset = static_cast<int>(pc() - code->entry()); | 1601 int pc_offset = static_cast<int>(pc() - code->entry()); |
1593 *stack_slots = code->stack_slots(); | 1602 *stack_slots = code->stack_slots(); |
1594 return table->LookupReturn(pc_offset); | 1603 return table->LookupReturn(pc_offset); |
1595 } | 1604 } |
1596 | 1605 |
| 1606 void WasmToJsFrame::ComputeCallerState(State* state) const { |
| 1607 // Remember at which of the two calls inside it we are, and transfer this |
| 1608 // information to the subsequent WASM frame. |
| 1609 Code* code = unchecked_code(); |
| 1610 AbstractCode* abstract_code = AbstractCode::cast(code); |
| 1611 int offset = static_cast<int>(pc() - code->instruction_start()); |
| 1612 int at_to_number_call = abstract_code->SourcePosition(offset); |
| 1613 DCHECK(at_to_number_call == 0 || at_to_number_call == 1); |
| 1614 StubFrame::ComputeCallerState(state); |
| 1615 // Use a little hack here: The constant pool address is not used for wasm |
| 1616 // frames, so use it to encode whether we are at the to_number call. |
| 1617 state->constant_pool_address = reinterpret_cast<Address*>(at_to_number_call); |
| 1618 } |
| 1619 |
1597 namespace { | 1620 namespace { |
1598 | 1621 |
1599 | 1622 |
1600 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, | 1623 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, |
1601 Code* code) { | 1624 Code* code) { |
1602 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { | 1625 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { |
1603 std::ostringstream os; | 1626 std::ostringstream os; |
1604 os << "--------- s o u r c e c o d e ---------\n" | 1627 os << "--------- s o u r c e c o d e ---------\n" |
1605 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) | 1628 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) |
1606 << "\n-----------------------------------------\n"; | 1629 << "\n-----------------------------------------\n"; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 2048 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
2026 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 2049 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
2027 list.Add(frame, zone); | 2050 list.Add(frame, zone); |
2028 } | 2051 } |
2029 return list.ToVector(); | 2052 return list.ToVector(); |
2030 } | 2053 } |
2031 | 2054 |
2032 | 2055 |
2033 } // namespace internal | 2056 } // namespace internal |
2034 } // namespace v8 | 2057 } // namespace v8 |
OLD | NEW |