[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: Thibaud Michaud <thibaudm@chromium.org> Cr-Commit-Position: refs/heads/master@{#68650}
This commit is contained in:
parent
3d2501b2e4
commit
98d843c83d
@ -2014,7 +2014,16 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
#ifdef DEBUG
|
||||
class TraceLine {
|
||||
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() {
|
||||
if (!FLAG_trace_wasm_decoder) return;
|
||||
@ -2114,6 +2123,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
public:
|
||||
explicit TraceLine(WasmFullDecoder*) {}
|
||||
|
||||
void AppendOpcode(WasmOpcode) {}
|
||||
|
||||
PRINTF_FORMAT(2, 3)
|
||||
void Append(const char* format, ...) {}
|
||||
};
|
||||
@ -2129,10 +2140,6 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
template <WasmOpcode opcode>
|
||||
int DecodeOp() {
|
||||
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.
|
||||
switch (opcode) {
|
||||
@ -2787,8 +2794,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
} else if (full_opcode >= kExprMemoryInit) {
|
||||
CHECK_PROTOTYPE_OPCODE(bulk_memory);
|
||||
}
|
||||
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_),
|
||||
WasmOpcodes::OpcodeName(full_opcode));
|
||||
trace_msg.AppendOpcode(full_opcode);
|
||||
return DecodeNumericOpcode(full_opcode);
|
||||
}
|
||||
case kSimdPrefix: {
|
||||
@ -2797,8 +2803,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
WasmOpcode full_opcode = this->template read_prefixed_opcode<validate>(
|
||||
this->pc_, &opcode_length);
|
||||
if (!VALIDATE(this->ok())) return 0;
|
||||
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_),
|
||||
WasmOpcodes::OpcodeName(full_opcode));
|
||||
trace_msg.AppendOpcode(full_opcode);
|
||||
return DecodeSimdOpcode(full_opcode, 1 + opcode_length);
|
||||
}
|
||||
case kAtomicPrefix: {
|
||||
@ -2807,8 +2812,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
this->template read_u8<validate>(this->pc_ + 1, "atomic index");
|
||||
WasmOpcode full_opcode =
|
||||
static_cast<WasmOpcode>(opcode << 8 | atomic_index);
|
||||
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_),
|
||||
WasmOpcodes::OpcodeName(full_opcode));
|
||||
trace_msg.AppendOpcode(full_opcode);
|
||||
return DecodeAtomicOpcode(full_opcode);
|
||||
}
|
||||
case kGCPrefix: {
|
||||
@ -2817,8 +2821,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
|
||||
this->template read_u8<validate>(this->pc_ + 1, "gc index");
|
||||
WasmOpcode full_opcode =
|
||||
static_cast<WasmOpcode>(opcode << 8 | gc_index);
|
||||
trace_msg.Append(TRACE_INST_FORMAT, startrel(this->pc_),
|
||||
WasmOpcodes::OpcodeName(full_opcode));
|
||||
trace_msg.AppendOpcode(full_opcode);
|
||||
return DecodeGCOpcode(full_opcode);
|
||||
}
|
||||
// Note that prototype opcodes are not handled in the fastpath
|
||||
|
Loading…
Reference in New Issue
Block a user