mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 21:21:33 +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::EmscriptenData;
|
||||
use wasmer_runtime_core::{types::Value, vm::Ctx};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
// #[no_mangle]
|
||||
/// 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);
|
||||
const MAX_ENV_VALUES: u32 = 64;
|
||||
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 {
|
||||
let (pool_offset, _pool_slice): (u32, &mut [u8]) =
|
||||
allocate_on_stack(TOTAL_ENV_SIZE as u32, ctx);
|
||||
let (env_offset, _env_slice): (u32, &mut [u8]) =
|
||||
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;
|
||||
*env_ptr = pool_offset as i32;
|
||||
*environment = env_offset as i32;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::env;
|
||||
use super::process::_abort;
|
||||
use wasmer_runtime_core::{vm::Ctx, Instance};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
/// emscripten: ___cxa_allocate_exception
|
||||
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
|
||||
/// 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");
|
||||
_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;
|
||||
// We create the jump buffer outside of the wasm memory
|
||||
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 _);
|
||||
// We set the jump index to be the last value of jumps
|
||||
*jump_index = jumps.len() as _;
|
||||
@ -29,9 +29,9 @@ pub extern "C" fn __longjmp(env_addr: u32, val: c_int, ctx: &mut Ctx) -> ! {
|
||||
unsafe {
|
||||
// We retrieve the jump index from the env address
|
||||
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
|
||||
let mut jump_buf = &jumps[*jump_index as usize];
|
||||
let jump_buf = &jumps[*jump_index as usize];
|
||||
longjmp(jump_buf.get() as _, val)
|
||||
};
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ use hashbrown::HashMap;
|
||||
use libc::c_int;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::{ffi::c_void, mem, ptr};
|
||||
use std::{mem::size_of, panic, slice};
|
||||
use std::{mem::size_of, slice};
|
||||
use wasmer_runtime_core::{
|
||||
error::{CallError, CallResult, ResolveError},
|
||||
error::{CallResult, ResolveError},
|
||||
export::{Context, Export, FuncPointer, GlobalPointer, MemoryPointer, TablePointer},
|
||||
import::{ImportObject, Namespace},
|
||||
instance::Instance,
|
||||
@ -120,7 +120,7 @@ impl EmscriptenData {
|
||||
}
|
||||
|
||||
pub fn run_emscripten_instance(
|
||||
module: &Module,
|
||||
_module: &Module,
|
||||
instance: &mut Instance,
|
||||
_path: &str,
|
||||
args: Vec<&str>,
|
||||
@ -332,7 +332,7 @@ impl<'a> EmscriptenGlobals<'a> {
|
||||
shared: false,
|
||||
};
|
||||
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 {
|
||||
ty: ElementType::Anyfunc,
|
||||
@ -340,7 +340,7 @@ impl<'a> EmscriptenGlobals<'a> {
|
||||
max: Some(10),
|
||||
};
|
||||
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 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");
|
||||
// TODO: Message incomplete. Need to finish em runtime data first
|
||||
abort_with_message("Stack overflow! Attempted to allocate some bytes on the stack");
|
||||
|
Reference in New Issue
Block a user