Commit d2d7f476 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Fix --trace-wasm-decoding for boolean validation

With boolean validation, we don't keep the PC for stack values any more.
This CL fixes the --trace-wasm-decoding logic to just not print the
opcode which produced a value. The producer can also be found by looking
back in the trace.
This also makes the tracing output a lot more concise, hence easier to
read.

Also fix the TraceFailed method to not try to print buffer relative
offsets if no PC is there.

R=zhin@chromium.org

Bug: v8:10969
Change-Id: I5a7a69ea5aa461a277401d87ee24635266517d3c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2465837Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70501}
parent d4febb6b
......@@ -2096,9 +2096,13 @@ class WasmFullDecoder : public WasmDecoder<validate> {
}
bool TraceFailed() {
TRACE("wasm-error module+%-6d func+%d: %s\n\n", this->error_.offset(),
this->GetBufferRelativeOffset(this->error_.offset()),
this->error_.message().c_str());
if (this->error_.offset()) {
TRACE("wasm-error module+%-6d func+%d: %s\n\n", this->error_.offset(),
this->GetBufferRelativeOffset(this->error_.offset()),
this->error_.message().c_str());
} else {
TRACE("wasm-error: %s\n\n", this->error_.message().c_str());
}
return false;
}
......@@ -2258,42 +2262,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
Append(" | ");
for (size_t i = 0; i < decoder_->stack_size(); ++i) {
Value& val = decoder_->stack_[i];
WasmOpcode val_opcode = static_cast<WasmOpcode>(*val.pc());
if (WasmOpcodes::IsPrefixOpcode(val_opcode)) {
val_opcode =
decoder_->template read_prefixed_opcode<Decoder::kNoValidation>(
val.pc());
}
Append(" %c@%d:%s", val.type.short_name(),
static_cast<int>(val.pc() - decoder_->start_),
WasmOpcodes::OpcodeName(val_opcode));
// If the decoder failed, don't try to decode the immediates, as this
// can trigger a DCHECK failure.
if (decoder_->failed()) continue;
switch (val_opcode) {
case kExprI32Const: {
ImmI32Immediate<Decoder::kNoValidation> imm(decoder_, val.pc() + 1);
Append("[%d]", imm.value);
break;
}
case kExprLocalGet:
case kExprLocalSet:
case kExprLocalTee: {
LocalIndexImmediate<Decoder::kNoValidation> imm(decoder_,
val.pc() + 1);
Append("[%u]", imm.index);
break;
}
case kExprGlobalGet:
case kExprGlobalSet: {
GlobalIndexImmediate<Decoder::kNoValidation> imm(decoder_,
val.pc() + 1);
Append("[%u]", imm.index);
break;
}
default:
break;
}
Append(" %c", val.type.short_name());
}
}
......
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