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 a428732b authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Fixed bug where duplicate blocks were created

parent ce779815
...@@ -34,7 +34,7 @@ gcc = "*" ...@@ -34,7 +34,7 @@ gcc = "*"
ast = {path = "src/ast"} ast = {path = "src/ast"}
utils = {path = "src/utils"} utils = {path = "src/utils"}
gc = {path = "src/gc"} gc = {path = "src/gc"}
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = "0.0.3" } rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
libc="*" libc="*"
field-offset = "*" field-offset = "*"
libloading = "*" libloading = "*"
......
...@@ -25,4 +25,4 @@ utils = {path = "../utils"} ...@@ -25,4 +25,4 @@ utils = {path = "../utils"}
lazy_static = "*" lazy_static = "*"
log = "*" log = "*"
simple_logger = "*" simple_logger = "*"
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = "0.0.3" } rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
...@@ -2127,22 +2127,6 @@ impl CodeGenerator for ASMCodeGen { ...@@ -2127,22 +2127,6 @@ impl CodeGenerator for ASMCodeGen {
) )
} }
fn emit_frame_shrink(&mut self) {
trace!("emit: \tframe shrink");
let asm = format!("ADD SP,SP,#{}", FRAME_SIZE_PLACEHOLDER.clone());
let line = self.line();
self.cur_mut().add_frame_size_patchpoint(ASMLocation::new(line, 11, FRAME_SIZE_PLACEHOLDER_LEN, 0));
self.add_asm_inst(
asm,
linked_hashmap!{},
linked_hashmap!{},
false
)
}
fn emit_add_str(&mut self, dest: Reg, src1: Reg, src2: &str) {self.internal_binop_str("ADD", dest, src1, src2)} fn emit_add_str(&mut self, dest: Reg, src1: Reg, src2: &str) {self.internal_binop_str("ADD", dest, src1, src2)}
// Pushes a pair of registers on the givne stack (uses the STP instruction) // Pushes a pair of registers on the givne stack (uses the STP instruction)
......
...@@ -49,7 +49,6 @@ pub trait CodeGenerator { ...@@ -49,7 +49,6 @@ pub trait CodeGenerator {
// emit code to adjust frame // emit code to adjust frame
fn emit_frame_grow(&mut self); // Emits a SUB fn emit_frame_grow(&mut self); // Emits a SUB
fn emit_frame_shrink(&mut self); // Emits an ADD
// Used to pass a string that the assembler will interpret as an immediate argument // Used to pass a string that the assembler will interpret as an immediate argument
// (This is neccesary to support the use of ELF relocations like ':tprel_hi12:foo') // (This is neccesary to support the use of ELF relocations like ':tprel_hi12:foo')
......
...@@ -189,7 +189,7 @@ impl <'a> InstructionSelection { ...@@ -189,7 +189,7 @@ impl <'a> InstructionSelection {
// it is possible that the fallthrough block is scheduled somewhere else // it is possible that the fallthrough block is scheduled somewhere else
// we need to explicitly jump to it // we need to explicitly jump to it
self.finish_block(); self.finish_block();
let fallthrough_temp_block = make_block_name(node, "branch_fallthrough", ); let fallthrough_temp_block = make_block_name(&self.current_fv_name, node.id(), "branch_fallthrough", );
self.start_block(fallthrough_temp_block, &vec![]); self.start_block(fallthrough_temp_block, &vec![]);
let fallthrough_target = f_content.get_block(fallthrough_dest.target).name(); let fallthrough_target = f_content.get_block(fallthrough_dest.target).name();
...@@ -343,7 +343,8 @@ impl <'a> InstructionSelection { ...@@ -343,7 +343,8 @@ impl <'a> InstructionSelection {
self.backend.emit_b_cond("EQ", target); self.backend.emit_b_cond("EQ", target);
self.finish_block(); self.finish_block();
self.start_block(make_block_name(node, format!("switch_not_met_case_{}", case_op_index).as_str()), &vec![]); let block_name = make_block_name(&self.current_fv_name, node.id(), format!("switch_not_met_case_{}", case_op_index).as_str());
self.start_block(block_name, &vec![]);
} }
// emit default // emit default
...@@ -628,9 +629,9 @@ impl <'a> InstructionSelection { ...@@ -628,9 +629,9 @@ impl <'a> InstructionSelection {
// overflows to_ty_size, but not to_ty_reg_size // overflows to_ty_size, but not to_ty_reg_size
let to_ty_reg_size = check_op_len(&tmp_res.ty); // The size of the aarch64 register let to_ty_reg_size = check_op_len(&tmp_res.ty); // The size of the aarch64 register
if to_ty_size != to_ty_reg_size { if to_ty_size != to_ty_reg_size {
let blk_positive = make_block_name(node, "positive"); let blk_positive = make_block_name(&self.current_fv_name, node.id(), "positive");
let blk_negative = make_block_name(node, "negative"); let blk_negative = make_block_name(&self.current_fv_name, node.id(), "negative");
let blk_end = make_block_name(node, "end"); let blk_end = make_block_name(&self.current_fv_name, node.id(), "end");
let tmp = make_temporary(f_context, to_ty.clone(), vm); let tmp = make_temporary(f_context, to_ty.clone(), vm);
self.backend.emit_tbnz(&tmp_res, (to_ty_size - 1) as u8, blk_negative.clone()); self.backend.emit_tbnz(&tmp_res, (to_ty_size - 1) as u8, blk_negative.clone());
...@@ -747,7 +748,7 @@ impl <'a> InstructionSelection { ...@@ -747,7 +748,7 @@ impl <'a> InstructionSelection {
self.finish_block(); self.finish_block();
let blk_load_start = make_block_name(node, "load_start"); let blk_load_start = make_block_name(&self.current_fv_name, node.id(), "load_start");
// load_start: // load_start:
self.start_block(blk_load_start.clone(), &vec![temp_loc.clone()]); self.start_block(blk_load_start.clone(), &vec![temp_loc.clone()]);
...@@ -849,7 +850,7 @@ impl <'a> InstructionSelection { ...@@ -849,7 +850,7 @@ impl <'a> InstructionSelection {
self.finish_block(); self.finish_block();
let blk_store_start = make_block_name(node, "store_start"); let blk_store_start = make_block_name(&self.current_fv_name, node.id(), "store_start");
// store_start: // store_start:
self.start_block(blk_store_start.clone(), &vec![temp_loc.clone()]); self.start_block(blk_store_start.clone(), &vec![temp_loc.clone()]);
...@@ -916,9 +917,9 @@ impl <'a> InstructionSelection { ...@@ -916,9 +917,9 @@ impl <'a> InstructionSelection {
let res_value = self.get_result_value(node, 0); let res_value = self.get_result_value(node, 0);
let res_success = self.get_result_value(node, 1); let res_success = self.get_result_value(node, 1);
let blk_cmpxchg_start = make_block_name(node, "cmpxchg_start"); let blk_cmpxchg_start = make_block_name(&self.current_fv_name, node.id(), "cmpxchg_start");
let blk_cmpxchg_failed = make_block_name(node, "cmpxchg_failed"); let blk_cmpxchg_failed = make_block_name(&self.current_fv_name, node.id(), "cmpxchg_failed");
let blk_cmpxchg_succeded = make_block_name(node, "cmpxchg_succeded"); let blk_cmpxchg_succeded = make_block_name(&self.current_fv_name, node.id(), "cmpxchg_succeded");
self.finish_block(); self.finish_block();
...@@ -1217,7 +1218,7 @@ impl <'a> InstructionSelection { ...@@ -1217,7 +1218,7 @@ impl <'a> InstructionSelection {
Some(node), f_context, vm Some(node), f_context, vm
); );
} }
// Runtime Entry // Runtime Entry
Instruction_::Throw(op_index) => { Instruction_::Throw(op_index) => {
trace!("instsel on THROW"); trace!("instsel on THROW");
...@@ -2706,8 +2707,8 @@ impl <'a> InstructionSelection { ...@@ -2706,8 +2707,8 @@ impl <'a> InstructionSelection {
// emit: ALLOC_LARGE: // emit: ALLOC_LARGE:
// emit: >> large object alloc // emit: >> large object alloc
// emit: ALLOC_LARGE_END: // emit: ALLOC_LARGE_END:
let blk_alloc_large = make_block_name(node, "alloc_large"); let blk_alloc_large = make_block_name(&self.current_fv_name, node.id(), "alloc_large");
let blk_alloc_large_end = make_block_name(node, "alloc_large_end"); let blk_alloc_large_end = make_block_name(&self.current_fv_name, node.id(), "alloc_large_end");
if OBJECT_HEADER_SIZE != 0 { if OBJECT_HEADER_SIZE != 0 {
let size_with_hdr = make_temporary(f_context, UINT64_TYPE.clone(), vm); let size_with_hdr = make_temporary(f_context, UINT64_TYPE.clone(), vm);
...@@ -2719,7 +2720,8 @@ impl <'a> InstructionSelection { ...@@ -2719,7 +2720,8 @@ impl <'a> InstructionSelection {
self.backend.emit_b_cond("GT", blk_alloc_large.clone()); self.backend.emit_b_cond("GT", blk_alloc_large.clone());
self.finish_block(); self.finish_block();
self.start_block(make_block_name(node, "allocsmall"), &vec![]); let block_name = make_block_name(&self.current_fv_name, node.id(), "allocsmall");
self.start_block(block_name, &vec![]);
self.emit_alloc_sequence_small(tmp_allocator.clone(), size.clone(), align, node, f_context, vm); self.emit_alloc_sequence_small(tmp_allocator.clone(), size.clone(), align, node, f_context, vm);
self.backend.emit_b(blk_alloc_large_end.clone()); self.backend.emit_b(blk_alloc_large_end.clone());
...@@ -3690,10 +3692,6 @@ impl <'a> InstructionSelection { ...@@ -3690,10 +3692,6 @@ impl <'a> InstructionSelection {
self.backend.emit_ldr_callee_saved(reg, &loc); self.backend.emit_ldr_callee_saved(reg, &loc);
} }
//self.backend.emit_frame_shrink();
// Pop the link register and frame pointers
// Pop the frame record // Pop the frame record
self.backend.emit_mov(&SP, &FP); self.backend.emit_mov(&SP, &FP);
self.backend.emit_pop_pair(&FP, &LR, &SP); self.backend.emit_pop_pair(&FP, &LR, &SP);
...@@ -4361,7 +4359,7 @@ impl <'a> InstructionSelection { ...@@ -4361,7 +4359,7 @@ impl <'a> InstructionSelection {
fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> String { fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> String {
let ret = { let ret = {
if cur_node.is_some() { if cur_node.is_some() {
make_block_name(cur_node.unwrap(), format!("callsite_{}", self.current_callsite_id).as_str()) make_block_name(&self.current_fv_name, cur_node.unwrap().id(), format!("callsite_{}", self.current_callsite_id).as_str())
} else { } else {
format!("{}:callsite_{}", self.current_fv_name, self.current_callsite_id) format!("{}:callsite_{}", self.current_fv_name, self.current_callsite_id)
} }
......
...@@ -2194,22 +2194,6 @@ impl CodeGenerator for ASMCodeGen { ...@@ -2194,22 +2194,6 @@ impl CodeGenerator for ASMCodeGen {
) )
} }
fn emit_frame_shrink(&mut self) {
trace!("emit frame shrink");
let asm = format!("addq ${},%rsp", FRAME_SIZE_PLACEHOLDER.clone());
let line = self.line();
self.cur_mut().add_frame_size_patchpoint(ASMLocation::new(line, 6, FRAME_SIZE_PLACEHOLDER_LEN, 0));
self.add_asm_inst(
asm,
linked_hashmap!{},
linked_hashmap!{},
false
)
}
fn emit_nop(&mut self, bytes: usize) { fn emit_nop(&mut self, bytes: usize) {
trace!("emit: nop ({} bytes)", bytes); trace!("emit: nop ({} bytes)", bytes);
...@@ -3528,7 +3512,7 @@ pub fn emit_context_with_reloc(vm: &VM, ...@@ -3528,7 +3512,7 @@ pub fn emit_context_with_reloc(vm: &VM,
use std::path; use std::path;
use std::io::prelude::*; use std::io::prelude::*;
emit_mu_types(vm); emit_mu_types("", vm);
debug!("---Emit VM Context---"); debug!("---Emit VM Context---");
create_emit_directory(vm); create_emit_directory(vm);
......
...@@ -44,8 +44,7 @@ pub trait CodeGenerator { ...@@ -44,8 +44,7 @@ pub trait CodeGenerator {
// emit code to adjust frame // emit code to adjust frame
fn emit_frame_grow(&mut self); fn emit_frame_grow(&mut self);
fn emit_frame_shrink(&mut self);
fn emit_nop(&mut self, bytes: usize); fn emit_nop(&mut self, bytes: usize);
// comparison // comparison
......
...@@ -347,7 +347,7 @@ impl <'a> InstructionSelection { ...@@ -347,7 +347,7 @@ impl <'a> InstructionSelection {
// we need to explicitly jump to it // we need to explicitly jump to it
self.finish_block(); self.finish_block();
let fallthrough_temp_block = make_block_name(node, "branch_fallthrough", ); let fallthrough_temp_block = make_block_name(&self.current_fv_name, node.id(), "branch_fallthrough", );
self.start_block(fallthrough_temp_block); self.start_block(fallthrough_temp_block);
let fallthrough_target = f_content.get_block(fallthrough_dest.target).name(); let fallthrough_target = f_content.get_block(fallthrough_dest.target).name();
...@@ -417,9 +417,9 @@ impl <'a> InstructionSelection { ...@@ -417,9 +417,9 @@ impl <'a> InstructionSelection {
} }
// jcc // jcc
_ => { _ => {
let blk_true = make_block_name(node, "select_true"); let blk_true = make_block_name(&self.current_fv_name, node.id(), "select_true");
let blk_false = make_block_name(node, "select_false"); let blk_false = make_block_name(&self.current_fv_name, node.id(), "select_false");
let blk_end = make_block_name(node, "select_end"); let blk_end = make_block_name(&self.current_fv_name, node.id(), "select_end");
// jump to blk_true if true // jump to blk_true if true
match cmpop { match cmpop {
...@@ -470,9 +470,9 @@ impl <'a> InstructionSelection { ...@@ -470,9 +470,9 @@ impl <'a> InstructionSelection {
} else if self.match_fpreg(true_val) { } else if self.match_fpreg(true_val) {
let tmp_res = self.get_result_value(node); let tmp_res = self.get_result_value(node);
let blk_true = make_block_name(node, "select_true"); let blk_true = make_block_name(&self.current_fv_name, node.id(), "select_true");
let blk_false = make_block_name(node, "select_false"); let blk_false = make_block_name(&self.current_fv_name, node.id(), "select_false");
let blk_end = make_block_name(node, "select_end"); let blk_end = make_block_name(&self.current_fv_name, node.id(), "select_end");
// jump to blk_true if true // jump to blk_true if true
match cmpop { match cmpop {
...@@ -610,7 +610,8 @@ impl <'a> InstructionSelection { ...@@ -610,7 +610,8 @@ impl <'a> InstructionSelection {
} }
self.finish_block(); self.finish_block();
self.start_block(make_block_name(node, format!("switch_not_met_case_{}", case_op_index).as_str())); let block_name = make_block_name(&self.current_fv_name, node.id(), format!("switch_not_met_case_{}", case_op_index).as_str());
self.start_block(block_name);
} }
// emit default // emit default
...@@ -945,9 +946,9 @@ impl <'a> InstructionSelection { ...@@ -945,9 +946,9 @@ impl <'a> InstructionSelection {
// testq %tmp_op %tmp_op // testq %tmp_op %tmp_op
self.backend.emit_test_r_r(&tmp_op, &tmp_op); self.backend.emit_test_r_r(&tmp_op, &tmp_op);
let blk_if_signed = make_block_name(node, "uitofp_float_if_signed",); let blk_if_signed = make_block_name(&self.current_fv_name, node.id(), "uitofp_float_if_signed",);
let blk_if_not_signed = make_block_name(node, "uitofp_float_if_not_signed"); let blk_if_not_signed = make_block_name(&self.current_fv_name, node.id(), "uitofp_float_if_not_signed");
let blk_done = make_block_name(node, "uitofp_float_done"); let blk_done = make_block_name(&self.current_fv_name, node.id(), "uitofp_float_done");
// js %if_signed // js %if_signed
self.backend.emit_js(blk_if_signed.clone()); self.backend.emit_js(blk_if_signed.clone());
...@@ -1424,7 +1425,28 @@ impl <'a> InstructionSelection { ...@@ -1424,7 +1425,28 @@ impl <'a> InstructionSelection {
Some(node), f_content, f_context, vm Some(node), f_content, f_context, vm
); );
} }
/*Instruction_::AllocA(ref ty) => {
trace!("instsel on AllocA");
if cfg!(debug_assertions) {
match ty.v {
MuType_::Hybrid(_) => panic!("cannot use ALLOCA for hybrid, use ALLOCAHYBRID instead"),
_ => {}
}
}
let ty_info = vm.get_backend_type_info(ty.id());
let size = ty_info.size;
let ty_align= ty_info.alignment;
if 16 % ty_align != 0 {
// It's not trivial to allign this type...
unimplemented!()
}
// Round size up to the nearest multiple of 16
let size = ((size + 16 - 1)/16)*16;
}*/
Instruction_::Throw(op_index) => { Instruction_::Throw(op_index) => {
trace!("instsel on THROW"); trace!("instsel on THROW");
...@@ -2534,8 +2556,8 @@ impl <'a> InstructionSelection { ...@@ -2534,8 +2556,8 @@ impl <'a> InstructionSelection {
// emit: ALLOC_LARGE: // emit: ALLOC_LARGE:
// emit: >> large object alloc // emit: >> large object alloc
// emit: ALLOC_LARGE_END: // emit: ALLOC_LARGE_END:
let blk_alloc_large = make_block_name(node, "alloc_large"); let blk_alloc_large = make_block_name(&self.current_fv_name, node.id(), "alloc_large");
let blk_alloc_large_end = make_block_name(node, "alloc_large_end"); let blk_alloc_large_end = make_block_name(&self.current_fv_name, node.id(), "alloc_large_end");
if OBJECT_HEADER_SIZE != 0 { if OBJECT_HEADER_SIZE != 0 {
let size_with_hdr = self.make_temporary(f_context, UINT64_TYPE.clone(), vm); let size_with_hdr = self.make_temporary(f_context, UINT64_TYPE.clone(), vm);
...@@ -2549,7 +2571,8 @@ impl <'a> InstructionSelection { ...@@ -2549,7 +2571,8 @@ impl <'a> InstructionSelection {
self.backend.emit_jg(blk_alloc_large.clone()); self.backend.emit_jg(blk_alloc_large.clone());
self.finish_block(); self.finish_block();
self.start_block(make_block_name(node, "allocsmall")); let block_name = make_block_name(&self.current_fv_name, node.id(), "allocsmall");
self.start_block(block_name);
// alloc small here // alloc small here
self.emit_alloc_sequence_small(tmp_allocator.clone(), size.clone(), align, node, f_content, f_context, vm); self.emit_alloc_sequence_small(tmp_allocator.clone(), size.clone(), align, node, f_content, f_context, vm);
...@@ -2652,12 +2675,13 @@ impl <'a> InstructionSelection { ...@@ -2652,12 +2675,13 @@ impl <'a> InstructionSelection {
// branch to slow path if end > limit (end - limit > 0) // branch to slow path if end > limit (end - limit > 0)
// ASM: jg alloc_slow // ASM: jg alloc_slow
let slowpath = make_block_name(node, "allocslow"); let slowpath = make_block_name(&self.current_fv_name, node.id(), "allocslow");
self.backend.emit_jg(slowpath.clone()); self.backend.emit_jg(slowpath.clone());
// finish current block // finish current block
self.finish_block(); self.finish_block();
self.start_block(make_block_name(node, "updatecursor")); let block_name = make_block_name(&self.current_fv_name, node.id(), "updatecursor");
self.start_block(block_name);
// update cursor // update cursor
// ASM: mov %end -> [%tl + allocator_offset + cursor_offset] // ASM: mov %end -> [%tl + allocator_offset + cursor_offset]
...@@ -2674,7 +2698,7 @@ impl <'a> InstructionSelection { ...@@ -2674,7 +2698,7 @@ impl <'a> InstructionSelection {
} }
// ASM jmp alloc_end // ASM jmp alloc_end
let allocend = make_block_name(node, "alloc_small_end"); let allocend = make_block_name(&self.current_fv_name, node.id(), "alloc_small_end");
self.backend.emit_jmp(allocend.clone()); self.backend.emit_jmp(allocend.clone());
// finishing current block // finishing current block
...@@ -3377,7 +3401,8 @@ impl <'a> InstructionSelection { ...@@ -3377,7 +3401,8 @@ impl <'a> InstructionSelection {
// insert an intermediate block to branch to normal // insert an intermediate block to branch to normal
// the branch is inserted later (because we need to deal with postcall convention) // the branch is inserted later (because we need to deal with postcall convention)
self.finish_block(); self.finish_block();
self.start_block(make_block_name(cur_node, "normal_cont_for_call")); let block_name = make_block_name(&self.current_fv_name, cur_node.id(), "normal_cont_for_call");
self.start_block(block_name);
} else { } else {
self.current_callsites.push_back((callsite.to_relocatable(), 0, stack_arg_size)); self.current_callsites.push_back((callsite.to_relocatable(), 0, stack_arg_size));
} }
...@@ -3643,7 +3668,8 @@ impl <'a> InstructionSelection { ...@@ -3643,7 +3668,8 @@ impl <'a> InstructionSelection {
} }
} }
// frame shrink // frame shrink
self.backend.emit_frame_shrink(); // RBP -> RSP
self.backend.emit_mov_r_r(&x86_64::RSP, &x86_64::RBP);
// pop rbp // pop rbp
self.backend.emit_pop_r64(&x86_64::RBP); self.backend.emit_pop_r64(&x86_64::RBP);
...@@ -4736,7 +4762,7 @@ impl <'a> InstructionSelection { ...@@ -4736,7 +4762,7 @@ impl <'a> InstructionSelection {
fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> String { fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> String {
let ret = { let ret = {
if cur_node.is_some() { if cur_node.is_some() {
make_block_name(cur_node.unwrap(), format!("callsite_{}", self.current_callsite_id).as_str()) make_block_name(&self.current_fv_name, cur_node.unwrap().id(), format!("callsite_{}", self.current_callsite_id).as_str())
} else { } else {
format!("{}:callsite_{}", self.current_fv_name, self.current_callsite_id) format!("{}:callsite_{}", self.current_fv_name, self.current_callsite_id)
} }
......
...@@ -36,37 +36,14 @@ pub fn create_emit_directory(vm: &VM) { ...@@ -36,37 +36,14 @@ pub fn create_emit_directory(vm: &VM) {
} }
} }
fn create_emit_file(name: String, vm: &VM) -> File {
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(name);
match File::create(file_path.as_path()) {
Err(why) => panic!("couldn't create emit file {}: {}", file_path.to_str().unwrap(), why),
Ok(file) => file
}
}
pub struct CodeEmission {
name: &'static str
}
impl CodeEmission {
pub fn new() -> CodeEmission {
CodeEmission {
name: "Code Emission"
}
}
}
#[allow(dead_code)] #[allow(dead_code)]
pub fn emit_mu_types(vm: &VM) { pub fn emit_mu_types(suffix: &str, vm: &VM) {
if EMIT_MUIR { if EMIT_MUIR {
create_emit_directory(vm); create_emit_directory(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("___types.muty"); file_path.push("___types".to_string() + suffix + ".muty");
let mut file = match File::create(file_path.as_path()) { let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!("couldn't create mu types file {}: {}", file_path.to_str().unwrap(), why), Err(why) => panic!("couldn't create mu types file {}: {}", file_path.to_str().unwrap(), why),
Ok(file) => file Ok(file) => file
...@@ -101,217 +78,27 @@ pub fn emit_mu_types(vm: &VM) { ...@@ -101,217 +78,27 @@ pub fn emit_mu_types(vm: &VM) {
} }
} }
#[allow(dead_code)] fn create_emit_file(name: String, vm: &VM) -> File {
fn emit_muir(func: &MuFunctionVersion, vm: &VM) { let mut file_path = path::PathBuf::new();
let func_name = func.name(); file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(name);
// create emit directory
create_emit_directory(vm);
// final IR
{
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func_name.clone() + ".muir");
let mut file = match File::create(file_path.as_path()) {
Err(why) => panic!("couldn't create muir file {}: {}", file_path.to_str().unwrap(), why),
Ok(file) => file
};
write!(file, "{:?}", func).unwrap();
}
// original IR (source/input)
{
let mut file_path = path::PathBuf::new();