6574 // According to profile, never executed. |
6574 // According to profile, never executed. |
6575 uncommon_trap_exact(Deoptimization::Reason_intrinsic, |
6575 uncommon_trap_exact(Deoptimization::Reason_intrinsic, |
6576 Deoptimization::Action_reinterpret); |
6576 Deoptimization::Action_reinterpret); |
6577 return true; |
6577 return true; |
6578 } |
6578 } |
|
6579 |
|
6580 // result is a boolean (0 or 1) and its profile (false_cnt & true_cnt) |
|
6581 // is a number of each value occurrences. |
|
6582 Node* result = argument(0); |
|
6583 if (false_cnt == 0 || true_cnt == 0) { |
|
6584 // According to profile, one value has been never seen. |
|
6585 int expected_val = (false_cnt == 0) ? 1 : 0; |
|
6586 |
|
6587 Node* cmp = _gvn.transform(new (C) CmpINode(result, intcon(expected_val))); |
|
6588 Node* test = _gvn.transform(new (C) BoolNode(cmp, BoolTest::eq)); |
|
6589 |
|
6590 IfNode* check = create_and_map_if(control(), test, PROB_ALWAYS, COUNT_UNKNOWN); |
|
6591 Node* fast_path = _gvn.transform(new (C) IfTrueNode(check)); |
|
6592 Node* slow_path = _gvn.transform(new (C) IfFalseNode(check)); |
|
6593 |
|
6594 { // Slow path: uncommon trap for never seen value and then reexecute |
|
6595 // MethodHandleImpl::profileBoolean() to bump the count, so JIT knows |
|
6596 // the value has been seen at least once. |
|
6597 PreserveJVMState pjvms(this); |
|
6598 PreserveReexecuteState preexecs(this); |
|
6599 jvms()->set_should_reexecute(true); |
|
6600 |
|
6601 set_control(slow_path); |
|
6602 set_i_o(i_o()); |
|
6603 |
|
6604 uncommon_trap_exact(Deoptimization::Reason_intrinsic, |
|
6605 Deoptimization::Action_reinterpret); |
|
6606 } |
|
6607 // The guard for never seen value enables sharpening of the result and |
|
6608 // returning a constant. It allows to eliminate branches on the same value |
|
6609 // later on. |
|
6610 set_control(fast_path); |
|
6611 result = intcon(expected_val); |
|
6612 } |
6579 // Stop profiling. |
6613 // Stop profiling. |
6580 // MethodHandleImpl::profileBoolean() has profiling logic in it's bytecode. |
6614 // MethodHandleImpl::profileBoolean() has profiling logic in its bytecode. |
6581 // By replacing method's body with profile data (represented as ProfileBooleanNode |
6615 // By replacing method body with profile data (represented as ProfileBooleanNode |
6582 // on IR level) we effectively disable profiling. |
6616 // on IR level) we effectively disable profiling. |
6583 // It enables full speed execution once optimized code is generated. |
6617 // It enables full speed execution once optimized code is generated. |
6584 Node* profile = _gvn.transform(new (C) ProfileBooleanNode(argument(0), false_cnt, true_cnt)); |
6618 Node* profile = _gvn.transform(new (C) ProfileBooleanNode(result, false_cnt, true_cnt)); |
6585 C->record_for_igvn(profile); |
6619 C->record_for_igvn(profile); |
6586 set_result(profile); |
6620 set_result(profile); |
6587 return true; |
6621 return true; |
6588 } else { |
6622 } else { |
6589 // Continue profiling. |
6623 // Continue profiling. |