Commit 78f16a05 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm-gc] Small fixes

- Remove fixed TODOs
- Fix typo
- Add a couple of types in subtyping tests

Bug: v8:7748
Change-Id: I757fa60ffe4fe9f9361cf0c4e9ca88b31747459f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2282529
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68700}
parent 6e93c1c3
......@@ -3397,16 +3397,15 @@ class WasmFullDecoder : public WasmDecoder<validate> {
ArrayIndexImmediate<validate> imm(this, this->pc_ + 2);
if (!this->Validate(this->pc_ + 2, imm)) return 0;
if (!VALIDATE(imm.array_type->element_type().is_packed())) {
this->errorf(this->pc_,
"%s is only valid for packed arrays. "
"Use or array.get instead.",
WasmOpcodes::OpcodeName(opcode));
this->errorf(
this->pc_,
"%s is only valid for packed arrays. Use array.get instead.",
WasmOpcodes::OpcodeName(opcode));
return 0;
}
Value index = Pop(1, kWasmI32);
Value array_obj = Pop(0, ValueType::Ref(imm.index, kNullable));
Value* value = Push(imm.array_type->element_type().Unpacked());
// TODO(7748): Optimize this when array_obj is non-nullable ref.
CALL_INTERFACE_IF_REACHABLE(ArrayGet, array_obj, imm, index,
opcode == kExprArrayGetS, value);
return 2 + imm.length;
......@@ -3423,7 +3422,6 @@ class WasmFullDecoder : public WasmDecoder<validate> {
Value index = Pop(1, kWasmI32);
Value array_obj = Pop(0, ValueType::Ref(imm.index, kNullable));
Value* value = Push(imm.array_type->element_type());
// TODO(7748): Optimize this when array_obj is non-nullable ref.
CALL_INTERFACE_IF_REACHABLE(ArrayGet, array_obj, imm, index, true,
value);
return 2 + imm.length;
......@@ -3438,7 +3436,6 @@ class WasmFullDecoder : public WasmDecoder<validate> {
Value value = Pop(2, imm.array_type->element_type().Unpacked());
Value index = Pop(1, kWasmI32);
Value array_obj = Pop(0, ValueType::Ref(imm.index, kNullable));
// TODO(7748): Optimize this when array_obj is non-nullable ref.
CALL_INTERFACE_IF_REACHABLE(ArraySet, array_obj, imm, index, value);
return 2 + imm.length;
}
......
......@@ -3779,12 +3779,12 @@ TEST_F(FunctionBodyDecoderTest, GCArray1) {
&sig_c_r,
{WASM_ARRAY_GET_S(array_type_index, WASM_GET_LOCAL(0), WASM_I32V(5))},
kAppendEnd,
"array.get_s is only valid for packed arrays. Use or array.get instead.");
"array.get_s is only valid for packed arrays. Use array.get instead.");
ExpectFailure(
&sig_c_r,
{WASM_ARRAY_GET_U(array_type_index, WASM_GET_LOCAL(0), WASM_I32V(5))},
kAppendEnd,
"array.get_u is only valid for packed arrays. Use or array.get instead.");
"array.get_u is only valid for packed arrays. Use array.get instead.");
/** array.set **/
ExpectValidates(
......
......@@ -50,10 +50,11 @@ TEST_F(WasmSubtypingTest, Subtyping) {
/* 8 */ DefineStruct(module, {mut(kWasmI32), immut(optRef(8))});
/* 9 */ DefineStruct(module, {mut(kWasmI32), immut(optRef(8))});
ValueType numeric_types[] = {kWasmI32, kWasmI64, kWasmF32, kWasmF64};
ValueType numeric_types[] = {kWasmI32, kWasmI64, kWasmF32, kWasmF64,
kWasmS128};
ValueType ref_types[] = {kWasmExternRef, kWasmFuncRef, kWasmExnRef,
kWasmEqRef, optRef(0), ref(0),
optRef(2), ref(2)};
kWasmEqRef, kWasmI31Ref, optRef(0),
ref(0), optRef(2), ref(2)};
// Value types are unrelated, except if they are equal.
for (ValueType subtype : numeric_types) {
......@@ -78,8 +79,11 @@ TEST_F(WasmSubtypingTest, Subtyping) {
CHECK(IsSubtypeOf(ref_type, ref_type, module));
}
for (ValueType type_1 : {kWasmExternRef, kWasmFuncRef, kWasmExnRef}) {
for (ValueType type_2 : {kWasmExternRef, kWasmFuncRef, kWasmExnRef}) {
// The rest of ref. types are unrelated.
for (ValueType type_1 :
{kWasmExternRef, kWasmFuncRef, kWasmExnRef, kWasmI31Ref}) {
for (ValueType type_2 :
{kWasmExternRef, kWasmFuncRef, kWasmExnRef, kWasmI31Ref}) {
CHECK_EQ(IsSubtypeOf(type_1, type_2, module), type_1 == type_2);
}
}
......
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