Commit c9b13533 authored by qinsoon's avatar qinsoon

linkutils (previously as testutils)

parent ca0d77bf
......@@ -37,4 +37,4 @@ pub extern crate gc;
pub mod vm;
pub mod compiler;
pub mod runtime;
pub mod testutil;
\ No newline at end of file
pub mod linkutils;
\ No newline at end of file
......@@ -12,11 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! This module contains utility functions for linking generated code and
//! running tests for Zebu.
extern crate libloading as ll;
use compiler::*;
use ast::ir::*;
use vm::*;
use std::sync::Arc;
use std::path::PathBuf;
......@@ -24,9 +26,13 @@ use std::process::Command;
use std::process::Output;
use std::os::unix::process::ExitStatusExt;
/// linking utilities for ahead-of-time compilation
pub mod aot;
pub fn get_test_clang_path() -> String {
/// gets a C compiler (for assembling and linking generated assembly code)
/// This function will check CC environment variable and return it.
/// Otherwise, it returns the default C compiler (clang).
fn get_c_compiler() -> String {
use std::env;
match env::var("CC") {
......@@ -35,15 +41,45 @@ pub fn get_test_clang_path() -> String {
}
}
pub fn exec (cmd: Command) -> Output {
let output = exec_nocheck(cmd);
/// concatenates the given path related to Zebu root path
/// This function will check MU_ZEBU environment variable and use it as Zebu root path.
/// Otherwise, it uses the current directory as Zebu root path.
fn get_path_under_zebu(str: &'static str) -> PathBuf {
use std::env;
assert!(output.status.success());
match env::var("MU_ZEBU") {
Ok(v) => {
let mut ret = PathBuf::from(v);
ret.push(str);
ret
}
Err(_) => PathBuf::from(str)
}
}
/// executes the executable of the given path, checks its exit status
/// panics if this executable does not finish normally
pub fn exec_path(executable: PathBuf) -> Output {
let run = Command::new(executable.as_os_str());
exec_cmd(run)
}
/// executes the executable of the given path, does not check exit status
pub fn exec_path_nocheck(executable: PathBuf) -> Output {
let run = Command::new(executable.as_os_str());
exec_cmd_nocheck(run)
}
/// executes the given command, checks its exit status,
/// panics if this command does not finish normally
fn exec_cmd(cmd: Command) -> Output {
let output = exec_cmd_nocheck(cmd);
assert!(output.status.success());
output
}
pub fn exec_nocheck (mut cmd: Command) -> Output {
/// executes the given command, does not check exit status
fn exec_cmd_nocheck(mut cmd: Command) -> Output {
info!("executing: {:?}", cmd);
let output = match cmd.output() {
Ok(res) => res,
......@@ -62,79 +98,14 @@ pub fn exec_nocheck (mut cmd: Command) -> Output {
output
}
pub fn get_path_under_mu(str: &'static str) -> PathBuf {
use std::env;
match env::var("MU_ZEBU") {
Ok(v) => {
let mut ret = PathBuf::from(v);
ret.push(str);
ret
}
Err(_) => PathBuf::from(str)
}
}
/// returns a name for dynamic library
#[cfg(target_os = "macos")]
pub fn get_dylib_name(name: &'static str) -> String {
format!("lib{}.dylib", name)
}
/// returns a name for dynamic library
#[cfg(target_os = "linux")]
pub fn get_dylib_name(name: &'static str) -> String {
format!("lib{}.so", name)
}
pub fn compile_fnc<'a>(fnc_name: &'static str, build_fnc: &'a Fn() -> VM) -> ll::Library {
VM::start_logging_trace();
let vm = Arc::new(build_fnc());
let compiler = Compiler::new(CompilerPolicy::default(), &vm);
let func_id = vm.id_of(fnc_name);
{
let funcs = vm.funcs().read().unwrap();
let func = match funcs.get(&func_id) {
Some(func) => func.read().unwrap(),
None => panic!("cannot find function {}", fnc_name)
};
let cur_ver = match func.cur_ver {
Some(v) => v,
None => panic!("function {} does not have a defined current version", fnc_name)
};
let func_vers = vm.func_vers().read().unwrap();
let mut func_ver = match func_vers.get(&cur_ver) {
Some(fv) => fv.write().unwrap(),
None => panic!("cannot find function version {}", cur_ver)
};
compiler.compile(&mut func_ver);
}
backend::emit_context(&vm);
let libname = &get_dylib_name(fnc_name);
let dylib = aot::link_dylib(vec![Mu(fnc_name)], libname, &vm);
ll::Library::new(dylib.as_os_str()).unwrap()
}
pub fn compile_fncs<'a>(entry: &'static str, fnc_names: Vec<&'static str>, build_fnc: &'a Fn() -> VM) -> ll::Library {
VM::start_logging_trace();
let vm = Arc::new(build_fnc());
let compiler = Compiler::new(CompilerPolicy::default(), &vm);
for func in fnc_names.iter() {
let func_id = vm.id_of(func);
let funcs = vm.funcs().read().unwrap();
let func = funcs.get(&func_id).unwrap().read().unwrap();
let func_vers = vm.func_vers().read().unwrap();
let mut func_ver = func_vers.get(&func.cur_ver.unwrap()).unwrap().write().unwrap();
compiler.compile(&mut func_ver);
}
backend::emit_context(&vm);
let libname = &get_dylib_name(entry);
let dylib = aot::link_dylib(fnc_names.iter().map(|x| Mu(x)).collect(), libname, &vm);
ll::Library::new(dylib.as_os_str()).unwrap()
}
}
\ No newline at end of file
......@@ -92,7 +92,7 @@ impl MuVM {
extern crate libloading as ll;
use compiler::*;
use testutil::aot;
use linkutils::aot;
let funcs : Vec<MuID> = {
let funcs = self.vm.funcs().read().unwrap();
......
......@@ -978,7 +978,7 @@ impl <'a> VM {
/// has dylib extension, otherwise generates an executable)
#[cfg(feature = "aot")]
fn link_boot_image(&self, funcs: Vec<MuID>, extra_srcs: Vec<String>, output_file: String) {
use testutil;
use linkutils;
info!("Linking boot image...");
......@@ -993,13 +993,13 @@ impl <'a> VM {
if output_file.ends_with("dylib") || output_file.ends_with("so") {
// compile as dynamic library
testutil::aot::link_dylib_with_extra_srcs(func_names, extra_srcs, &output_file, self);
linkutils::aot::link_dylib_with_extra_srcs(func_names, extra_srcs, &output_file, self);
} else {
if extra_srcs.len() != 0 {
panic!("trying to create an executable with linking extern sources, unimplemented");
}
// compile as executable
testutil::aot::link_primordial(func_names, &output_file, self);
linkutils::aot::link_primordial(func_names, &output_file, self);
}
trace!("Done!");
......
......@@ -26,8 +26,8 @@ use self::mu::utils::Address;
use self::mu::utils::LinkedHashMap;
use std::sync::Arc;
use self::mu::testutil;
use self::mu::testutil::aot;
use self::mu::linkutils;
use self::mu::linkutils::aot;
#[test]
fn test_allocation_fastpath() {
......@@ -51,7 +51,7 @@ fn test_allocation_fastpath() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec!["allocation_fastpath".to_string()], "allocation_fastpath_test", &vm);
aot::execute(executable);
linkutils::exec_path(executable);
}
fn allocation_fastpath() -> VM {
......@@ -125,7 +125,7 @@ fn test_instruction_new() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec!["alloc_new".to_string()], "alloc_new_test", &vm);
aot::execute(executable);
linkutils::exec_path(executable);
}
#[allow(dead_code)]
......@@ -153,7 +153,7 @@ fn test_instruction_new_on_cur_thread() {
backend::emit_context(&vm);
// link
let libname = &testutil::get_dylib_name("alloc_new_on_cur_thread");
let libname = &linkutils::get_dylib_name("alloc_new_on_cur_thread");
let dylib = aot::link_dylib(vec![Mu("alloc_new")], libname, &vm);
let lib = libloading::Library::new(dylib.as_os_str()).unwrap();
......
......@@ -21,12 +21,12 @@ use self::mu::ast::ir::*;
use self::mu::ast::inst::*;
use self::mu::ast::op::*;
use self::mu::vm::*;
use self::mu::testutil;
use self::mu::linkutils;
use mu::utils::LinkedHashMap;
#[test]
fn test_udiv() {
let lib = testutil::compile_fnc("udiv", &udiv);
let lib = linkutils::aot::compile_fnc("udiv", &udiv);
unsafe {
let udiv : libloading::Symbol<unsafe extern fn(u64, u64) -> u64> = lib.get(b"udiv").unwrap();
......@@ -76,7 +76,7 @@ fn udiv() -> VM {
#[test]
fn test_sdiv() {
let lib = testutil::compile_fnc("sdiv", &sdiv);
let lib = linkutils::aot::compile_fnc("sdiv", &sdiv);
unsafe {
let sdiv : libloading::Symbol<unsafe extern fn(i64, i64) -> i64> = lib.get(b"sdiv").unwrap();
......@@ -130,7 +130,7 @@ fn sdiv() -> VM {
#[test]
fn test_shl() {
let lib = testutil::compile_fnc("shl", &shl);
let lib = linkutils::aot::compile_fnc("shl", &shl);
unsafe {
let shl : libloading::Symbol<unsafe extern fn(u64, u8) -> u64> = lib.get(b"shl").unwrap();
......@@ -184,7 +184,7 @@ fn shl() -> VM {
#[test]
fn test_lshr() {
let lib = testutil::compile_fnc("lshr", &lshr);
let lib = linkutils::aot::compile_fnc("lshr", &lshr);
unsafe {
let lshr : libloading::Symbol<unsafe extern fn(u64, u8) -> u64> = lib.get(b"lshr").unwrap();
......@@ -234,7 +234,7 @@ fn lshr() -> VM {
#[test]
fn test_add_simple() {
let lib = testutil::compile_fnc("add", &add);
let lib = linkutils::aot::compile_fnc("add", &add);
unsafe {
let add : libloading::Symbol<unsafe extern fn(u64, u64) -> u64> = lib.get(b"add").unwrap();
......@@ -279,7 +279,7 @@ fn add() -> VM {
#[test]
fn test_add_int64_n() {
let lib = testutil::compile_fnc("add_int64_n", &add_int64_n);
let lib = linkutils::aot::compile_fnc("add_int64_n", &add_int64_n);
unsafe {
let add_int64_n : libloading::Symbol<unsafe extern fn(i64, i64) -> u8> = lib.get(b"add_int64_n").unwrap();
......@@ -338,7 +338,7 @@ fn add_int64_n() -> VM {
#[test]
fn test_add_int64_z() {
let lib = testutil::compile_fnc("add_int64_z", &add_int64_z);
let lib = linkutils::aot::compile_fnc("add_int64_z", &add_int64_z);
unsafe {
let add_int64_z : libloading::Symbol<unsafe extern fn(i64, i64) -> u8> = lib.get(b"add_int64_z").unwrap();
......@@ -395,7 +395,7 @@ fn add_int64_z() -> VM {
fn test_add_int64_c() {
use std::u64;
let lib = testutil::compile_fnc("add_int64_c", &add_int64_c);
let lib = linkutils::aot::compile_fnc("add_int64_c", &add_int64_c);
unsafe {
let add_int64_c : libloading::Symbol<unsafe extern fn(u64, u64) -> u8> = lib.get(b"add_int64_c").unwrap();
......@@ -448,7 +448,7 @@ fn add_int64_c() -> VM {
fn test_add_int64_v() {
use std::i64;
let lib = testutil::compile_fnc("add_int64_v", &add_int64_v);
let lib = linkutils::aot::compile_fnc("add_int64_v", &add_int64_v);
unsafe {
let add_int64_v : libloading::Symbol<unsafe extern fn(i64, i64) -> u8> = lib.get(b"add_int64_v").unwrap();
......@@ -509,7 +509,7 @@ fn add_int64_v() -> VM {
fn test_add_int64_nzc() {
use std::u64;
let lib = testutil::compile_fnc("add_int64_nzc", &add_int64_nzc);
let lib = linkutils::aot::compile_fnc("add_int64_nzc", &add_int64_nzc);
unsafe {
let add_int64_nzc : libloading::Symbol<unsafe extern fn(u64, u64) -> u8> = lib.get(b"add_int64_nzc").unwrap();
......
......@@ -23,8 +23,8 @@ use mu::vm::*;
use mu::compiler::*;
use std::sync::Arc;
use mu::testutil;
use mu::testutil::aot;
use mu::linkutils;
use mu::linkutils::aot;
use mu::utils::LinkedHashMap;
// NOTE: aarch64 has 2 more parameter registers than x86-64 so it needs different test cases for stack arguments
......@@ -51,7 +51,7 @@ fn test_ccall_exit() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec!["ccall_exit".to_string()], "ccall_exit_test", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
assert!(output.status.code().is_some());
......@@ -144,7 +144,7 @@ fn test_pass_1arg_by_stack() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("foo7"), Mu("pass_1arg_by_stack")], "test_pass_1arg_by_stack", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// exit with (1)
assert!(output.status.code().is_some());
......@@ -387,7 +387,7 @@ fn test_pass_2args_by_stack() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("foo8"), Mu("pass_2args_by_stack")], "test_pass_2args_by_stack", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// exit with (2)
assert!(output.status.code().is_some());
......@@ -638,7 +638,7 @@ fn test_pass_2_int8_args_by_stack() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("foo8"), Mu("pass_2_int8_args_by_stack")], "test_pass_2_int8_args_by_stack", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// exit with (2)
assert!(output.status.code().is_some());
......@@ -906,7 +906,7 @@ fn test_pass_mixed_args_by_stack() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("foo8"), Mu("pass_mixed_args_by_stack")], "test_pass_mixed_args_by_stack", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// exit with (2)
assert!(output.status.code().is_some());
......@@ -1137,7 +1137,7 @@ fn pass_mixed_args_by_stack() -> VM {
#[test]
fn test_pass_fp_arg() {
let lib = testutil::compile_fncs("pass_fp_arg", vec!["pass_fp_arg", "foo"], &pass_fp_arg);
let lib = linkutils::aot::compile_fncs("pass_fp_arg", vec!["pass_fp_arg", "foo"], &pass_fp_arg);
unsafe {
let pass_fp_arg : libloading::Symbol<unsafe extern fn (f64) -> f64> = lib.get(b"pass_fp_arg").unwrap();
......@@ -1214,7 +1214,7 @@ fn pass_fp_arg() -> VM {
#[test]
fn test_store_funcref() {
let lib = testutil::compile_fncs("store_funcref", vec!["store_funcref", "foo"], &store_funcref);
let lib = linkutils::aot::compile_fncs("store_funcref", vec!["store_funcref", "foo"], &store_funcref);
unsafe {
use mu::utils::mem::memsec::malloc;
......@@ -1342,7 +1342,7 @@ fn test_call_int128_arg() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("add_u128"), Mu("call_add_u128")], "test_call_int128_arg", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// exit with (84)
assert!(output.status.code().is_some());
......
......@@ -17,11 +17,11 @@ extern crate mu;
use test_ir::test_ir::sum;
use test_ir::test_ir::factorial;
use mu::testutil;
use mu::linkutils;
#[test]
fn test_factorial() {
let lib = testutil::compile_fnc("fac", &factorial);
let lib = linkutils::aot::compile_fnc("fac", &factorial);
unsafe {
let fac: ll::Symbol<unsafe extern fn (u64) -> u64> = lib.get(b"fac").unwrap();
println!("fac(10) = {}", fac(10));
......@@ -31,7 +31,7 @@ fn test_factorial() {
#[test]
fn test_sum() {
let lib = testutil::compile_fnc("sum", &sum);
let lib = linkutils::aot::compile_fnc("sum", &sum);
unsafe {
let sumptr: ll::Symbol<unsafe extern fn (u64) -> u64> = lib.get(b"sum").unwrap();
println!("sum(5) = {}", sumptr(5));
......
......@@ -19,12 +19,12 @@ use mu::ast::ir::*;
use mu::ast::inst::*;
use mu::ast::op::*;
use mu::vm::*;
use mu::testutil;
use mu::linkutils;
use mu::utils::LinkedHashMap;
#[test]
fn test_switch() {
let lib = testutil::compile_fnc("switch", &switch);
let lib = linkutils::aot::compile_fnc("switch", &switch);
unsafe {
let switch : libloading::Symbol<unsafe extern fn(u64) -> u64> = lib.get(b"switch").unwrap();
......@@ -152,7 +152,7 @@ fn switch() -> VM {
#[test]
fn test_select_eq_zero() {
let lib = testutil::compile_fnc("select_eq_zero", &select_eq_zero);
let lib = linkutils::aot::compile_fnc("select_eq_zero", &select_eq_zero);
unsafe {
let select_eq_zero : libloading::Symbol<unsafe extern fn(u64) -> u64> = lib.get(b"select_eq_zero").unwrap();
......@@ -210,7 +210,7 @@ fn select_eq_zero() -> VM {
#[test]
fn test_select_u8_eq_zero() {
let lib = testutil::compile_fnc("select_u8_eq_zero", &select_u8_eq_zero);
let lib = linkutils::aot::compile_fnc("select_u8_eq_zero", &select_u8_eq_zero);
unsafe {
let select_eq_zero : libloading::Symbol<unsafe extern fn(u8) -> u8> = lib.get(b"select_u8_eq_zero").unwrap();
......@@ -268,7 +268,7 @@ fn select_u8_eq_zero() -> VM {
#[test]
fn test_select_sge_zero() {
let lib = testutil::compile_fnc("select_sge_zero", &select_sge_zero);
let lib = linkutils::aot::compile_fnc("select_sge_zero", &select_sge_zero);
unsafe {
let select_sge_zero : libloading::Symbol<unsafe extern fn(i64) -> u64> = lib.get(b"select_sge_zero").unwrap();
......@@ -330,7 +330,7 @@ fn select_sge_zero() -> VM {
#[test]
fn test_sgt_value() {
let lib = testutil::compile_fnc("sgt_value", &sgt_value);
let lib = linkutils::aot::compile_fnc("sgt_value", &sgt_value);
unsafe {
let sgt_value : libloading::Symbol<unsafe extern fn(i64, i64) -> u8> = lib.get(b"sgt_value").unwrap();
......@@ -386,7 +386,7 @@ fn sgt_value() -> VM {
#[test]
fn test_sgt_u8_value() {
let lib = testutil::compile_fnc("sgt_u8_value", &sgt_u8_value);
let lib = linkutils::aot::compile_fnc("sgt_u8_value", &sgt_u8_value);
unsafe {
let sgt_u8_value : libloading::Symbol<unsafe extern fn(i8, i8) -> u8> = lib.get(b"sgt_u8_value").unwrap();
......@@ -454,7 +454,7 @@ fn sgt_u8_value() -> VM {
#[test]
fn test_sgt_i32_branch() {
let lib = testutil::compile_fnc("sgt_i32_branch", &sgt_i32_branch);
let lib = linkutils::aot::compile_fnc("sgt_i32_branch", &sgt_i32_branch);
unsafe {
let sgt_i32 : libloading::Symbol<unsafe extern fn(i32, i32) -> u32> = lib.get(b"sgt_i32_branch").unwrap();
......@@ -565,7 +565,7 @@ fn sgt_i32_branch() -> VM {
#[test]
fn test_sge_i32_branch() {
let lib = testutil::compile_fnc("sge_i32_branch", &sge_i32_branch);
let lib = linkutils::aot::compile_fnc("sge_i32_branch", &sge_i32_branch);
unsafe {
let sge_i32 : libloading::Symbol<unsafe extern fn(i32, i32) -> u32> = lib.get(b"sge_i32_branch").unwrap();
......@@ -676,7 +676,7 @@ fn sge_i32_branch() -> VM {
#[test]
fn test_branch2_eq_50p_1() {
let lib = testutil::compile_fnc("branch2_eq_50p_1", &branch2_eq_50p_1);
let lib = linkutils::aot::compile_fnc("branch2_eq_50p_1", &branch2_eq_50p_1);
unsafe {
let branch2_eq_50p : libloading::Symbol<unsafe extern fn(u8) -> (u64)> = lib.get(b"branch2_eq_50p_1").unwrap();
......@@ -761,7 +761,7 @@ fn branch2_eq_50p_1() -> VM {
#[test]
fn test_branch2_eq_50p_2() {
let lib = testutil::compile_fnc("branch2_eq_50p_2", &branch2_eq_50p_2);
let lib = linkutils::aot::compile_fnc("branch2_eq_50p_2", &branch2_eq_50p_2);
unsafe {
let branch2_eq_50p : libloading::Symbol<unsafe extern fn(u8) -> (u64)> = lib.get(b"branch2_eq_50p_2").unwrap();
......@@ -846,7 +846,7 @@ fn branch2_eq_50p_2() -> VM {
#[test]
fn test_branch2_high_prob_branch_cannot_fallthrough() {
let lib = testutil::compile_fnc("branch2", &branch2_high_prob_branch_cannot_fallthrough);
let lib = linkutils::aot::compile_fnc("branch2", &branch2_high_prob_branch_cannot_fallthrough);
unsafe {
let branch2 : libloading::Symbol<unsafe extern fn(u8) -> (u64)> = lib.get(b"branch2").unwrap();
......
......@@ -21,12 +21,12 @@ use self::mu::ast::ir::*;
use self::mu::ast::inst::*;
use self::mu::ast::op::*;
use self::mu::vm::*;
use self::mu::testutil;
use self::mu::linkutils;
use mu::utils::LinkedHashMap;
#[test]
fn test_truncate_then_call() {
let lib = testutil::compile_fncs("truncate_then_call", vec!["truncate_then_call", "dummy_call"], &truncate_then_call);
let lib = linkutils::aot::compile_fncs("truncate_then_call", vec!["truncate_then_call", "dummy_call"], &truncate_then_call);
unsafe {
let truncate_then_call : libloading::Symbol<unsafe extern fn(u64) -> u32> = lib.get(b"truncate_then_call").unwrap();
......
......@@ -23,7 +23,8 @@ use mu::vm::*;
use mu::compiler::*;
use mu::utils::LinkedHashMap;
use mu::testutil::aot;
use mu::linkutils;
use mu::linkutils::aot;
use test_compiler::test_call::gen_ccall_exit;
......@@ -60,7 +61,7 @@ fn test_exception_throw_catch_simple() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("throw_exception"), Mu("catch_exception")], "throw_catch_simple_test", &vm);
aot::execute(executable);
linkutils::exec_path(executable);
}
fn declare_commons(vm: &VM) {
......@@ -222,7 +223,7 @@ fn test_exception_throw_catch_dont_use_exception_arg() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("throw_exception"), Mu("catch_exception")], "throw_catch_simple_test", &vm);
aot::execute(executable);
linkutils::exec_path(executable);
}
fn throw_catch_dont_use_exception_arg() -> VM {
......@@ -267,7 +268,7 @@ fn test_exception_throw_catch_and_add() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("throw_exception"), Mu("catch_and_add")], "throw_catch_and_add", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// throw 1, add 0, 1, 2, 3, 4
assert!(output.status.code().is_some());
......@@ -480,7 +481,7 @@ fn test_exception_throw_catch_twice() {
backend::emit_context(&vm);
let executable = aot::link_primordial(vec![Mu("throw_exception"), Mu("catch_twice")], "throw_catch_twice", &vm);
let output = aot::execute_nocheck(executable);
let output = linkutils::exec_path_nocheck(executable);
// throw 1 twice, add 1 and 1 (equals 2)
assert!(output.status.code().is_some());
......
......@@ -21,12 +21,12 @@ use self::mu::ast::ir::*;
use self::mu::ast::inst::*;
use self::mu::ast::op::*;
use self::mu::vm::*;
use self::mu::testutil;
use self::mu::linkutils;
use mu::utils::LinkedHashMap;
#[test]
fn test_double_add() {
let lib = testutil::compile_fnc("double_add", &double_add);
let lib = linkutils::aot::compile_fnc("double_add", &double_add);
unsafe {
let double_add : libloading::Symbol<unsafe extern fn(f64, f64) -> f64> = lib.get(b"double_add").unwrap();
......@@ -76,7 +76,7 @@ fn double_add() -> VM {
#[test]
fn test_float_add() {
let lib = testutil::compile_fnc("float_add", &float_add);
let lib = linkutils::aot::compile_fnc("float_add", &float_add);
unsafe {
let float_add : libloading::Symbol<unsafe extern fn(f32, f32) -> f32> = lib.get(b"float_add").unwrap();
......@@ -126,7 +126,7 @@ fn float_add() -> VM {
#[test]
fn test_fp_ogt_branch() {
let lib = testutil::compile_fnc("fp_ogt_branch", &fp_ogt_branch);
let lib = linkutils::aot::compile_fnc("fp_ogt_branch", &fp_ogt_branch);
unsafe {
let fp_ogt : libloading::Symbol<unsafe extern fn(f64, f64) -> u32> = lib.get(b"fp_ogt_branch").unwrap();
......@@ -230,7 +230,7 @@ fn fp_ogt_branch() -> VM {
#[test]
fn test_sitofp() {
let lib = testutil::compile_fnc("sitofp", &sitofp);
let lib = linkutils::aot::compile_fnc("sitofp", &sitofp);
unsafe {
let sitofp : libloading::Symbol<unsafe extern fn(i64) -> f64> = lib.get(b"sitofp").unwrap();
......@@ -283,7 +283,7 @@ fn sitofp() -> VM {
#[test]
fn test_ui64tofp() {
let lib = testutil::compile_fnc("ui64tofp", &ui64tofp);
let lib = linkutils::aot::compile_fnc("ui64tofp", &ui64tofp);
unsafe {
let ui64tofp : libloading::Symbol<unsafe extern fn(u64) -> f64> = lib.get(b"ui64tofp").unwrap();
......@@ -332,7 +332,7 @@ fn ui64tofp() -> VM {
#[test]
fn test_ui64tofp_float() {
let lib = testutil::compile_fnc("ui64tofp_float", &ui64tofp_float);
let lib = linkutils::aot::compile_fnc("ui64tofp_float", &ui64tofp_float);
unsafe {
let ui64tofp_float : libloading::Symbol<unsafe extern fn(u64) -> f32> = lib.get(b"ui64tofp_float").unwrap();
......@@ -381,7 +381,7 @@ fn ui64tofp_float() -> VM {
#[test]
fn test_ui32tofp() {
let lib = testutil::compile_fnc("ui32tofp", &ui32tofp);
let lib = linkutils::aot::compile_fnc("ui32tofp", &ui32tofp);
unsafe {
let ui32tofp : libloading::Symbol<unsafe extern fn(u32) -> f64> = lib.get(b"ui32tofp").unwrap();
......@@ -430,7 +430,7 @@ fn ui32tofp() -> VM {
#[test]
fn test_ui16tofp() {
let lib = testutil::compile_fnc("ui16tofp", &ui16tofp);
let lib = linkutils::aot::compile_fnc("ui16tofp", &ui16tofp);
unsafe {
let ui16tofp : libloading::Symbol<unsafe extern fn(u16) -> f64> = lib.get(b"ui16tofp").unwrap();
......@@ -479,7 +479,7 @@ fn ui16tofp() -> VM {
#[test]
fn test_ui8tofp() {
let lib = testutil::compile_fnc("ui8tofp", &ui8tofp);
let lib = linkutils::aot::compile_fnc("ui8tofp", &ui8tofp);
unsafe {
let ui8tofp : libloading::Symbol<unsafe extern fn(u8) -> f64> = lib.get(b"ui8tofp").unwrap();
......@@ -528,7 +528,7 @@ fn ui8tofp() -> VM {
#[test]
fn test_fptoui64() {
let lib = testutil::compile_fnc("fptoui64", &fptoui64);
let lib = linkutils::aot::compile_fnc("fptoui64", &fptoui64);
unsafe {
let fptoui64 : libloading::Symbol<unsafe extern fn(f64) -> u64> = lib.get(b"fptoui64").unwrap();
......@@ -577,7 +577,7 @@ fn fptoui64() -> VM {
#[test]
fn test_fptoui32() {