Index: src/wasm/function-body-decoder.cc |
diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc |
index 00612b8fde5ef0ccce3eb1b072a18e2f9ef0b2cb..47677248b5188e16b9c23cae8d8a4436a7ada863 100644 |
--- a/src/wasm/function-body-decoder.cc |
+++ b/src/wasm/function-body-decoder.cc |
@@ -1881,14 +1881,27 @@ unsigned OpcodeLength(const byte* pc, const byte* end) { |
void PrintWasmCodeForDebugging(const byte* start, const byte* end) { |
titzer
2017/01/25 13:17:42
Can you also rename this method as well?
|
AccountingAllocator allocator; |
- OFStream os(stdout); |
- PrintWasmCode(&allocator, FunctionBodyForTesting(start, end), nullptr, os, |
- nullptr); |
+ PrintRawWasmCode(&allocator, FunctionBodyForTesting(start, end), nullptr); |
+} |
+ |
+namespace { |
+const char* RawOpcodeName(WasmOpcode opcode) { |
+ switch (opcode) { |
+#define DECLARE_NAME_CASE(name, opcode, sig) \ |
+ case kExpr##name: \ |
+ return "kExpr" #name; |
+ FOREACH_OPCODE(DECLARE_NAME_CASE) |
+#undef DECLARE_NAME_CASE |
+ default: |
+ break; |
+ } |
+ return "Unknown"; |
} |
+} // namespace |
-bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body, |
- const wasm::WasmModule* module, std::ostream& os, |
- std::vector<std::tuple<uint32_t, int, int>>* offset_table) { |
+bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body, |
+ const wasm::WasmModule* module) { |
+ OFStream os(stdout); |
Zone zone(allocator, ZONE_NAME); |
WasmFullDecoder decoder(&zone, module, body); |
int line_nr = 0; |
@@ -1937,16 +1950,13 @@ bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body, |
if (opcode == kExprElse) control_depth--; |
int num_whitespaces = control_depth < 32 ? 2 * control_depth : 64; |
- if (offset_table) { |
- offset_table->push_back( |
- std::make_tuple(i.pc_offset(), line_nr, num_whitespaces)); |
- } |
// 64 whitespaces |
const char* padding = |
" "; |
os.write(padding, num_whitespaces); |
- os << "k" << WasmOpcodes::OpcodeName(opcode) << ","; |
+ |
+ os << RawOpcodeName(opcode) << ","; |
for (size_t j = 1; j < length; ++j) { |
os << " 0x" << AsHex(i.pc()[j], 2) << ","; |