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.

Commit 3b4708dc authored by Javad Ebrahimian Amiri's avatar Javad Ebrahimian Amiri
Browse files

timer works now

parent ffe7295c
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 14)
#set(triple x86_64-pc-linux-gnu)
#set(CMAKE_C_COMPILER gcc)
#set(CMAKE_C_COMPILER_TARGET ${triple})
#set(CMAKE_CXX_COMPILER g++)
#set(CMAKE_CXX_COMPILER_TARGET ${triple})
project(cmake_zebu_runtime_helpers)
add_library(runtime_c_x64 STATIC src/runtime/runtime_c_x64_sysv.c)
add_library(runtime_asm_x64 STATIC src/runtime/runtime_asm_x64_sysv.S)
set_target_properties(runtime_asm_x64 PROPERTIES LINKER_LANGUAGE C)
add_library(runtime_c_aarch64 STATIC src/runtime/runtime_c_aarch64_sysv.c)
add_library(runtime_asm_aarch64 STATIC src/runtime/runtime_asm_aarch64_sysv.S)
set_target_properties(runtime_asm_aarch64 PROPERTIES LINKER_LANGUAGE C)
...@@ -40,23 +40,26 @@ rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", branch = "master", version ...@@ -40,23 +40,26 @@ rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", branch = "master", version
libc="*" libc="*"
field-offset = "*" field-offset = "*"
libloading = "*" libloading = "*"
lazy_static = "0.2.11" lazy_static = "*"
log = "0.3.8" log = "*"
stderrlog = "0.2.3" stderrlog = "*"
num = "*" num = "*"
hprof = "*" hprof = "*"
memmap = "*" memmap = "*"
memsec = "0.1.9" memsec = "*"
serde = { version = "*", features = ["derive"]} serde = { version = "*", features = ["derive"]}
bincode = "*" bincode = "*"
serde_derive = "*" serde_derive = "*"
time = "*" time = "*"
maplit = "*" maplit = "*"
docopt = "0.8.1" docopt = "*"
petgraph = "*" petgraph = "*"
extprim = "*" extprim = "*"
num-traits = "*" num-traits = "*"
built = "*" built = "*"
mu_gc = { path = "src/gc"} mu_gc = { path = "src/gc"}
cfg-if = "*" cfg-if = "*"
rand = "*" rand = "*"
\ No newline at end of file rusty-asm = "*"
timer = "*"
chrono = "*"
#!/bin/sh #!/bin/sh
export MU_ZEBU=$PWD export MU_ZEBU=$PWD
export ZEBU_BUILD=release export ZEBU_BUILD=debug
export CARGO_HOME=~/.cargo export CARGO_HOME=~/.cargo
export CC=clang export CC=clang
export CXX=clang++ export CXX=clang++
export RUST_TEST_THREADS=1 export RUST_TEST_THREADS=1
export RUST_BACKTRACE=1
export MU_LOG_LEVEL=trace
export LD_LIBRARY_PATH=$MU_ZEBU/target/$ZEBU_BUILD/deps/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$MU_ZEBU/target/$ZEBU_BUILD/deps/:$LD_LIBRARY_PATH
// Copyright 2019 The Australian National University
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
fn main() {
}
\ No newline at end of file
...@@ -87,6 +87,10 @@ impl Instruction { ...@@ -87,6 +87,10 @@ impl Instruction {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex
| DeleteFutex(_)
| LockFutex(_)
| UnlockFutex(_)
| AllocAU(_) | AllocAU(_)
| AllocAUHybrid(_,_) | AllocAUHybrid(_,_)
| NewReg(_) | NewReg(_)
...@@ -104,6 +108,11 @@ impl Instruction { ...@@ -104,6 +108,11 @@ impl Instruction {
| AffinityIsset(_,_) | AffinityIsset(_,_)
| GetTime | GetTime
| SetTime(_) | SetTime(_)
| NewTimer
| SetTimer(_,_,_,_)
| CancelTimer(_)
| DeleteTimer(_)
| Sleep(_)
| NewFrameCursor(_) | NewFrameCursor(_)
| GetIRef(_) | GetIRef(_)
| GetFieldIRef { .. } | GetFieldIRef { .. }
...@@ -176,12 +185,21 @@ impl Instruction { ...@@ -176,12 +185,21 @@ impl Instruction {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex
| DeleteFutex(_)
| LockFutex(_)
| UnlockFutex(_)
| NotifyThread(_) | NotifyThread(_)
| SetPriority(_, _) | SetPriority(_, _)
| AffinityClear(_, _) | AffinityClear(_, _)
| AffinitySet(_, _) | AffinitySet(_, _)
// | AffinityZero(_) // | AffinityZero(_)
| SetTime(_) | SetTime(_)
| NewTimer
| SetTimer(_,_,_,_)
| CancelTimer(_)
| DeleteTimer(_)
| Sleep(_)
| NewFrameCursor(_) | NewFrameCursor(_)
| Fence(_) | Fence(_)
| Return(_) | Return(_)
...@@ -278,6 +296,10 @@ impl Instruction { ...@@ -278,6 +296,10 @@ impl Instruction {
| eDelete(_) | eDelete(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex
| DeleteFutex(_)
| LockFutex(_)
| UnlockFutex(_)
| NotifyThread(_) | NotifyThread(_)
| SetPriority(_, _) | SetPriority(_, _)
| GetPriority(_) | GetPriority(_)
...@@ -286,6 +308,11 @@ impl Instruction { ...@@ -286,6 +308,11 @@ impl Instruction {
| AffinityIsset(_, _) | AffinityIsset(_, _)
| GetTime | GetTime
| SetTime(_) | SetTime(_)
| NewTimer
| SetTimer(_,_,_,_)
| CancelTimer(_)
| DeleteTimer(_)
| Sleep(_)
| NewFrameCursor(_) | NewFrameCursor(_)
| GetIRef(_) | GetIRef(_)
| GetFieldIRef { .. } | GetFieldIRef { .. }
...@@ -376,6 +403,10 @@ impl Instruction { ...@@ -376,6 +403,10 @@ impl Instruction {
| NewStack(_) | NewStack(_)
| NewThread { .. } | NewThread { .. }
| NewRTThread { .. } | NewRTThread { .. }
| NewFutex
| DeleteFutex(_)
| LockFutex(_)
| UnlockFutex(_)
| NotifyThread(_) | NotifyThread(_)
| SetPriority(_,_) // FIXME - Not sure about these | SetPriority(_,_) // FIXME - Not sure about these
| GetPriority(_) | GetPriority(_)
...@@ -386,6 +417,11 @@ impl Instruction { ...@@ -386,6 +417,11 @@ impl Instruction {
// | AffinityZero(_) // | AffinityZero(_)
| SetTime(_) | SetTime(_)
| GetTime | GetTime
| NewTimer
| SetTimer(_,_,_,_)
| CancelTimer(_)
| DeleteTimer(_)
| Sleep(_)
| NewFrameCursor(_) | NewFrameCursor(_)
| GetIRef(_) | GetIRef(_)
| GetFieldIRef { .. } | GetFieldIRef { .. }
...@@ -466,7 +502,11 @@ impl Instruction { ...@@ -466,7 +502,11 @@ impl Instruction {
NewStack(_) | NewStack(_) |
NewThread { .. } | NewThread { .. } |
NewRTThread { .. } | NewRTThread { .. } |
NotifyThread(_) | NewFutex
| DeleteFutex(_)
| LockFutex(_)
| UnlockFutex(_)
| NotifyThread(_) |
SetPriority(_,_) | SetPriority(_,_) |
NewFrameCursor(_) | NewFrameCursor(_) |
GetIRef(_) | GetIRef(_) |
...@@ -661,7 +701,7 @@ impl Instruction { ...@@ -661,7 +701,7 @@ impl Instruction {
// ), // ),
&Instruction_::eAlloc(ref ty) => { &Instruction_::eAlloc(ref ty) => {
format!("COMMINST @uvm.eAlloc({})", ty.id()) format!("COMMINST @uvm.eAlloc({})", ty.id())
} },
&Instruction_::eAllocHybrid(ref ty, var_len) => format!( &Instruction_::eAllocHybrid(ref ty, var_len) => format!(
"COMMINST @uvm.eAllocHybrid({}, {})", "COMMINST @uvm.eAllocHybrid({}, {})",
ty.id(), ty.id(),
...@@ -673,7 +713,7 @@ impl Instruction { ...@@ -673,7 +713,7 @@ impl Instruction {
// ), // ),
&Instruction_::eDelete(obj) => { &Instruction_::eDelete(obj) => {
format!("COMMINST @uvm.eDelete({})", ops[obj]) format!("COMMINST @uvm.eDelete({})", ops[obj])
} },
// &Instruction_::eDeleteT( obj) => format!( // &Instruction_::eDeleteT( obj) => format!(
// "COMMINST @uvm.eDeleteT({})", // "COMMINST @uvm.eDeleteT({})",
// ops[obj] // ops[obj]
...@@ -693,7 +733,27 @@ impl Instruction { ...@@ -693,7 +733,27 @@ impl Instruction {
"NEWTHREAD {}{} {}", "NEWTHREAD {}{} {}",
ops[stack], thread_local, new_stack_clause, ops[stack], thread_local, new_stack_clause,
) )
} },
&Instruction_::NewFutex => format!("NEWFUTEX"),
&Instruction_::DeleteFutex(futexref) => {
format!(
"DELETEFUTEX {}",
ops[futexref]
)
},
&Instruction_::LockFutex(futexref) => {
format!(
"LockFUTEX {}",
ops[futexref]
)
},
&Instruction_::UnlockFutex(futexref) => {
format!(
"UNLOCKFUTEX {}",
ops[futexref]
)
},
&Instruction_::NewRTThread { &Instruction_::NewRTThread {
attr, attr,
...@@ -711,11 +771,11 @@ impl Instruction { ...@@ -711,11 +771,11 @@ impl Instruction {
"NEWRTTHREAD {}, {}, {}, {}", "NEWRTTHREAD {}, {}, {}, {}",
ops[attr], ops[stack], thread_local, new_stack_clause, ops[attr], ops[stack], thread_local, new_stack_clause,
) )
} },
&Instruction_::NotifyThread(thread) => { &Instruction_::NotifyThread(thread) => {
format!("COMMINST @uvm.notifythread({})", ops[thread]) format!("COMMINST @uvm.notifythread({})", ops[thread])
} },
&Instruction_::SetPriority(thread, priority) => format!( &Instruction_::SetPriority(thread, priority) => format!(
"COMMINST @uvm.setpriority({}, {})", "COMMINST @uvm.setpriority({}, {})",
ops[thread], ops[priority] ops[thread], ops[priority]
...@@ -742,6 +802,28 @@ impl Instruction { ...@@ -742,6 +802,28 @@ impl Instruction {
"COMMINST @uvm.settime({})", "COMMINST @uvm.settime({})",
ops[time] ops[time]
), ),
&Instruction_::NewTimer => format!(
"COMMINST @uvm.newtimer"
),
&Instruction_::SetTimer(tmr, tm, func, args) => format!(
"COMMINST @uvm.settimer({}, {}, {}, {})",
ops[tmr],
ops[tm],
ops[func],
ops[args]
),
&Instruction_::CancelTimer(tmr) => format!(
"COMMINST @uvm.canceltimer({})",
ops[tmr]
),
&Instruction_::DeleteTimer(tmr) => format!(
"COMMINST @uvm.deletetimer({})",
ops[tmr]
),
&Instruction_::Sleep(dur) => format!(
"COMMINST @uvm.sleep_ns({})",
ops[dur]
),
&Instruction_::NewFrameCursor(stack) => { &Instruction_::NewFrameCursor(stack) => {
format!("COMMINST @uvm.meta.new_cursor({})", ops[stack]) format!("COMMINST @uvm.meta.new_cursor({})", ops[stack])
} }
...@@ -1222,6 +1304,11 @@ pub enum Instruction_ { ...@@ -1222,6 +1304,11 @@ pub enum Instruction_ {
args: Vec<OpIndex> args: Vec<OpIndex>
}, },
NewFutex,
DeleteFutex(OpIndex),
LockFutex(OpIndex),
UnlockFutex(OpIndex),
// #[cfg(feature = "realtime")] // #[cfg(feature = "realtime")]
/// notify a thread to start running /// notify a thread to start running
/// args: threadref for the target thread /// args: threadref for the target thread
...@@ -1262,6 +1349,12 @@ pub enum Instruction_ { ...@@ -1262,6 +1349,12 @@ pub enum Instruction_ {
GetTime, GetTime,
SetTime(OpIndex), SetTime(OpIndex),
NewTimer,
SetTimer(OpIndex, OpIndex, OpIndex, OpIndex),
CancelTimer(OpIndex),
DeleteTimer(OpIndex),
Sleep(OpIndex),
/// create a frame cursor reference /// create a frame cursor reference
/// args: stackref of a Mu stack /// args: stackref of a Mu stack
NewFrameCursor(OpIndex), // stack NewFrameCursor(OpIndex), // stack
......
...@@ -133,12 +133,12 @@ impl fmt::Display for MuFunction { ...@@ -133,12 +133,12 @@ impl fmt::Display for MuFunction {
} }
} }
/// MuFunctionVersion represents a specific definition of a Mu function
/// It owns the tree structure of MuIRs for the function version
// FIXME: currently part of compilation information is also stored in this data // FIXME: currently part of compilation information is also stored in this data
// structure we should move them (see Issue #18) // structure we should move them (see Issue #18)
rodal_named!(MuFunctionVersion); rodal_named!(MuFunctionVersion);
/// MuFunctionVersion represents a specific definition of a Mu function
/// It owns the tree structure of MuIRs for the function version
pub struct MuFunctionVersion { pub struct MuFunctionVersion {
pub hdr: MuEntityHeader, pub hdr: MuEntityHeader,
......
// Copyright 2019 The Australian National University
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
extern crate libc;
pub type SysThreadID = libc::pthread_t;
pub type SysThreadAttr = libc::pthread_attr_t;
pub type SysPriority = libc::c_int;
pub type SysTime = libc::timespec;
pub type SysAffinityMask = libc::cpu_set_t;
pub type SysAffinitySize = libc::size_t;
...@@ -70,6 +70,8 @@ lazy_static! { ...@@ -70,6 +70,8 @@ lazy_static! {
P(MuType::new(new_internal_id(), MuType_::stackref())); P(MuType::new(new_internal_id(), MuType_::stackref()));
pub static ref THREADREF_TYPE: P<MuType> = pub static ref THREADREF_TYPE: P<MuType> =
P(MuType::new(new_internal_id(), MuType_::threadref())); P(MuType::new(new_internal_id(), MuType_::threadref()));
pub static ref FUTEXREF_TYPE: P<MuType> =
P(MuType::new(new_internal_id(), MuType_::futexref()));
} }
#[cfg(not(feature = "realtime"))] #[cfg(not(feature = "realtime"))]
...@@ -90,6 +92,7 @@ lazy_static! { ...@@ -90,6 +92,7 @@ lazy_static! {
IREF_VOID_TYPE.clone(), IREF_VOID_TYPE.clone(),
STACKREF_TYPE.clone(), STACKREF_TYPE.clone(),
THREADREF_TYPE.clone(), THREADREF_TYPE.clone(),
FUTEXREF_TYPE.clone(),
UPTR_U8_TYPE.clone(), UPTR_U8_TYPE.clone(),
UPTR_U64_TYPE.clone() UPTR_U64_TYPE.clone()
]; ];
...@@ -130,6 +133,7 @@ lazy_static! { ...@@ -130,6 +133,7 @@ lazy_static! {
RTATTR_TYPE.clone(), RTATTR_TYPE.clone(),
UPTR_RTATTR_TYPE.clone(), UPTR_RTATTR_TYPE.clone(),
REGREF_TYPE.clone(), REGREF_TYPE.clone(),
FUTEXREF_TYPE.clone(),
]; ];
} }
...@@ -244,7 +248,7 @@ impl MuType { ...@@ -244,7 +248,7 @@ impl MuType {
pub fn is_opaque_reference(&self) -> bool { pub fn is_opaque_reference(&self) -> bool {
match self.v { match self.v {
MuType_::FuncRef(_) | MuType_::StackRef | MuType_::ThreadRef => { MuType_::FuncRef(_) | MuType_::StackRef | MuType_::ThreadRef | MuType_::FutexRef => {
true true
} }
...@@ -306,6 +310,7 @@ impl MuType { ...@@ -306,6 +310,7 @@ impl MuType {
| MuType_::ThreadRef | MuType_::ThreadRef
| MuType_::StackRef | MuType_::StackRef
| MuType_::Tagref64 | MuType_::Tagref64
| MuType_::FutexRef
| MuType_::UPtr(_) => true, | MuType_::UPtr(_) => true,
#[cfg(feature = "realtime")] #[cfg(feature = "realtime")]
MuType_::RTAttr MuType_::RTAttr
...@@ -536,7 +541,7 @@ impl MuType { ...@@ -536,7 +541,7 @@ impl MuType {
use types::MuType_::*; use types::MuType_::*;
match self.v { match self.v {
Int(len) => Some(len), Int(len) => Some(len),
Ref(_) | IRef(_) | WeakRef(_) | UPtr(_) | ThreadRef | StackRef Ref(_) | IRef(_) | WeakRef(_) | UPtr(_) | ThreadRef | StackRef | FutexRef
| Tagref64 | FuncRef(_) | UFuncPtr(_) => Some(64), | Tagref64 | FuncRef(_) | UFuncPtr(_) => Some(64),
#[cfg(feature = "realtime")] #[cfg(feature = "realtime")]
...@@ -573,17 +578,17 @@ impl MuType { ...@@ -573,17 +578,17 @@ impl MuType {
} }
// #[cfg(feature = "realtime")] // #[cfg(feature = "realtime")]
pub fn containsIRef(&self) -> bool { pub fn contains_iref(&self) -> bool {
let res = match &self.v { let res = match &self.v {
MuType_::IRef(_) => true, MuType_::IRef(_) => true,
MuType_::Array(ty, size) => ty.is_iref() && *size > 0, MuType_::Array(ty, size) => ty.is_iref() && *size > 0,
MuType_::Struct(tag) => { MuType_::Struct(tag) => {
let structMap = STRUCT_TAG_MAP.read().unwrap(); let struct_map = STRUCT_TAG_MAP.read().unwrap();
let _struct: &StructType_ = structMap.get(tag).unwrap(); let _struct: &StructType_ = struct_map.get(tag).unwrap();
let _types = _struct.get_tys(); let _types = _struct.get_tys();
for _type in _types { for _type in _types {
if _type.is_iref() || _type.containsIRef() { if _type.is_iref() || _type.contains_iref() {
return true; return true;
} }
} }
...@@ -597,12 +602,12 @@ impl MuType { ...@@ -597,12 +602,12 @@ impl MuType {
let var_ty = _hybrid.get_var_ty(); let var_ty = _hybrid.get_var_ty();
for _type in fix_tys.iter() { for _type in fix_tys.iter() {
if _type.is_iref() || _type.containsIRef() { if _type.is_iref() || _type.contains_iref() {
return true; return true;
} }
} }
if var_ty.is_iref() || var_ty.containsIRef() { if var_ty.is_iref() || var_ty.contains_iref() {
return true; return true;
} }
...@@ -667,6 +672,8 @@ pub enum MuType_ { ...@@ -667,6 +672,8 @@ pub enum MuType_ {
/// ufuncptr<@sig> /// ufuncptr<@sig>
UFuncPtr(P<MuFuncSig>), UFuncPtr(P<MuFuncSig>),
FutexRef,
/// RTMu-specific /// RTMu-specific
/// Real-Time Threads' attributes /// Real-Time Threads' attributes
#[cfg(feature = "realtime")] #[cfg(feature = "realtime")]
...@@ -690,12 +697,12 @@ impl MuType_ { ...@@ -690,12 +697,12 @@ impl MuType_ {
#[cfg(not(feature = "realtime"))] #[cfg(not(feature = "realtime"))]
rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty), rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty),
(Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, StackRef, Tagref64, (Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, StackRef, FutexRef, Tagref64,
(Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)}); (Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)});
#[cfg(feature = "realtime")] #[cfg(feature = "realtime")]
rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty), rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty),
(Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, RegionRef, TimerRef, TimeVal, RTAttr, StackRef, Tagref64, (Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, RegionRef, TimerRef, FutexRef, TimeVal, RTAttr, StackRef, Tagref64,
(Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)}); (Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)});
impl fmt::Display for MuType { impl fmt::Display for MuType {
...@@ -708,7 +715,7 @@ impl fmt::Display for MuType_ { ...@@ -708,7 +715,7 @@ impl fmt::Display for MuType_ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
&MuType_::Int(n) => write!(f, "int<{}>", n), &MuType_::Int(n) => write!(f, "int<{}>", n),