wasmer 7.1.0

High-performance WebAssembly runtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
pub(crate) mod env;
pub(crate) mod typed;

use rusty_jsc::{
    JSContext, JSObject, JSObjectCallAsFunctionCallback, JSValue, callback, callback_closure,
};
use std::marker::PhantomData;
use std::panic::{self, AssertUnwindSafe};
use wasmer_types::{FunctionType, RawValue};

use crate::{
    AsStoreMut, AsStoreRef, BackendFunction, BackendFunctionEnvMut, FromToNativeWasmType,
    FunctionEnv, FunctionEnvMut, HostFunction, HostFunctionKind, IntoResult, NativeWasmType,
    NativeWasmTypeInto, RuntimeError, StoreMut, Value, WasmTypeList, WithEnv, WithoutEnv,
    jsc::{
        store::{InternalStoreHandle, StoreHandle},
        utils::convert::{AsJsc, jsc_value_to_wasmer},
        vm::{VMFuncRef, VMFunction, VMFunctionEnvironment},
    },
    vm::VMExtern,
};

use super::engine::IntoJSC;

pub(crate) use env::*;
pub(crate) use typed::*;

#[derive(Clone, PartialEq, Eq)]
pub struct Function {
    pub(crate) handle: VMFunction,
}

// Function can't be Send in js because it dosen't support `structuredClone`
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
// unsafe impl Send for Function {}

impl From<VMFunction> for Function {
    fn from(handle: VMFunction) -> Self {
        Self { handle }
    }
}

impl Function {
    /// To `VMExtern`.
    pub fn to_vm_extern(&self) -> VMExtern {
        VMExtern::Jsc(crate::backend::jsc::vm::VMExtern::Function(
            self.handle.clone(),
        ))
    }

    #[allow(clippy::cast_ptr_alignment)]
    pub fn new_with_env<FT, F, T: Send + 'static>(
        store: &mut impl AsStoreMut,
        env: &FunctionEnv<T>,
        ty: FT,
        func: F,
    ) -> Self
    where
        FT: Into<FunctionType>,
        F: Fn(FunctionEnvMut<'_, T>, &[Value]) -> Result<Vec<Value>, RuntimeError>
            + 'static
            + Send
            + Sync,
    {
        let store = store.as_store_mut();
        let context = store.jsc().context();
        let function_type = ty.into();

        let new_function_type = function_type.clone();
        let raw_env = env.clone();

        let callback = callback_closure!(&context, move |ctx: JSContext,
                                                         function: JSObject,
                                                         this: JSObject,
                                                         args: &[JSValue]|
              -> Result<JSValue, JSValue> {
            let global = ctx.get_global_object();
            let store_ptr = global
                .get_property(&ctx, "__store_ptr".to_string())
                .to_number(&ctx)
                .unwrap();

            let mut store = unsafe { StoreMut::from_raw(store_ptr as usize as *mut _) };

            let env: FunctionEnvMut<T> = raw_env.clone().into_mut(&mut store);

            let wasm_arguments = new_function_type
                .params()
                .iter()
                .enumerate()
                .map(|(i, param)| jsc_value_to_wasmer(&ctx, param, &args[i]))
                .collect::<Vec<_>>();
            let results = func(env, &wasm_arguments).map_err(|e| {
                let value = format!("{e}");
                JSValue::string(&ctx, value)
            })?;
            match new_function_type.results().len() {
                0 => Ok(JSValue::undefined(&ctx)),
                1 => Ok(results[0].as_jsc_value(&store)),
                _ => Ok(JSObject::new_array(
                    &ctx,
                    &results
                        .into_iter()
                        .map(|result| result.as_jsc_value(&store))
                        .collect::<Vec<_>>(),
                )?
                .to_jsvalue()),
            }
        });

        let vm_function = VMFunction::new(callback, function_type);
        Self {
            handle: vm_function,
        }
    }

    /// Creates a new host `Function` from a native function.
    pub fn new_typed<F, Args, Rets>(store: &mut impl AsStoreMut, func: F) -> Self
    where
        F: HostFunction<(), Args, Rets, WithoutEnv> + 'static + Send + Sync,
        Args: WasmTypeList,
        Rets: WasmTypeList,
    {
        let store = store.as_store_mut();
        let function = WasmFunction::<Args, Rets>::new(func);
        let callback = function.callback(store.jsc().context());

        let ty = function.ty();
        let vm_function = VMFunction::new(callback, ty);
        Self {
            handle: vm_function,
        }
    }

    pub fn new_typed_with_env<T, F, Args, Rets>(
        store: &mut impl AsStoreMut,
        env: &FunctionEnv<T>,
        func: F,
    ) -> Self
    where
        F: HostFunction<T, Args, Rets, WithEnv>,
        Args: WasmTypeList,
        Rets: WasmTypeList,
    {
        let store = store.as_store_mut();
        let context = store.jsc().context();
        let function = WasmFunction::<Args, Rets>::new(func);
        let callback = function.callback(store.jsc().context());

        let bind = callback
            .get_property(context, "bind".to_string())
            .to_object(context)
            .unwrap();
        let callback_with_env = bind
            .call(
                context,
                Some(&callback),
                &[
                    JSValue::undefined(context),
                    JSValue::number(
                        context,
                        env.as_jsc().handle.internal_handle().index() as f64,
                    ),
                ],
            )
            .unwrap()
            .to_object(context)
            .unwrap();

        let ty = function.ty();
        let vm_function = VMFunction::new(callback_with_env, ty);
        Self {
            handle: vm_function,
        }
    }

    pub fn ty(&self, _store: &impl AsStoreRef) -> FunctionType {
        self.handle.ty.clone()
    }

    pub fn call_raw(
        &self,
        _store: &mut impl AsStoreMut,
        _params: Vec<RawValue>,
    ) -> Result<Box<[Value]>, RuntimeError> {
        // There is no optimal call_raw in JSC, so we just
        // simply rely the call
        // self.call(store, params)
        unimplemented!();
    }

    pub fn call(
        &self,
        store: &mut impl AsStoreMut,
        params: &[Value],
    ) -> Result<Box<[Value]>, RuntimeError> {
        let store_mut = store.as_store_mut();
        let engine = store_mut.engine();
        let context = engine.as_jsc().context();

        let mut global = context.get_global_object();
        let store_ptr = store_mut.as_raw() as usize;
        global.set_property(
            context,
            "__store_ptr".to_string(),
            JSValue::number(context, store_ptr as _),
        );

        let params_list = params
            .iter()
            .map(|v| v.as_jsc_value(&store_mut))
            .collect::<Vec<_>>();
        let result = {
            let mut r;
            // TODO: This loop is needed for asyncify. It will be refactored with https://github.com/wasmerio/wasmer/issues/3451
            loop {
                let store_mut = store.as_store_mut();
                let engine = store_mut.engine();
                let context = engine.as_jsc().context();
                r = self.handle.function.call(context, None, &params_list);
                if let Some(callback) = store_mut.inner.on_called.take() {
                    match callback(store_mut) {
                        Ok(wasmer_types::OnCalledAction::InvokeAgain) => {
                            continue;
                        }
                        Ok(wasmer_types::OnCalledAction::Finish) => {
                            break;
                        }
                        Ok(wasmer_types::OnCalledAction::Trap(trap)) => {
                            return Err(RuntimeError::user(trap));
                        }
                        Err(trap) => return Err(RuntimeError::user(trap)),
                    }
                }
                break;
            }
            r?
        };
        let result_types = self.handle.ty.results();
        let store_mut = store.as_store_mut();
        let engine = store_mut.engine();
        let context = engine.as_jsc().context();
        match result_types.len() {
            0 => Ok(Box::new([])),
            1 => {
                let value = jsc_value_to_wasmer(context, &result_types[0], &result);
                Ok(vec![value].into_boxed_slice())
            }
            n => {
                let result = result.to_object(context).unwrap();
                Ok((0..n)
                    .map(|i| {
                        let js_val = result.get_property_at_index(context, i as _).unwrap();
                        jsc_value_to_wasmer(context, &result_types[i], &js_val)
                    })
                    .collect::<Vec<_>>()
                    .into_boxed_slice())
            }
        }
    }

    pub(crate) fn from_vm_extern(
        _store: &mut impl AsStoreMut,
        internal: crate::vm::VMExternFunction,
    ) -> Self {
        Self {
            handle: internal.into_jsc(),
        }
    }

    pub(crate) fn vm_funcref(&self, _store: &impl AsStoreRef) -> VMFuncRef {
        unimplemented!();
    }

    pub(crate) unsafe fn from_vm_funcref(
        _store: &mut impl AsStoreMut,
        _funcref: VMFuncRef,
    ) -> Self {
        unimplemented!();
    }

    /// Checks whether this `Function` can be used with the given context.
    pub fn is_from_store(&self, _store: &impl AsStoreRef) -> bool {
        true
    }
}

impl std::fmt::Debug for Function {
    fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
        formatter.debug_struct("Function").finish()
    }
}

/// Represents a low-level Wasm static host function. See
/// `super::Function::new` and `super::Function::new_env` to learn
/// more.
#[derive(Clone, Debug, Hash)]
pub struct WasmFunction<Args = (), Rets = ()> {
    callback: JSObjectCallAsFunctionCallback,
    _phantom: PhantomData<(Args, Rets)>,
}

unsafe impl<Args, Rets> Send for WasmFunction<Args, Rets> {}

impl<Args, Rets> WasmFunction<Args, Rets>
where
    Args: WasmTypeList,
    Rets: WasmTypeList,
{
    /// Creates a new `WasmFunction`.
    #[allow(dead_code)]
    pub fn new<F, T, Kind: HostFunctionKind>(function: F) -> Self
    where
        F: HostFunction<T, Args, Rets, Kind>,
        T: Sized,
    {
        Self {
            callback: function
                .function_callback(crate::BackendKind::Jsc)
                .into_jsc(),
            _phantom: PhantomData,
        }
    }

    /// Get the function type of this `WasmFunction`.
    #[allow(dead_code)]
    pub fn ty(&self) -> FunctionType {
        FunctionType::new(Args::wasm_types(), Rets::wasm_types())
    }

    /// Get the address of this `WasmFunction`.
    #[allow(dead_code)]
    pub fn callback(&self, context: &JSContext) -> JSObject {
        JSObject::new_function_with_callback(context, "FunctionCallback".to_string(), self.callback)
    }
}

impl crate::Function {
    /// Consume [`self`] into [`crate::backend::jsc::function::Function`].
    pub fn into_jsc(self) -> crate::backend::jsc::function::Function {
        match self.0 {
            BackendFunction::Jsc(s) => s,
            _ => panic!("Not a `jsc` function!"),
        }
    }

    /// Convert a reference to [`self`] into a reference to [`crate::backend::jsc::function::Function`].
    pub fn as_jsc(&self) -> &crate::backend::jsc::function::Function {
        match self.0 {
            BackendFunction::Jsc(ref s) => s,
            _ => panic!("Not a `jsc` function!"),
        }
    }

    /// Convert a mutable reference to [`self`] into a mutable reference [`crate::backend::jsc::function::Function`].
    pub fn as_jsc_mut(&mut self) -> &mut crate::backend::jsc::function::Function {
        match self.0 {
            BackendFunction::Jsc(ref mut s) => s,
            _ => panic!("Not a `jsc` function!"),
        }
    }
}

// Black-magic to count the number of identifiers at compile-time.
macro_rules! count_idents {
    ( $($idents:ident),* ) => {
        {
            #[allow(dead_code, non_camel_case_types)]
            enum Idents { $( $idents, )* __CountIdentsLast }
            const COUNT: usize = Idents::__CountIdentsLast as usize;
            COUNT
        }
    };
}

macro_rules! impl_host_function {
    ([$c_struct_representation:ident] $c_struct_name:ident, $( $x:ident ),* ) => {
        paste::paste! {
        #[allow(non_snake_case)]
        pub(crate) fn [<gen_fn_callback_ $c_struct_name:lower _no_env>]
            <$( $x: FromToNativeWasmType, )* Rets: WasmTypeList, RetsAsResult: IntoResult<Rets>, Func: Fn($( $x , )*) -> RetsAsResult + 'static>
            (this: &Func) -> crate::backend::jsc::vm::VMFunctionCallback {

            #[callback]
            fn fn_callback<$( $x, )* Rets, RetsAsResult, Func>(
                ctx: JSContext,
                function: JSObject,
                this_object: JSObject,
                arguments: &[JSValue],
            ) -> Result<JSValue, JSValue>
            where
                $( $x: FromToNativeWasmType, )*
                Rets: WasmTypeList,
                RetsAsResult: IntoResult<Rets>,
                Func: Fn($( $x , )*) -> RetsAsResult + 'static,
                // $( $x: NativeWasmTypeInto, )*
            {
                use std::convert::TryInto;

                let func: &Func = unsafe { &*(&() as *const () as *const Func) };
                let global = ctx.get_global_object();
                let store_ptr = global.get_property(&ctx, "__store_ptr".to_string()).to_number(&ctx).unwrap();
                if store_ptr.is_nan() {
                    panic!("Store pointer is invalid. Received {}", store_ptr as usize)
                }

                let mut store = unsafe { StoreMut::from_raw(store_ptr as usize as *mut _) };
                let result = panic::catch_unwind(AssertUnwindSafe(|| {
                    type JSArray<'a> = &'a [JSValue; count_idents!( $( $x ),* )];
                    let args_without_store: JSArray = arguments.try_into().unwrap();
                    let [ $( $x ),* ] = args_without_store;
                    func($( FromToNativeWasmType::from_native( unsafe {
                        $x::Native::from_raw(&mut store, RawValue {
                            u128: {
                                // TODO: This may not be the fastest way, but JSC doesn't expose a BigInt interface
                                // so the only thing we can do is parse from the string repr
                                if $x.is_number(&ctx) {
                                    $x.to_number(&ctx).unwrap() as _
                                } else {
                                    $x.to_string(&ctx).unwrap().to_string().parse::<u128>().unwrap()
                                }
                            }
                        })
                    }) ),* ).into_result()
                }));

                match result {
                    Ok(Ok(result)) => {
                        match Rets::size() {
                            0 => {Ok(JSValue::undefined(&ctx))},
                            1 => {
                                let ty = Rets::wasm_types()[0];
                                let mut arr = unsafe { result.into_array(&mut store) };
                                let val = unsafe { Value::from_raw(&mut store, ty, arr.as_mut()[0]) };
                                let value: JSValue = val.as_jsc_value(&store);
                                Ok(value)
                            }
                            _n => {
                                let mut arr = unsafe { result.into_array(&mut store) };
                                let result_values = Rets::wasm_types().iter().enumerate().map(|(i, ret_type)| {
                                    let raw = arr.as_mut()[i];
                                    let value = unsafe { Value::from_raw(&mut store, *ret_type, raw) };
                                    value.as_jsc_value(&mut store)
                                }).collect::<Vec<_>>();
                                Ok(JSObject::new_array(&ctx, &result_values).unwrap().to_jsvalue())
                            }
                        }
                    },
                    Ok(Err(err)) => {
                        let trap = crate::backend::jsc::error::Trap::user(Box::new(err));
                        Err(trap.into_jsc_value(&ctx))
                    },
                    Err(panic) => {
                        Err(JSValue::string(&ctx, format!("panic: {:?}", panic)))
                        // We can't just resume the unwind, because it will put
                        // JavacriptCore in a bad state, so we need to transform
                        // the error

                        // std::panic::resume_unwind(panic)
                    },
                }

            }
            Some(fn_callback::< $( $x, )* Rets, RetsAsResult, Func> as _)
        }


        #[allow(non_snake_case)]
        pub(crate) fn [<gen_fn_callback_ $c_struct_name:lower>]
            <$( $x: FromToNativeWasmType, )* Rets: WasmTypeList, RetsAsResult: IntoResult<Rets>, T: Send + 'static,  Func: Fn(FunctionEnvMut<T>, $( $x , )*) -> RetsAsResult + 'static>
            (this: &Func) -> crate::backend::jsc::vm::VMFunctionCallback {

            #[callback]
            fn fn_callback<T, $( $x, )* Rets, RetsAsResult, Func>(
                ctx: JSContext,
                function: JSObject,
                this_object: JSObject,
                arguments: &[JSValue],
            ) -> Result<JSValue, JSValue>
            where
                $( $x: FromToNativeWasmType, )*
                Rets: WasmTypeList,
                RetsAsResult: IntoResult<Rets>,
                Func: Fn(FunctionEnvMut<'_, T>, $( $x , )*) -> RetsAsResult + 'static,
                T: Send + 'static,
            {
                use std::convert::TryInto;

                let func: &Func = unsafe { &*(&() as *const () as *const Func) };
                let global = ctx.get_global_object();
                let store_ptr = global.get_property(&ctx, "__store_ptr".to_string()).to_number(&ctx).unwrap();
                if store_ptr.is_nan() {
                    panic!("Store pointer is invalid. Received {}", store_ptr as usize)
                }
                let mut store = unsafe { StoreMut::from_raw(store_ptr as usize as *mut _) };

                let handle_index = arguments[0].to_number(&ctx).unwrap() as usize;
                let handle: StoreHandle<VMFunctionEnvironment> = unsafe {
                    StoreHandle::from_internal(
                        store.objects_mut().id(),
                        InternalStoreHandle::from_index(handle_index).unwrap(),
                    )
                };
                let env = crate::backend::jsc::function::env::FunctionEnv::from_handle(handle).into_mut(&mut store);

                let result = panic::catch_unwind(AssertUnwindSafe(|| {
                    type JSArray<'a> = &'a [JSValue; count_idents!( $( $x ),* )];
                    let args_without_store: JSArray = arguments[1..].try_into().unwrap();
                    let [ $( $x ),* ] = args_without_store;
                    let mut store = unsafe { StoreMut::from_raw(store_ptr as usize as *mut _) };
                    func(
                        BackendFunctionEnvMut::Jsc(env).into(),
                        $( FromToNativeWasmType::from_native( unsafe {
                            $x::Native::from_raw(&mut store, RawValue {
                                u128: {
                                    // TODO: This may not be the fastest way, but JSC doesn't expose a BigInt interface
                                    // so the only thing we can do is parse from the string repr
                                    if $x.is_number(&ctx) {
                                        $x.to_number(&ctx).unwrap() as _
                                    } else {
                                        $x.to_string(&ctx).unwrap().to_string().parse::<u128>().unwrap()
                                    }
                                }
                            })
                        }) ),*
                    ).into_result()
                }));

                match result {
                    Ok(Ok(result)) => {
                        match Rets::size() {
                            0 => {Ok(JSValue::undefined(&ctx))},
                            1 => {
                                // unimplemented!();

                                let ty = Rets::wasm_types()[0];
                                let mut arr = unsafe { result.into_array(&mut store) };
                                // Value::from_raw(&store, ty, arr[0])
                                let val = unsafe { Value::from_raw(&mut store, ty, arr.as_mut()[0]) };
                                let value: JSValue = val.as_jsc_value(&store);
                                Ok(value)
                                // *mut_rets = val.as_raw(&mut store);
                            }
                            _n => {
                                // if !results.is_array(&context) {
                                //     panic!("Expected results to be an array.")
                                // }
                                let mut arr = unsafe { result.into_array(&mut store) };
                                let result_values = Rets::wasm_types().iter().enumerate().map(|(i, ret_type)| {
                                    let raw = arr.as_mut()[i];
                                    let value = unsafe { Value::from_raw(&mut store, *ret_type, raw) };
                                    value.as_jsc_value(&mut store)
                                }).collect::<Vec<_>>();
                                Ok(JSObject::new_array(&ctx, &result_values).unwrap().to_jsvalue())
                            }
                        }
                    },
                    Ok(Err(err)) => {
                        let trap = crate::backend::jsc::error::Trap::user(Box::new(err));
                        Err(trap.into_jsc_value(&ctx))
                    },
                    Err(panic) => {
                        Err(JSValue::string(&ctx, format!("panic: {:?}", panic)))
                    },
                }

            }

            Some(fn_callback::<T, $( $x, )* Rets, RetsAsResult, Func> as _)
        }

        }
    };
}

// Here we go! Let's generate all the C struct, `WasmTypeList`
// implementations and `HostFunction` implementations.
impl_host_function!([C] S0,);
impl_host_function!([transparent] S1, A1);
impl_host_function!([C] S2, A1, A2);
impl_host_function!([C] S3, A1, A2, A3);
impl_host_function!([C] S4, A1, A2, A3, A4);
impl_host_function!([C] S5, A1, A2, A3, A4, A5);
impl_host_function!([C] S6, A1, A2, A3, A4, A5, A6);
impl_host_function!([C] S7, A1, A2, A3, A4, A5, A6, A7);
impl_host_function!([C] S8, A1, A2, A3, A4, A5, A6, A7, A8);
impl_host_function!([C] S9, A1, A2, A3, A4, A5, A6, A7, A8, A9);
impl_host_function!([C] S10, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
impl_host_function!([C] S11, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11);
impl_host_function!([C] S12, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12);
impl_host_function!([C] S13, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13);
impl_host_function!([C] S14, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14);
impl_host_function!([C] S15, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15);
impl_host_function!([C] S16, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16);
impl_host_function!([C] S17, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17);
impl_host_function!([C] S18, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18);
impl_host_function!([C] S19, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19);
impl_host_function!([C] S20, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20);
impl_host_function!([C] S21, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21);
impl_host_function!([C] S22, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22);
impl_host_function!([C] S23, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23);
impl_host_function!([C] S24, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24);
impl_host_function!([C] S25, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25);
impl_host_function!([C] S26, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26);