mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-13 09:01:21 +00:00
Merge branch 'master' into fix/localtime
# Conflicts: # emtests/README.md # src/apis/emscripten/mod.rs # src/apis/emscripten/storage.rs # src/bin/wasmer.rs
This commit is contained in:
@ -22,13 +22,11 @@ pub use self::storage::{align_memory};
|
||||
pub use self::utils::{is_emscripten_module, allocate_on_stack, allocate_cstr_on_stack};
|
||||
|
||||
// TODO: Magic number - how is this calculated?
|
||||
const TOTAL_STACK: u32 = 5242880;
|
||||
const TOTAL_STACK: u32 = 5_242_880;
|
||||
// TODO: Magic number - how is this calculated?
|
||||
const DYNAMICTOP_PTR_DIFF: u32 = 1088;
|
||||
// TODO: make this variable
|
||||
const STATIC_BUMP: u32 = 215536;
|
||||
// TODO: make this variable
|
||||
const GLOBAL_BASE: u32 = 1024;
|
||||
const STATIC_BUMP: u32 = 215_536;
|
||||
|
||||
fn stacktop(static_bump: u32) -> u32 {
|
||||
align_memory(dynamictop_ptr(static_bump) + 4)
|
||||
@ -489,35 +487,3 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
|
||||
import_object
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::generate_emscripten_env;
|
||||
use crate::webassembly::{instantiate, Export, Instance};
|
||||
|
||||
#[test]
|
||||
fn test_putchar() {
|
||||
let wasm_bytes = include_wast2wasm_bytes!("tests/putchar.wast");
|
||||
let import_object = generate_emscripten_env();
|
||||
let result_object = instantiate(wasm_bytes, import_object).expect("Not compiled properly");
|
||||
let func_index = match result_object.module.info.exports.get("main") {
|
||||
Some(&Export::Function(index)) => index,
|
||||
_ => panic!("Function not found"),
|
||||
};
|
||||
let main: fn(&Instance) = get_instance_function!(result_object.instance, func_index);
|
||||
main(&result_object.instance);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_print() {
|
||||
let wasm_bytes = include_wast2wasm_bytes!("tests/printf.wast");
|
||||
let import_object = generate_emscripten_env();
|
||||
let result_object = instantiate(wasm_bytes, import_object).expect("Not compiled properly");
|
||||
let func_index = match result_object.module.info.exports.get("main") {
|
||||
Some(&Export::Function(index)) => index,
|
||||
_ => panic!("Function not found"),
|
||||
};
|
||||
let main: fn(&Instance) = get_instance_function!(result_object.instance, func_index);
|
||||
main(&result_object.instance);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user