Commit 1b65bccd authored by qinsoon's avatar qinsoon

profile substages in reg alloc, change --allow-inline to

--disable-inline
parent 928b9053
extern crate hprof;
use ast::ir::*; use ast::ir::*;
use compiler::backend; use compiler::backend;
use compiler::backend::reg_alloc::graph_coloring; use compiler::backend::reg_alloc::graph_coloring;
...@@ -113,6 +115,8 @@ impl <'a> GraphColoring<'a> { ...@@ -113,6 +115,8 @@ impl <'a> GraphColoring<'a> {
fn regalloc(mut self) -> GraphColoring<'a> { fn regalloc(mut self) -> GraphColoring<'a> {
trace!("---InterenceGraph---"); trace!("---InterenceGraph---");
let _p = hprof::enter("regalloc: graph coloring");
self.ig.print(&self.func.context); self.ig.print(&self.func.context);
// precolor for all machine registers // precolor for all machine registers
...@@ -161,6 +165,8 @@ impl <'a> GraphColoring<'a> { ...@@ -161,6 +165,8 @@ impl <'a> GraphColoring<'a> {
self.assign_colors(); self.assign_colors();
drop(_p);
if !self.spilled_nodes.is_empty() { if !self.spilled_nodes.is_empty() {
trace!("spill required"); trace!("spill required");
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
......
extern crate hprof;
use compiler::machine_code::CompiledFunction; use compiler::machine_code::CompiledFunction;
use ast::ir::*; use ast::ir::*;
use compiler::backend; use compiler::backend;
...@@ -231,6 +233,8 @@ impl InterferenceGraph { ...@@ -231,6 +233,8 @@ impl InterferenceGraph {
} }
} }
const TRACE_BUILD_LIVE_SET : bool = false;
fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) { fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) {
info!("---start building live set---"); info!("---start building live set---");
...@@ -243,7 +247,9 @@ fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) { ...@@ -243,7 +247,9 @@ fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) {
let mut i = 0; let mut i = 0;
while is_changed { while is_changed {
trace!("---iteration {}---", i); if TRACE_BUILD_LIVE_SET {
trace!("---iteration {}---", i);
}
i += 1; i += 1;
// reset // reset
...@@ -281,11 +287,13 @@ fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) { ...@@ -281,11 +287,13 @@ fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) {
// is in/out changed in this iteration? // is in/out changed in this iteration?
let n_changed = !in_set_old.equals(&livein[n]) || !out_set_old.equals(&liveout[n]); let n_changed = !in_set_old.equals(&livein[n]) || !out_set_old.equals(&liveout[n]);
trace!("inst {}", n); if TRACE_BUILD_LIVE_SET {
trace!("in(old) = {:?}", in_set_old); trace!("inst {}", n);
trace!("in(new) = {:?}", livein[n]); trace!("in(old) = {:?}", in_set_old);
trace!("out(old) = {:?}", out_set_old); trace!("in(new) = {:?}", livein[n]);
trace!("out(new) = {:?}", liveout[n]); trace!("out(old) = {:?}", out_set_old);
trace!("out(new) = {:?}", liveout[n]);
}
is_changed = is_changed || n_changed; is_changed = is_changed || n_changed;
} }
...@@ -314,7 +322,11 @@ fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) { ...@@ -314,7 +322,11 @@ fn build_live_set (cf: &mut CompiledFunction, func: &MuFunctionVersion) {
// from Tailoring Graph-coloring Register Allocation For Runtime Compilation, Figure 4 // from Tailoring Graph-coloring Register Allocation For Runtime Compilation, Figure 4
pub fn build_chaitin_briggs (cf: &mut CompiledFunction, func: &MuFunctionVersion) -> InterferenceGraph { pub fn build_chaitin_briggs (cf: &mut CompiledFunction, func: &MuFunctionVersion) -> InterferenceGraph {
let _p = hprof::enter("regalloc: build live set");
build_live_set(cf, func); build_live_set(cf, func);
drop(_p);
let _p = hprof::enter("regalloc: build interference graph");
info!("---start building interference graph---"); info!("---start building interference graph---");
...@@ -462,6 +474,7 @@ pub fn build_chaitin_briggs (cf: &mut CompiledFunction, func: &MuFunctionVersion ...@@ -462,6 +474,7 @@ pub fn build_chaitin_briggs (cf: &mut CompiledFunction, func: &MuFunctionVersion
} }
} }
drop(_p);
info!("---finish building interference graph---"); info!("---finish building interference graph---");
ig ig
} }
......
...@@ -453,7 +453,7 @@ impl CompilerPass for Inlining { ...@@ -453,7 +453,7 @@ impl CompilerPass for Inlining {
} }
fn visit_function(&mut self, vm: &VM, func: &mut MuFunctionVersion) { fn visit_function(&mut self, vm: &VM, func: &mut MuFunctionVersion) {
if !vm.vm_options.flag_allow_inline { if vm.vm_options.flag_disable_inline {
info!("inlining is disabled"); info!("inlining is disabled");
return; return;
} }
......
...@@ -15,7 +15,7 @@ VM: ...@@ -15,7 +15,7 @@ VM:
--log-level=<level> logging level: none, error, warn, info, debug, trace [default: trace] --log-level=<level> logging level: none, error, warn, info, debug, trace [default: trace]
Compiler: Compiler:
--allow-inline=<flag> allow compiler inlining functions on its decision [default: true] --disable-inline disable compiler function inlining
AOT Compiler: AOT Compiler:
--aot-emit-dir=<dir> the emit directory for ahead-of-time compiling [default: emit] --aot-emit-dir=<dir> the emit directory for ahead-of-time compiling [default: emit]
...@@ -29,7 +29,7 @@ Garbage Collection: ...@@ -29,7 +29,7 @@ Garbage Collection:
#[derive(Debug, RustcDecodable, RustcEncodable)] #[derive(Debug, RustcDecodable, RustcEncodable)]
pub struct VMOptions { pub struct VMOptions {
pub flag_log_level: MuLogLevel, pub flag_log_level: MuLogLevel,
pub flag_allow_inline: bool, pub flag_disable_inline: bool,
pub flag_aot_emit_dir: String, pub flag_aot_emit_dir: String,
pub flag_gc_immixspace_size: usize, pub flag_gc_immixspace_size: usize,
pub flag_gc_lospace_size: usize, pub flag_gc_lospace_size: usize,
......
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