| 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 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 int WasmFrame::position() const { | 1531 int WasmFrame::position() const { |
| 1532 int position = StandardFrame::position(); | 1532 int position = StandardFrame::position(); |
| 1533 if (wasm::WasmIsAsmJs(wasm_instance(), isolate())) { | 1533 if (wasm::WasmIsAsmJs(wasm_instance(), isolate())) { |
| 1534 Handle<WasmCompiledModule> compiled_module( | 1534 Handle<WasmCompiledModule> compiled_module( |
| 1535 WasmInstanceObject::cast(wasm_instance())->get_compiled_module(), | 1535 WasmInstanceObject::cast(wasm_instance())->get_compiled_module(), |
| 1536 isolate()); | 1536 isolate()); |
| 1537 DCHECK_LE(0, position); | 1537 DCHECK_LE(0, position); |
| 1538 position = WasmCompiledModule::GetAsmJsSourcePosition( | 1538 position = WasmCompiledModule::GetAsmJsSourcePosition( |
| 1539 compiled_module, function_index(), static_cast<uint32_t>(position)); | 1539 compiled_module, function_index(), static_cast<uint32_t>(position), |
| 1540 at_to_number_conversion()); |
| 1540 } | 1541 } |
| 1541 return position; | 1542 return position; |
| 1542 } | 1543 } |
| 1543 | 1544 |
| 1545 bool WasmFrame::at_to_number_conversion() const { |
| 1546 // WasmToJsFrame::ComputeCallerState encoded this for us in the constant pool |
| 1547 // address ;) |
| 1548 return !!constant_pool_address(); |
| 1549 } |
| 1550 |
| 1544 int WasmFrame::LookupExceptionHandlerInTable(int* stack_slots) { | 1551 int WasmFrame::LookupExceptionHandlerInTable(int* stack_slots) { |
| 1545 DCHECK_NOT_NULL(stack_slots); | 1552 DCHECK_NOT_NULL(stack_slots); |
| 1546 Code* code = LookupCode(); | 1553 Code* code = LookupCode(); |
| 1547 HandlerTable* table = HandlerTable::cast(code->handler_table()); | 1554 HandlerTable* table = HandlerTable::cast(code->handler_table()); |
| 1548 int pc_offset = static_cast<int>(pc() - code->entry()); | 1555 int pc_offset = static_cast<int>(pc() - code->entry()); |
| 1549 *stack_slots = code->stack_slots(); | 1556 *stack_slots = code->stack_slots(); |
| 1550 return table->LookupReturn(pc_offset); | 1557 return table->LookupReturn(pc_offset); |
| 1551 } | 1558 } |
| 1552 | 1559 |
| 1560 void WasmToJsFrame::ComputeCallerState(State* state) const { |
| 1561 // Remember at which of the two calls inside it we are, and transfer this |
| 1562 // information to the subsequent WASM frame. |
| 1563 Code* code = unchecked_code(); |
| 1564 AbstractCode* abstract_code = AbstractCode::cast(code); |
| 1565 int offset = static_cast<int>(pc() - code->instruction_start()); |
| 1566 int at_to_number_call = abstract_code->SourcePosition(offset); |
| 1567 DCHECK(at_to_number_call == 0 || at_to_number_call == 1); |
| 1568 StubFrame::ComputeCallerState(state); |
| 1569 DCHECK_EQ(StackFrame::WASM, ComputeType(iterator_, state)); |
| 1570 // Use a little hack here: The constant pool address is not used for wasm |
| 1571 // frames, so use it to encode whether we are at the to_number call. |
| 1572 state->constant_pool_address = reinterpret_cast<Address*>(at_to_number_call); |
| 1573 } |
| 1574 |
| 1553 namespace { | 1575 namespace { |
| 1554 | 1576 |
| 1555 | 1577 |
| 1556 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, | 1578 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, |
| 1557 Code* code) { | 1579 Code* code) { |
| 1558 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { | 1580 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { |
| 1559 std::ostringstream os; | 1581 std::ostringstream os; |
| 1560 os << "--------- s o u r c e c o d e ---------\n" | 1582 os << "--------- s o u r c e c o d e ---------\n" |
| 1561 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) | 1583 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) |
| 1562 << "\n-----------------------------------------\n"; | 1584 << "\n-----------------------------------------\n"; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 2003 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1982 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 2004 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1983 list.Add(frame, zone); | 2005 list.Add(frame, zone); |
| 1984 } | 2006 } |
| 1985 return list.ToVector(); | 2007 return list.ToVector(); |
| 1986 } | 2008 } |
| 1987 | 2009 |
| 1988 | 2010 |
| 1989 } // namespace internal | 2011 } // namespace internal |
| 1990 } // namespace v8 | 2012 } // namespace v8 |
| OLD | NEW |