< prev index next >

src/share/vm/opto/library_call.cpp

Print this page
rev 7986 : [mq]: never_taken.8074548


5853       && (ary = counts->bottom_type()->isa_aryptr()) != NULL
5854       && (aobj = ary->const_oop()->as_array()) != NULL
5855       && (aobj->length() == 2)) {
5856     // Profile is int[2] where [0] and [1] correspond to false and true value occurrences respectively.
5857     jint false_cnt = aobj->element_value(0).as_int();
5858     jint  true_cnt = aobj->element_value(1).as_int();
5859 
5860     method()->set_injected_profile(true);
5861 
5862     if (C->log() != NULL) {
5863       C->log()->elem("observe source='profileBoolean' false='%d' true='%d'",
5864                      false_cnt, true_cnt);
5865     }
5866 
5867     if (false_cnt + true_cnt == 0) {
5868       // According to profile, never executed.
5869       uncommon_trap_exact(Deoptimization::Reason_intrinsic,
5870                           Deoptimization::Action_reinterpret);
5871       return true;
5872     }


































5873     // Stop profiling.
5874     // MethodHandleImpl::profileBoolean() has profiling logic in it's bytecode.
5875     // By replacing method's body with profile data (represented as ProfileBooleanNode
5876     // on IR level) we effectively disable profiling.
5877     // It enables full speed execution once optimized code is generated.
5878     Node* profile = _gvn.transform(new ProfileBooleanNode(argument(0), false_cnt, true_cnt));
5879     C->record_for_igvn(profile);
5880     set_result(profile);
5881     return true;
5882   } else {
5883     // Continue profiling.
5884     // Profile data isn't available at the moment. So, execute method's bytecode version.
5885     // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
5886     // is compiled and counters aren't available since corresponding MethodHandle
5887     // isn't a compile-time constant.
5888     return false;
5889   }
5890 }


5853       && (ary = counts->bottom_type()->isa_aryptr()) != NULL
5854       && (aobj = ary->const_oop()->as_array()) != NULL
5855       && (aobj->length() == 2)) {
5856     // Profile is int[2] where [0] and [1] correspond to false and true value occurrences respectively.
5857     jint false_cnt = aobj->element_value(0).as_int();
5858     jint  true_cnt = aobj->element_value(1).as_int();
5859 
5860     method()->set_injected_profile(true);
5861 
5862     if (C->log() != NULL) {
5863       C->log()->elem("observe source='profileBoolean' false='%d' true='%d'",
5864                      false_cnt, true_cnt);
5865     }
5866 
5867     if (false_cnt + true_cnt == 0) {
5868       // According to profile, never executed.
5869       uncommon_trap_exact(Deoptimization::Reason_intrinsic,
5870                           Deoptimization::Action_reinterpret);
5871       return true;
5872     }
5873 
5874     // result is a boolean (0 or 1) and its profile (false_cnt & true_cnt)
5875     // is a number of each value occurrences.
5876     Node* result = argument(0);
5877     if (false_cnt == 0 || true_cnt == 0) {
5878       // According to profile, one value has been never seen.
5879       int expected_val = (false_cnt == 0) ? 1 : 0;
5880 
5881       Node* cmp  = _gvn.transform(new CmpINode(result, intcon(expected_val)));
5882       Node* test = _gvn.transform(new BoolNode(cmp, BoolTest::eq));
5883 
5884       IfNode* check = create_and_map_if(control(), test, PROB_ALWAYS, COUNT_UNKNOWN);
5885       Node* fast_path = _gvn.transform(new IfTrueNode(check));
5886       Node* slow_path = _gvn.transform(new IfFalseNode(check));
5887 
5888       { // Slow path: uncommon trap for never seen value and then reexecute
5889         // MethodHandleImpl::profileBoolean() to bump the count, so JIT knows
5890         // the value has been seen at least once.
5891         PreserveJVMState pjvms(this);
5892         PreserveReexecuteState preexecs(this);
5893         jvms()->set_should_reexecute(true);
5894 
5895         set_control(slow_path);
5896         set_i_o(i_o());
5897 
5898         uncommon_trap_exact(Deoptimization::Reason_intrinsic,
5899                             Deoptimization::Action_reinterpret);
5900       }
5901       // The guard for never seen value enables sharpening of the result and
5902       // returning a constant. It allows to eliminate branches on the same value
5903       // later on.
5904       set_control(fast_path);
5905       result = intcon(expected_val);
5906     }
5907     // Stop profiling.
5908     // MethodHandleImpl::profileBoolean() has profiling logic in its bytecode.
5909     // By replacing method body with profile data (represented as ProfileBooleanNode
5910     // on IR level) we effectively disable profiling.
5911     // It enables full speed execution once optimized code is generated.
5912     Node* profile = _gvn.transform(new ProfileBooleanNode(result, false_cnt, true_cnt));
5913     C->record_for_igvn(profile);
5914     set_result(profile);
5915     return true;
5916   } else {
5917     // Continue profiling.
5918     // Profile data isn't available at the moment. So, execute method's bytecode version.
5919     // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
5920     // is compiled and counters aren't available since corresponding MethodHandle
5921     // isn't a compile-time constant.
5922     return false;
5923   }
5924 }
< prev index next >