GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit da56db93 authored by qinsoon's avatar qinsoon

[wip] exception unimplemented. gonna work on it

parent e408366b
......@@ -298,7 +298,7 @@ impl Instruction_ {
&Instruction_::Return(ref vals) => format!("RET {}", op_vector_str(vals, ops)),
&Instruction_::ThreadExit => "THREADEXIT".to_string(),
&Instruction_::Throw(ref val) => format!("THROW {}", val),
&Instruction_::Throw(exn_obj) => format!("THROW {}", ops[exn_obj]),
&Instruction_::TailCall(ref call) => format!("TAILCALL {}", call.debug_str(ops)),
&Instruction_::Branch1(ref dest) => format!("BRANCH {}", dest.debug_str(ops)),
&Instruction_::Branch2{cond, ref true_dest, ref false_dest, ..} => {
......
......@@ -91,7 +91,7 @@ impl fmt::Display for MuFunction {
}
}
#[derive(Debug, RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable)]
pub struct MuFunctionVersion {
pub hdr: MuEntityHeader,
......@@ -109,6 +109,24 @@ impl fmt::Display for MuFunctionVersion {
}
}
impl fmt::Debug for MuFunctionVersion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "FuncVer {} of Func #{}\n", self.hdr, self.func_id).unwrap();
write!(f, "Signature: {}\n", self.sig).unwrap();
write!(f, "IR:\n").unwrap();
if self.content.is_some() {
write!(f, "{:?}\n", self.content.as_ref().unwrap()).unwrap();
} else {
write!(f, "Empty\n").unwrap();
}
if self.block_trace.is_some() {
write!(f, "{:?}\n", self.block_trace.as_ref().unwrap())
} else {
write!(f, "Trace not available\n")
}
}
}
impl MuFunctionVersion {
pub fn new(id: MuID, func: MuID, sig: P<MuFuncSig>) -> MuFunctionVersion {
MuFunctionVersion{
......@@ -163,12 +181,25 @@ impl MuFunctionVersion {
}
}
#[derive(Debug, RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable)]
pub struct FunctionContent {
pub entry: MuID,
pub blocks: HashMap<MuID, Block>
}
impl fmt::Debug for FunctionContent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let entry = self.get_entry_block();
write!(f, "{:?}\n", entry).unwrap();
for blk_id in self.blocks.keys() {
let block = self.get_block(*blk_id);
write!(f, "{:?}\n", block).unwrap();
}
Ok(())
}
}
impl FunctionContent {
pub fn get_entry_block(&self) -> &Block {
self.get_block(self.entry)
......@@ -231,13 +262,27 @@ impl FunctionContext {
}
}
#[derive(Debug, RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable)]
pub struct Block {
pub hdr: MuEntityHeader,
pub content: Option<BlockContent>,
pub control_flow: ControlFlow
}
impl fmt::Debug for Block {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "Block {}", self.hdr).unwrap();
writeln!(f, "with preds: {:?}", self.control_flow.preds).unwrap();
writeln!(f, " succs: {:?}", self.control_flow.succs).unwrap();
if self.content.is_some() {
writeln!(f, "{:?}", self.content.as_ref().unwrap()).unwrap();
} else {
writeln!(f, "Empty").unwrap();
}
Ok(())
}
}
impl Block {
pub fn new(id: MuID) -> Block {
Block{hdr: MuEntityHeader::unnamed(id), content: None, control_flow: ControlFlow::default()}
......@@ -302,7 +347,7 @@ pub enum EdgeKind {
Forward, Backward
}
#[derive(Debug, RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable)]
pub struct BlockContent {
pub args: Vec<P<Value>>,
pub exn_arg: Option<P<Value>>,
......@@ -310,6 +355,18 @@ pub struct BlockContent {
pub keepalives: Option<Vec<P<Value>>>
}
impl fmt::Debug for BlockContent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "args: {:?}", self.args).unwrap();
writeln!(f, "exception arg: {:?}", self.args).unwrap();
writeln!(f, "keepalives: {:?}", self.keepalives).unwrap();
for node in self.body.iter() {
writeln!(f, "{}", node).unwrap();
}
Ok(())
}
}
impl BlockContent {
pub fn get_out_arguments(&self) -> Vec<P<Value>> {
let n_insts = self.body.len();
......
......@@ -80,7 +80,9 @@ impl CompilerPass for RegisterAllocation {
PassExecutionResult::ProceedToNext
} else {
PassExecutionResult::GoBackTo(compiler::PASS4_INST_SEL)
// PassExecutionResult::GoBackTo(compiler::PASS_INST_SEL)
unimplemented!()
}
}
}
......@@ -11,14 +11,15 @@ pub mod backend;
pub use compiler::passes::CompilerPass;
pub use compiler::passes::PassExecutionResult;
pub use compiler::passes::PASS0_DEF_USE;
pub use compiler::passes::PASS1_TREE_GEN;
pub use compiler::passes::PASS2_CFA;
pub use compiler::passes::PASS3_TRACE_GEN;
pub use compiler::passes::PASS4_INST_SEL;
pub use compiler::passes::PASS5_REG_ALLOC;
pub use compiler::passes::PASS6_PEEPHOLE;
pub use compiler::passes::PASS7_CODE_EMIT;
pub use compiler::passes::PASS_IR_CHECK;
pub use compiler::passes::PASS_DEF_USE;
pub use compiler::passes::PASS_TREE_GEN;
pub use compiler::passes::PASS_CFA;
pub use compiler::passes::PASS_TRACE_GEN;
pub use compiler::passes::PASS_INST_SEL;
pub use compiler::passes::PASS_REG_ALLOC;
pub use compiler::passes::PASS_PEEPHOLE;
pub use compiler::passes::PASS_CODE_EMIT;
pub struct Compiler {
policy: RefCell<CompilerPolicy>,
......@@ -34,6 +35,8 @@ impl Compiler {
}
pub fn compile(&self, func: &mut MuFunctionVersion) {
trace!("{:?}", func);
// FIXME: should use function name here (however hprof::enter only accept &'static str)
let _p = hprof::enter("Function Compilation");
......
......@@ -11,14 +11,15 @@ pub use compiler::passes::tree_gen::TreeGen;
pub use compiler::passes::control_flow::ControlFlowAnalysis;
pub use compiler::passes::trace_gen::TraceGen;
pub const PASS0_DEF_USE : usize = 0;
pub const PASS1_TREE_GEN : usize = 1;
pub const PASS2_CFA : usize = 2;
pub const PASS3_TRACE_GEN : usize = 3;
pub const PASS4_INST_SEL : usize = 4;
pub const PASS5_REG_ALLOC : usize = 5;
pub const PASS6_PEEPHOLE : usize = 6;
pub const PASS7_CODE_EMIT : usize = 7;
pub const PASS_IR_CHECK : usize = 0;
pub const PASS_DEF_USE : usize = 1;
pub const PASS_TREE_GEN : usize = 2;
pub const PASS_CFA : usize = 3;
pub const PASS_TRACE_GEN : usize = 4;
pub const PASS_INST_SEL : usize = 5;
pub const PASS_REG_ALLOC : usize = 6;
pub const PASS_PEEPHOLE : usize = 7;
pub const PASS_CODE_EMIT : usize = 8;
pub enum PassExecutionResult {
ProceedToNext,
......
......@@ -147,7 +147,6 @@ fn create_catch_exception_func (vm: &VM) {
ops: RwLock::new(vec![]),
v: Instruction_::ThreadExit
});
blk_normal_cont.content = Some(BlockContent {
args: vec![],
exn_arg: None,
......@@ -244,6 +243,14 @@ fn create_throw_exception_func (vm: &VM) {
v: Instruction_::Throw(0)
});
let blk_0_content = BlockContent {
args: vec![],
exn_arg: None,
body: vec![blk_0_inst0, blk_0_inst1, blk_0_inst2, blk_0_term],
keepalives: None
};
blk_0.content = Some(blk_0_content);
func_ver.define(FunctionContent {
entry: blk_0.id(),
blocks: {
......
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