mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 06:31:32 +00:00
Cleanup imports and other warnings
This commit is contained in:
@ -9,7 +9,7 @@ use std::os::raw::c_char;
|
|||||||
|
|
||||||
use super::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
use super::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
||||||
use super::EmscriptenData;
|
use super::EmscriptenData;
|
||||||
use wasmer_runtime_core::{types::Value, vm::Ctx};
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
// #[no_mangle]
|
// #[no_mangle]
|
||||||
/// emscripten: _getenv // (name: *const char) -> *const c_char;
|
/// emscripten: _getenv // (name: *const char) -> *const c_char;
|
||||||
@ -157,13 +157,13 @@ pub extern "C" fn ___build_environment(environ: c_int, ctx: &mut Ctx) {
|
|||||||
debug!("emscripten::___build_environment {}", environ);
|
debug!("emscripten::___build_environment {}", environ);
|
||||||
const MAX_ENV_VALUES: u32 = 64;
|
const MAX_ENV_VALUES: u32 = 64;
|
||||||
const TOTAL_ENV_SIZE: u32 = 1024;
|
const TOTAL_ENV_SIZE: u32 = 1024;
|
||||||
let mut environment = ctx.memory(0)[environ as usize] as *mut c_int;
|
let environment = ctx.memory(0)[environ as usize] as *mut c_int;
|
||||||
unsafe {
|
unsafe {
|
||||||
let (pool_offset, _pool_slice): (u32, &mut [u8]) =
|
let (pool_offset, _pool_slice): (u32, &mut [u8]) =
|
||||||
allocate_on_stack(TOTAL_ENV_SIZE as u32, ctx);
|
allocate_on_stack(TOTAL_ENV_SIZE as u32, ctx);
|
||||||
let (env_offset, _env_slice): (u32, &mut [u8]) =
|
let (env_offset, _env_slice): (u32, &mut [u8]) =
|
||||||
allocate_on_stack((MAX_ENV_VALUES * 4) as u32, ctx);
|
allocate_on_stack((MAX_ENV_VALUES * 4) as u32, ctx);
|
||||||
let mut env_ptr = ctx.memory(0)[env_offset as usize] as *mut c_int;
|
let env_ptr = ctx.memory(0)[env_offset as usize] as *mut c_int;
|
||||||
let mut _pool_ptr = ctx.memory(0)[pool_offset as usize] as *mut c_int;
|
let mut _pool_ptr = ctx.memory(0)[pool_offset as usize] as *mut c_int;
|
||||||
*env_ptr = pool_offset as i32;
|
*env_ptr = pool_offset as i32;
|
||||||
*environment = env_offset as i32;
|
*environment = env_offset as i32;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::env;
|
use super::env;
|
||||||
use super::process::_abort;
|
use super::process::_abort;
|
||||||
use wasmer_runtime_core::{vm::Ctx, Instance};
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
/// emscripten: ___cxa_allocate_exception
|
/// emscripten: ___cxa_allocate_exception
|
||||||
pub extern "C" fn ___cxa_allocate_exception(size: u32, vmctx: &mut Ctx) -> u32 {
|
pub extern "C" fn ___cxa_allocate_exception(size: u32, vmctx: &mut Ctx) -> u32 {
|
||||||
@ -10,7 +10,7 @@ pub extern "C" fn ___cxa_allocate_exception(size: u32, vmctx: &mut Ctx) -> u32 {
|
|||||||
|
|
||||||
/// emscripten: ___cxa_throw
|
/// emscripten: ___cxa_throw
|
||||||
/// TODO: We don't have support for exceptions yet
|
/// TODO: We don't have support for exceptions yet
|
||||||
pub extern "C" fn ___cxa_throw(_ptr: u32, ty: u32, destructor: u32, vmctx: &mut Ctx) {
|
pub extern "C" fn ___cxa_throw(_ptr: u32, _ty: u32, _destructor: u32, _vmctx: &mut Ctx) {
|
||||||
debug!("emscripten::___cxa_throw");
|
debug!("emscripten::___cxa_throw");
|
||||||
_abort();
|
_abort();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ pub extern "C" fn __setjmp(env_addr: u32, ctx: &mut Ctx) -> c_int {
|
|||||||
let jump_index = ctx.memory(0)[env_addr as usize] as *mut i8;
|
let jump_index = ctx.memory(0)[env_addr as usize] as *mut i8;
|
||||||
// We create the jump buffer outside of the wasm memory
|
// We create the jump buffer outside of the wasm memory
|
||||||
let jump_buf: UnsafeCell<[c_int; 27]> = UnsafeCell::new([0; 27]);
|
let jump_buf: UnsafeCell<[c_int; 27]> = UnsafeCell::new([0; 27]);
|
||||||
let mut jumps = &mut get_emscripten_data(ctx).jumps;
|
let jumps = &mut get_emscripten_data(ctx).jumps;
|
||||||
let result = setjmp(jump_buf.get() as _);
|
let result = setjmp(jump_buf.get() as _);
|
||||||
// We set the jump index to be the last value of jumps
|
// We set the jump index to be the last value of jumps
|
||||||
*jump_index = jumps.len() as _;
|
*jump_index = jumps.len() as _;
|
||||||
@ -29,9 +29,9 @@ pub extern "C" fn __longjmp(env_addr: u32, val: c_int, ctx: &mut Ctx) -> ! {
|
|||||||
unsafe {
|
unsafe {
|
||||||
// We retrieve the jump index from the env address
|
// We retrieve the jump index from the env address
|
||||||
let jump_index = ctx.memory(0)[env_addr as usize] as *mut i8;
|
let jump_index = ctx.memory(0)[env_addr as usize] as *mut i8;
|
||||||
let mut jumps = &mut get_emscripten_data(ctx).jumps;
|
let jumps = &mut get_emscripten_data(ctx).jumps;
|
||||||
// We get the real jump buffer from the jumps vector, using the retrieved index
|
// We get the real jump buffer from the jumps vector, using the retrieved index
|
||||||
let mut jump_buf = &jumps[*jump_index as usize];
|
let jump_buf = &jumps[*jump_index as usize];
|
||||||
longjmp(jump_buf.get() as _, val)
|
longjmp(jump_buf.get() as _, val)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ use hashbrown::HashMap;
|
|||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::{ffi::c_void, mem, ptr};
|
use std::{ffi::c_void, mem, ptr};
|
||||||
use std::{mem::size_of, panic, slice};
|
use std::{mem::size_of, slice};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
error::{CallError, CallResult, ResolveError},
|
error::{CallResult, ResolveError},
|
||||||
export::{Context, Export, FuncPointer, GlobalPointer, MemoryPointer, TablePointer},
|
export::{Context, Export, FuncPointer, GlobalPointer, MemoryPointer, TablePointer},
|
||||||
import::{ImportObject, Namespace},
|
import::{ImportObject, Namespace},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
@ -120,7 +120,7 @@ impl EmscriptenData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_emscripten_instance(
|
pub fn run_emscripten_instance(
|
||||||
module: &Module,
|
_module: &Module,
|
||||||
instance: &mut Instance,
|
instance: &mut Instance,
|
||||||
_path: &str,
|
_path: &str,
|
||||||
args: Vec<&str>,
|
args: Vec<&str>,
|
||||||
@ -332,7 +332,7 @@ impl<'a> EmscriptenGlobals<'a> {
|
|||||||
shared: false,
|
shared: false,
|
||||||
};
|
};
|
||||||
let mut memory = LinearMemory::new(&memory_type);
|
let mut memory = LinearMemory::new(&memory_type);
|
||||||
let mut vm_memory = memory.into_vm_memory(LocalMemoryIndex::new(0));
|
let vm_memory = memory.into_vm_memory(LocalMemoryIndex::new(0));
|
||||||
|
|
||||||
let table_type = Table {
|
let table_type = Table {
|
||||||
ty: ElementType::Anyfunc,
|
ty: ElementType::Anyfunc,
|
||||||
@ -340,7 +340,7 @@ impl<'a> EmscriptenGlobals<'a> {
|
|||||||
max: Some(10),
|
max: Some(10),
|
||||||
};
|
};
|
||||||
let mut table = TableBacking::new(&table_type);
|
let mut table = TableBacking::new(&table_type);
|
||||||
let mut vm_table = table.into_vm_table();
|
let vm_table = table.into_vm_table();
|
||||||
|
|
||||||
let memory_base = (STATIC_BASE as u64, I32);
|
let memory_base = (STATIC_BASE as u64, I32);
|
||||||
let table_base = (0 as u64, I32);
|
let table_base = (0 as u64, I32);
|
||||||
|
@ -41,7 +41,7 @@ pub extern "C" fn em_abort(message: u32, vmctx: &mut Ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub extern "C" fn abort_stack_overflow(what: c_int) {
|
pub extern "C" fn abort_stack_overflow(_what: c_int) {
|
||||||
debug!("emscripten::abort_stack_overflow");
|
debug!("emscripten::abort_stack_overflow");
|
||||||
// TODO: Message incomplete. Need to finish em runtime data first
|
// TODO: Message incomplete. Need to finish em runtime data first
|
||||||
abort_with_message("Stack overflow! Attempted to allocate some bytes on the stack");
|
abort_with_message("Stack overflow! Attempted to allocate some bytes on the stack");
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use std::{mem::size_of, panic, slice};
|
use std::panic;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
self as runtime,
|
self as runtime,
|
||||||
error::CallError,
|
|
||||||
error::{CallResult, Result},
|
error::{CallResult, Result},
|
||||||
ImportObject, Instance, Module,
|
ImportObject, Instance, Module,
|
||||||
};
|
};
|
||||||
@ -87,7 +86,7 @@ pub fn run_instance(
|
|||||||
args: Vec<&str>,
|
args: Vec<&str>,
|
||||||
) -> CallResult<()> {
|
) -> CallResult<()> {
|
||||||
if is_emscripten_module(module) {
|
if is_emscripten_module(module) {
|
||||||
run_emscripten_instance(module, instance, path, args);
|
run_emscripten_instance(module, instance, path, args)?;
|
||||||
} else {
|
} else {
|
||||||
instance.call("main", &[])?;
|
instance.call("main", &[])?;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user