mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 16:41:33 +00:00
Improved formatting
This commit is contained in:
@ -38,8 +38,7 @@ pub fn generate_libc_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
mod tests {
|
||||
use super::generate_libc_env;
|
||||
use crate::webassembly::{
|
||||
instantiate, ErrorKind, Export, ImportObject, Instance, Module, ResultObject,
|
||||
VmCtx
|
||||
instantiate, ErrorKind, Export, ImportObject, Instance, Module, ResultObject, VmCtx,
|
||||
};
|
||||
use libc::putchar;
|
||||
|
||||
|
@ -14,8 +14,8 @@ extern crate wabt;
|
||||
extern crate target_lexicon;
|
||||
extern crate spin;
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
use std::alloc::System;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
// #[global_allocator]
|
||||
// static A: System = System;
|
||||
@ -75,8 +75,10 @@ fn execute_wasm(wasm_path: PathBuf) -> Result<(), String> {
|
||||
}
|
||||
|
||||
let import_object = integrations::generate_libc_env();
|
||||
let webassembly::ResultObject { module, mut instance } =
|
||||
webassembly::instantiate(wasm_binary, import_object)
|
||||
let webassembly::ResultObject {
|
||||
module,
|
||||
mut instance,
|
||||
} = webassembly::instantiate(wasm_binary, import_object)
|
||||
.map_err(|err| String::from(err.description()))?;
|
||||
let func_index = instance
|
||||
.start_func
|
||||
|
@ -68,7 +68,6 @@ fn get_function_addr(
|
||||
// (base as usize + offset) as _
|
||||
// }
|
||||
|
||||
|
||||
// #[derive(Debug)]
|
||||
#[repr(C, packed)]
|
||||
pub struct VmCtx<'phantom> {
|
||||
@ -506,8 +505,10 @@ impl Instance {
|
||||
}
|
||||
|
||||
pub fn generate_context(&mut self) -> VmCtx {
|
||||
let memories: Vec<UncheckedSlice<u8>> = self.memories.iter().map(|mem| mem[..].into()).collect();
|
||||
let tables: Vec<BoundedSlice<usize>> = self.tables.iter().map(|table| table[..].into()).collect();
|
||||
let memories: Vec<UncheckedSlice<u8>> =
|
||||
self.memories.iter().map(|mem| mem[..].into()).collect();
|
||||
let tables: Vec<BoundedSlice<usize>> =
|
||||
self.tables.iter().map(|table| table[..].into()).collect();
|
||||
let globals: UncheckedSlice<u8> = self.globals[..].into();
|
||||
|
||||
// println!("GENERATING CONTEXT {:?}", self.tables);
|
||||
@ -570,7 +571,6 @@ impl Clone for Instance {
|
||||
}
|
||||
|
||||
extern "C" fn grow_memory(size: u32, memory_index: u32, vmctx: &mut VmCtx) -> i32 {
|
||||
|
||||
return 0;
|
||||
// unimplemented!();
|
||||
// let instance = &vmctx.user_data.instance;
|
||||
|
@ -36,7 +36,8 @@ impl LinearMemory {
|
||||
initial, maximum
|
||||
);
|
||||
|
||||
let len: u64 = PAGE_SIZE as u64 * match maximum {
|
||||
let len: u64 = PAGE_SIZE as u64
|
||||
* match maximum {
|
||||
Some(val) => val as u64,
|
||||
None => initial as u64,
|
||||
};
|
||||
|
@ -539,12 +539,9 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> {
|
||||
ext
|
||||
// pos.ins().imul_imm(ext, 4)
|
||||
};
|
||||
let entry_addr = pos.ins().table_addr(
|
||||
self.pointer_type(),
|
||||
table,
|
||||
callee_offset,
|
||||
0,
|
||||
);
|
||||
let entry_addr = pos
|
||||
.ins()
|
||||
.table_addr(self.pointer_type(), table, callee_offset, 0);
|
||||
let mut mflags = ir::MemFlags::new();
|
||||
mflags.set_notrap();
|
||||
mflags.set_aligned();
|
||||
|
Reference in New Issue
Block a user