| 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 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); | 1522 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, | 1525 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, |
| 1526 int index) const { | 1526 int index) const { |
| 1527 PrintIndex(accumulator, mode, index); | 1527 PrintIndex(accumulator, mode, index); |
| 1528 accumulator->Add("WASM ["); | 1528 accumulator->Add("WASM ["); |
| 1529 Script* script = this->script(); | 1529 Script* script = this->script(); |
| 1530 accumulator->PrintName(script->name()); | 1530 accumulator->PrintName(script->name()); |
| 1531 int pc = static_cast<int>(this->pc() - LookupCode()->instruction_start()); | 1531 int pc = static_cast<int>(this->pc() - LookupCode()->instruction_start()); |
| 1532 Vector<const uint8_t> raw_func_name; | 1532 Object* instance = this->wasm_instance(); |
| 1533 Object* instance_or_undef = this->wasm_instance(); | 1533 Vector<const uint8_t> raw_func_name = |
| 1534 if (instance_or_undef->IsUndefined(this->isolate())) { | 1534 WasmInstanceObject::cast(instance)->compiled_module()->GetRawFunctionName( |
| 1535 raw_func_name = STATIC_CHAR_VECTOR("<undefined>"); | 1535 this->function_index()); |
| 1536 } else { | |
| 1537 raw_func_name = WasmInstanceObject::cast(instance_or_undef) | |
| 1538 ->compiled_module() | |
| 1539 ->GetRawFunctionName(this->function_index()); | |
| 1540 } | |
| 1541 const int kMaxPrintedFunctionName = 64; | 1536 const int kMaxPrintedFunctionName = 64; |
| 1542 char func_name[kMaxPrintedFunctionName + 1]; | 1537 char func_name[kMaxPrintedFunctionName + 1]; |
| 1543 int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length()); | 1538 int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length()); |
| 1544 memcpy(func_name, raw_func_name.start(), func_name_len); | 1539 memcpy(func_name, raw_func_name.start(), func_name_len); |
| 1545 func_name[func_name_len] = '\0'; | 1540 func_name[func_name_len] = '\0'; |
| 1546 accumulator->Add("], function #%u ('%s'), pc=%p, pos=%d\n", | 1541 accumulator->Add("], function #%u ('%s'), pc=%p, pos=%d\n", |
| 1547 this->function_index(), func_name, pc, this->position()); | 1542 this->function_index(), func_name, pc, this->position()); |
| 1548 if (mode != OVERVIEW) accumulator->Add("\n"); | 1543 if (mode != OVERVIEW) accumulator->Add("\n"); |
| 1549 } | 1544 } |
| 1550 | 1545 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 2038 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 2044 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 2039 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 2045 list.Add(frame, zone); | 2040 list.Add(frame, zone); |
| 2046 } | 2041 } |
| 2047 return list.ToVector(); | 2042 return list.ToVector(); |
| 2048 } | 2043 } |
| 2049 | 2044 |
| 2050 | 2045 |
| 2051 } // namespace internal | 2046 } // namespace internal |
| 2052 } // namespace v8 | 2047 } // namespace v8 |
| OLD | NEW |