Commit 4adfd97b authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Fix decoder tracing

This fixes two issues with --trace-wasm-decoder and --trace-liftoff.
First, cache state tracing in liftoff only makes sense together with
--trace-wasm-decoder, so disable it otherwise.
Second, we were sometimes hitting a DCHECK with --trace-wasm-decoder on
functions which bailed out to Turbofan, since the bailout was resetting
the end pointer of the decoder to the current pc.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: Ib4e052a1cdec6389b12b4a0ea57f07c031324ed5
Reviewed-on: https://chromium-review.googlesource.com/853493
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50415}
parent 2ca420e4
...@@ -771,7 +771,7 @@ class LiftoffCompiler { ...@@ -771,7 +771,7 @@ class LiftoffCompiler {
void TraceCacheState(Decoder* decoder) const { void TraceCacheState(Decoder* decoder) const {
#ifdef DEBUG #ifdef DEBUG
if (!FLAG_trace_liftoff) return; if (!FLAG_trace_liftoff || !FLAG_trace_wasm_decoder) return;
OFStream os(stdout); OFStream os(stdout);
for (int control_depth = decoder->control_depth() - 1; control_depth >= -1; for (int control_depth = decoder->control_depth() - 1; control_depth >= -1;
--control_depth) { --control_depth) {
......
...@@ -1871,22 +1871,25 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -1871,22 +1871,25 @@ class WasmFullDecoder : public WasmDecoder<validate> {
TRACE_PART(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type), TRACE_PART(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type),
static_cast<int>(val.pc - this->start_), static_cast<int>(val.pc - this->start_),
WasmOpcodes::OpcodeName(opcode)); WasmOpcodes::OpcodeName(opcode));
// If the decoder failed, don't try to decode the operands, as this
// can trigger a DCHECK failure.
if (this->failed()) continue;
switch (opcode) { switch (opcode) {
case kExprI32Const: { case kExprI32Const: {
ImmI32Operand<validate> operand(this, val.pc); ImmI32Operand<Decoder::kNoValidate> operand(this, val.pc);
TRACE_PART("[%d]", operand.value); TRACE_PART("[%d]", operand.value);
break; break;
} }
case kExprGetLocal: case kExprGetLocal:
case kExprSetLocal: case kExprSetLocal:
case kExprTeeLocal: { case kExprTeeLocal: {
LocalIndexOperand<Decoder::kValidate> operand(this, val.pc); LocalIndexOperand<Decoder::kNoValidate> operand(this, val.pc);
TRACE_PART("[%u]", operand.index); TRACE_PART("[%u]", operand.index);
break; break;
} }
case kExprGetGlobal: case kExprGetGlobal:
case kExprSetGlobal: { case kExprSetGlobal: {
GlobalIndexOperand<validate> operand(this, val.pc); GlobalIndexOperand<Decoder::kNoValidate> operand(this, val.pc);
TRACE_PART("[%u]", operand.index); TRACE_PART("[%u]", operand.index);
break; 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