mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-04-24 23:02:15 +00:00
Renamings.
This commit is contained in:
parent
0482373afc
commit
0ea8a48a64
@ -41,7 +41,7 @@ fn export_entry_performance(b: &mut Bencher) {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// add both modules to program
|
// add both modules to program
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
program.add_module("callee_module", callee_module, None).unwrap();
|
program.add_module("callee_module", callee_module, None).unwrap();
|
||||||
let caller_module = program.add_module("caller_module", caller_module, None).unwrap();
|
let caller_module = program.add_module("caller_module", caller_module, None).unwrap();
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Intrepreter initialization.
|
// Intrepreter initialization.
|
||||||
// It also initializes a default "env" module.
|
// It also initializes a default "env" module.
|
||||||
let program = parity_wasm::ProgramInstance::with_env_params(
|
let program = parity_wasm::ProgramInstance::with_emscripten_env(
|
||||||
interpreter::EnvParams {
|
interpreter::EnvParams {
|
||||||
total_stack: 128*1024,
|
total_stack: 128*1024,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -17,7 +17,7 @@ fn main() {
|
|||||||
|
|
||||||
// Intrepreter initialization.
|
// Intrepreter initialization.
|
||||||
// It also initializes a default "env" module.
|
// It also initializes a default "env" module.
|
||||||
let program = parity_wasm::ProgramInstance::with_env_params(
|
let program = parity_wasm::ProgramInstance::with_emscripten_env(
|
||||||
interpreter::EnvParams {
|
interpreter::EnvParams {
|
||||||
total_stack: 128*1024,
|
total_stack: 128*1024,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -20,24 +20,21 @@ pub struct ProgramInstanceEssence {
|
|||||||
|
|
||||||
impl ProgramInstance {
|
impl ProgramInstance {
|
||||||
/// Create new program instance.
|
/// Create new program instance.
|
||||||
pub fn new() -> Result<Self, Error> {
|
pub fn new() -> Self {
|
||||||
ProgramInstance::with_env_params(emscripten::EnvParams::default())
|
ProgramInstance {
|
||||||
|
essence: Arc::new(ProgramInstanceEssence::new()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new program instance with custom env module params (mostly memory)
|
/// Create new program instance with added Emscripten's `env` module.
|
||||||
pub fn with_env_params(params: emscripten::EnvParams) -> Result<Self, Error> {
|
///
|
||||||
|
/// You can specify desired environment params. Or you can just pass `Default::default()`.
|
||||||
|
pub fn with_emscripten_env(params: emscripten::EnvParams) -> Result<Self, Error> {
|
||||||
Ok(ProgramInstance {
|
Ok(ProgramInstance {
|
||||||
essence: Arc::new(ProgramInstanceEssence::with_env_params(params)?),
|
essence: Arc::new(ProgramInstanceEssence::with_env_params(params)?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new program instance with a custom env module
|
|
||||||
pub fn with_env_module(env_module: Arc<ModuleInstanceInterface>) -> Self {
|
|
||||||
ProgramInstance {
|
|
||||||
essence: Arc::new(ProgramInstanceEssence::with_env_module(env_module)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Instantiate module with validation.
|
/// Instantiate module with validation.
|
||||||
pub fn add_module<'a>(&self, name: &str, module: Module, externals: Option<&'a HashMap<String, Arc<ModuleInstanceInterface + 'a>>>) -> Result<Arc<ModuleInstance>, Error> {
|
pub fn add_module<'a>(&self, name: &str, module: Module, externals: Option<&'a HashMap<String, Arc<ModuleInstanceInterface + 'a>>>) -> Result<Arc<ModuleInstance>, Error> {
|
||||||
let mut module_instance = ModuleInstance::new(Arc::downgrade(&self.essence), name.into(), module)?;
|
let mut module_instance = ModuleInstance::new(Arc::downgrade(&self.essence), name.into(), module)?;
|
||||||
@ -64,8 +61,10 @@ impl ProgramInstance {
|
|||||||
|
|
||||||
impl ProgramInstanceEssence {
|
impl ProgramInstanceEssence {
|
||||||
/// Create new program essence.
|
/// Create new program essence.
|
||||||
pub fn new() -> Result<Self, Error> {
|
pub fn new() -> Self {
|
||||||
ProgramInstanceEssence::with_env_params(emscripten::EnvParams::default())
|
ProgramInstanceEssence {
|
||||||
|
modules: RwLock::new(HashMap::new()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_env_params(env_params: emscripten::EnvParams) -> Result<Self, Error> {
|
pub fn with_env_params(env_params: emscripten::EnvParams) -> Result<Self, Error> {
|
||||||
|
@ -40,7 +40,7 @@ fn import_function() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let external_module = program.add_module("external_module", module1, None).unwrap();
|
let external_module = program.add_module("external_module", module1, None).unwrap();
|
||||||
let main_module = program.add_module("main", module2, None).unwrap();
|
let main_module = program.add_module("main", module2, None).unwrap();
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ fn wrong_import() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let _side_module_instance = program.add_module("side_module", side_module, None).unwrap();
|
let _side_module_instance = program.add_module("side_module", side_module, None).unwrap();
|
||||||
assert!(program.add_module("main", module, None).is_err());
|
assert!(program.add_module("main", module, None).is_err());
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ fn global_get_set() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(50));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(50));
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(58));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(58));
|
||||||
@ -196,7 +196,7 @@ impl UserFunctionExecutor for FunctionExecutor {
|
|||||||
#[test]
|
#[test]
|
||||||
fn native_env_function() {
|
fn native_env_function() {
|
||||||
// create new program
|
// create new program
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::with_emscripten_env(Default::default()).unwrap();
|
||||||
// => env module is created
|
// => env module is created
|
||||||
let env_instance = program.module("env").unwrap();
|
let env_instance = program.module("env").unwrap();
|
||||||
// => linear memory is created
|
// => linear memory is created
|
||||||
@ -256,7 +256,7 @@ fn native_env_function() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn native_env_function_own_memory() {
|
fn native_env_function_own_memory() {
|
||||||
// create program + env module is auto instantiated + env module memory is instantiated (we do not need this)
|
// create program + env module is auto instantiated + env module memory is instantiated (we do not need this)
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::with_emscripten_env(Default::default()).unwrap();
|
||||||
|
|
||||||
struct OwnMemoryReference {
|
struct OwnMemoryReference {
|
||||||
pub memory: RefCell<Option<Arc<MemoryInstance>>>,
|
pub memory: RefCell<Option<Arc<MemoryInstance>>>,
|
||||||
@ -326,7 +326,7 @@ fn native_env_function_own_memory() {
|
|||||||
fn native_env_global() {
|
fn native_env_global() {
|
||||||
// module constructor
|
// module constructor
|
||||||
let module_constructor = |elements| {
|
let module_constructor = |elements| {
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::with_emscripten_env(Default::default()).unwrap();
|
||||||
let env_instance = program.module("env").unwrap();
|
let env_instance = program.module("env").unwrap();
|
||||||
let native_env_instance = Arc::new(env_native_module(env_instance.clone(), elements).unwrap());
|
let native_env_instance = Arc::new(env_native_module(env_instance.clone(), elements).unwrap());
|
||||||
let params = ExecutionParams::with_external("env".into(), native_env_instance);
|
let params = ExecutionParams::with_external("env".into(), native_env_instance);
|
||||||
@ -375,7 +375,7 @@ fn native_env_global() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn native_custom_error() {
|
fn native_custom_error() {
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::with_emscripten_env(Default::default()).unwrap();
|
||||||
let env_instance = program.module("env").unwrap();
|
let env_instance = program.module("env").unwrap();
|
||||||
let env_memory = env_instance.memory(ItemIndex::Internal(0)).unwrap();
|
let env_memory = env_instance.memory(ItemIndex::Internal(0)).unwrap();
|
||||||
let mut executor = FunctionExecutor { memory: env_memory.clone(), values: Vec::new() };
|
let mut executor = FunctionExecutor { memory: env_memory.clone(), values: Vec::new() };
|
||||||
@ -428,7 +428,7 @@ fn native_custom_error() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn import_env_mutable_global() {
|
fn import_env_mutable_global() {
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::with_emscripten_env(Default::default()).unwrap();
|
||||||
|
|
||||||
let module = module()
|
let module = module()
|
||||||
.with_import(ImportEntry::new("env".into(), "STACKTOP".into(), External::Global(GlobalType::new(ValueType::I32, false))))
|
.with_import(ImportEntry::new("env".into(), "STACKTOP".into(), External::Global(GlobalType::new(ValueType::I32, false))))
|
||||||
@ -439,7 +439,7 @@ fn import_env_mutable_global() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn env_native_export_entry_type_check() {
|
fn env_native_export_entry_type_check() {
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::with_emscripten_env(Default::default()).unwrap();
|
||||||
let mut function_executor = FunctionExecutor {
|
let mut function_executor = FunctionExecutor {
|
||||||
memory: program.module("env").unwrap().memory(ItemIndex::Internal(0)).unwrap(),
|
memory: program.module("env").unwrap().memory(ItemIndex::Internal(0)).unwrap(),
|
||||||
values: Vec::new(),
|
values: Vec::new(),
|
||||||
@ -498,7 +498,7 @@ fn memory_import_limits_initial() {
|
|||||||
.with_export(ExportEntry::new("memory".into(), Internal::Memory(0)))
|
.with_export(ExportEntry::new("memory".into(), Internal::Memory(0)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
program.add_module("core", core_module, None).unwrap();
|
program.add_module("core", core_module, None).unwrap();
|
||||||
|
|
||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
@ -535,7 +535,7 @@ fn memory_import_limits_maximum() {
|
|||||||
(None, None, MaximumError::Ok),
|
(None, None, MaximumError::Ok),
|
||||||
];
|
];
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
for test_case in test_cases {
|
for test_case in test_cases {
|
||||||
let (core_maximum, client_maximum, expected_err) = test_case;
|
let (core_maximum, client_maximum, expected_err) = test_case;
|
||||||
let core_module = module()
|
let core_module = module()
|
||||||
@ -566,7 +566,7 @@ fn table_import_limits_initial() {
|
|||||||
.with_export(ExportEntry::new("table".into(), Internal::Table(0)))
|
.with_export(ExportEntry::new("table".into(), Internal::Table(0)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
program.add_module("core", core_module, None).unwrap();
|
program.add_module("core", core_module, None).unwrap();
|
||||||
|
|
||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
@ -603,7 +603,7 @@ fn table_import_limits_maximum() {
|
|||||||
(None, None, MaximumError::Ok),
|
(None, None, MaximumError::Ok),
|
||||||
];
|
];
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
for test_case in test_cases {
|
for test_case in test_cases {
|
||||||
let (core_maximum, client_maximum, expected_err) = test_case;
|
let (core_maximum, client_maximum, expected_err) = test_case;
|
||||||
let core_module = module()
|
let core_module = module()
|
||||||
|
@ -17,7 +17,7 @@ fn make_function_i32(body: Opcodes) -> (ProgramInstance, Arc<ModuleInstanceInter
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
(program, module)
|
(program, module)
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ fn return_void() {
|
|||||||
.body().with_opcodes(body).build()
|
.body().with_opcodes(body).build()
|
||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
|
|
||||||
module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap();
|
module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap();
|
||||||
@ -520,7 +520,7 @@ fn call_1() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(10));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(10));
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ fn call_2() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3628800));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3628800));
|
||||||
}
|
}
|
||||||
@ -612,7 +612,7 @@ fn call_zero_args() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(43));
|
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(43));
|
||||||
}
|
}
|
||||||
@ -658,7 +658,7 @@ fn callindirect_1() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(2, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -731,7 +731,7 @@ fn callindirect_2() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(14));
|
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(14));
|
||||||
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(6));
|
assert_eq!(module.execute_index(3, vec![RuntimeValue::I32(10), RuntimeValue::I32(4), RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(6));
|
||||||
@ -813,7 +813,7 @@ fn select() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(2));
|
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(0)].into()).unwrap().unwrap(), RuntimeValue::I32(2));
|
||||||
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![RuntimeValue::I32(1)].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -966,7 +966,7 @@ fn binary_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(3));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(16));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(16));
|
||||||
@ -1126,7 +1126,7 @@ fn binary_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(16));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(16));
|
||||||
@ -1216,7 +1216,7 @@ fn binary_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(5.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(5.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-9995.500000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-9995.500000));
|
||||||
@ -1298,7 +1298,7 @@ fn binary_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1111111110.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1111111110.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(123400000000000007812762268812638756607430593436581896388608.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(123400000000000007812762268812638756607430593436581896388608.000000));
|
||||||
@ -1351,7 +1351,7 @@ fn cast() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4.5));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4.5));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1067450368)); // 3227516928
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1067450368)); // 3227516928
|
||||||
@ -1617,7 +1617,7 @@ fn compare_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -1907,7 +1907,7 @@ fn compare_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -2091,7 +2091,7 @@ fn compare_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -2263,7 +2263,7 @@ fn compare_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
@ -2331,7 +2331,7 @@ fn convert_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1)); // 4294967295
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1)); // 4294967295
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-100)); // 4294967196
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-100)); // 4294967196
|
||||||
@ -2404,7 +2404,7 @@ fn convert_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4294967295));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4294967295));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1)); // 18446744073709551615
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1)); // 18446744073709551615
|
||||||
@ -2462,7 +2462,7 @@ fn convert_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-1.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-1.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4294967296.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(4294967296.000000));
|
||||||
@ -2519,7 +2519,7 @@ fn convert_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-1.000000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-1.000000));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(4294967295.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(4294967295.000000));
|
||||||
@ -2579,7 +2579,7 @@ fn load_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1));
|
||||||
@ -2655,7 +2655,7 @@ fn load_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(-1));
|
||||||
@ -2685,7 +2685,7 @@ fn load_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(25.750000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(25.750000));
|
||||||
}
|
}
|
||||||
@ -2709,7 +2709,7 @@ fn load_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1023.875000));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(1023.875000));
|
||||||
}
|
}
|
||||||
@ -2766,7 +2766,7 @@ fn store_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-16909061));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-16909061));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-859059511));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-859059511));
|
||||||
@ -2836,7 +2836,7 @@ fn store_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4278058235));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(4278058235));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3435907785));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I64(3435907785));
|
||||||
@ -2864,7 +2864,7 @@ fn store_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1069547520));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1069547520));
|
||||||
}
|
}
|
||||||
@ -2889,7 +2889,7 @@ fn store_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1064352256));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(-1064352256));
|
||||||
}
|
}
|
||||||
@ -2940,7 +2940,7 @@ fn unary_i32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -2995,7 +2995,7 @@ fn unary_i64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
assert_eq!(module.execute_index(0, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(0));
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::I32(1));
|
||||||
@ -3094,7 +3094,7 @@ fn unary_f32() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-100.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(-100.000000));
|
||||||
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(100.000000));
|
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F32(100.000000));
|
||||||
@ -3197,7 +3197,7 @@ fn unary_f64() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let program = ProgramInstance::new().unwrap();
|
let program = ProgramInstance::new();
|
||||||
let module = program.add_module("main", module, None).unwrap();
|
let module = program.add_module("main", module, None).unwrap();
|
||||||
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-100.000000));
|
assert_eq!(module.execute_index(1, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(-100.000000));
|
||||||
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(100.000000));
|
assert_eq!(module.execute_index(2, vec![].into()).unwrap().unwrap(), RuntimeValue::F64(100.000000));
|
||||||
|
@ -11,7 +11,7 @@ fn interpreter_inc_i32() {
|
|||||||
// The WASM file containing the module and function
|
// The WASM file containing the module and function
|
||||||
const WASM_FILE: &str = &"res/cases/v1/inc_i32.wasm";
|
const WASM_FILE: &str = &"res/cases/v1/inc_i32.wasm";
|
||||||
|
|
||||||
let program = ProgramInstance::new().expect("Failed to instanciate program");
|
let program = ProgramInstance::with_emscripten_env(Default::default()).expect("Failed to instanciate program");
|
||||||
|
|
||||||
let module: Module =
|
let module: Module =
|
||||||
deserialize_file(WASM_FILE).expect("Failed to deserialize module from buffer");
|
deserialize_file(WASM_FILE).expect("Failed to deserialize module from buffer");
|
||||||
@ -43,7 +43,7 @@ fn interpreter_accumulate_u8() {
|
|||||||
const BUF: &[u8] = &[9,8,7,6,5,4,3,2,1];
|
const BUF: &[u8] = &[9,8,7,6,5,4,3,2,1];
|
||||||
|
|
||||||
// Declare the memory limits of the runtime-environment
|
// Declare the memory limits of the runtime-environment
|
||||||
let program = ProgramInstance::new().expect("Failed to instanciate program");
|
let program = ProgramInstance::with_emscripten_env(Default::default()).expect("Failed to instanciate program");
|
||||||
|
|
||||||
// Load the module-structure from wasm-file and add to program
|
// Load the module-structure from wasm-file and add to program
|
||||||
let module: Module =
|
let module: Module =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user