File tree Expand file tree Collapse file tree
crates/wasmparser/src/validator
cli/component-model/async
snapshots/cli/component-model/async Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1265,17 +1265,17 @@ impl ComponentFuncType {
12651265 }
12661266 }
12671267
1268+ // Results of lowered functions that contains pointers must be allocated
1269+ // by the callee meaning that realloc is required. Results of lifted
1270+ // function are allocated by the guest which means that no realloc
1271+ // option is necessary.
1272+ if let Some ( ty) = & self . result {
1273+ options. require_realloc_if ( offset, || abi == Abi :: Lower && ty. contains_ptr ( types) ) ?;
1274+ }
1275+
12681276 match ( abi, options. concurrency ) {
12691277 ( Abi :: Lower | Abi :: Lift , Concurrency :: Sync ) => {
12701278 if let Some ( ty) = & self . result {
1271- // Results of lowered functions that contains pointers must be
1272- // allocated by the callee meaning that realloc is required.
1273- // Results of lifted function are allocated by the guest which
1274- // means that no realloc option is necessary.
1275- options. require_realloc_if ( offset, || {
1276- abi == Abi :: Lower && ty. contains_ptr ( types)
1277- } ) ?;
1278-
12791279 if !ty. push_wasm_types ( ptr_size, types, & mut sig. results ) {
12801280 // Too many results to return directly, either a retptr
12811281 // parameter will be used (import) or a single pointer
Original file line number Diff line number Diff line change 4848 )
4949 " the `async` canonical option requires an async function type"
5050)
51+
52+ ;; `async` option requires as `async` function type
53+ (assert_invalid
54+ (component
55+ (import " foo" (func $foo async (result string)))
56+ (core func $foo (canon lower (func $foo ) async))
57+ )
58+ " canonical option `memory` is required"
59+ )
60+ (assert_invalid
61+ (component
62+ (import " foo" (func $foo async (result string)))
63+ (core module $libc (memory (export " memory" ) 1 ))
64+ (core instance $libc (instantiate $libc ))
65+ (core func $foo (canon lower (func $foo ) async (memory (core memory $libc " memory" ))))
66+ )
67+ " canonical option `realloc` is required"
68+ )
Original file line number Diff line number Diff line change 2727 "filename" : " lower.3.wasm" ,
2828 "module_type" : " binary" ,
2929 "text" : " the `async` canonical option requires an async function type"
30+ },
31+ {
32+ "type" : " assert_invalid" ,
33+ "line" : 54 ,
34+ "filename" : " lower.4.wasm" ,
35+ "module_type" : " binary" ,
36+ "text" : " canonical option `memory` is required"
37+ },
38+ {
39+ "type" : " assert_invalid" ,
40+ "line" : 61 ,
41+ "filename" : " lower.5.wasm" ,
42+ "module_type" : " binary" ,
43+ "text" : " canonical option `realloc` is required"
3044 }
3145 ]
3246}
You can’t perform that action at this time.
0 commit comments