Skip to content

Commit 3f98505

Browse files
authored
wasmtime(gc): Add support for noextern and eq heap types (bytecodealliance#8542)
With this commit, we now support all GC heap types.
1 parent dc1d128 commit 3f98505

File tree

6 files changed

+241
-28
lines changed

6 files changed

+241
-28
lines changed

crates/cranelift/src/func_environ.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,9 @@ impl<'a, 'func, 'module_env> Call<'a, 'func, 'module_env> {
14671467
WasmHeapType::ConcreteFunc(EngineOrModuleTypeIndex::Engine(_))
14681468
| WasmHeapType::ConcreteFunc(EngineOrModuleTypeIndex::RecGroup(_))
14691469
| WasmHeapType::Extern
1470+
| WasmHeapType::NoExtern
14701471
| WasmHeapType::Any
1472+
| WasmHeapType::Eq
14711473
| WasmHeapType::I31
14721474
| WasmHeapType::Array
14731475
| WasmHeapType::ConcreteArray(_)

crates/types/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ impl EngineOrModuleTypeIndex {
390390
pub enum WasmHeapType {
391391
// External types.
392392
Extern,
393+
NoExtern,
393394

394395
// Function types.
395396
Func,
@@ -398,6 +399,7 @@ pub enum WasmHeapType {
398399

399400
// Internal types.
400401
Any,
402+
Eq,
401403
I31,
402404
Array,
403405
ConcreteArray(EngineOrModuleTypeIndex),
@@ -421,10 +423,12 @@ impl fmt::Display for WasmHeapType {
421423
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
422424
match self {
423425
Self::Extern => write!(f, "extern"),
426+
Self::NoExtern => write!(f, "noextern"),
424427
Self::Func => write!(f, "func"),
425428
Self::ConcreteFunc(i) => write!(f, "func {i}"),
426429
Self::NoFunc => write!(f, "nofunc"),
427430
Self::Any => write!(f, "any"),
431+
Self::Eq => write!(f, "eq"),
428432
Self::I31 => write!(f, "i31"),
429433
Self::Array => write!(f, "array"),
430434
Self::ConcreteArray(i) => write!(f, "array {i}"),
@@ -489,13 +493,14 @@ impl WasmHeapType {
489493
#[inline]
490494
pub fn top(&self) -> WasmHeapTopType {
491495
match self {
492-
WasmHeapType::Extern => WasmHeapTopType::Extern,
496+
WasmHeapType::Extern | WasmHeapType::NoExtern => WasmHeapTopType::Extern,
493497

494498
WasmHeapType::Func | WasmHeapType::ConcreteFunc(_) | WasmHeapType::NoFunc => {
495499
WasmHeapTopType::Func
496500
}
497501

498502
WasmHeapType::Any
503+
| WasmHeapType::Eq
499504
| WasmHeapType::I31
500505
| WasmHeapType::Array
501506
| WasmHeapType::ConcreteArray(_)
@@ -1541,19 +1546,18 @@ pub trait TypeConvert {
15411546
fn convert_heap_type(&self, ty: wasmparser::HeapType) -> WasmHeapType {
15421547
match ty {
15431548
wasmparser::HeapType::Extern => WasmHeapType::Extern,
1549+
wasmparser::HeapType::NoExtern => WasmHeapType::NoExtern,
15441550
wasmparser::HeapType::Func => WasmHeapType::Func,
15451551
wasmparser::HeapType::NoFunc => WasmHeapType::NoFunc,
15461552
wasmparser::HeapType::Concrete(i) => self.lookup_heap_type(i),
15471553
wasmparser::HeapType::Any => WasmHeapType::Any,
1554+
wasmparser::HeapType::Eq => WasmHeapType::Eq,
15481555
wasmparser::HeapType::I31 => WasmHeapType::I31,
15491556
wasmparser::HeapType::Array => WasmHeapType::Array,
15501557
wasmparser::HeapType::Struct => WasmHeapType::Struct,
15511558
wasmparser::HeapType::None => WasmHeapType::None,
15521559

1553-
wasmparser::HeapType::Exn
1554-
| wasmparser::HeapType::NoExn
1555-
| wasmparser::HeapType::NoExtern
1556-
| wasmparser::HeapType::Eq => {
1560+
wasmparser::HeapType::Exn | wasmparser::HeapType::NoExn => {
15571561
unimplemented!("unsupported heap type {ty:?}");
15581562
}
15591563
}

crates/wasmtime/src/runtime/externals/global.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ impl Global {
133133
.into(),
134134
),
135135

136+
HeapType::NoExtern => Ref::Extern(None),
137+
136138
HeapType::Any
139+
| HeapType::Eq
137140
| HeapType::I31
138141
| HeapType::Struct
139142
| HeapType::ConcreteStruct(_)

0 commit comments

Comments
 (0)