Commit b7c2a4f7 authored by qinsoon's avatar qinsoon

inject fastpath as Mu IR

parent 22c3a1b0
Pipeline #1307 failed with stages
in 22 minutes and 14 seconds
......@@ -108,6 +108,7 @@ impl Instruction {
Move(_) |
PrintHex(_) |
SetRetval(_) |
GetVMThreadLocal |
KillStack(_) |
CurrentStack |
SwapStackExpr { .. } => false
......@@ -185,7 +186,8 @@ impl Instruction {
CommonInst_Tr64ToRef(_) |
CommonInst_Tr64ToTag(_) |
Move(_) |
CurrentStack => false
CurrentStack |
GetVMThreadLocal => false
}
}
......@@ -250,6 +252,7 @@ impl Instruction {
Move(_) |
PrintHex(_) |
SetRetval(_) |
GetVMThreadLocal |
KillStack(_) |
CurrentStack |
SwapStackExpr { .. } |
......@@ -322,6 +325,7 @@ impl Instruction {
Move(_) |
PrintHex(_) |
SetRetval(_) |
GetVMThreadLocal |
KillStack(_) |
CurrentStack |
SwapStackExpr { .. } |
......@@ -395,6 +399,7 @@ impl Instruction {
Move(_) |
PrintHex(_) |
SetRetval(_) |
GetVMThreadLocal |
KillStack(_) |
CurrentStack |
SwapStackKill { .. } => false,
......@@ -820,7 +825,9 @@ impl Instruction {
// print hex
&Instruction_::PrintHex(i) => format!("PRINTHEX<{}> {}", ops[i].ty(), ops[i]),
// set retval
&Instruction_::SetRetval(val) => format!("SETRETVAL {}", ops[val])
&Instruction_::SetRetval(val) => format!("SETRETVAL {}", ops[val]),
// get vm thread local
&Instruction_::GetVMThreadLocal => format!("GETVMTHREADLOCAL")
}
}
}
......@@ -1118,7 +1125,9 @@ pub enum Instruction_ {
/// internal use: print op as hex value
PrintHex(OpIndex),
/// internal use: set return value for main
SetRetval(OpIndex)
SetRetval(OpIndex),
/// internal use: get zebu thread local
GetVMThreadLocal
}
fn format_value_types(value: &Option<Vec<P<Value>>>) -> String {
......
......@@ -566,6 +566,14 @@ impl Block {
}
}
pub fn clear_insts(&mut self) {
self.content.as_mut().unwrap().body.clear();
}
pub fn append_inst(&mut self, inst: P<TreeNode>) {
self.content.as_mut().unwrap().body.push(inst);
}
/// does this block have an exception arguments?
pub fn is_receiving_exception_arg(&self) -> bool {
return self.content.as_ref().unwrap().exn_arg.is_some();
......@@ -859,6 +867,30 @@ impl TreeNode {
})
}
/// is instruction
pub fn is_inst(&self) -> bool {
match self.v {
TreeNode_::Instruction(_) => true,
_ => false
}
}
/// is value
pub fn is_value(&self) -> bool {
match self.v {
TreeNode_::Value(_) => true,
_ => false
}
}
/// is constant value
pub fn is_const_value(&self) -> bool {
match self.v {
TreeNode_::Value(ref val) => val.is_const(),
_ => false
}
}
/// extracts the MuID of an SSA TreeNode
/// if the node is not an SSA, returns None
pub fn extract_ssa_id(&self) -> Option<MuID> {
......@@ -975,10 +1007,14 @@ rodal_struct!(Value { hdr, ty, v });
impl Value {
/// creates an int constant value
pub fn make_int_const(id: MuID, val: u64) -> P<Value> {
pub fn make_int32_const(id: MuID, val: u64) -> P<Value> {
Value::make_int_const_ty(id, UINT32_TYPE.clone(), val)
}
pub fn make_int64_const(id: MuID, val: u64) -> P<Value> {
Value::make_int_const_ty(id, UINT64_TYPE.clone(), val)
}
pub fn make_int_const_ty(id: MuID, ty: P<MuType>, val: u64) -> P<Value> {
P(Value {
hdr: MuEntityHeader::unnamed(id),
......
......@@ -75,6 +75,14 @@ lazy_static! {
MuType::new(new_internal_id(), MuType_::iref(VOID_TYPE.clone()))
);
pub static ref UPTR_U8_TYPE: P<MuType> = P(
MuType::new(new_internal_id(), MuType_::uptr(UINT8_TYPE.clone()))
);
pub static ref UPTR_U64_TYPE: P<MuType> = P(
MuType::new(new_internal_id(), MuType_::uptr(UINT64_TYPE.clone()))
);
pub static ref STACKREF_TYPE : P<MuType> = P(
MuType::new(new_internal_id(), MuType_::StackRef)
);
......@@ -99,6 +107,8 @@ lazy_static! {
IREF_VOID_TYPE.clone(),
STACKREF_TYPE.clone(),
THREADREF_TYPE.clone(),
UPTR_U8_TYPE.clone(),
UPTR_U64_TYPE.clone()
];
}
......
......@@ -1604,6 +1604,12 @@ impl<'a> InstructionSelection {
);
}
Instruction_::GetVMThreadLocal => {
trace!("instsel on GETVMTHREADLOCAL");
let tl = self.emit_get_threadlocal(Some(node), f_content, f_context, vm);
let tmp_res = self.get_result_value(node);
self.backend.emit_mov_r_r(&tmp_res, &tl);
}
Instruction_::CommonInst_GetThreadLocal => {
trace!("instsel on GETTHREADLOCAL");
// get thread local
......@@ -3493,7 +3499,7 @@ impl<'a> InstructionSelection {
f_context: &mut FunctionContext,
vm: &VM
) -> P<Value> {
let size = math::align_up(size + OBJECT_HEADER_SIZE, POINTER_SIZE);
let size = math::align_up(mm::check_size(size), POINTER_SIZE);
let encode = mm::gen_object_encode(backend_ty, size, vm);
let tmp_res = self.get_result_value(node);
......
......@@ -218,7 +218,7 @@ impl FrameSlot {
ty: ty.clone(),
v: Value_::Memory(MemoryLocation::Address {
base: x86_64::RBP.clone(),
offset: Some(Value::make_int_const(vm.next_id(), self.offset as u64)),
offset: Some(Value::make_int32_const(vm.next_id(), self.offset as u64)),
index: None,
scale: None
})
......@@ -234,7 +234,7 @@ impl FrameSlot {
ty: ty.clone(),
v: Value_::Memory(MemoryLocation::VirtualAddress {
base: aarch64::FP.clone(),
offset: Some(Value::make_int_const(vm.next_id(), self.offset as u64)),
offset: Some(Value::make_int32_const(vm.next_id(), self.offset as u64)),
scale: 1,
signed: true
})
......
......@@ -104,6 +104,7 @@ impl Default for CompilerPolicy {
// ir level passes
passes.push(Box::new(passes::RetSink::new()));
passes.push(Box::new(passes::Inlining::new()));
passes.push(Box::new(passes::InjectRuntime::new()));
passes.push(Box::new(passes::DefUse::new()));
passes.push(Box::new(passes::TreeGen::new()));
passes.push(Box::new(passes::GenMovPhi::new()));
......
This diff is collapsed.
......@@ -27,6 +27,10 @@ pub use compiler::passes::inlining::Inlining;
mod ret_sink;
pub use compiler::passes::ret_sink::RetSink;
/// A pass to inject runtime fastpath into Mu IR
mod inject_runtime;
pub use compiler::passes::inject_runtime::InjectRuntime;
/// A Def-Use pass. Getting use info and count for SSA variables in the IR
mod def_use;
pub use compiler::passes::def_use::DefUse;
......
......@@ -88,7 +88,8 @@ fn is_suitable_child(inst: &Instruction) -> bool {
CommonInst_GetAddr(_) |
CmpXchg { .. } |
AtomicRMW { .. } |
Store { .. } => false,
Store { .. } |
GetVMThreadLocal => false,
BinOp(_, _, _) | BinOpWithStatus(_, _, _, _) | CommonInst_GetThreadLocal | Move(_) => false,
......
......@@ -41,8 +41,8 @@ pub struct ImmixAllocator {
}
lazy_static! {
pub static ref CURSOR_OFFSET : usize = offset_of!(ImmixAllocator=>cursor).get_byte_offset();
pub static ref LIMIT_OFFSET : usize = offset_of!(ImmixAllocator=>limit).get_byte_offset();
pub static ref CURSOR_OFFSET : ByteSize = offset_of!(ImmixAllocator=>cursor).get_byte_offset();
pub static ref LIMIT_OFFSET : ByteSize = offset_of!(ImmixAllocator=>limit).get_byte_offset();
}
impl Allocator for ImmixAllocator {
......
......@@ -113,6 +113,13 @@ pub struct Mutator {
global: Arc<MutatorGlobal>
}
lazy_static! {
pub static ref TINY_ALLOCATOR_OFFSET: ByteSize =
offset_of!(Mutator=>tiny).get_byte_offset();
pub static ref NORMAL_ALLOCATOR_OFFSET: ByteSize =
offset_of!(Mutator=>normal).get_byte_offset();
}
impl Mutator {
pub fn new(
tiny: ImmixAllocator,
......
......@@ -121,7 +121,7 @@ pub const LARGE_OBJECT_THRESHOLD: usize = BYTES_IN_LINE;
/// the mutator that the user is supposed to put to every mutator thread
/// Most interface functions provided by the GC require a pointer to this mutator.
pub use heap::Mutator;
pub use heap::*;
pub use objectmodel::*;
......
......@@ -38,4 +38,13 @@ pub fn check_alignment(align: ByteSize) -> ByteSize {
} else {
align
}
}
#[inline(always)]
pub fn check_size(size: ByteSize) -> ByteSize {
if size < MINIMAL_OBJECT_SIZE {
MINIMAL_OBJECT_SIZE
} else {
size
}
}
\ No newline at end of file
......@@ -89,11 +89,21 @@ lazy_static! {
vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()],
vec![ADDRESS_TYPE.clone()]
);
pub static ref ALLOC_TINY_SLOW: RuntimeEntrypoint = RuntimeEntrypoint::new(
"muentry_alloc_tiny_slow",
vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()],
vec![ADDRESS_TYPE.clone()]
);
pub static ref ALLOC_NORMAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
"muentry_alloc_normal",
vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()],
vec![ADDRESS_TYPE.clone()]
);
pub static ref ALLOC_NORMAL_SLOW: RuntimeEntrypoint = RuntimeEntrypoint::new(
"muentry_alloc_normal_slow",
vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()],
vec![ADDRESS_TYPE.clone()]
);
pub static ref ALLOC_LARGE: RuntimeEntrypoint = RuntimeEntrypoint::new(
"muentry_alloc_large",
vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment