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 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1480 | 1480 |
1481 | 1481 |
1482 void StackFrame::PrintIndex(StringStream* accumulator, | 1482 void StackFrame::PrintIndex(StringStream* accumulator, |
1483 PrintMode mode, | 1483 PrintMode mode, |
1484 int index) { | 1484 int index) { |
1485 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); | 1485 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); |
1486 } | 1486 } |
1487 | 1487 |
1488 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, | 1488 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, |
1489 int index) const { | 1489 int index) const { |
1490 accumulator->Add("wasm frame"); | 1490 PrintIndex(accumulator, mode, index); |
1491 accumulator->Add("WASM ["); | |
1492 Script* script = this->script(); | |
1493 accumulator->PrintName(script->name()); | |
1494 int pc = static_cast<int>(this->pc() - LookupCode()->instruction_start()); | |
1495 Vector<const uint8_t> raw_func_name; | |
1496 Object* instance_or_undef = this->wasm_instance(); | |
1497 if (instance_or_undef->IsUndefined(this->isolate())) { | |
1498 raw_func_name = STATIC_CHAR_VECTOR("<undefined>"); | |
1499 } else { | |
1500 raw_func_name = WasmInstanceObject::cast(instance_or_undef) | |
1501 ->get_compiled_module() | |
1502 ->GetRawFunctionName(this->function_index()); | |
1503 } | |
1504 const int kMaxPrintedFunctionName = 64; | |
1505 char func_name[kMaxPrintedFunctionName + 1]; | |
1506 int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length()); | |
1507 memcpy(func_name, raw_func_name.start(), func_name_len); | |
1508 func_name[func_name_len] = '\0'; | |
1509 accumulator->Add("], function #%u ('%s'), pc=%p, pos=%d\n", | |
titzer
2016/11/18 10:38:21
Does the accumulator pass the format string to pri
Clemens Hammacher
2016/11/18 12:01:27
No, unfortunately not. It does the formatting inte
| |
1510 this->function_index(), func_name, pc, this->position()); | |
1511 if (mode != OVERVIEW) accumulator->Add("\n"); | |
1491 } | 1512 } |
1492 | 1513 |
1493 Code* WasmFrame::unchecked_code() const { | 1514 Code* WasmFrame::unchecked_code() const { |
1494 return static_cast<Code*>(isolate()->FindCodeObject(pc())); | 1515 return static_cast<Code*>(isolate()->FindCodeObject(pc())); |
1495 } | 1516 } |
1496 | 1517 |
1497 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } | 1518 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } |
1498 | 1519 |
1499 Address WasmFrame::GetCallerStackPointer() const { | 1520 Address WasmFrame::GetCallerStackPointer() const { |
1500 return fp() + ExitFrameConstants::kCallerSPOffset; | 1521 return fp() + ExitFrameConstants::kCallerSPOffset; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1967 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1988 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1968 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1989 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1969 list.Add(frame, zone); | 1990 list.Add(frame, zone); |
1970 } | 1991 } |
1971 return list.ToVector(); | 1992 return list.ToVector(); |
1972 } | 1993 } |
1973 | 1994 |
1974 | 1995 |
1975 } // namespace internal | 1996 } // namespace internal |
1976 } // namespace v8 | 1997 } // namespace v8 |
OLD | NEW |