1.1 --- a/src/share/vm/c1/c1_IR.cpp Thu Sep 02 11:40:02 2010 -0700 1.2 +++ b/src/share/vm/c1/c1_IR.cpp Fri Sep 03 17:51:07 2010 -0700 1.3 @@ -296,19 +296,21 @@ 1.4 1.5 void IR::optimize() { 1.6 Optimizer opt(this); 1.7 - if (DoCEE) { 1.8 - opt.eliminate_conditional_expressions(); 1.9 + if (!compilation()->profile_branches()) { 1.10 + if (DoCEE) { 1.11 + opt.eliminate_conditional_expressions(); 1.12 #ifndef PRODUCT 1.13 - if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after CEE"); print(true); } 1.14 - if (PrintIR || PrintIR1 ) { tty->print_cr("IR after CEE"); print(false); } 1.15 + if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after CEE"); print(true); } 1.16 + if (PrintIR || PrintIR1 ) { tty->print_cr("IR after CEE"); print(false); } 1.17 #endif 1.18 - } 1.19 - if (EliminateBlocks) { 1.20 - opt.eliminate_blocks(); 1.21 + } 1.22 + if (EliminateBlocks) { 1.23 + opt.eliminate_blocks(); 1.24 #ifndef PRODUCT 1.25 - if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after block elimination"); print(true); } 1.26 - if (PrintIR || PrintIR1 ) { tty->print_cr("IR after block elimination"); print(false); } 1.27 + if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after block elimination"); print(true); } 1.28 + if (PrintIR || PrintIR1 ) { tty->print_cr("IR after block elimination"); print(false); } 1.29 #endif 1.30 + } 1.31 } 1.32 if (EliminateNullChecks) { 1.33 opt.eliminate_null_checks(); 1.34 @@ -484,6 +486,8 @@ 1.35 BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop 1.36 BlockList _work_list; // temporary list (used in mark_loops and compute_order) 1.37 1.38 + Compilation* _compilation; 1.39 + 1.40 // accessors for _visited_blocks and _active_blocks 1.41 void init_visited() { _active_blocks.clear(); _visited_blocks.clear(); } 1.42 bool is_visited(BlockBegin* b) const { return _visited_blocks.at(b->block_id()); } 1.43 @@ -526,8 +530,9 @@ 1.44 NOT_PRODUCT(void print_blocks();) 1.45 DEBUG_ONLY(void verify();) 1.46 1.47 + Compilation* compilation() const { return _compilation; } 1.48 public: 1.49 - ComputeLinearScanOrder(BlockBegin* start_block); 1.50 + ComputeLinearScanOrder(Compilation* c, BlockBegin* start_block); 1.51 1.52 // accessors for final result 1.53 BlockList* linear_scan_order() const { return _linear_scan_order; } 1.54 @@ -535,7 +540,7 @@ 1.55 }; 1.56 1.57 1.58 -ComputeLinearScanOrder::ComputeLinearScanOrder(BlockBegin* start_block) : 1.59 +ComputeLinearScanOrder::ComputeLinearScanOrder(Compilation* c, BlockBegin* start_block) : 1.60 _max_block_id(BlockBegin::number_of_blocks()), 1.61 _num_blocks(0), 1.62 _num_loops(0), 1.63 @@ -547,13 +552,18 @@ 1.64 _loop_end_blocks(8), 1.65 _work_list(8), 1.66 _linear_scan_order(NULL), // initialized later with correct size 1.67 - _loop_map(0, 0) // initialized later with correct size 1.68 + _loop_map(0, 0), // initialized later with correct size 1.69 + _compilation(c) 1.70 { 1.71 TRACE_LINEAR_SCAN(2, "***** computing linear-scan block order"); 1.72 1.73 init_visited(); 1.74 count_edges(start_block, NULL); 1.75 1.76 + if (compilation()->is_profiling()) { 1.77 + compilation()->method()->method_data()->set_compilation_stats(_num_loops, _num_blocks); 1.78 + } 1.79 + 1.80 if (_num_loops > 0) { 1.81 mark_loops(); 1.82 clear_non_natural_loops(start_block); 1.83 @@ -1130,7 +1140,7 @@ 1.84 void IR::compute_code() { 1.85 assert(is_valid(), "IR must be valid"); 1.86 1.87 - ComputeLinearScanOrder compute_order(start()); 1.88 + ComputeLinearScanOrder compute_order(compilation(), start()); 1.89 _num_loops = compute_order.num_loops(); 1.90 _code = compute_order.linear_scan_order(); 1.91 }