mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Formatted emscripten files
This commit is contained in:
parent
15d1fd4bbb
commit
d3d84cbc22
16
lib/emscripten/src/env/mod.rs
vendored
16
lib/emscripten/src/env/mod.rs
vendored
@ -22,11 +22,23 @@ use wasmer_runtime_core::{
|
||||
};
|
||||
|
||||
pub fn call_malloc(ctx: &mut Ctx, size: u32) -> u32 {
|
||||
get_emscripten_data(ctx).malloc.as_ref().unwrap().call(size).unwrap()
|
||||
get_emscripten_data(ctx)
|
||||
.malloc
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.call(size)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn call_malloc_with_cast<T: Copy, Ty>(ctx: &mut Ctx, size: u32) -> WasmPtr<T, Ty> {
|
||||
WasmPtr::new(get_emscripten_data(ctx).malloc.as_ref().unwrap().call(size).unwrap())
|
||||
WasmPtr::new(
|
||||
get_emscripten_data(ctx)
|
||||
.malloc
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.call(size)
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn call_memalign(ctx: &mut Ctx, alignment: u32, size: u32) -> u32 {
|
||||
|
@ -167,7 +167,10 @@ impl<'a> EmscriptenData<'a> {
|
||||
) -> EmscriptenData<'a> {
|
||||
let malloc = instance.func("_malloc").or(instance.func("malloc")).ok();
|
||||
let free = instance.func("_free").or(instance.func("free")).ok();
|
||||
let memalign = instance.func("_memalign").or(instance.func("memalign")).ok();
|
||||
let memalign = instance
|
||||
.func("_memalign")
|
||||
.or(instance.func("memalign"))
|
||||
.ok();
|
||||
let memset = instance.func("_memset").or(instance.func("memset")).ok();
|
||||
let stack_alloc = instance.func("stackAlloc").ok();
|
||||
|
||||
@ -228,7 +231,10 @@ impl<'a> EmscriptenData<'a> {
|
||||
|
||||
let stack_save = instance.func("stackSave").ok();
|
||||
let stack_restore = instance.func("stackRestore").ok();
|
||||
let set_threw = instance.func("_setThrew").or(instance.func("setThrew")).ok();
|
||||
let set_threw = instance
|
||||
.func("_setThrew")
|
||||
.or(instance.func("setThrew"))
|
||||
.ok();
|
||||
|
||||
EmscriptenData {
|
||||
malloc,
|
||||
@ -334,15 +340,11 @@ pub fn run_emscripten_instance(
|
||||
instance.call(&ep, &[Value::I32(arg as i32)])?;
|
||||
} else {
|
||||
let (func_name, main_func) = match instance.dyn_func("_main") {
|
||||
Ok(func) => {
|
||||
Ok(("_main", func))
|
||||
Ok(func) => Ok(("_main", func)),
|
||||
Err(_e) => match instance.dyn_func("main") {
|
||||
Ok(func) => Ok(("main", func)),
|
||||
Err(e) => Err(e),
|
||||
},
|
||||
Err(_e) => {
|
||||
match instance.dyn_func("main") {
|
||||
Ok(func) => Ok(("main", func)),
|
||||
Err(e) => Err(e)
|
||||
}
|
||||
}
|
||||
}?;
|
||||
let num_params = main_func.signature().params().len();
|
||||
let _result = match num_params {
|
||||
@ -350,7 +352,10 @@ pub fn run_emscripten_instance(
|
||||
let mut new_args = vec![path];
|
||||
new_args.extend(args);
|
||||
let (argc, argv) = store_module_arguments(instance.context_mut(), new_args);
|
||||
instance.call(func_name, &[Value::I32(argc as i32), Value::I32(argv as i32)])?;
|
||||
instance.call(
|
||||
func_name,
|
||||
&[Value::I32(argc as i32), Value::I32(argv as i32)],
|
||||
)?;
|
||||
}
|
||||
0 => {
|
||||
instance.call(func_name, &[])?;
|
||||
|
@ -13,7 +13,9 @@ pub fn _pthread_attr_getstack(
|
||||
) -> i32 {
|
||||
trace!(
|
||||
"emscripten::_pthread_attr_getstack({}, {}, {})",
|
||||
_stackaddr, _stacksize, _other
|
||||
_stackaddr,
|
||||
_stacksize,
|
||||
_other
|
||||
);
|
||||
// TODO: Translate from Emscripten
|
||||
// HEAP32[stackaddr >> 2] = STACK_BASE;
|
||||
|
@ -24,7 +24,9 @@ pub fn is_emscripten_module(module: &Module) -> bool {
|
||||
.namespace_table
|
||||
.get(import_name.namespace_index);
|
||||
let field = module.info().name_table.get(import_name.name_index);
|
||||
if (field == "_emscripten_memcpy_big" || field=="emscripten_memcpy_big") && namespace == "env" {
|
||||
if (field == "_emscripten_memcpy_big" || field == "emscripten_memcpy_big")
|
||||
&& namespace == "env"
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user