Commit 815502d8 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm-gc] Update OpcodeLength, PrintRawWasmCode

Bug: v8:7748
Change-Id: If779c3c581317fb062c062a3ad60d1eebc1743d4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2767142Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73484}
parent 8e2be558
......@@ -1960,7 +1960,10 @@ class WasmDecoder : public Decoder {
ArrayIndexImmediate<validate> imm(decoder, pc + length);
return length + imm.length;
}
case kExprBrOnCast: {
case kExprBrOnCast:
case kExprBrOnData:
case kExprBrOnFunc:
case kExprBrOnI31: {
BranchDepthImmediate<validate> imm(decoder, pc + length);
return length + imm.length;
}
......@@ -1972,12 +1975,15 @@ class WasmDecoder : public Decoder {
case kExprI31New:
case kExprI31GetS:
case kExprI31GetU:
return length;
case kExprRefAsData:
case kExprRefAsFunc:
case kExprRefAsI31:
case kExprRefIsData:
case kExprRefIsFunc:
case kExprRefIsI31:
case kExprRefTest:
case kExprRefCast: {
TypeIndexImmediate<validate> ht(decoder, pc + length);
return length + ht.length;
}
case kExprRefCast:
return length;
default:
// This is unreachable except for malformed modules.
if (validate) {
......
......@@ -209,27 +209,26 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
os << RawOpcodeName(opcode) << ",";
if (opcode == kExprLoop || opcode == kExprIf || opcode == kExprBlock ||
opcode == kExprTry) {
DCHECK_EQ(2, length);
// TODO(7748) Update this for gc and ref types if needed
switch (i.pc()[1]) {
#define CASE_LOCAL_TYPE(local_name, type_name) \
case k##local_name##Code: \
os << " kWasm" #type_name ","; \
break;
CASE_LOCAL_TYPE(I32, I32)
CASE_LOCAL_TYPE(I64, I64)
CASE_LOCAL_TYPE(F32, F32)
CASE_LOCAL_TYPE(F64, F64)
CASE_LOCAL_TYPE(S128, S128)
CASE_LOCAL_TYPE(Void, Stmt)
default:
os << " 0x" << AsHex(i.pc()[1], 2) << ",";
break;
opcode == kExprTry || opcode == kExprLet) {
if (i.pc()[1] & 0x80) {
uint32_t temp_length;
ValueType type =
value_type_reader::read_value_type<Decoder::kNoValidation>(
&decoder, i.pc() + 1, &temp_length, module,
WasmFeatures::All());
if (temp_length == 1) {
os << type.name() << ",";
} else {
// TODO(manoskouk): Improve this for rtts and (nullable) refs.
for (unsigned j = offset; j < length; ++j) {
os << " 0x" << AsHex(i.pc()[j], 2) << ",";
}
}
} else {
for (unsigned j = offset; j < length; ++j) {
os << " 0x" << AsHex(i.pc()[j], 2) << ",";
}
}
#undef CASE_LOCAL_TYPE
} else {
for (unsigned j = offset; j < length; ++j) {
os << " 0x" << AsHex(i.pc()[j], 2) << ",";
......@@ -249,7 +248,8 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
case kExprLoop:
case kExprIf:
case kExprBlock:
case kExprTry: {
case kExprTry:
case kExprLet: {
BlockTypeImmediate<Decoder::kNoValidation> imm(WasmFeatures::All(), &i,
i.pc() + 1, module);
os << " @" << i.pc_offset();
......
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