GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Working test groups: binop, floating_point, alloc

parent edd644e3
......@@ -27,6 +27,7 @@ default = ["aot"]
aot = []
jit = []
sel4-rumprun = []
sel4-rumprun-target-side = []
[build-dependencies]
gcc = "0.3"
......@@ -34,8 +35,7 @@ gcc = "0.3"
[dependencies]
ast = {path = "src/ast"}
utils = {path = "src/utils"}
gc = {path = "src/gc"}
#gc = {path = "src/gc"}
field-offset = "0.1.1"
libloading = "0.3"
......@@ -52,3 +52,12 @@ docopt = "0.6"
petgraph = "0.4.1"
extprim = "*"
num-traits = "*"
[target.x86_64-unknown-linux-gnu.dependencies]
gc = { path = "src/gc", default-features = false}
[target.x86_64-apple-darwin.dependencies]
gc = { path = "src/gc", default-features = false}
[target.x86_64-rumprun-netbsd.dependencies]
gc = { path = "src/gc", default-features = false, features = ["sel4-rumprun-target-side"], target = "x86_64-rumprun-netbsd"}
......@@ -13,7 +13,9 @@
// limitations under the License.
extern crate gcc;
use std::env;
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(target_arch = "x86_64")]
fn main() {
......@@ -24,6 +26,7 @@ fn main() {
.compile("libswap_stack.a");
}
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[cfg(target_os = "linux")]
#[cfg(target_arch = "aarch64")]
fn main() {
......@@ -35,6 +38,7 @@ fn main() {
}
// This is here to enable cross compiling from windows/x86_64 to linux/aarch64
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[cfg(target_os = "windows")]
#[cfg(target_arch = "x86_64")]
fn main() {
......@@ -45,9 +49,14 @@ fn main() {
.compile("libswap_stack.a");
}
#[cfg(feature = "sel4-rumprun")]
//#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
#[cfg(feature = "sel4-rumprun-target-side")]
#[cfg(target_arch = "x86_64")]
fn main() {
// env::set_var("ZEBU_TARGET", "x86_64-rumprun-netbsd");
// println!("*****ENV VAR SET*****");
use std::path::Path;
let mut compiler_name = String::new();
compiler_name.push_str("x86_64-rumprun-netbsd-gcc");
gcc::Config::new().flag("-O3").flag("-c")
......@@ -56,10 +65,10 @@ fn main() {
.compile("libruntime.a");
gcc::Config::new().flag("-O3").flag("-c")
.compiler(Path::new(compiler_name.as_str()))
.file("src/runtime/swap_stack_x64_sysv.S")
.file("src/runtime/swap_stack_x64_sel4_rumprun_sysv.S")
.compile("libswap_stack.a");
gcc::Config::new().flag("-O3").flag("-c")
.compiler(Path::new(compiler_name.as_str()))
.file("c_helpers.c")
.compile("libc_helpers.a");
.file("zebu_c_helpers.c")
.compile("libzebu_c_helpers.a");
}
\ No newline at end of file
#!/usr/bin/env bash
export ZEBU_TARGET=x86_64-rumprun-netbsd
cd ././../rumprun-sel4/
bash clean_and_build.sh
\ No newline at end of file
This diff is collapsed.
......@@ -802,7 +802,7 @@ impl Value {
}
const DISPLAY_ID : bool = true;
const DISPLAY_TYPE : bool = false;
const DISPLAY_TYPE : bool = true;
const PRINT_ABBREVIATE_NAME: bool = true;
impl fmt::Debug for Value {
......
......@@ -2790,6 +2790,7 @@ fn write_const_value(f: &mut File, constant: P<Value>) {
}
}
use std::collections::HashMap;
pub fn emit_context_with_reloc(vm: &VM,
......
......@@ -15,6 +15,7 @@
#![allow(unused_variables)]
use compiler::backend::AOT_EMIT_CONTEXT_FILE;
use compiler::backend::AOT_EMIT_SYM_TABLE_FILE;
use compiler::backend::RegGroup;
use utils::ByteSize;
use utils::Address;
......@@ -2998,6 +2999,7 @@ impl CodeGenerator for ASMCodeGen {
self.add_asm_branch2(asm, dest_name);
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "macos")]
fn emit_call_near_rel32(&mut self, callsite: String, func: MuName, pe: Option<MuName>) -> ValueLocation {
trace!("emit: call {}", func);
......@@ -3012,6 +3014,7 @@ impl CodeGenerator for ASMCodeGen {
ValueLocation::Relocatable(RegGroup::GPR, callsite)
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "linux")]
// generating Position-Independent Code using PLT
fn emit_call_near_rel32(&mut self, callsite: String, func: MuName, pe: Option<MuName>) -> ValueLocation {
......@@ -3436,11 +3439,14 @@ fn write_const_min_align(f: &mut File) {
write_align(f, MIN_ALIGN);
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "linux")]
fn write_align(f: &mut File, align: ByteSize) {
use std::io::Write;
f.write_fmt(format_args!("\t.align {}\n", check_min_align(align))).unwrap();
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "macos")]
fn write_align(f: &mut File, align: ByteSize) {
use std::io::Write;
......@@ -3524,6 +3530,128 @@ fn write_const_value(f: &mut File, constant: P<Value>) {
}
}
#[cfg(not(feature = "sel4-rumprun"))]
pub fn emit_sym_table(vm: &VM) {
debug!("Currently nothing to emit for --!");
}
#[cfg(feature = "sel4-rumprun")]
pub fn emit_sym_table(vm: &VM){
use std::path;
use std::io::Write;
// Javad-cross-compile
// code to generate an asm file to resolve symbol addresses at link time!
// in this stage, a single sym_file is generated for each test
// these sym_files will be merged in build.rs\
// in the parent directory of sel4 side
//**************************************************
// Code starts here
// first create the asm file in the correct path
// _st added file name and path stands for _SymTable
// *************************************************
debug!("Going to emit Sym table for sel4-rumprun");
let mut file_path_st = path::PathBuf::new();
file_path_st.push(&vm.vm_options.flag_aot_emit_dir);
//just the file name is changed compared to context.s
// vm file name is: "fnID_sym_table.s"
file_path_st.push(format!("{}", AOT_EMIT_SYM_TABLE_FILE));
let mut file_st = match File::create(file_path_st.as_path()) {
Err(why) => panic!("couldn't create SYM TABLE file {}: {}", file_path_st.to_str().unwrap(), why),
Ok(file) => file
};
// **************************************************
// fnID_sym_table.s is created, but it's empty
// *************************************************
// **************************************************
// Code for exporting all of the required symbols \
// in vm, using the following fields:
// compiled_funcs.CompiledFunction.start
// compiled_funcs.CompiledFunction.end
// compiled_funcs.CompiledFunction.Frame. \
// exception_callsites[iter](src,_)
// compiled_funcs.CompiledFunction.Frame. \
// exception_callsites[iter](_,dest)
// ret
// *************************************************
let mut sym_vec: Vec<String> = Vec::new();
let compiled_funcs : &HashMap<_, _> = &vm.compiled_funcs().read().unwrap();
debug!("Number of Compiled functions: {}\n", compiled_funcs.len());
for (theID, theCFs) in compiled_funcs.iter() {
let theCF : &CompiledFunction = &theCFs.read().unwrap();
debug!("new theCF\n");
match theCF.start {
// CF.start can only be relocatable , otherwise panic
ValueLocation::Relocatable(_, ref symbol) => {
debug!("theCF.start, symbol = {}\n", *symbol);
sym_vec.push((*symbol).clone());
},
// CF.start can't reach this state
_ => panic!("Sym_Table_start: expecting Relocatable location, found {}", theCF.start)
}
match theCF.end {
// CF.start can only be relocatable , otherwise panic
ValueLocation::Relocatable(_, ref symbol) => {
debug!("theCF.end, symbol = {}\n", *symbol);
sym_vec.push((*symbol).clone());
},
// CF.end can't reach this state
_ => panic!("Sym_Table_end: expecting Relocatable location, found {}", theCF.end)
}
debug!("Number of exp callsites = {}\n", theCF.frame.get_exception_callsites().len());
for &(ref callsite, ref dest) in theCF.frame.get_exception_callsites().iter(){
debug!("exception callsite, step 1\n");
match *callsite {
ValueLocation::Relocatable(_, ref symbol) => {
debug!("exception callsite, step 2, callsite symbol = {}\n", *symbol);
sym_vec.push((*symbol).clone());
},
// can't reach this state
_ => panic!("Sym_Table_callsite: expecting Relocatable location, found {}", callsite)
}
match *dest {
ValueLocation::Relocatable(_, ref symbol) => {
debug!("exception callsite, step 3, dest symbol = {}\n", *symbol);
sym_vec.push((*symbol).clone());
},
// can't reach this state
_ => panic!("Sym_Table_callsite: expecting Relocatable location, found {}", dest)
}
}
}
// **************************************************
// To generate the following code
// .data
// .globl mu_sym_table
// mu_sym_table:
// for each symbol {
// .quad "symbol_name".length()
// __symbol_name:
// .ascii "symbol_name"
// .quad 0
// }
// *************************************************
file_st.write("\t.data\n".as_bytes()).unwrap();
file_st.write_fmt(format_args!("\t{}\n", directive_globl("mu_sym_table".to_string()))).unwrap();
file_st.write_fmt(format_args!("mu_sym_table:\n")).unwrap();
file_st.write_fmt(format_args!(".quad {}\n", sym_vec.len())).unwrap();
for i in 0..sym_vec.len(){
file_st.write_fmt(format_args!(".quad {}\n", sym_vec[i].len())).unwrap();
file_st.write_fmt(format_args!(".ascii \"{}\"\n", sym_vec[i])).unwrap();
// file_st.write_fmt(format_args!("__{}:\n", sym_vec[i])).unwrap();
file_st.write_fmt(format_args!(".quad {}\n", sym_vec[i])).unwrap();
}
//**************************************************
// Javad's code for generating sym_table ends here
// __
// *************************************************
}
use std::collections::HashMap;
use compiler::backend::code_emission::emit_mu_types;
......@@ -3669,6 +3797,8 @@ pub fn emit_context_with_reloc(vm: &VM,
// let primordial = primordial.as_ref().unwrap();
// }
emit_sym_table(vm);
debug!("---finish---");
}
......@@ -3706,14 +3836,18 @@ fn directive_comm(name: String, size: ByteSize, align: ByteSize) -> String {
format!(".comm {},{},{}", name, size, align)
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "linux")]
pub fn symbol(name: String) -> String {
name
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "macos")]
pub fn symbol(name: String) -> String {
format!("_{}", name)
}
// same as Linux
#[cfg(feature = "sel4-rumprun")]
pub fn symbol(name: String) -> String {
......@@ -3722,11 +3856,13 @@ pub fn symbol(name: String) -> String {
#[allow(dead_code)]
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "linux")]
pub fn pic_symbol(name: String) -> String {
format!("{}@GOTPCREL", name)
}
#[allow(dead_code)]
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(target_os = "macos")]
pub fn pic_symbol(name: String) -> String {
symbol(name)
......
......@@ -3943,15 +3943,15 @@ impl <'a> InstructionSelection {
self.backend.emit_mov_r64_imm64(&tmp_h, vals[1] as i64);
},
&Constant::FuncRef(func_id) => {
if cfg!(target_os = "macos") {
if cfg!(feature = "sel4-rumprun") {
let mem = self.get_mem_for_funcref(func_id, vm);
self.backend.emit_mov_r_mem(&tmp, &mem);
} else if cfg!(target_os = "macos") {
let mem = self.get_mem_for_funcref(func_id, vm);
self.backend.emit_lea_r64(&tmp, &mem);
} else if cfg!(target_os = "linux") {
let mem = self.get_mem_for_funcref(func_id, vm);
self.backend.emit_mov_r_mem(&tmp, &mem);
} else if cfg!(feature = "sel4-rumprun") {
let mem = self.get_mem_for_funcref(func_id, vm);
self.backend.emit_mov_r_mem(&tmp, &mem);
} else {
unimplemented!()
}
......@@ -4117,17 +4117,7 @@ impl <'a> InstructionSelection {
unimplemented!()
} else {
// symbolic
if cfg!(target_os = "macos") {
P(Value {
hdr: MuEntityHeader::unnamed(vm.next_id()),
ty: types::get_referent_ty(&pv.ty).unwrap(),
v: Value_::Memory(MemoryLocation::Symbolic {
base: Some(x86_64::RIP.clone()),
label: pv.name().unwrap(),
is_global: true,
})
})
} else if cfg!(target_os = "linux") {
if cfg!(feature = "sel4-rumprun") {
// for a(%RIP), we need to load its address from a@GOTPCREL(%RIP)
// then load from the address.
// asm_backend will emit a@GOTPCREL(%RIP) for a(%RIP)
......@@ -4146,7 +4136,17 @@ impl <'a> InstructionSelection {
self.emit_move_value_to_value(&actual_loc, &got_loc);
self.make_memory_op_base_offset(&actual_loc, 0, types::get_referent_ty(&pv.ty).unwrap(), vm)
} else if cfg!(feature = "sel4-rumprun") {
} else if cfg!(target_os = "macos") {
P(Value {
hdr: MuEntityHeader::unnamed(vm.next_id()),
ty: types::get_referent_ty(&pv.ty).unwrap(),
v: Value_::Memory(MemoryLocation::Symbolic {
base: Some(x86_64::RIP.clone()),
label: pv.name().unwrap(),
is_global: true,
})
})
} else if cfg!(target_os = "linux") {
// for a(%RIP), we need to load its address from a@GOTPCREL(%RIP)
// then load from the address.
// asm_backend will emit a@GOTPCREL(%RIP) for a(%RIP)
......
......@@ -27,6 +27,8 @@ pub const WORD_SIZE : ByteSize = 8;
pub const AOT_EMIT_CONTEXT_FILE : &'static str = "context.s";
pub const AOT_EMIT_SYM_TABLE_FILE : &'static str = "mu_sym_table.s";
// this is not full name, but pro/epilogue name is generated from this
pub const PROLOGUE_BLOCK_NAME: &'static str = "prologue";
pub const EPILOGUE_BLOCK_NAME: &'static str = "epilogue";
......
......@@ -24,6 +24,8 @@ crate-type = ["rlib"]
[features]
default = []
use-sidemap = []
sel4-rumprun = []
sel4-rumprun-target-side = []
[build-dependencies]
gcc = "0.3"
......
......@@ -14,32 +14,61 @@
extern crate gcc;
//#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(target_arch = "x86_64")]
fn main() {
fn build_libgc(){
println!("detected macos or linux");
gcc::compile_library("libgc_clib_x64.a", &["src/heap/gc/clib_x64.c"]);
}
//#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[cfg(target_os = "linux")]
#[cfg(target_arch = "aarch64")]
fn main() {
fn build_libgc() {
println!("detected linux aarch64");
gcc::compile_library("libgc_clib_aarch64.a", &["src/heap/gc/clib_aarch64.S"]);
}
// This is here to enable cross compiling from windows/x86_64 to linux/aarch64
//#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[cfg(target_os = "windows")]
#[cfg(target_arch = "x86_64")]
fn main() {
fn build_libgc() {
println!("detected windows 64");
gcc::compile_library("libgc_clib_aarch64.a", &["src/heap/gc/clib_aarch64.S"]);
}
#[cfg(feature = "sel4-rumprun")]
#[cfg(target_arch = "x86_64")]
//#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
//#[cfg(feature = "sel4-rumprun-target-side")]
//#[cfg(target_arch = "x86_64")]
fn main() {
use std::env;
let mut gc_target = 0; // 1 for rumprun-sel4 and 0 otherwise
for (key, value) in env::vars() {
if key == "ZEBU_TARGET" {
if value == "x86_64-rumprun-netbsd" {
gc_target = 1;
break;
}
else {
gc_target = 0;
break;
}
}
}
// for sel4-rumprun, do (if)
// otherwise, call the related target function
if gc_target == 1 {
use std::path::Path;
println!("detected rumprun-netbsd");
let mut compiler_name = String::new();
compiler_name.push_str("x86_64-rumprun-netbsd-gcc");
gcc::Config::new().flag("-O3").flag("-c")
.compiler(Path::new(compiler_name.as_str()))
.file("src/heap/gc/clib_x64_sel4_rumprun.c")
.compile("libgc_clib_x64_sel4_rumprun.a");
.compile("libgc_clib_x64.a");
}
else { build_libgc(); }
}
......@@ -13,9 +13,11 @@
// limitations under the License.
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
void* malloc_zero(size_t size) {
void* ret = malloc(size);
......
......@@ -87,18 +87,6 @@ extern "C" {
fn get_registers_count() -> i32;
}
#[cfg(target_arch = "x86_64")]
#[cfg(feature = "sel4-rumprun")]
#[link(name = "gc_clib_x64_sel4_rumprun")]
extern "C" {
pub fn malloc_zero(size: usize) -> *const c_void;
fn immmix_get_stack_ptr() -> Address;
pub fn set_low_water_mark();
fn get_low_water_mark() -> Address;
fn get_registers() -> *const Address;
fn get_registers_count() -> i32;
}
pub fn stack_scan() -> Vec<ObjectReference> {
trace!("stack scanning...");
let stack_ptr : Address = unsafe {immmix_get_stack_ptr()};
......
......@@ -12,6 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
mod test_gc_harness;
pub mod test_gc_harness;
mod test_gcbench;
mod test_gc_linked_list;
......@@ -65,7 +65,7 @@ const FIXSIZE_REFx1_ENCODE : u64 = 0xb000000000000001u64;
#[test]
fn test_exhaust_alloc() {
pub fn test_exhaust_alloc() {
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8, false);
let mut mutator = gc::new_mutator();
......
......@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![feature(cfg_target_vendor)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
......
......@@ -44,7 +44,8 @@ pub mod exception;
// consider using libloading crate instead of the raw c functions for dynalic libraries
// however i am not sure if libloading can load symbols from current process (not from an actual dylib)
// so here i use dlopen/dlsym from C
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(not(feature = "sel4-rumprun-target-side"))]
//#[cfg(not(all(target_os = "netbsd", target_vendor = "rumprun")))]
#[link(name="dl")]
extern "C" {
fn dlopen(filename: *const c_char, flags: isize) -> *const c_void;
......@@ -52,7 +53,8 @@ extern "C" {
fn dlerror() -> *const c_char;
}
#[cfg(not(feature = "sel4-rumprun"))]
#[cfg(not(feature = "sel4-rumprun-target-side"))]
//#[cfg(not(all(target_os = "netbsd", target_vendor = "rumprun")))]
pub fn resolve_symbol(symbol: String) -> Address {
use std::ptr;
......@@ -76,8 +78,9 @@ pub fn resolve_symbol(symbol: String) -> Address {
// This function is specific to sel4-rumprun platform
// it replaces the resolve_symbol function provided by Linux and Mac
// all other platforms (except sel4-rumprun) already provide this function
#[cfg(feature = "sel4-rumprun")]
#[link(name="c_helpers")]
#[cfg(feature = "sel4-rumprun-target-side")]
//#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
#[link(name="zebu_c_helpers")]
extern "C" {
fn c_resolve_symbol(symbol: *const c_char) -> *const c_void;
}
......@@ -102,8 +105,10 @@ extern "C" {
// TODO
// resolve symbol is different from the one used for Linux and Mac
#[cfg(feature = "sel4-rumprun")]
#[cfg(feature = "sel4-rumprun-target-side")]
//#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
pub fn resolve_symbol(symbol: String) -> Address {
debug!("Going to resolve Symbol -{}-", symbol);
let ret = unsafe { c_resolve_symbol(CString::new(symbol.clone()).unwrap().as_ptr()) };
if ret.is_null() {
panic!("failed to resolve symbol: {}", symbol.clone());
......@@ -271,7 +276,6 @@ pub extern fn mu_main(serialized_vm : *const c_char, argc: c_int, argv: *const *
// create mu stack
let stack = vm.new_stack(primordial.func_id);
// if the primordial named some const arguments, we use the const args
// otherwise we push 'argc' and 'argv' to new stack
let args : Vec<ValueLocation> = if primordial.has_const_args {
......@@ -287,11 +291,9 @@ pub extern fn mu_main(serialized_vm : *const c_char, argc: c_int, argv: *const *
args
};
// FIXME: currently assumes no user defined thread local
// will need to fix this after we can serialize heap object
let thread = thread::MuThread::new_thread_normal(stack, unsafe{Address::zero()}, args, vm.clone());
thread.join().unwrap();
}
}
......
......@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <assert.h>
int tls_initialized = 0;
......@@ -63,6 +64,10 @@ void muentry_set_retval(int32_t x) {
mu_retval = x;
}
int32_t muentry_get_retval() {
return mu_retval;
}
int32_t c_check_result() {
return mu_retval;
}
\ No newline at end of file
......@@ -320,6 +320,7 @@ impl fmt::Display for MuThread {
#[cfg(target_arch = "aarch64")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[link(name = "swap_stack")]
extern "C" {
fn swap_to_mu_stack(new_sp: Address, entry: Address, old_sp_loc: Address);
......@@ -331,6 +332,7 @@ extern "C" {
#[cfg(target_arch = "aarch64")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[link(name = "runtime")]
#[allow(improper_ctypes)]
extern "C" {
......@@ -341,6 +343,7 @@ extern "C" {
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[link(name = "runtime")]
extern "C" {
pub fn set_thread_local(thread: *mut MuThread);
......@@ -350,6 +353,7 @@ extern "C" {
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(not(feature = "sel4-rumprun-target-side"))]
#[link(name = "swap_stack")]
extern "C" {
fn swap_to_mu_stack(new_sp: Address, entry: Address, old_sp_loc: Address);
......@@ -360,7 +364,8 @@ extern "C" {
}
#[cfg(target_arch = "x86_64")]
#[cfg(feature = "sel4-rumprun")]
//#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
#[cfg(feature = "sel4-rumprun-target-side")]
#[link(name = "runtime")]
extern "C" {
pub fn set_thread_local(thread: *mut MuThread);
......@@ -369,7 +374,8 @@ extern "C" {
}
#[cfg(target_arch = "x86_64")]
#[cfg(feature = "sel4-rumprun")]
//#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
#[cfg(feature = "sel4-rumprun-target-side")]
#[link(name = "swap_stack")]
extern "C" {
fn swap_to_mu_stack(new_sp: Address, entry: Address, old_sp_loc: Address);
......
......@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
extern crate time;
use testutil::*;
use ast::ir::MuName;
use runtime;
......@@ -21,6 +23,7 @@ use compiler::backend;
use std::path::PathBuf;
use std::process::Command;
use std::process::Output;
use std::process::Stdio;
fn link_executable_internal (files: Vec<PathBuf>, lib: &Vec<String>, libpath: &Vec<String>, out: PathBuf) -> PathBuf {
let mut cc = Command::new(get_test_clang_path());
......@@ -288,3 +291,242 @@ pub fn link_dylib_with_extra_srcs(funcs: Vec<MuName>, srcs: Vec<String>, out: &s
&vm.vm_options.flag_bootimage_external_libpath,
out_path)
}
#[cfg(not(feature = "sel4-rumprun"))]
pub fn run_test(vm: &VM, test_name: &str, tester_name: &str){
let output_name = test_name.to_string()+ "_" + tester_name;
let executable = link_test_primordial(vec![test_name.to_string(), tester_name.to_string()], output_name.as_str(), vm);
execute(executable);
}
#[cfg(feature = "sel4-rumprun")]
pub fn run_test(vm: &VM, test_name: &str, tester_name: &str){
use std::fs::File;
// emit/add.s
let test_asm_file = "emit/".to_string() + test_name + ".s";
// emit/add_test1.s
let tester_asm_file = "emit/".to_string() + tester_name + ".s";
// emit/context.s
let context_asm_file = "emit/".to_string() + "context.s";
// emit/mu_sym_table.s
let mu_sym_table_asm_file = "emit/".to_string() + "mu_sym_table.s";
// clean the destination first
let destination_prefix = "../rumprun-sel4/apps/zebu_rt/src/emit/";
let output = Command::new("rm")
.arg("-R")
.arg(destination_prefix)
.output()
.expect("failed to RM dest emit");
assert!(output.status.success());
// recreate the emit folder, deleted by the previous command
let output = Command::new("mkdir")
.arg(destination_prefix)
.output()
.expect("failed to RM dest emit");
assert!(output.status.success());
// above file will be pasted in \
// rumprun-sel4/apps/zebu_rt/src + the above Strings
let destination_prefix = "../rumprun-sel4/apps/zebu_rt/src/";
let dest_test_asm_file = destination_prefix.to_string() + &test_asm_file;
let dest_tester_asm_file = destination_prefix.to_string() + &tester_asm_file;
let dest_context_asm_file = destination_prefix.to_string() + &context_asm_file;
let dest_mu_sym_table_asm_file = destination_prefix.to_string() + &mu_sym_table_asm_file;