[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: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50415}
This commit is contained in:
Clemens Hammacher 2018-01-08 16:35:43 +01:00 committed by Commit Bot
parent 2ca420e46c
commit 4adfd97b29
2 changed files with 7 additions and 4 deletions

View File

@ -771,7 +771,7 @@ class LiftoffCompiler {
void TraceCacheState(Decoder* decoder) const {
#ifdef DEBUG
if (!FLAG_trace_liftoff) return;
if (!FLAG_trace_liftoff || !FLAG_trace_wasm_decoder) return;
OFStream os(stdout);
for (int control_depth = decoder->control_depth() - 1; control_depth >= -1;
--control_depth) {

View File

@ -1871,22 +1871,25 @@ class WasmFullDecoder : public WasmDecoder<validate> {
TRACE_PART(" %c@%d:%s", WasmOpcodes::ShortNameOf(val.type),
static_cast<int>(val.pc - this->start_),
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) {
case kExprI32Const: {
ImmI32Operand<validate> operand(this, val.pc);
ImmI32Operand<Decoder::kNoValidate> operand(this, val.pc);
TRACE_PART("[%d]", operand.value);
break;
}
case kExprGetLocal:
case kExprSetLocal:
case kExprTeeLocal: {
LocalIndexOperand<Decoder::kValidate> operand(this, val.pc);
LocalIndexOperand<Decoder::kNoValidate> operand(this, val.pc);
TRACE_PART("[%u]", operand.index);
break;
}
case kExprGetGlobal:
case kExprSetGlobal: {
GlobalIndexOperand<validate> operand(this, val.pc);
GlobalIndexOperand<Decoder::kNoValidate> operand(this, val.pc);
TRACE_PART("[%u]", operand.index);
break;
}