[wasm-gc] Implement StackEffect for GC instructions

Bug: v8:7748
Change-Id: I1c844768e09095ad85396f1752420b616048ec36
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2278473
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68665}
This commit is contained in:
Manos Koukoutos 2020-07-02 11:57:40 +00:00 committed by Commit Bot
parent ecfbc749b7
commit 0215fd7232

View File

@ -1827,10 +1827,53 @@ class WasmDecoder : public Decoder {
sig = WasmOpcodes::Signature(opcode);
if (sig) {
return {sig->parameter_count(), sig->return_count()};
} else {
UNREACHABLE();
}
}
}
V8_FALLTHROUGH;
}
case kGCPrefix: {
opcode = this->read_prefixed_opcode<validate>(pc);
switch (opcode) {
case kExprStructGet:
case kExprStructGetS:
case kExprStructGetU:
case kExprI31New:
case kExprI31GetS:
case kExprI31GetU:
case kExprArrayLen:
case kExprRttSub:
return {1, 1};
case kExprStructSet:
return {2, 0};
case kExprArrayNew:
case kExprArrayGet:
case kExprArrayGetS:
case kExprArrayGetU:
case kExprRefTest:
case kExprRefCast:
case kExprBrOnCast:
return {2, 1};
case kExprArraySet:
return {3, 0};
case kExprRttCanon:
return {0, 1};
case kExprArrayNewSub:
return {3, 1};
case kExprStructNew: {
StructIndexImmediate<validate> imm(this, this->pc_ + 2);
this->Complete(imm);
return {imm.struct_type->field_count(), 1};
}
case kExprStructNewWithRtt: {
StructIndexImmediate<validate> imm(this, this->pc_ + 2);
this->Complete(imm);
return {imm.struct_type->field_count() + 1, 1};
}
default:
UNREACHABLE();
}
}
default:
FATAL("unimplemented opcode: %x (%s)", opcode,