WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 031c6307 authored by Javad Ebrahimian Amiri's avatar Javad Ebrahimian Amiri
Browse files

first running collision detection benchmark (seg faults on futex)

parent dc48e635
...@@ -87,10 +87,10 @@ impl Instruction { ...@@ -87,10 +87,10 @@ impl Instruction {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex | NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_,_) | LockFutex(_,_)
| UnlockFutex(_) | UnlockFutex(_,_)
| AllocAU(_) | AllocAU(_)
| AllocAUHybrid(_,_) | AllocAUHybrid(_,_)
| NewReg(_) | NewReg(_)
...@@ -202,10 +202,10 @@ impl Instruction { ...@@ -202,10 +202,10 @@ impl Instruction {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex | NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_,_) | LockFutex(_,_)
| UnlockFutex(_) | UnlockFutex(_,_)
| NotifyThread(_) | NotifyThread(_)
| ThreadSetPriority(_, _) | ThreadSetPriority(_, _)
| ThreadClearCPU(_, _) | ThreadClearCPU(_, _)
...@@ -330,10 +330,10 @@ impl Instruction { ...@@ -330,10 +330,10 @@ impl Instruction {
| eDelete(_) | eDelete(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex | NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_, _) | LockFutex(_, _)
| UnlockFutex(_) | UnlockFutex(_,_)
| NotifyThread(_) | NotifyThread(_)
| ThreadSetPriority(_, _) | ThreadSetPriority(_, _)
| ThreadGetPriority(_) | ThreadGetPriority(_)
...@@ -454,10 +454,10 @@ impl Instruction { ...@@ -454,10 +454,10 @@ impl Instruction {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex | NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_,_) | LockFutex(_,_)
| UnlockFutex(_) | UnlockFutex(_,_)
| NotifyThread(_) | NotifyThread(_)
| ThreadSetPriority(_,_) // FIXME - Not sure about these | ThreadSetPriority(_,_) // FIXME - Not sure about these
| ThreadGetPriority(_) | ThreadGetPriority(_)
...@@ -570,10 +570,10 @@ impl Instruction { ...@@ -570,10 +570,10 @@ impl Instruction {
NewStack(_) | NewStack(_) |
NewThread { .. } | NewThread { .. } |
NewRTThread { .. } | NewRTThread { .. } |
NewFutex NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_,_) | LockFutex(_,_)
| UnlockFutex(_) | UnlockFutex(_,_)
| NotifyThread(_) | | NotifyThread(_) |
ThreadSetPriority(_,_) | ThreadSetPriority(_,_) |
NewFrameCursor(_) | NewFrameCursor(_) |
...@@ -805,15 +805,15 @@ impl Instruction { ...@@ -805,15 +805,15 @@ impl Instruction {
) )
} }
&Instruction_::NewFutex => format!("NEWFUTEX"), &Instruction_::NewFutex(init_val) => format!("NEWFUTEX {}", ops[init_val]),
&Instruction_::DeleteFutex(futexref) => { &Instruction_::DeleteFutex(futexref) => {
format!("DELETEFUTEX {}", ops[futexref]) format!("DELETEFUTEX {}", ops[futexref])
} }
&Instruction_::LockFutex(futexref, timeout) => { &Instruction_::LockFutex(futexref, timeout) => {
format!("LockFUTEX ({}, {})", ops[futexref], ops[timeout]) format!("LockFUTEX ({}, {})", ops[futexref], ops[timeout])
} }
&Instruction_::UnlockFutex(futexref) => { &Instruction_::UnlockFutex(futexref, count) => {
format!("UNLOCKFUTEX {}", ops[futexref]) format!("UNLOCKFUTEX {}, {}", ops[futexref], ops[count])
} }
&Instruction_::NewRTThread { &Instruction_::NewRTThread {
...@@ -1442,10 +1442,10 @@ pub enum Instruction_ { ...@@ -1442,10 +1442,10 @@ pub enum Instruction_ {
AttrIssetCPU(OpIndex, OpIndex), AttrIssetCPU(OpIndex, OpIndex),
AttrZeroCPU(OpIndex), AttrZeroCPU(OpIndex),
NewFutex, NewFutex(OpIndex),
DeleteFutex(OpIndex), DeleteFutex(OpIndex),
LockFutex(OpIndex, OpIndex), LockFutex(OpIndex, OpIndex),
UnlockFutex(OpIndex), UnlockFutex(OpIndex, OpIndex),
// #[cfg(feature = "realtime")] // #[cfg(feature = "realtime")]
/// notify a thread to start running /// notify a thread to start running
......
...@@ -3853,6 +3853,7 @@ use std::fs::File; ...@@ -3853,6 +3853,7 @@ use std::fs::File;
pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) { pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
use std::io::prelude::*; use std::io::prelude::*;
use std::path; use std::path;
use compiler::passes::tune_file_name;
let funcs = vm.funcs().read().unwrap(); let funcs = vm.funcs().read().unwrap();
let func = funcs.get(&fv.func_id).unwrap().read().unwrap(); let func = funcs.get(&fv.func_id).unwrap().read().unwrap();
...@@ -3865,7 +3866,9 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) { ...@@ -3865,7 +3866,9 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
let mut file_path = path::PathBuf::new(); let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir); file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func.name().to_string() + ".S"); let fname = func.name();
let fname = tune_file_name(fname);
file_path.push(fname.clone().to_string() + ".S");
{ {
let mut file = match File::create(file_path.as_path()) { let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
...@@ -3905,7 +3908,7 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) { ...@@ -3905,7 +3908,7 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
{ {
let mut demangled_path = path::PathBuf::new(); let mut demangled_path = path::PathBuf::new();
demangled_path.push(&vm.vm_options.flag_aot_emit_dir); demangled_path.push(&vm.vm_options.flag_aot_emit_dir);
demangled_path.push((*func.name()).clone() + ".demangled.S"); demangled_path.push(fname.clone().to_string() + ".demangled.S");
let mut demangled_file = match File::create(demangled_path.as_path()) { let mut demangled_file = match File::create(demangled_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
......
...@@ -4003,6 +4003,8 @@ use std::fs::File; ...@@ -4003,6 +4003,8 @@ use std::fs::File;
/// emit assembly file for a function version /// emit assembly file for a function version
pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) { pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
use compiler::passes::tune_file_name;
// acquire lock and function // acquire lock and function
let funcs = vm.funcs().read().unwrap(); let funcs = vm.funcs().read().unwrap();
let func = funcs.get(&fv.func_id).unwrap().read().unwrap(); let func = funcs.get(&fv.func_id).unwrap().read().unwrap();
...@@ -4017,7 +4019,9 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) { ...@@ -4017,7 +4019,9 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
// create emit file // create emit file
let mut file_path = path::PathBuf::new(); let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir); file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push((*func.name()).clone() + ".S"); let fname = func.name().clone();
let fname = tune_file_name(fname);
file_path.push(fname.clone().to_string() + ".S");
{ {
let mut file = match File::create(file_path.as_path()) { let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
...@@ -4052,7 +4056,7 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) { ...@@ -4052,7 +4056,7 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
{ {
let mut demangled_path = path::PathBuf::new(); let mut demangled_path = path::PathBuf::new();
demangled_path.push(&vm.vm_options.flag_aot_emit_dir); demangled_path.push(&vm.vm_options.flag_aot_emit_dir);
demangled_path.push((*func.name()).clone() + ".demangled.S"); demangled_path.push(fname.clone().to_string() + ".demangled.S");
let mut demangled_file = match File::create(demangled_path.as_path()) { let mut demangled_file = match File::create(demangled_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
......
...@@ -2883,14 +2883,17 @@ impl<'a> InstructionSelection { ...@@ -2883,14 +2883,17 @@ impl<'a> InstructionSelection {
// vm, // vm,
// ); // );
// } // }
Instruction_::NewFutex => { Instruction_::NewFutex(init_val) => {
trace!("instsel on NewFutex"); trace!("instsel on NewFutex");
let ref val = inst.ops[init_val];
let tmp_val = self.emit_ireg(val, f_content, f_context, vm);
let res = self.get_result_value(node); let res = self.get_result_value(node);
self.emit_runtime_entry( self.emit_runtime_entry(
&entrypoints::NEW_FUTEX, &entrypoints::NEW_FUTEX,
vec![], vec![tmp_val],
Some(vec![res]), Some(vec![res]),
Some(node), Some(node),
f_content, f_content,
...@@ -2939,18 +2942,22 @@ impl<'a> InstructionSelection { ...@@ -2939,18 +2942,22 @@ impl<'a> InstructionSelection {
vm vm
); );
} }
Instruction_::UnlockFutex(futexref) => { Instruction_::UnlockFutex(futexref, count) => {
trace!("instsel on UnlockFutex"); trace!("instsel on UnlockFutex");
let ref ops = inst.ops; let ref ops = inst.ops;
let ref futexref = ops[futexref]; let ref futexref = ops[futexref];
let ref count = ops[count];
let tmp_futex = let tmp_futex =
self.emit_ireg(futexref, f_content, f_context, vm); self.emit_ireg(futexref, f_content, f_context, vm);
let tmp_count =
self.emit_ireg(count, f_content, f_context, vm);
self.emit_runtime_entry( self.emit_runtime_entry(
&entrypoints::UNLOCK_FUTEX, &entrypoints::UNLOCK_FUTEX,
vec![tmp_futex], vec![tmp_futex, tmp_count],
None, None,
Some(node), Some(node),
f_content, f_content,
......
...@@ -716,10 +716,10 @@ pub fn estimate_insts_for_ir(inst: &Instruction) -> usize { ...@@ -716,10 +716,10 @@ pub fn estimate_insts_for_ir(inst: &Instruction) -> usize {
NewStack(_) NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex | NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_, _) | LockFutex(_, _)
| UnlockFutex(_) | UnlockFutex(_,_)
| NotifyThread(_) | NotifyThread(_)
| ThreadSetPriority(_, _) | ThreadSetPriority(_, _)
| ThreadGetPriority(_) | ThreadGetPriority(_)
......
...@@ -62,9 +62,12 @@ impl CompilerPass for CodeEmission { ...@@ -62,9 +62,12 @@ impl CompilerPass for CodeEmission {
/// creates an file to write, panics if the creation fails /// creates an file to write, panics if the creation fails
fn create_emit_file(name: String, vm: &VM) -> File { fn create_emit_file(name: String, vm: &VM) -> File {
use compiler::passes::tune_file_name;
let mut file_path = path::PathBuf::new(); let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir); file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(name); let name = tune_file_name(Arc::from(name));
file_path.push(&*name);
match File::create(file_path.as_path()) { match File::create(file_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
......
...@@ -25,9 +25,12 @@ use std::path; ...@@ -25,9 +25,12 @@ use std::path;
use vm::uir_output::{create_emit_directory, EMIT_MUIR}; use vm::uir_output::{create_emit_directory, EMIT_MUIR};
fn create_emit_file(name: String, vm: &VM) -> File { fn create_emit_file(name: String, vm: &VM) -> File {
use compiler::passes::tune_file_name;
let mut file_path = path::PathBuf::new(); let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir); file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(name); let name = tune_file_name(Arc::from(name));
file_path.push(&*name);
match File::create(file_path.as_path()) { match File::create(file_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
...@@ -55,7 +58,10 @@ impl DotGen { ...@@ -55,7 +58,10 @@ impl DotGen {
#[allow(dead_code)] #[allow(dead_code)]
fn emit_muir_dot(suffix: &str, func: &MuFunctionVersion, vm: &VM) { fn emit_muir_dot(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
use compiler::passes::tune_file_name;
let func_name = func.name(); let func_name = func.name();
let func_name = tune_file_name(func_name);
// create emit directory // create emit directory
create_emit_directory(vm); create_emit_directory(vm);
......
...@@ -142,3 +142,13 @@ pub trait CompilerPass { ...@@ -142,3 +142,13 @@ pub trait CompilerPass {
) { ) {
} }
} }
pub fn tune_file_name(fname: Arc<String>) -> Arc<String> {
let ln = fname.len();
if ln < 200 {
return fname
}
let res = String::from(fname.get(0..100).unwrap()) + fname.get((ln-100)..ln).unwrap();
return Arc::from(res)
}
...@@ -91,10 +91,10 @@ fn is_suitable_child(inst: &Instruction) -> bool { ...@@ -91,10 +91,10 @@ fn is_suitable_child(inst: &Instruction) -> bool {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex | NewFutex(_)
| DeleteFutex(_) | DeleteFutex(_)
| LockFutex(_, _) | LockFutex(_, _)
| UnlockFutex(_) | UnlockFutex(_,_)
| NotifyThread(_) | NotifyThread(_)
| ThreadSetPriority(_, _) | ThreadSetPriority(_, _)
| ThreadGetPriority(_) | ThreadGetPriority(_)
......
...@@ -26,9 +26,12 @@ use vm::uir_output::create_emit_directory; ...@@ -26,9 +26,12 @@ use vm::uir_output::create_emit_directory;
pub const EMIT_MUIR: bool = true; pub const EMIT_MUIR: bool = true;
fn create_emit_file(name: String, vm: &VM) -> File { fn create_emit_file(name: String, vm: &VM) -> File {
use compiler::passes::tune_file_name;
let mut file_path = path::PathBuf::new(); let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir); file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(name); let name = tune_file_name(Arc::from(name));
file_path.push(&*name);
match File::create(file_path.as_path()) { match File::create(file_path.as_path()) {
Err(why) => panic!( Err(why) => panic!(
...@@ -54,9 +57,13 @@ impl UIRGen { ...@@ -54,9 +57,13 @@ impl UIRGen {
} }
} }
#[allow(dead_code)] #[allow(dead_code)]
fn emit_uir(suffix: &str, func_ver: &MuFunctionVersion, vm: &VM) { fn emit_uir(suffix: &str, func_ver: &MuFunctionVersion, vm: &VM) {
use compiler::passes::tune_file_name;
let func_ver_name = func_ver.name(); let func_ver_name = func_ver.name();
let func_ver_name = tune_file_name(func_ver_name);
// create emit directory // create emit directory
create_emit_directory(vm); create_emit_directory(vm);
......
...@@ -444,7 +444,7 @@ lazy_static! { ...@@ -444,7 +444,7 @@ lazy_static! {
lazy_static! { lazy_static! {
pub static ref NEW_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new( pub static ref NEW_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
"muentry_futex_new", "muentry_futex_new",
vec![], vec![UINT64_TYPE.clone()],
vec![ADDRESS_TYPE.clone()] vec![ADDRESS_TYPE.clone()]
); );
pub static ref DELETE_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new( pub static ref DELETE_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
...@@ -459,7 +459,7 @@ lazy_static! { ...@@ -459,7 +459,7 @@ lazy_static! {
); );
pub static ref UNLOCK_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new( pub static ref UNLOCK_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
"muentry_futex_unlock", "muentry_futex_unlock",
vec![ADDRESS_TYPE.clone()], vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],
vec![] vec![]
); );
} }
......
...@@ -20,8 +20,10 @@ use super::*; ...@@ -20,8 +20,10 @@ use super::*;
use super::futex_rtmu_linux::*; use super::futex_rtmu_linux::*;
#[no_mangle] #[no_mangle]
pub extern "C" fn muentry_futex_new() -> Address { pub extern "C" fn muentry_futex_new(init_val: u64) -> Address {
sys_rtmu_futex::new() let res = sys_rtmu_futex::new(init_val as u32);
debug!("muentry_futex_new.futex_addr: {}", res);
res
} }
#[no_mangle] #[no_mangle]
...@@ -31,12 +33,14 @@ pub extern "C" fn muentry_futex_delete(f: Address) { ...@@ -31,12 +33,14 @@ pub extern "C" fn muentry_futex_delete(f: Address) {
#[no_mangle] #[no_mangle]
pub extern "C" fn muentry_futex_lock(futex_addr: Address, timeout_ns: u64) { pub extern "C" fn muentry_futex_lock(futex_addr: Address, timeout_ns: u64) {
debug!("muentry_futex_lock.futex_addr: {}", futex_addr);
let the_futex: &mut sys_rtmu_futex = unsafe { futex_addr.to_ref_mut() }; let the_futex: &mut sys_rtmu_futex = unsafe { futex_addr.to_ref_mut() };
the_futex.lock(timeout_ns); the_futex.lock(timeout_ns);
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn muentry_futex_unlock(futex_addr: Address) { pub extern "C" fn muentry_futex_unlock(futex_addr: Address, count: u64) {
debug!("muentry_futex_unlock.futex_addr: {}", futex_addr);
let the_futex: &mut sys_rtmu_futex = unsafe { futex_addr.to_ref_mut() }; let the_futex: &mut sys_rtmu_futex = unsafe { futex_addr.to_ref_mut() };
the_futex.unlock(); the_futex.unlock(count);
} }
...@@ -27,9 +27,9 @@ pub(super) struct sys_rtmu_futex { ...@@ -27,9 +27,9 @@ pub(super) struct sys_rtmu_futex {
} }
impl sys_rtmu_futex { impl sys_rtmu_futex {
pub fn new() -> Address { pub fn new(init_val: u32) -> Address {
let fbox = Box::new(sys_rtmu_futex { let fbox = Box::new(sys_rtmu_futex {
mem: AtomicU32::new(0) mem: AtomicU32::new(init_val)
}); });
Address::from_mut_ptr(Box::into_raw(fbox)) Address::from_mut_ptr(Box::into_raw(fbox))
...@@ -65,7 +65,7 @@ impl sys_rtmu_futex { ...@@ -65,7 +65,7 @@ impl sys_rtmu_futex {
} }
} }
pub fn unlock(&mut self) { pub fn unlock(&mut self, count: u64) {
let my_tid = os_gettid(); let my_tid = os_gettid();
match self.mem.compare_exchange( match self.mem.compare_exchange(
my_tid as u32, my_tid as u32,
...@@ -82,7 +82,8 @@ impl sys_rtmu_futex { ...@@ -82,7 +82,8 @@ impl sys_rtmu_futex {
id id
); );
sys_futex_unlock_slowpath( sys_futex_unlock_slowpath(
&mut self.mem as *const AtomicU32 as *const u32 as *mut u32 &mut self.mem as *const AtomicU32 as *const u32 as *mut u32,
count
); );
} }
} }
...@@ -130,7 +131,7 @@ fn sys_futex_lock_slowpath(futex_ptr: *mut u32, timeout_ns: u64) { ...@@ -130,7 +131,7 @@ fn sys_futex_lock_slowpath(futex_ptr: *mut u32, timeout_ns: u64) {
trace!("FUTEX.lock slowpath aquired #{:#?}", futex_ptr); trace!("FUTEX.lock slowpath aquired #{:#?}", futex_ptr);
} }
fn sys_futex_unlock_slowpath(futex_ptr: *mut u32) { fn sys_futex_unlock_slowpath(futex_ptr: *mut u32, count: u64) {
let null_ts: *mut libc::timespec = std::ptr::null_mut(); let null_ts: *mut libc::timespec = std::ptr::null_mut();
let null_cl: *mut libc::c_long = std::ptr::null_mut(); let null_cl: *mut libc::c_long = std::ptr::null_mut();
...@@ -139,7 +140,7 @@ fn sys_futex_unlock_slowpath(futex_ptr: *mut u32) { ...@@ -139,7 +140,7 @@ fn sys_futex_unlock_slowpath(futex_ptr: *mut u32) {
libc::SYS_futex, libc::SYS_futex,
futex_ptr, futex_ptr,
libc::FUTEX_UNLOCK_PI, libc::FUTEX_UNLOCK_PI,
0, count,
null_ts, null_ts,
null_cl, null_cl,
0 0
......
...@@ -70,7 +70,7 @@ impl MuThread { ...@@ -70,7 +70,7 @@ impl MuThread {