[wasm-gc] Fix type union bug

Bug: v8:13422, v8:7748
Change-Id: I0eef5ec4bf7699d374e32d6af566babde3d97aa9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3985866
Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
Auto-Submit: Manos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83948}
This commit is contained in:
Manos Koukoutos 2022-10-27 11:12:23 +02:00 committed by V8 LUCI CQ
parent 0b251add9b
commit 1717a1c1b8

View File

@ -382,6 +382,9 @@ HeapType::Representation CommonAncestor(uint32_t type_index1,
// Returns the least common ancestor of a generic HeapType {heap1}, and
// another HeapType {heap2}.
// TODO(7748): This function sometimes assumes that incompatible types cannot be
// compared, in some cases explicitly and in others implicitly. Make it
// consistent.
HeapType::Representation CommonAncestorWithGeneric(HeapType heap1,
HeapType heap2,
const WasmModule* module2) {
@ -445,7 +448,8 @@ HeapType::Representation CommonAncestorWithGeneric(HeapType heap1,
case HeapType::kNone:
return HeapType::kArray;
case HeapType::kStruct:
return HeapType::kEq;
return v8_flags.wasm_gc_structref_as_dataref ? HeapType::kStruct
: HeapType::kEq;
case HeapType::kI31:
case HeapType::kEq:
return HeapType::kEq;