diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc index dfcdfdb9ab..659223ee4b 100644 --- a/src/wasm/function-body-decoder.cc +++ b/src/wasm/function-body-decoder.cc @@ -152,7 +152,10 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body, WasmOpcode opcode = i.current(); if (line_numbers) line_numbers->push_back(i.position()); - if (opcode == kExprElse) control_depth--; + if (opcode == kExprElse || opcode == kExprCatch || + opcode == kExprCatchAll) { + control_depth--; + } int num_whitespaces = control_depth < 32 ? 2 * control_depth : 64; @@ -192,6 +195,8 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body, switch (opcode) { case kExprElse: + case kExprCatch: + case kExprCatchAll: os << " // @" << i.pc_offset(); control_depth++; break; diff --git a/src/wasm/wasm-text.cc b/src/wasm/wasm-text.cc index 16b803aecd..17b6b37d16 100644 --- a/src/wasm/wasm-text.cc +++ b/src/wasm/wasm-text.cc @@ -81,7 +81,10 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes, for (; i.has_next(); i.next()) { WasmOpcode opcode = i.current(); - if (opcode == kExprElse || opcode == kExprEnd) --control_depth; + if (opcode == kExprElse || opcode == kExprCatch || + opcode == kExprCatchAll || opcode == kExprEnd) { + --control_depth; + } DCHECK_LE(0, control_depth); const int kMaxIndentation = 64; @@ -118,7 +121,8 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes, break; } case kExprElse: - os << "else"; + case kExprCatchAll: + os << WasmOpcodes::OpcodeName(opcode); control_depth++; break; case kExprEnd: @@ -149,8 +153,10 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes, os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index; break; } - case kExprThrow: - case kExprCatch: { + case kExprCatch: + control_depth++; + V8_FALLTHROUGH; + case kExprThrow: { ExceptionIndexImmediate imm(&i, i.pc()); os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index; break;