Commit bfd0ccf2 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[wasm] EquivalentTypes() should be symmetric

Fixed: v8:12935
Change-Id: Ib4dfdc276e6a9f465666b068bdbe31776429f359
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3687699
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarManos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80941}
parent 83feb804
......@@ -248,7 +248,7 @@ V8_NOINLINE bool EquivalentTypes(ValueType type1, ValueType type2,
const WasmModule* module1,
const WasmModule* module2) {
if (type1 == type2 && module1 == module2) return true;
if (!type1.has_index()) return type1 == type2;
if (!type1.has_index() || !type2.has_index()) return type1 == type2;
if (type1.kind() != type2.kind()) return false;
DCHECK(type1.has_index() && type2.has_index() &&
......
......@@ -216,6 +216,17 @@ TEST_F(WasmSubtypingTest, Subtyping) {
SUBTYPE(ref_type, kWasmAnyRef);
// Only anyref is a subtype of anyref.
SUBTYPE_IFF(kWasmAnyRef, ref_type, ref_type == kWasmAnyRef);
// Make sure symmetric relations are symmetric.
for (ValueType ref_type2 : ref_types) {
if (ref_type == ref_type2) {
EXPECT_TRUE(EquivalentTypes(ref_type, ref_type2, module, module1));
EXPECT_TRUE(EquivalentTypes(ref_type2, ref_type, module1, module));
} else {
EXPECT_FALSE(EquivalentTypes(ref_type, ref_type2, module, module1));
EXPECT_FALSE(EquivalentTypes(ref_type2, ref_type, module1, module));
}
}
}
// The rest of ref. types are unrelated.
......
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