Mercurial > hg > truffle
comparison src/share/vm/opto/ifg.cpp @ 14513:16c705d792be
Merge
author | morris |
---|---|
date | Fri, 28 Feb 2014 08:02:20 -0800 |
parents | 1077c8270209 |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14493:7d30d4f37d31 | 14513:16c705d792be |
---|---|
437 if (r.overlap(*Matcher::idealreg2regmask[Op_RegI])) { | 437 if (r.overlap(*Matcher::idealreg2regmask[Op_RegI])) { |
438 int_pressure.lower(lrg, location); | 438 int_pressure.lower(lrg, location); |
439 } | 439 } |
440 } | 440 } |
441 } | 441 } |
442 assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect"); | 442 assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); |
443 assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect"); | 443 assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); |
444 } | 444 } |
445 | 445 |
446 /* Go to the first non-phi index in a block */ | 446 /* Go to the first non-phi index in a block */ |
447 static uint first_nonphi_index(Block* b) { | 447 static uint first_nonphi_index(Block* b) { |
448 uint i; | 448 uint i; |
511 LRG& lrg = lrgs(lid); | 511 LRG& lrg = lrgs(lid); |
512 lrg._area += cost; | 512 lrg._area += cost; |
513 raise_pressure(b, lrg, int_pressure, float_pressure); | 513 raise_pressure(b, lrg, int_pressure, float_pressure); |
514 lid = elements.next(); | 514 lid = elements.next(); |
515 } | 515 } |
516 assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect"); | 516 assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); |
517 assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect"); | 517 assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); |
518 } | 518 } |
519 | 519 |
520 /* | 520 /* |
521 * Remove dead node if it's not used. | 521 * Remove dead node if it's not used. |
522 * We only remove projection nodes if the node "defining" the projection is | 522 * We only remove projection nodes if the node "defining" the projection is |
546 * block. If we find a low to high transition, we record it. | 546 * block. If we find a low to high transition, we record it. |
547 */ | 547 */ |
548 void PhaseChaitin::check_for_high_pressure_transition_at_fatproj(uint& block_reg_pressure, uint location, LRG& lrg, Pressure& pressure, const int op_regtype) { | 548 void PhaseChaitin::check_for_high_pressure_transition_at_fatproj(uint& block_reg_pressure, uint location, LRG& lrg, Pressure& pressure, const int op_regtype) { |
549 RegMask mask_tmp = lrg.mask(); | 549 RegMask mask_tmp = lrg.mask(); |
550 mask_tmp.AND(*Matcher::idealreg2regmask[op_regtype]); | 550 mask_tmp.AND(*Matcher::idealreg2regmask[op_regtype]); |
551 // this pressure is only valid at this instruction, i.e. we don't need to lower | 551 pressure.check_pressure_at_fatproj(location, mask_tmp); |
552 // the register pressure since the fat proj was never live before (going backwards) | |
553 uint new_pressure = pressure._current_pressure + mask_tmp.Size(); | |
554 if (new_pressure > pressure._final_pressure) { | |
555 pressure._final_pressure = new_pressure; | |
556 } | |
557 // if we were at a low pressure and now at the fat proj is at high pressure, record the fat proj location | |
558 // as coming from a low to high (to low again) | |
559 if (pressure._current_pressure <= pressure._high_pressure_limit && new_pressure > pressure._high_pressure_limit) { | |
560 pressure._high_pressure_index = location; | |
561 } | |
562 } | 552 } |
563 | 553 |
564 /* | 554 /* |
565 * Insure high score for immediate-use spill copies so they get a color. | 555 * Insure high score for immediate-use spill copies so they get a color. |
566 * All single-use MachSpillCopy(s) that immediately precede their | 556 * All single-use MachSpillCopy(s) that immediately precede their |
698 | 688 |
699 if (liveout->insert(lid)) { | 689 if (liveout->insert(lid)) { |
700 // Newly live things assumed live from here to top of block | 690 // Newly live things assumed live from here to top of block |
701 lrg._area += cost; | 691 lrg._area += cost; |
702 raise_pressure(b, lrg, int_pressure, float_pressure); | 692 raise_pressure(b, lrg, int_pressure, float_pressure); |
703 assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect"); | 693 assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); |
704 assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect"); | 694 assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); |
705 } | 695 } |
706 assert(!(lrg._area < 0.0), "negative spill area" ); | 696 assert(lrg._area >= 0.0, "negative spill area" ); |
707 } | 697 } |
708 } | 698 } |
709 | 699 |
710 /* | 700 /* |
711 * If we run off the top of the block with high pressure just record that the | 701 * If we run off the top of the block with high pressure just record that the |
712 * whole block is high pressure. (Even though we might have a transition | 702 * whole block is high pressure. (Even though we might have a transition |
713 * lower down in the block) | 703 * later down in the block) |
714 */ | 704 */ |
715 void PhaseChaitin::check_for_high_pressure_block(Pressure& pressure) { | 705 void PhaseChaitin::check_for_high_pressure_block(Pressure& pressure) { |
716 // current pressure now means the pressure before the first instruction in the block | 706 // current pressure now means the pressure before the first instruction in the block |
717 // (since we have stepped through all instructions backwards) | 707 // (since we have stepped through all instructions backwards) |
718 if (pressure._current_pressure > pressure._high_pressure_limit) { | 708 if (pressure.current_pressure() > pressure.high_pressure_limit()) { |
719 pressure._high_pressure_index = 0; | 709 pressure.set_high_pressure_index_to_block_start(); |
720 } | 710 } |
721 } | 711 } |
722 | 712 |
723 /* | 713 /* |
724 * Compute high pressure indice; avoid landing in the middle of projnodes | 714 * Compute high pressure indice; avoid landing in the middle of projnodes |
725 * and set the high pressure index for the block | 715 * and set the high pressure index for the block |
726 */ | 716 */ |
727 void PhaseChaitin::adjust_high_pressure_index(Block* b, uint& block_hrp_index, Pressure& pressure) { | 717 void PhaseChaitin::adjust_high_pressure_index(Block* b, uint& block_hrp_index, Pressure& pressure) { |
728 uint i = pressure._high_pressure_index; | 718 uint i = pressure.high_pressure_index(); |
729 if (i < b->number_of_nodes() && i < b->end_idx() + 1) { | 719 if (i < b->number_of_nodes() && i < b->end_idx() + 1) { |
730 Node* cur = b->get_node(i); | 720 Node* cur = b->get_node(i); |
731 while (cur->is_Proj() || (cur->is_MachNullCheck()) || cur->is_Catch()) { | 721 while (cur->is_Proj() || (cur->is_MachNullCheck()) || cur->is_Catch()) { |
732 cur = b->get_node(--i); | 722 cur = b->get_node(--i); |
733 } | 723 } |
770 block->_reg_pressure = 0; | 760 block->_reg_pressure = 0; |
771 block->_freg_pressure = 0; | 761 block->_freg_pressure = 0; |
772 | 762 |
773 int inst_count = last_inst - first_inst; | 763 int inst_count = last_inst - first_inst; |
774 double cost = (inst_count <= 0) ? 0.0 : block->_freq * double(inst_count); | 764 double cost = (inst_count <= 0) ? 0.0 : block->_freq * double(inst_count); |
775 assert(!(cost < 0.0), "negative spill cost" ); | 765 assert(cost >= 0.0, "negative spill cost" ); |
776 | 766 |
777 compute_initial_block_pressure(block, &liveout, int_pressure, float_pressure, cost); | 767 compute_initial_block_pressure(block, &liveout, int_pressure, float_pressure, cost); |
778 | 768 |
779 for (uint location = last_inst; location > 0; location--) { | 769 for (uint location = last_inst; location > 0; location--) { |
780 Node* n = block->get_node(location); | 770 Node* n = block->get_node(location); |
787 // removed from the DEF sight, so LOWER costs here. | 777 // removed from the DEF sight, so LOWER costs here. |
788 lrg._cost += n->rematerialize() ? 0 : block->_freq; | 778 lrg._cost += n->rematerialize() ? 0 : block->_freq; |
789 | 779 |
790 if (!liveout.member(lid) && n->Opcode() != Op_SafePoint) { | 780 if (!liveout.member(lid) && n->Opcode() != Op_SafePoint) { |
791 if (remove_node_if_not_used(block, location, n, lid, &liveout)) { | 781 if (remove_node_if_not_used(block, location, n, lid, &liveout)) { |
792 float_pressure._high_pressure_index--; | 782 float_pressure.lower_high_pressure_index(); |
793 int_pressure._high_pressure_index--; | 783 int_pressure.lower_high_pressure_index(); |
794 continue; | 784 continue; |
795 } | 785 } |
796 if (lrg._fat_proj) { | 786 if (lrg._fat_proj) { |
797 check_for_high_pressure_transition_at_fatproj(block->_reg_pressure, location, lrg, int_pressure, Op_RegI); | 787 check_for_high_pressure_transition_at_fatproj(block->_reg_pressure, location, lrg, int_pressure, Op_RegI); |
798 check_for_high_pressure_transition_at_fatproj(block->_freg_pressure, location, lrg, float_pressure, Op_RegD); | 788 check_for_high_pressure_transition_at_fatproj(block->_freg_pressure, location, lrg, float_pressure, Op_RegD); |
799 } | 789 } |
800 } else { | 790 } else { |
801 // A live range ends at its definition, remove the remaining area. | 791 // A live range ends at its definition, remove the remaining area. |
802 lrg._area -= cost; | 792 // If the cost is +Inf (which might happen in extreme cases), the lrg area will also be +Inf, |
793 // and +Inf - +Inf = NaN. So let's not do that subtraction. | |
794 if (g_isfinite(cost)) { | |
795 lrg._area -= cost; | |
796 } | |
803 assert(lrg._area >= 0.0, "negative spill area" ); | 797 assert(lrg._area >= 0.0, "negative spill area" ); |
804 | 798 |
805 assign_high_score_to_immediate_copies(block, n, lrg, location + 1, last_inst); | 799 assign_high_score_to_immediate_copies(block, n, lrg, location + 1, last_inst); |
806 | 800 |
807 if (liveout.remove(lid)) { | 801 if (liveout.remove(lid)) { |
835 check_for_high_pressure_block(int_pressure); | 829 check_for_high_pressure_block(int_pressure); |
836 check_for_high_pressure_block(float_pressure); | 830 check_for_high_pressure_block(float_pressure); |
837 adjust_high_pressure_index(block, block->_ihrp_index, int_pressure); | 831 adjust_high_pressure_index(block, block->_ihrp_index, int_pressure); |
838 adjust_high_pressure_index(block, block->_fhrp_index, float_pressure); | 832 adjust_high_pressure_index(block, block->_fhrp_index, float_pressure); |
839 // set the final_pressure as the register pressure for the block | 833 // set the final_pressure as the register pressure for the block |
840 block->_reg_pressure = int_pressure._final_pressure; | 834 block->_reg_pressure = int_pressure.final_pressure(); |
841 block->_freg_pressure = float_pressure._final_pressure; | 835 block->_freg_pressure = float_pressure.final_pressure(); |
842 | 836 |
843 #ifndef PRODUCT | 837 #ifndef PRODUCT |
844 // Gather Register Pressure Statistics | 838 // Gather Register Pressure Statistics |
845 if (PrintOptoStatistics) { | 839 if (PrintOptoStatistics) { |
846 if (block->_reg_pressure > int_pressure._high_pressure_limit || block->_freg_pressure > float_pressure._high_pressure_limit) { | 840 if (block->_reg_pressure > int_pressure.high_pressure_limit() || block->_freg_pressure > float_pressure.high_pressure_limit()) { |
847 _high_pressure++; | 841 _high_pressure++; |
848 } else { | 842 } else { |
849 _low_pressure++; | 843 _low_pressure++; |
850 } | 844 } |
851 } | 845 } |