Commit 98d843c8 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Move more functionality into TraceLine

This moves some more tracing functionality into the {TraceLine} helper,
such that for most operations we only need to instantiate a {TraceLine}
object via its constructor and be done with it.

R=thibaudm@chromium.org

Bug: v8:10576
Change-Id: Ide368d4a52768089a23744b9e1e25df4b8fed2ee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2276275
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68650}
parent 3d2501b2
...@@ -2014,7 +2014,16 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2014,7 +2014,16 @@ class WasmFullDecoder : public WasmDecoder<validate> {
#ifdef DEBUG #ifdef DEBUG
class TraceLine { class TraceLine {
public: public:
explicit TraceLine(WasmFullDecoder* decoder) : decoder_(decoder) {} explicit TraceLine(WasmFullDecoder* decoder) : decoder_(decoder) {
WasmOpcode opcode = static_cast<WasmOpcode>(*decoder->pc());
if (!WasmOpcodes::IsPrefixOpcode(opcode)) AppendOpcode(opcode);
}
void AppendOpcode(WasmOpcode opcode) {
DCHECK(!WasmOpcodes::IsPrefixOpcode(opcode));
Append(TRACE_INST_FORMAT, decoder_->startrel(decoder_->pc_),
WasmOpcodes::OpcodeName(opcode));
}
~TraceLine() { ~TraceLine() {
if (!FLAG_trace_wasm_decoder) return; if (!FLAG_trace_wasm_decoder) return;
...@@ -2114,6 +2123,8 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2114,6 +2123,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
public: public:
explicit TraceLine(WasmFullDecoder*) {} explicit TraceLine(WasmFullDecoder*) {}
void AppendOpcode(WasmOpcode) {}
PRINTF_FORMAT(2, 3) PRINTF_FORMAT(2, 3)
void Append(const char* format, ...) {} void Append(const char* format, ...) {}
}; };
...@@ -2129,10 +2140,6 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2129,10 +2140,6 @@ class WasmFullDecoder : public WasmDecoder<validate> {
template <WasmOpcode opcode> template <WasmOpcode opcode>
int DecodeOp() { int DecodeOp() {
TraceLine trace_msg(this); TraceLine trace_msg(this);
if (!WasmOpcodes::IsPrefixOpcode(opcode)) {
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_),
WasmOpcodes::OpcodeName(opcode));
}
// TODO(clemensb): Break this up into individual functions. // TODO(clemensb): Break this up into individual functions.
switch (opcode) { switch (opcode) {
...@@ -2787,8 +2794,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2787,8 +2794,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
} else if (full_opcode >= kExprMemoryInit) { } else if (full_opcode >= kExprMemoryInit) {
CHECK_PROTOTYPE_OPCODE(bulk_memory); CHECK_PROTOTYPE_OPCODE(bulk_memory);
} }
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_), trace_msg.AppendOpcode(full_opcode);
WasmOpcodes::OpcodeName(full_opcode));
return DecodeNumericOpcode(full_opcode); return DecodeNumericOpcode(full_opcode);
} }
case kSimdPrefix: { case kSimdPrefix: {
...@@ -2797,8 +2803,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2797,8 +2803,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
WasmOpcode full_opcode = this->template read_prefixed_opcode<validate>( WasmOpcode full_opcode = this->template read_prefixed_opcode<validate>(
this->pc_, &opcode_length); this->pc_, &opcode_length);
if (!VALIDATE(this->ok())) return 0; if (!VALIDATE(this->ok())) return 0;
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_), trace_msg.AppendOpcode(full_opcode);
WasmOpcodes::OpcodeName(full_opcode));
return DecodeSimdOpcode(full_opcode, 1 + opcode_length); return DecodeSimdOpcode(full_opcode, 1 + opcode_length);
} }
case kAtomicPrefix: { case kAtomicPrefix: {
...@@ -2807,8 +2812,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2807,8 +2812,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
this->template read_u8<validate>(this->pc_ + 1, "atomic index"); this->template read_u8<validate>(this->pc_ + 1, "atomic index");
WasmOpcode full_opcode = WasmOpcode full_opcode =
static_cast<WasmOpcode>(opcode << 8 | atomic_index); static_cast<WasmOpcode>(opcode << 8 | atomic_index);
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_), trace_msg.AppendOpcode(full_opcode);
WasmOpcodes::OpcodeName(full_opcode));
return DecodeAtomicOpcode(full_opcode); return DecodeAtomicOpcode(full_opcode);
} }
case kGCPrefix: { case kGCPrefix: {
...@@ -2817,8 +2821,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2817,8 +2821,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
this->template read_u8<validate>(this->pc_ + 1, "gc index"); this->template read_u8<validate>(this->pc_ + 1, "gc index");
WasmOpcode full_opcode = WasmOpcode full_opcode =
static_cast<WasmOpcode>(opcode << 8 | gc_index); static_cast<WasmOpcode>(opcode << 8 | gc_index);
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_), trace_msg.AppendOpcode(full_opcode);
WasmOpcodes::OpcodeName(full_opcode));
return DecodeGCOpcode(full_opcode); return DecodeGCOpcode(full_opcode);
} }
// Note that prototype opcodes are not handled in the fastpath // Note that prototype opcodes are not handled in the fastpath
......
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