[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/1375849
Reviewed-by: Stephan Herhut <herhut@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58225}
This commit is contained in:
Michael Starzinger 2018-12-13 15:42:27 +01:00 committed by Commit Bot
parent 366cddfa82
commit 4f2333692f
2 changed files with 16 additions and 5 deletions

View File

@ -152,7 +152,10 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
WasmOpcode opcode = i.current(); WasmOpcode opcode = i.current();
if (line_numbers) line_numbers->push_back(i.position()); 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; int num_whitespaces = control_depth < 32 ? 2 * control_depth : 64;
@ -192,6 +195,8 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
switch (opcode) { switch (opcode) {
case kExprElse: case kExprElse:
case kExprCatch:
case kExprCatchAll:
os << " // @" << i.pc_offset(); os << " // @" << i.pc_offset();
control_depth++; control_depth++;
break; break;

View File

@ -81,7 +81,10 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes,
for (; i.has_next(); i.next()) { for (; i.has_next(); i.next()) {
WasmOpcode opcode = i.current(); 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); DCHECK_LE(0, control_depth);
const int kMaxIndentation = 64; const int kMaxIndentation = 64;
@ -118,7 +121,8 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes,
break; break;
} }
case kExprElse: case kExprElse:
os << "else"; case kExprCatchAll:
os << WasmOpcodes::OpcodeName(opcode);
control_depth++; control_depth++;
break; break;
case kExprEnd: case kExprEnd:
@ -149,8 +153,10 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes,
os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index; os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index;
break; break;
} }
case kExprThrow: case kExprCatch:
case kExprCatch: { control_depth++;
V8_FALLTHROUGH;
case kExprThrow: {
ExceptionIndexImmediate<Decoder::kNoValidate> imm(&i, i.pc()); ExceptionIndexImmediate<Decoder::kNoValidate> imm(&i, i.pc());
os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index; os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index;
break; break;