748
749 // Effect on jsr on stack
750 push(_gvn.makecon(ret_addr));
751
752 // Flow to the jsr.
753 merge(jsr_bci);
754 }
755
756 // Handle ret bytecode
757 void Parse::do_ret() {
758 // Find to whom we return.
759 assert(block()->num_successors() == 1, "a ret can only go one place now");
760 Block* target = block()->successor_at(0);
761 assert(!target->is_ready(), "our arrival must be expected");
762 profile_ret(target->flow()->start());
763 int pnum = target->next_path_num();
764 merge_common(target, pnum);
765 }
766
767 static bool has_injected_profile(BoolTest::mask btest, Node* test, int& taken, int& not_taken) {
768 ProfileBooleanNode* profile = NULL;
769
770 if (btest != BoolTest::eq && btest != BoolTest::ne) {
771 // Only ::eq and ::ne are supported for profile injection.
772 return false;
773 }
774
775 if (test->is_Cmp()) {
776 Node* n = test->in(1);
777 switch (n->Opcode()) {
778 case Op_ProfileBoolean:
779 profile = (ProfileBooleanNode*) n;
780 break;
781 case Op_AndI:
782 // Look for the following shape: AndI (ProfileBoolean) (ConI 1))
783 const TypeInt* t = NULL;
784 if (n->in(1)->Opcode() == Op_ProfileBoolean &&
785 n->in(2)->is_Con() &&
786 (t = n->in(2)->bottom_type()->isa_int()) != NULL &&
787 t->get_con() == 1) {
788 profile = (ProfileBooleanNode*) n->in(1);
789 }
790 break;
791 }
792 }
793 if (profile != NULL) {
794 int false_cnt = profile->false_count();
795 int true_cnt = profile->true_count();
796
797 // Counts matching depends on the actual test operation (::eq or ::ne).
798 taken = (btest == BoolTest::eq) ? false_cnt : true_cnt;
799 not_taken = (btest == BoolTest::eq) ? true_cnt : false_cnt;
800
801 profile->consume();
802 return true;
803 }
804 return false;
805 }
806 //--------------------------dynamic_branch_prediction--------------------------
807 // Try to gather dynamic branch prediction behavior. Return a probability
808 // of the branch being taken and set the "cnt" field. Returns a -1.0
809 // if we need to use static prediction for some reason.
810 float Parse::dynamic_branch_prediction(float &cnt, BoolTest::mask btest, Node* test) {
811 ResourceMark rm;
812
813 cnt = COUNT_UNKNOWN;
814
815 int taken = 0;
816 int not_taken = 0;
817
|
748
749 // Effect on jsr on stack
750 push(_gvn.makecon(ret_addr));
751
752 // Flow to the jsr.
753 merge(jsr_bci);
754 }
755
756 // Handle ret bytecode
757 void Parse::do_ret() {
758 // Find to whom we return.
759 assert(block()->num_successors() == 1, "a ret can only go one place now");
760 Block* target = block()->successor_at(0);
761 assert(!target->is_ready(), "our arrival must be expected");
762 profile_ret(target->flow()->start());
763 int pnum = target->next_path_num();
764 merge_common(target, pnum);
765 }
766
767 static bool has_injected_profile(BoolTest::mask btest, Node* test, int& taken, int& not_taken) {
768 if (btest != BoolTest::eq && btest != BoolTest::ne) {
769 // Only ::eq and ::ne are supported for profile injection.
770 return false;
771 }
772 if (test->is_Cmp() &&
773 test->in(1)->Opcode() == Op_ProfileBoolean) {
774 ProfileBooleanNode* profile = (ProfileBooleanNode*)test->in(1);
775 int false_cnt = profile->false_count();
776 int true_cnt = profile->true_count();
777
778 // Counts matching depends on the actual test operation (::eq or ::ne).
779 // No need to scale the counts because profile injection was designed
780 // to feed exact counts into VM.
781 taken = (btest == BoolTest::eq) ? false_cnt : true_cnt;
782 not_taken = (btest == BoolTest::eq) ? true_cnt : false_cnt;
783
784 profile->consume();
785 return true;
786 }
787 return false;
788 }
789 //--------------------------dynamic_branch_prediction--------------------------
790 // Try to gather dynamic branch prediction behavior. Return a probability
791 // of the branch being taken and set the "cnt" field. Returns a -1.0
792 // if we need to use static prediction for some reason.
793 float Parse::dynamic_branch_prediction(float &cnt, BoolTest::mask btest, Node* test) {
794 ResourceMark rm;
795
796 cnt = COUNT_UNKNOWN;
797
798 int taken = 0;
799 int not_taken = 0;
800
|