@@ -8,6 +8,13 @@ use wasmtime_environ::WasmHeapTopType;
88
99pub use crate :: runtime:: vm:: ValRaw ;
1010
11+ /// A stub implementation for continuation references.
12+ ///
13+ /// This is a placeholder until continuation objects are fully integrated
14+ /// with the GC system (see #10248).
15+ #[ derive( Debug , Clone , Copy ) ]
16+ pub struct ContRef ;
17+
1118/// Possible runtime values that a WebAssembly module can either consume or
1219/// produce.
1320///
@@ -50,6 +57,12 @@ pub enum Val {
5057
5158 /// An exception reference.
5259 ExnRef ( Option < Rooted < ExnRef > > ) ,
60+
61+ /// A continuation reference.
62+ ///
63+ /// Note: This is currently a stub implementation as continuation objects
64+ /// are not yet fully integrated with the GC system. See #10248.
65+ ContRef ( Option < ContRef > ) ,
5366}
5467
5568macro_rules! accessors {
@@ -118,7 +131,7 @@ impl Val {
118131 WasmHeapTopType :: Extern => Val :: ExternRef ( None ) ,
119132 WasmHeapTopType :: Any => Val :: AnyRef ( None ) ,
120133 WasmHeapTopType :: Exn => Val :: ExnRef ( None ) ,
121- WasmHeapTopType :: Cont => todo ! ( ) , // FIXME(#10248)
134+ WasmHeapTopType :: Cont => Val :: ContRef ( None ) ,
122135 }
123136 }
124137
@@ -177,6 +190,12 @@ impl Val {
177190 Val :: AnyRef ( Some ( a) ) => ValType :: Ref ( RefType :: new ( false , a. _ty ( store) ?) ) ,
178191 Val :: ExnRef ( None ) => ValType :: NULLEXNREF ,
179192 Val :: ExnRef ( Some ( e) ) => ValType :: Ref ( RefType :: new ( false , e. _ty ( store) ?. into ( ) ) ) ,
193+ Val :: ContRef ( _) => {
194+ // TODO(#10248): Return proper continuation reference type when available
195+ return Err ( anyhow:: anyhow!(
196+ "continuation references not yet supported in embedder API"
197+ ) ) ;
198+ }
180199 } )
181200 }
182201
@@ -216,7 +235,8 @@ impl Val {
216235 | ( Val :: FuncRef ( _) , _)
217236 | ( Val :: ExternRef ( _) , _)
218237 | ( Val :: AnyRef ( _) , _)
219- | ( Val :: ExnRef ( _) , _) => false ,
238+ | ( Val :: ExnRef ( _) , _)
239+ | ( Val :: ContRef ( _) , _) => false ,
220240 } )
221241 }
222242
@@ -268,6 +288,12 @@ impl Val {
268288 Some ( f) => f. to_raw ( store) ,
269289 None => ptr:: null_mut ( ) ,
270290 } ) ) ,
291+ Val :: ContRef ( _) => {
292+ // TODO(#10248): Implement proper continuation reference to_raw conversion
293+ Err ( anyhow:: anyhow!(
294+ "continuation references not yet supported in to_raw conversion"
295+ ) )
296+ }
271297 }
272298 }
273299
@@ -363,6 +389,7 @@ impl Val {
363389 Val :: AnyRef ( a) => Some ( Ref :: Any ( a) ) ,
364390 Val :: ExnRef ( e) => Some ( Ref :: Exn ( e) ) ,
365391 Val :: I32 ( _) | Val :: I64 ( _) | Val :: F32 ( _) | Val :: F64 ( _) | Val :: V128 ( _) => None ,
392+ Val :: ContRef ( _) => None , // TODO(#10248): Return proper Ref::Cont when available
366393 }
367394 }
368395
@@ -509,6 +536,9 @@ impl Val {
509536 // particular store, so they're always considered as "yes I came
510537 // from that store",
511538 Val :: I32 ( _) | Val :: I64 ( _) | Val :: F32 ( _) | Val :: F64 ( _) | Val :: V128 ( _) => true ,
539+
540+ // Continuation references are not yet associated with stores
541+ Val :: ContRef ( _) => true , // TODO(#10248): Proper store association when implemented
512542 }
513543 }
514544}
0 commit comments