Skip to content

Commit 6ffa923

Browse files
committed
Fix an issue with DRC collector's barriers and (extern.convert_any (ref.i31 ...))
1 parent 8357599 commit 6ffa923

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

crates/cranelift/src/gc/enabled.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,14 @@ impl FuncEnvironment<'_> {
13881388
| WasmHeapType::ConcreteStruct(_)
13891389
| WasmHeapType::None => false,
13901390

1391-
// Wrong type hierarchy: cannot be an i31.
1392-
WasmHeapType::Extern | WasmHeapType::NoExtern => false,
1391+
// Despite being a different type hierarchy, this *could* be an
1392+
// `i31` if it is the result of
1393+
//
1394+
// (extern.convert_any (ref.i31 ...))
1395+
WasmHeapType::Extern => true,
1396+
1397+
// Can only ever be `null`.
1398+
WasmHeapType::NoExtern => false,
13931399

13941400
// Wrong type hierarchy, and also funcrefs are not GC-managed
13951401
// types. Should have been caught by the assertion at the start of
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
;;! gc = true
2+
3+
(module
4+
(type (struct (field externref)))
5+
(func (export "")
6+
i32.const 0x7fffffff
7+
ref.i31
8+
extern.convert_any
9+
struct.new 0
10+
drop
11+
)
12+
)
13+
14+
(assert_return (invoke ""))

0 commit comments

Comments
 (0)