mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-19 11:51:22 +00:00
chore(runtime-core) Use vm::Ctx
to access it.
Just to be consistent with the rest of the code.
This commit is contained in:
@ -3,7 +3,7 @@ use crate::{
|
|||||||
export::{Context, Export, FuncPointer},
|
export::{Context, Export, FuncPointer},
|
||||||
import::IsExport,
|
import::IsExport,
|
||||||
types::{FuncSig, NativeWasmType, Type, WasmExternType},
|
types::{FuncSig, NativeWasmType, Type, WasmExternType},
|
||||||
vm::{self, Ctx},
|
vm,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
@ -52,10 +52,10 @@ impl fmt::Display for WasmTrapInfo {
|
|||||||
/// of the `Func` struct.
|
/// of the `Func` struct.
|
||||||
pub trait Kind {}
|
pub trait Kind {}
|
||||||
|
|
||||||
pub type Trampoline = unsafe extern "C" fn(*mut Ctx, NonNull<vm::Func>, *const u64, *mut u64);
|
pub type Trampoline = unsafe extern "C" fn(*mut vm::Ctx, NonNull<vm::Func>, *const u64, *mut u64);
|
||||||
pub type Invoke = unsafe extern "C" fn(
|
pub type Invoke = unsafe extern "C" fn(
|
||||||
Trampoline,
|
Trampoline,
|
||||||
*mut Ctx,
|
*mut vm::Ctx,
|
||||||
NonNull<vm::Func>,
|
NonNull<vm::Func>,
|
||||||
*const u64,
|
*const u64,
|
||||||
*mut u64,
|
*mut u64,
|
||||||
@ -173,7 +173,7 @@ where
|
|||||||
pub struct Func<'a, Args = (), Rets = (), Inner: Kind = Wasm> {
|
pub struct Func<'a, Args = (), Rets = (), Inner: Kind = Wasm> {
|
||||||
inner: Inner,
|
inner: Inner,
|
||||||
f: NonNull<vm::Func>,
|
f: NonNull<vm::Func>,
|
||||||
ctx: *mut Ctx,
|
ctx: *mut vm::Ctx,
|
||||||
_phantom: PhantomData<(&'a (), Args, Rets)>,
|
_phantom: PhantomData<(&'a (), Args, Rets)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ where
|
|||||||
pub(crate) unsafe fn from_raw_parts(
|
pub(crate) unsafe fn from_raw_parts(
|
||||||
inner: Wasm,
|
inner: Wasm,
|
||||||
f: NonNull<vm::Func>,
|
f: NonNull<vm::Func>,
|
||||||
ctx: *mut Ctx,
|
ctx: *mut vm::Ctx,
|
||||||
) -> Func<'a, Args, Rets, Wasm> {
|
) -> Func<'a, Args, Rets, Wasm> {
|
||||||
Func {
|
Func {
|
||||||
inner,
|
inner,
|
||||||
@ -267,7 +267,7 @@ impl WasmTypeList for Infallible {
|
|||||||
self,
|
self,
|
||||||
_: NonNull<vm::Func>,
|
_: NonNull<vm::Func>,
|
||||||
_: Wasm,
|
_: Wasm,
|
||||||
_: *mut Ctx,
|
_: *mut vm::Ctx,
|
||||||
) -> Result<Rets, RuntimeError>
|
) -> Result<Rets, RuntimeError>
|
||||||
where
|
where
|
||||||
Rets: WasmTypeList,
|
Rets: WasmTypeList,
|
||||||
@ -313,7 +313,7 @@ where
|
|||||||
self,
|
self,
|
||||||
f: NonNull<vm::Func>,
|
f: NonNull<vm::Func>,
|
||||||
wasm: Wasm,
|
wasm: Wasm,
|
||||||
ctx: *mut Ctx,
|
ctx: *mut vm::Ctx,
|
||||||
) -> Result<Rets, RuntimeError>
|
) -> Result<Rets, RuntimeError>
|
||||||
where
|
where
|
||||||
Rets: WasmTypeList,
|
Rets: WasmTypeList,
|
||||||
@ -405,7 +405,7 @@ macro_rules! impl_traits {
|
|||||||
self,
|
self,
|
||||||
f: NonNull<vm::Func>,
|
f: NonNull<vm::Func>,
|
||||||
wasm: Wasm,
|
wasm: Wasm,
|
||||||
ctx: *mut Ctx,
|
ctx: *mut vm::Ctx,
|
||||||
) -> Result<Rets, RuntimeError>
|
) -> Result<Rets, RuntimeError>
|
||||||
where
|
where
|
||||||
Rets: WasmTypeList
|
Rets: WasmTypeList
|
||||||
@ -443,7 +443,7 @@ macro_rules! impl_traits {
|
|||||||
$( $x: WasmExternType, )*
|
$( $x: WasmExternType, )*
|
||||||
Rets: WasmTypeList,
|
Rets: WasmTypeList,
|
||||||
Trap: TrapEarly<Rets>,
|
Trap: TrapEarly<Rets>,
|
||||||
FN: Fn(&mut Ctx $( , $x )*) -> Trap,
|
FN: Fn(&mut vm::Ctx $( , $x )*) -> Trap,
|
||||||
{
|
{
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn to_raw(&self) -> NonNull<vm::Func> {
|
fn to_raw(&self) -> NonNull<vm::Func> {
|
||||||
@ -451,13 +451,13 @@ macro_rules! impl_traits {
|
|||||||
/// This is required for the llvm backend to be able to unwind through this function.
|
/// This is required for the llvm backend to be able to unwind through this function.
|
||||||
#[cfg_attr(nightly, unwind(allowed))]
|
#[cfg_attr(nightly, unwind(allowed))]
|
||||||
extern fn wrap<$( $x, )* Rets, Trap, FN>(
|
extern fn wrap<$( $x, )* Rets, Trap, FN>(
|
||||||
ctx: &mut Ctx $( , $x: <$x as WasmExternType>::Native )*
|
ctx: &mut vm::Ctx $( , $x: <$x as WasmExternType>::Native )*
|
||||||
) -> Rets::CStruct
|
) -> Rets::CStruct
|
||||||
where
|
where
|
||||||
$( $x: WasmExternType, )*
|
$( $x: WasmExternType, )*
|
||||||
Rets: WasmTypeList,
|
Rets: WasmTypeList,
|
||||||
Trap: TrapEarly<Rets>,
|
Trap: TrapEarly<Rets>,
|
||||||
FN: Fn(&mut Ctx $( , $x )*) -> Trap,
|
FN: Fn(&mut vm::Ctx $( , $x )*) -> Trap,
|
||||||
{
|
{
|
||||||
let f: FN = unsafe { mem::transmute_copy(&()) };
|
let f: FN = unsafe { mem::transmute_copy(&()) };
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_call() {
|
fn test_call() {
|
||||||
fn foo(_ctx: &mut Ctx, a: i32, b: i32) -> (i32, i32) {
|
fn foo(_ctx: &mut vm::Ctx, a: i32, b: i32) -> (i32, i32) {
|
||||||
(a, b)
|
(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ mod tests {
|
|||||||
fn test_imports() {
|
fn test_imports() {
|
||||||
use crate::{func, imports};
|
use crate::{func, imports};
|
||||||
|
|
||||||
fn foo(_ctx: &mut Ctx, a: i32) -> i32 {
|
fn foo(_ctx: &mut vm::Ctx, a: i32) -> i32 {
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user