mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-26 15:11:37 +00:00
Update the loader interface for 128 bit types.
This commit is contained in:
@ -75,7 +75,7 @@ impl Loader for KernelLoader {
|
|||||||
if module.imported_globals.len() > 0 {
|
if module.imported_globals.len() > 0 {
|
||||||
return Err("imported globals are not supported".into());
|
return Err("imported globals are not supported".into());
|
||||||
}
|
}
|
||||||
let globals: Vec<u64> = unsafe {
|
let globals: Vec<u128> = unsafe {
|
||||||
let globals: &[*mut LocalGlobal] =
|
let globals: &[*mut LocalGlobal] =
|
||||||
::std::slice::from_raw_parts(ctx.globals, module.globals.len());
|
::std::slice::from_raw_parts(ctx.globals, module.globals.len());
|
||||||
globals.iter().map(|x| (**x).data).collect()
|
globals.iter().map(|x| (**x).data).collect()
|
||||||
@ -138,11 +138,11 @@ pub struct KernelInstance {
|
|||||||
|
|
||||||
impl Instance for KernelInstance {
|
impl Instance for KernelInstance {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
fn call(&mut self, id: usize, args: &[Value]) -> Result<u64, String> {
|
fn call(&mut self, id: usize, args: &[Value]) -> Result<u128, String> {
|
||||||
if args.len() != self.param_counts[id] {
|
if args.len() != self.param_counts[id] {
|
||||||
return Err("param count mismatch".into());
|
return Err("param count mismatch".into());
|
||||||
}
|
}
|
||||||
let args: Vec<u64> = args.iter().map(|x| x.to_u64()).collect();
|
let args: Vec<u128> = args.iter().map(|x| x.to_u128()).collect();
|
||||||
|
|
||||||
let ret = self
|
let ret = self
|
||||||
.context
|
.context
|
||||||
|
@ -54,7 +54,7 @@ struct LoadCodeRequest {
|
|||||||
memory_max: u32,
|
memory_max: u32,
|
||||||
table: *const TableEntryRequest,
|
table: *const TableEntryRequest,
|
||||||
table_count: u32,
|
table_count: u32,
|
||||||
globals: *const u64,
|
globals: *const u128,
|
||||||
global_count: u32,
|
global_count: u32,
|
||||||
|
|
||||||
imported_funcs: *const ImportRequest,
|
imported_funcs: *const ImportRequest,
|
||||||
@ -67,7 +67,7 @@ struct LoadCodeRequest {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct RunCodeRequest {
|
struct RunCodeRequest {
|
||||||
entry_offset: u32,
|
entry_offset: u32,
|
||||||
params: *const u64,
|
params: *const u128,
|
||||||
param_count: u32,
|
param_count: u32,
|
||||||
result: *mut RunCodeResult,
|
result: *mut RunCodeResult,
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ struct RunCodeRequest {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct RunCodeResult {
|
struct RunCodeResult {
|
||||||
success: u32,
|
success: u32,
|
||||||
retval: u64,
|
retval: u128,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -108,7 +108,7 @@ pub struct LoadProfile<'a> {
|
|||||||
pub code: &'a [u8],
|
pub code: &'a [u8],
|
||||||
pub memory: Option<&'a [u8]>,
|
pub memory: Option<&'a [u8]>,
|
||||||
pub memory_max: usize,
|
pub memory_max: usize,
|
||||||
pub globals: &'a [u64],
|
pub globals: &'a [u128],
|
||||||
pub imports: &'a [ImportInfo],
|
pub imports: &'a [ImportInfo],
|
||||||
pub dynamic_sigindices: &'a [u32],
|
pub dynamic_sigindices: &'a [u32],
|
||||||
pub table: Option<&'a [TableEntryRequest]>,
|
pub table: Option<&'a [TableEntryRequest]>,
|
||||||
@ -121,7 +121,7 @@ pub struct ImportInfo {
|
|||||||
|
|
||||||
pub struct RunProfile<'a> {
|
pub struct RunProfile<'a> {
|
||||||
pub entry_offset: u32,
|
pub entry_offset: u32,
|
||||||
pub params: &'a [u64],
|
pub params: &'a [u128],
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ServiceContext {
|
pub struct ServiceContext {
|
||||||
@ -181,7 +181,7 @@ impl ServiceContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_code(&mut self, run: RunProfile) -> ServiceResult<u64> {
|
pub fn run_code(&mut self, run: RunProfile) -> ServiceResult<u128> {
|
||||||
let mut result: RunCodeResult = unsafe { ::std::mem::zeroed() };
|
let mut result: RunCodeResult = unsafe { ::std::mem::zeroed() };
|
||||||
let mut req = RunCodeRequest {
|
let mut req = RunCodeRequest {
|
||||||
entry_offset: run.entry_offset,
|
entry_offset: run.entry_offset,
|
||||||
|
@ -20,7 +20,7 @@ pub trait Loader {
|
|||||||
|
|
||||||
pub trait Instance {
|
pub trait Instance {
|
||||||
type Error: Debug;
|
type Error: Debug;
|
||||||
fn call(&mut self, id: usize, args: &[Value]) -> Result<u64, Self::Error>;
|
fn call(&mut self, id: usize, args: &[Value]) -> Result<u128, Self::Error>;
|
||||||
fn read_memory(&mut self, _offset: u32, _len: u32) -> Result<Vec<u8>, Self::Error> {
|
fn read_memory(&mut self, _offset: u32, _len: u32) -> Result<Vec<u8>, Self::Error> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ pub struct LocalInstance {
|
|||||||
|
|
||||||
impl Instance for LocalInstance {
|
impl Instance for LocalInstance {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
fn call(&mut self, id: usize, args: &[Value]) -> Result<u64, Self::Error> {
|
fn call(&mut self, id: usize, args: &[Value]) -> Result<u128, Self::Error> {
|
||||||
let mut args_u64: Vec<u64> = Vec::new();
|
let mut args_u64: Vec<u64> = Vec::new();
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if arg.ty() == Type::V128 {
|
if arg.ty() == Type::V128 {
|
||||||
@ -81,23 +81,23 @@ impl Instance for LocalInstance {
|
|||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
Ok(unsafe {
|
Ok(unsafe {
|
||||||
match args_u64.len() {
|
match args_u64.len() {
|
||||||
0 => (transmute::<_, extern "C" fn() -> u64>(addr))(),
|
0 => (transmute::<_, extern "C" fn() -> u128>(addr))(),
|
||||||
1 => (transmute::<_, extern "C" fn(u64) -> u64>(addr))(args_u64[0]),
|
1 => (transmute::<_, extern "C" fn(u64) -> u128>(addr))(args_u64[0]),
|
||||||
2 => {
|
2 => {
|
||||||
(transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))(args_u64[0], args_u64[1])
|
(transmute::<_, extern "C" fn(u64, u64) -> u128>(addr))(args_u64[0], args_u64[1])
|
||||||
}
|
}
|
||||||
3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u64>(addr))(
|
3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u128>(addr))(
|
||||||
args_u64[0],
|
args_u64[0],
|
||||||
args_u64[1],
|
args_u64[1],
|
||||||
args_u64[2],
|
args_u64[2],
|
||||||
),
|
),
|
||||||
4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u64>(addr))(
|
4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u128>(addr))(
|
||||||
args_u64[0],
|
args_u64[0],
|
||||||
args_u64[1],
|
args_u64[1],
|
||||||
args_u64[2],
|
args_u64[2],
|
||||||
args_u64[3],
|
args_u64[3],
|
||||||
),
|
),
|
||||||
5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u64>(addr))(
|
5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u128>(addr))(
|
||||||
args_u64[0],
|
args_u64[0],
|
||||||
args_u64[1],
|
args_u64[1],
|
||||||
args_u64[2],
|
args_u64[2],
|
||||||
|
Reference in New Issue
Block a user