Commit 4f233369 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix indentation when printing exception expressions.

R=herhut@chromium.org
BUG=v8:8091

Change-Id: Ia4353dff0726a4c317c8e5e41617d93df193705f
Reviewed-on: https://chromium-review.googlesource.com/c/1375849Reviewed-by: 's avatarStephan Herhut <herhut@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58225}
parent 366cddfa
......@@ -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;
......
......@@ -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<Decoder::kNoValidate> imm(&i, i.pc());
os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index;
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment