Commit c85800e2 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm-gc] Establish HeapType shorthands, rework signatures.

This CL introduces one-letter shorthands to HeapTypes, and fixes
signatures to be in sync with the ValueType and HeapType shorthands.

Bug: v8:7748
Change-Id: I4cc8e26d6523074bc36bf2d29289e63a23e80ddc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2249672
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68425}
parent 94dd3e99
......@@ -41,10 +41,10 @@ class Simd128;
V(Bottom, -1, Void, None, '*', "<bot>")
enum HeapType : uint32_t {
kHeapFunc = kV8MaxWasmTypes,
kHeapExtern,
kHeapEq,
kHeapExn
kHeapFunc = kV8MaxWasmTypes, // shorthand: c
kHeapExtern, // shorthand: e
kHeapEq, // shorthand: q
kHeapExn // shorthand: x
};
enum Nullability : bool { kNonNullable, kNullable };
......
......@@ -231,8 +231,7 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, const WasmFeatures&);
V(I64SExtendI16, 0xc3, l_l) \
V(I64SExtendI32, 0xc4, l_l)
#define FOREACH_SIMPLE_PROTOTYPE_OPCODE(V) \
V(RefEq, 0xd5, i_rr) // made-up opcode, guessing future spec (GC)
#define FOREACH_SIMPLE_PROTOTYPE_OPCODE(V) V(RefEq, 0xd5, i_qq)
// For compatibility with Asm.js.
// These opcodes are not spec'ed (or visible) externally; the idea is
......@@ -505,26 +504,28 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, const WasmFeatures&);
FOREACH_SIMD_1_OPERAND_1_PARAM_OPCODE(V) \
FOREACH_SIMD_1_OPERAND_2_PARAM_OPCODE(V)
#define FOREACH_NUMERIC_OPCODE(V) \
V(I32SConvertSatF32, 0xfc00, i_f) \
V(I32UConvertSatF32, 0xfc01, i_f) \
V(I32SConvertSatF64, 0xfc02, i_d) \
V(I32UConvertSatF64, 0xfc03, i_d) \
V(I64SConvertSatF32, 0xfc04, l_f) \
V(I64UConvertSatF32, 0xfc05, l_f) \
V(I64SConvertSatF64, 0xfc06, l_d) \
V(I64UConvertSatF64, 0xfc07, l_d) \
V(MemoryInit, 0xfc08, v_iii) \
V(DataDrop, 0xfc09, v_v) \
V(MemoryCopy, 0xfc0a, v_iii) \
V(MemoryFill, 0xfc0b, v_iii) \
V(TableInit, 0xfc0c, v_iii) \
V(ElemDrop, 0xfc0d, v_v) \
V(TableCopy, 0xfc0e, v_iii) \
V(TableGrow, 0xfc0f, i_ai) \
V(TableSize, 0xfc10, i_v) \
/* TableFill is polymorph in the second parameter. */ \
/* It's externref or funcref. */ \
#define FOREACH_NUMERIC_OPCODE(V) \
V(I32SConvertSatF32, 0xfc00, i_f) \
V(I32UConvertSatF32, 0xfc01, i_f) \
V(I32SConvertSatF64, 0xfc02, i_d) \
V(I32UConvertSatF64, 0xfc03, i_d) \
V(I64SConvertSatF32, 0xfc04, l_f) \
V(I64UConvertSatF32, 0xfc05, l_f) \
V(I64SConvertSatF64, 0xfc06, l_d) \
V(I64UConvertSatF64, 0xfc07, l_d) \
V(MemoryInit, 0xfc08, v_iii) \
V(DataDrop, 0xfc09, v_v) \
V(MemoryCopy, 0xfc0a, v_iii) \
V(MemoryFill, 0xfc0b, v_iii) \
V(TableInit, 0xfc0c, v_iii) \
V(ElemDrop, 0xfc0d, v_v) \
V(TableCopy, 0xfc0e, v_iii) \
/* TableGrow is polymorphic in the first parameter. */ \
/* It's whatever the table type is. */ \
V(TableGrow, 0xfc0f, i_ci) \
V(TableSize, 0xfc10, i_v) \
/* TableFill is polymorphic in the second parameter. */ \
/* It's whatever the table type is. */ \
V(TableFill, 0xfc11, v_iii)
#define FOREACH_ATOMIC_OPCODE(V) \
......@@ -685,9 +686,9 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, const WasmFeatures&);
V(l_ill, kWasmI64, kWasmI32, kWasmI64, kWasmI64) \
V(i_iil, kWasmI32, kWasmI32, kWasmI32, kWasmI64) \
V(i_ill, kWasmI32, kWasmI32, kWasmI64, kWasmI64) \
V(i_r, kWasmI32, kWasmExternRef) \
V(i_ai, kWasmI32, kWasmFuncRef, kWasmI32) \
V(i_rr, kWasmI32, kWasmEqRef, kWasmEqRef)
V(i_e, kWasmI32, kWasmExternRef) \
V(i_ci, kWasmI32, kWasmFuncRef, kWasmI32) \
V(i_qq, kWasmI32, kWasmEqRef, kWasmEqRef)
#define FOREACH_SIMD_SIGNATURE(V) \
V(s_s, kWasmS128, kWasmS128) \
......
......@@ -25,9 +25,9 @@ class TestSignatures {
sig_i_ff(1, 2, kIntFloatTypes4),
sig_i_d(1, 1, kIntDoubleTypes4),
sig_i_dd(1, 2, kIntDoubleTypes4),
sig_i_r(1, 1, kIntExternRefTypes4),
sig_i_rr(1, 2, kIntExternRefTypes4),
sig_i_a(1, 1, kIntFuncRefTypes4),
sig_i_e(1, 1, kIntExternRefTypes4),
sig_i_ee(1, 2, kIntExternRefTypes4),
sig_i_c(1, 1, kIntFuncRefTypes4),
sig_i_s(1, 1, kIntSimd128Types4),
sig_l_v(1, 0, kLongTypes4),
sig_l_l(1, 1, kLongTypes4),
......@@ -37,16 +37,16 @@ class TestSignatures {
sig_f_ff(1, 2, kFloatTypes4),
sig_d_d(1, 1, kDoubleTypes4),
sig_d_dd(1, 2, kDoubleTypes4),
sig_r_v(1, 0, kRefTypes4),
sig_a_v(1, 0, kFuncTypes4),
sig_r_r(1, 1, kRefTypes4),
sig_a_a(1, 1, kFuncTypes4),
sig_e_v(1, 0, kExternRefTypes4),
sig_c_v(1, 0, kFuncTypes4),
sig_e_e(1, 1, kExternRefTypes4),
sig_c_c(1, 1, kFuncTypes4),
sig_v_v(0, 0, kIntTypes4),
sig_v_i(0, 1, kIntTypes4),
sig_v_ii(0, 2, kIntTypes4),
sig_v_iii(0, 3, kIntTypes4),
sig_v_r(0, 1, kRefTypes4),
sig_v_a(0, 1, kFuncTypes4),
sig_v_e(0, 1, kExternRefTypes4),
sig_v_c(0, 1, kFuncTypes4),
sig_s_i(1, 1, kSimd128IntTypes4),
sig_ii_v(2, 0, kIntTypes4),
sig_iii_v(3, 0, kIntTypes4) {
......@@ -55,7 +55,7 @@ class TestSignatures {
for (int i = 0; i < 4; i++) kLongTypes4[i] = kWasmI64;
for (int i = 0; i < 4; i++) kFloatTypes4[i] = kWasmF32;
for (int i = 0; i < 4; i++) kDoubleTypes4[i] = kWasmF64;
for (int i = 0; i < 4; i++) kRefTypes4[i] = kWasmExternRef;
for (int i = 0; i < 4; i++) kExternRefTypes4[i] = kWasmExternRef;
for (int i = 0; i < 4; i++) kFuncTypes4[i] = kWasmFuncRef;
for (int i = 1; i < 4; i++) kIntLongTypes4[i] = kWasmI64;
for (int i = 1; i < 4; i++) kIntFloatTypes4[i] = kWasmF32;
......@@ -87,9 +87,9 @@ class TestSignatures {
FunctionSig* l_l() { return &sig_l_l; }
FunctionSig* l_ll() { return &sig_l_ll; }
FunctionSig* i_ll() { return &sig_i_ll; }
FunctionSig* i_r() { return &sig_i_r; }
FunctionSig* i_rr() { return &sig_i_rr; }
FunctionSig* i_a() { return &sig_i_a; }
FunctionSig* i_e() { return &sig_i_e; }
FunctionSig* i_ee() { return &sig_i_ee; }
FunctionSig* i_c() { return &sig_i_c; }
FunctionSig* i_s() { return &sig_i_s; }
FunctionSig* f_f() { return &sig_f_f; }
......@@ -97,17 +97,17 @@ class TestSignatures {
FunctionSig* d_d() { return &sig_d_d; }
FunctionSig* d_dd() { return &sig_d_dd; }
FunctionSig* r_v() { return &sig_r_v; }
FunctionSig* a_v() { return &sig_a_v; }
FunctionSig* r_r() { return &sig_r_r; }
FunctionSig* a_a() { return &sig_a_a; }
FunctionSig* e_v() { return &sig_e_v; }
FunctionSig* a_v() { return &sig_c_v; }
FunctionSig* e_e() { return &sig_e_e; }
FunctionSig* c_c() { return &sig_c_c; }
FunctionSig* v_v() { return &sig_v_v; }
FunctionSig* v_i() { return &sig_v_i; }
FunctionSig* v_ii() { return &sig_v_ii; }
FunctionSig* v_iii() { return &sig_v_iii; }
FunctionSig* v_r() { return &sig_v_r; }
FunctionSig* v_a() { return &sig_v_a; }
FunctionSig* v_e() { return &sig_v_e; }
FunctionSig* v_c() { return &sig_v_c; }
FunctionSig* s_i() { return &sig_s_i; }
FunctionSig* ii_v() { return &sig_ii_v; }
......@@ -127,7 +127,7 @@ class TestSignatures {
ValueType kLongTypes4[4];
ValueType kFloatTypes4[4];
ValueType kDoubleTypes4[4];
ValueType kRefTypes4[4];
ValueType kExternRefTypes4[4];
ValueType kFuncTypes4[4];
ValueType kIntLongTypes4[4];
ValueType kIntFloatTypes4[4];
......@@ -146,9 +146,9 @@ class TestSignatures {
FunctionSig sig_i_ff;
FunctionSig sig_i_d;
FunctionSig sig_i_dd;
FunctionSig sig_i_r;
FunctionSig sig_i_rr;
FunctionSig sig_i_a;
FunctionSig sig_i_e;
FunctionSig sig_i_ee;
FunctionSig sig_i_c;
FunctionSig sig_i_s;
FunctionSig sig_l_v;
......@@ -161,17 +161,17 @@ class TestSignatures {
FunctionSig sig_d_d;
FunctionSig sig_d_dd;
FunctionSig sig_r_v;
FunctionSig sig_a_v;
FunctionSig sig_r_r;
FunctionSig sig_a_a;
FunctionSig sig_e_v;
FunctionSig sig_c_v;
FunctionSig sig_e_e;
FunctionSig sig_c_c;
FunctionSig sig_v_v;
FunctionSig sig_v_i;
FunctionSig sig_v_ii;
FunctionSig sig_v_iii;
FunctionSig sig_v_r;
FunctionSig sig_v_a;
FunctionSig sig_v_e;
FunctionSig sig_v_c;
FunctionSig sig_s_i;
FunctionSig sig_ii_v;
......
......@@ -327,7 +327,7 @@ TEST_F(FunctionBodyDecoderTest, Int32Const1) {
TEST_F(FunctionBodyDecoderTest, RefNull) {
WASM_FEATURE_SCOPE(reftypes);
ExpectValidates(sigs.r_v(), {kExprRefNull, kLocalExternRef});
ExpectValidates(sigs.e_v(), {kExprRefNull, kLocalExternRef});
}
TEST_F(FunctionBodyDecoderTest, RefFunc) {
......@@ -2593,9 +2593,9 @@ TEST_F(FunctionBodyDecoderTest, Select) {
TEST_F(FunctionBodyDecoderTest, Select_needs_value_type) {
WASM_FEATURE_SCOPE(reftypes);
ExpectFailure(sigs.r_r(),
ExpectFailure(sigs.e_e(),
{WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)});
ExpectFailure(sigs.a_a(),
ExpectFailure(sigs.c_c(),
{WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)});
}
......@@ -2653,10 +2653,10 @@ TEST_F(FunctionBodyDecoderTest, SelectWithType) {
{WASM_SELECT_D(WASM_F64(0.0), WASM_F64(0.0), WASM_ZERO)});
ExpectValidates(sigs.l_l(),
{WASM_SELECT_L(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)});
ExpectValidates(sigs.r_r(),
ExpectValidates(sigs.e_e(),
{WASM_SELECT_R(WASM_REF_NULL(kLocalExternRef),
WASM_REF_NULL(kLocalExternRef), WASM_ZERO)});
ExpectValidates(sigs.a_a(),
ExpectValidates(sigs.c_c(),
{WASM_SELECT_A(WASM_REF_NULL(kLocalFuncRef),
WASM_REF_NULL(kLocalFuncRef), WASM_ZERO)});
}
......@@ -3199,24 +3199,24 @@ TEST_F(FunctionBodyDecoderTest, TableGrow) {
byte tab_ref = builder.AddTable(kWasmExternRef, 10, true, 20);
ExpectFailure(
sigs.i_a(),
sigs.i_c(),
{WASM_TABLE_GROW(tab_func, WASM_REF_NULL(kLocalFuncRef), WASM_ONE)});
WASM_FEATURE_SCOPE(reftypes);
ExpectValidates(
sigs.i_a(),
sigs.i_c(),
{WASM_TABLE_GROW(tab_func, WASM_REF_NULL(kLocalFuncRef), WASM_ONE)});
ExpectValidates(
sigs.i_r(),
sigs.i_e(),
{WASM_TABLE_GROW(tab_ref, WASM_REF_NULL(kLocalExternRef), WASM_ONE)});
// FuncRef table cannot be initialized with an ExternRef value.
ExpectFailure(sigs.i_r(),
ExpectFailure(sigs.i_e(),
{WASM_TABLE_GROW(tab_func, WASM_GET_LOCAL(0), WASM_ONE)});
// ExternRef table cannot be initialized with a FuncRef value.
ExpectFailure(sigs.i_a(),
ExpectFailure(sigs.i_c(),
{WASM_TABLE_GROW(tab_ref, WASM_GET_LOCAL(0), WASM_ONE)});
// Check that the table index gets verified.
ExpectFailure(
sigs.i_r(),
sigs.i_e(),
{WASM_TABLE_GROW(tab_ref + 2, WASM_REF_NULL(kLocalExternRef), WASM_ONE)});
}
......@@ -3233,24 +3233,24 @@ TEST_F(FunctionBodyDecoderTest, TableFill) {
byte tab_func = builder.AddTable(kWasmFuncRef, 10, true, 20);
byte tab_ref = builder.AddTable(kWasmExternRef, 10, true, 20);
ExpectFailure(sigs.v_a(),
ExpectFailure(sigs.v_c(),
{WASM_TABLE_FILL(tab_func, WASM_ONE,
WASM_REF_NULL(kLocalFuncRef), WASM_ONE)});
WASM_FEATURE_SCOPE(reftypes);
ExpectValidates(sigs.v_a(),
ExpectValidates(sigs.v_c(),
{WASM_TABLE_FILL(tab_func, WASM_ONE,
WASM_REF_NULL(kLocalFuncRef), WASM_ONE)});
ExpectValidates(sigs.v_r(),
ExpectValidates(sigs.v_e(),
{WASM_TABLE_FILL(tab_ref, WASM_ONE,
WASM_REF_NULL(kLocalExternRef), WASM_ONE)});
// FuncRef table cannot be initialized with an ExternRef value.
ExpectFailure(sigs.v_r(), {WASM_TABLE_FILL(tab_func, WASM_ONE,
ExpectFailure(sigs.v_e(), {WASM_TABLE_FILL(tab_func, WASM_ONE,
WASM_GET_LOCAL(0), WASM_ONE)});
// ExternRef table cannot be initialized with a FuncRef value.
ExpectFailure(sigs.v_a(), {WASM_TABLE_FILL(tab_ref, WASM_ONE,
ExpectFailure(sigs.v_c(), {WASM_TABLE_FILL(tab_ref, WASM_ONE,
WASM_GET_LOCAL(0), WASM_ONE)});
// Check that the table index gets verified.
ExpectFailure(sigs.v_r(),
ExpectFailure(sigs.v_e(),
{WASM_TABLE_FILL(tab_ref + 2, WASM_ONE,
WASM_REF_NULL(kLocalExternRef), WASM_ONE)});
}
......@@ -3262,7 +3262,7 @@ TEST_F(FunctionBodyDecoderTest, TableOpsWithoutTable) {
sigs.i_v(),
{WASM_TABLE_GROW(0, WASM_REF_NULL(kLocalExternRef), WASM_ONE)});
ExpectFailure(sigs.i_v(), {WASM_TABLE_SIZE(0)});
ExpectFailure(sigs.i_r(),
ExpectFailure(sigs.i_e(),
{WASM_TABLE_FILL(0, WASM_ONE, WASM_REF_NULL(kLocalExternRef),
WASM_ONE)});
}
......
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