Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1/c1_IR.cpp @ 1783:d5d065957597
6953144: Tiered compilation
Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation.
Reviewed-by: kvn, never, phh, twisti
author | iveresov |
---|---|
date | Fri, 03 Sep 2010 17:51:07 -0700 |
parents | b812ff5abc73 |
children | f02a8bbe6ed4 |
comparison
equal
deleted
inserted
replaced
1782:f353275af40e | 1783:d5d065957597 |
---|---|
294 } | 294 } |
295 | 295 |
296 | 296 |
297 void IR::optimize() { | 297 void IR::optimize() { |
298 Optimizer opt(this); | 298 Optimizer opt(this); |
299 if (DoCEE) { | 299 if (!compilation()->profile_branches()) { |
300 opt.eliminate_conditional_expressions(); | 300 if (DoCEE) { |
301 opt.eliminate_conditional_expressions(); | |
301 #ifndef PRODUCT | 302 #ifndef PRODUCT |
302 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after CEE"); print(true); } | 303 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after CEE"); print(true); } |
303 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after CEE"); print(false); } | 304 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after CEE"); print(false); } |
304 #endif | 305 #endif |
305 } | 306 } |
306 if (EliminateBlocks) { | 307 if (EliminateBlocks) { |
307 opt.eliminate_blocks(); | 308 opt.eliminate_blocks(); |
308 #ifndef PRODUCT | 309 #ifndef PRODUCT |
309 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after block elimination"); print(true); } | 310 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after block elimination"); print(true); } |
310 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after block elimination"); print(false); } | 311 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after block elimination"); print(false); } |
311 #endif | 312 #endif |
313 } | |
312 } | 314 } |
313 if (EliminateNullChecks) { | 315 if (EliminateNullChecks) { |
314 opt.eliminate_null_checks(); | 316 opt.eliminate_null_checks(); |
315 #ifndef PRODUCT | 317 #ifndef PRODUCT |
316 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after null check elimination"); print(true); } | 318 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after null check elimination"); print(true); } |
482 intArray _forward_branches; // number of incoming forward branches for each block | 484 intArray _forward_branches; // number of incoming forward branches for each block |
483 BlockList _loop_end_blocks; // list of all loop end blocks collected during count_edges | 485 BlockList _loop_end_blocks; // list of all loop end blocks collected during count_edges |
484 BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop | 486 BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop |
485 BlockList _work_list; // temporary list (used in mark_loops and compute_order) | 487 BlockList _work_list; // temporary list (used in mark_loops and compute_order) |
486 | 488 |
489 Compilation* _compilation; | |
490 | |
487 // accessors for _visited_blocks and _active_blocks | 491 // accessors for _visited_blocks and _active_blocks |
488 void init_visited() { _active_blocks.clear(); _visited_blocks.clear(); } | 492 void init_visited() { _active_blocks.clear(); _visited_blocks.clear(); } |
489 bool is_visited(BlockBegin* b) const { return _visited_blocks.at(b->block_id()); } | 493 bool is_visited(BlockBegin* b) const { return _visited_blocks.at(b->block_id()); } |
490 bool is_active(BlockBegin* b) const { return _active_blocks.at(b->block_id()); } | 494 bool is_active(BlockBegin* b) const { return _active_blocks.at(b->block_id()); } |
491 void set_visited(BlockBegin* b) { assert(!is_visited(b), "already set"); _visited_blocks.set_bit(b->block_id()); } | 495 void set_visited(BlockBegin* b) { assert(!is_visited(b), "already set"); _visited_blocks.set_bit(b->block_id()); } |
524 | 528 |
525 // debug functions | 529 // debug functions |
526 NOT_PRODUCT(void print_blocks();) | 530 NOT_PRODUCT(void print_blocks();) |
527 DEBUG_ONLY(void verify();) | 531 DEBUG_ONLY(void verify();) |
528 | 532 |
533 Compilation* compilation() const { return _compilation; } | |
529 public: | 534 public: |
530 ComputeLinearScanOrder(BlockBegin* start_block); | 535 ComputeLinearScanOrder(Compilation* c, BlockBegin* start_block); |
531 | 536 |
532 // accessors for final result | 537 // accessors for final result |
533 BlockList* linear_scan_order() const { return _linear_scan_order; } | 538 BlockList* linear_scan_order() const { return _linear_scan_order; } |
534 int num_loops() const { return _num_loops; } | 539 int num_loops() const { return _num_loops; } |
535 }; | 540 }; |
536 | 541 |
537 | 542 |
538 ComputeLinearScanOrder::ComputeLinearScanOrder(BlockBegin* start_block) : | 543 ComputeLinearScanOrder::ComputeLinearScanOrder(Compilation* c, BlockBegin* start_block) : |
539 _max_block_id(BlockBegin::number_of_blocks()), | 544 _max_block_id(BlockBegin::number_of_blocks()), |
540 _num_blocks(0), | 545 _num_blocks(0), |
541 _num_loops(0), | 546 _num_loops(0), |
542 _iterative_dominators(false), | 547 _iterative_dominators(false), |
543 _visited_blocks(_max_block_id), | 548 _visited_blocks(_max_block_id), |
545 _dominator_blocks(_max_block_id), | 550 _dominator_blocks(_max_block_id), |
546 _forward_branches(_max_block_id, 0), | 551 _forward_branches(_max_block_id, 0), |
547 _loop_end_blocks(8), | 552 _loop_end_blocks(8), |
548 _work_list(8), | 553 _work_list(8), |
549 _linear_scan_order(NULL), // initialized later with correct size | 554 _linear_scan_order(NULL), // initialized later with correct size |
550 _loop_map(0, 0) // initialized later with correct size | 555 _loop_map(0, 0), // initialized later with correct size |
556 _compilation(c) | |
551 { | 557 { |
552 TRACE_LINEAR_SCAN(2, "***** computing linear-scan block order"); | 558 TRACE_LINEAR_SCAN(2, "***** computing linear-scan block order"); |
553 | 559 |
554 init_visited(); | 560 init_visited(); |
555 count_edges(start_block, NULL); | 561 count_edges(start_block, NULL); |
562 | |
563 if (compilation()->is_profiling()) { | |
564 compilation()->method()->method_data()->set_compilation_stats(_num_loops, _num_blocks); | |
565 } | |
556 | 566 |
557 if (_num_loops > 0) { | 567 if (_num_loops > 0) { |
558 mark_loops(); | 568 mark_loops(); |
559 clear_non_natural_loops(start_block); | 569 clear_non_natural_loops(start_block); |
560 assign_loop_depth(start_block); | 570 assign_loop_depth(start_block); |
1128 | 1138 |
1129 | 1139 |
1130 void IR::compute_code() { | 1140 void IR::compute_code() { |
1131 assert(is_valid(), "IR must be valid"); | 1141 assert(is_valid(), "IR must be valid"); |
1132 | 1142 |
1133 ComputeLinearScanOrder compute_order(start()); | 1143 ComputeLinearScanOrder compute_order(compilation(), start()); |
1134 _num_loops = compute_order.num_loops(); | 1144 _num_loops = compute_order.num_loops(); |
1135 _code = compute_order.linear_scan_order(); | 1145 _code = compute_order.linear_scan_order(); |
1136 } | 1146 } |
1137 | 1147 |
1138 | 1148 |