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 a5943a79 authored by qinsoon's avatar qinsoon
Browse files

add TraceHint for each block for better trace scheduling

parent 1b6f904a
......@@ -453,11 +453,16 @@ impl FunctionContext {
/// Block contains BlockContent, which includes all the instructions for the block
// FIXME: control_flow field should be moved out of ast crate (Issue #18)
// FIXME: control_flow field should be moved out of ast crate (Issue #18)
// FIXME: trace_hint should also be moved
#[derive(Clone)]
pub struct Block {
pub hdr: MuEntityHeader,
/// the actual content of this block
pub content: Option<BlockContent>,
/// a trace scheduling hint about where to layout this block
pub trace_hint: TraceHint,
/// control flow info about this block (predecessors, successors, etc)
pub control_flow: ControlFlow
}
......@@ -477,7 +482,7 @@ impl fmt::Debug for Block {
impl Block {
pub fn new(entity: MuEntityHeader) -> Block {
Block{hdr: entity, content: None, control_flow: ControlFlow::default()}
Block{hdr: entity, content: None, trace_hint: TraceHint::None, control_flow: ControlFlow::default()}
}
/// does this block have an exception arguments?
......@@ -497,6 +502,19 @@ impl Block {
}
}
/// TraceHint is a hint for the compiler to generate better trace for this block
#[derive(Clone)]
pub enum TraceHint {
/// no hint provided. Trace scheduler should use its own heuristics to decide
None,
/// this block is fast path, and should be put in straightline code where possible
FastPath,
/// this block is slow path, and should be kept out of hot loops
SlowPath,
/// this block is return sink, and should be put at the end of a function
ReturnSink
}
/// ControlFlow stores compilation info about control flows of a block
// FIXME: Issue #18
......
......@@ -365,6 +365,7 @@ fn copy_inline_blocks(caller: &mut Vec<Block>, ret_block: MuID, callee: &Functio
let mut block = Block {
hdr: MuEntityHeader::named(new_id, format!("{}:inlinedblock.#{}", block.name(), new_id)),
content: block.content.clone(),
trace_hint: TraceHint::None,
control_flow: ControlFlow::default()
};
......
......@@ -54,6 +54,8 @@ impl CompilerPass for RetSink {
trace!("created return sink {}", block_name);
let mut block = Block::new(MuEntityHeader::named(vm.next_id(), block_name));
// tell the compiler this is the return sink
block.trace_hint = TraceHint::ReturnSink;
vm.set_name(block.as_entity());
let sig = func.sig.clone();
......
......@@ -1521,6 +1521,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
Block {
hdr: hdr,
content: Some(ctn),
trace_hint: TraceHint::None,
control_flow: Default::default(),
}
}
......
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