diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc index 40d4a0bac625..48db8e9e6808 100644 --- a/src/wasm/ast-decoder.cc +++ b/src/wasm/ast-decoder.cc @@ -509,7 +509,7 @@ class WasmFullDecoder : public WasmDecoder { } if (ssa_env_->go()) { - TRACE(" @%-6d #xx:%-20s|", startrel(pc_), "ImplicitReturn"); + TRACE(" @%-8d #xx:%-20s|", startrel(pc_), "ImplicitReturn"); DoReturn(); if (failed()) return TraceFailed(); TRACE("\n"); @@ -707,8 +707,10 @@ class WasmFullDecoder : public WasmDecoder { while (true) { // decoding loop. unsigned len = 1; WasmOpcode opcode = static_cast(*pc_); - TRACE(" @%-6d #%02x:%-20s|", startrel(pc_), opcode, - WasmOpcodes::ShortOpcodeName(opcode)); + if (!WasmOpcodes::IsPrefixOpcode(opcode)) { + TRACE(" @%-8d #%02x:%-20s|", startrel(pc_), opcode, + WasmOpcodes::ShortOpcodeName(opcode)); + } FunctionSig* sig = WasmOpcodes::Signature(opcode); if (sig) { @@ -1271,6 +1273,8 @@ class WasmFullDecoder : public WasmDecoder { len++; byte simd_index = *(pc_ + 1); opcode = static_cast(opcode << 8 | simd_index); + TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, + simd_index, WasmOpcodes::ShortOpcodeName(opcode)); DecodeSimdOpcode(opcode); break; } @@ -1285,6 +1289,9 @@ class WasmFullDecoder : public WasmDecoder { for (size_t i = 0; i < stack_.size(); ++i) { Value& val = stack_[i]; WasmOpcode opcode = static_cast(*val.pc); + if (WasmOpcodes::IsPrefixOpcode(opcode)) { + opcode = static_cast(opcode << 8 | *(val.pc + 1)); + } PrintF(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type), static_cast(val.pc - start_), WasmOpcodes::ShortOpcodeName(opcode)); diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc index 8f5420766136..3bffa60a7b8e 100644 --- a/src/wasm/wasm-opcodes.cc +++ b/src/wasm/wasm-opcodes.cc @@ -38,6 +38,18 @@ const char* WasmOpcodes::ShortOpcodeName(WasmOpcode opcode) { return "Unknown"; } +bool WasmOpcodes::IsPrefixOpcode(WasmOpcode opcode) { + switch (opcode) { +#define CHECK_PREFIX(name, opcode) \ + case k##name##Prefix: \ + return true; + FOREACH_PREFIX(CHECK_PREFIX) +#undef CHECK_PREFIX + default: + return false; + } +} + std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) { if (sig.return_count() == 0) os << "v"; for (size_t i = 0; i < sig.return_count(); ++i) { diff --git a/src/wasm/wasm-opcodes.h b/src/wasm/wasm-opcodes.h index 1412587097e5..77c2c46633c2 100644 --- a/src/wasm/wasm-opcodes.h +++ b/src/wasm/wasm-opcodes.h @@ -489,6 +489,7 @@ class WasmOpcodes { static const char* OpcodeName(WasmOpcode opcode); static const char* ShortOpcodeName(WasmOpcode opcode); static FunctionSig* Signature(WasmOpcode opcode); + static bool IsPrefixOpcode(WasmOpcode opcode); static int TrapReasonToMessageId(TrapReason reason); static const char* TrapReasonMessage(TrapReason reason);