@@ -3761,6 +3761,20 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) {
3761
3761
Node* test_pin_count_over_underflow = _gvn.transform (new BoolNode (pin_count_cmp, BoolTest::eq));
3762
3762
IfNode* iff_pin_count_over_underflow = create_and_map_if (control (), test_pin_count_over_underflow, PROB_MIN, COUNT_UNKNOWN);
3763
3763
3764
+ // True branch, pin count over/underflow.
3765
+ Node* pin_count_over_underflow = _gvn.transform (new IfTrueNode (iff_pin_count_over_underflow));
3766
+ {
3767
+ // Trap (but not deoptimize (Action_none)) and continue in the interpreter
3768
+ // which will throw IllegalStateException for pin count over/underflow.
3769
+ // No memory changed so far - we can use memory create by reset_memory()
3770
+ // at the beginning of this intrinsic. No need to call reset_memory() again.
3771
+ PreserveJVMState pjvms (this );
3772
+ set_control (pin_count_over_underflow);
3773
+ uncommon_trap (Deoptimization::Reason_intrinsic,
3774
+ Deoptimization::Action_none);
3775
+ assert (stopped (), " invariant" );
3776
+ }
3777
+
3764
3778
// False branch, no pin count over/underflow. Increment or decrement pin count and store back.
3765
3779
Node* valid_pin_count = _gvn.transform (new IfFalseNode (iff_pin_count_over_underflow));
3766
3780
set_control (valid_pin_count);
@@ -3772,20 +3786,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) {
3772
3786
next_pin_count = _gvn.transform (new AddINode (pin_count, _gvn.intcon (1 )));
3773
3787
}
3774
3788
3775
- Node* updated_pin_count_memory = store_to_memory (control (), pin_count_offset, next_pin_count, T_INT, MemNode::unordered);
3776
-
3777
- // True branch, pin count over/underflow.
3778
- Node* pin_count_over_underflow = _gvn.transform (new IfTrueNode (iff_pin_count_over_underflow));
3779
- {
3780
- // Trap (but not deoptimize (Action_none)) and continue in the interpreter
3781
- // which will throw IllegalStateException for pin count over/underflow.
3782
- PreserveJVMState pjvms (this );
3783
- set_control (pin_count_over_underflow);
3784
- set_all_memory (input_memory_state);
3785
- uncommon_trap_exact (Deoptimization::Reason_intrinsic,
3786
- Deoptimization::Action_none);
3787
- assert (stopped (), " invariant" );
3788
- }
3789
+ store_to_memory (control (), pin_count_offset, next_pin_count, T_INT, MemNode::unordered);
3789
3790
3790
3791
// Result of top level CFG and Memory.
3791
3792
RegionNode* result_rgn = new RegionNode (PATH_LIMIT);
@@ -3795,7 +3796,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) {
3795
3796
3796
3797
result_rgn->init_req (_true_path, _gvn.transform (valid_pin_count));
3797
3798
result_rgn->init_req (_false_path, _gvn.transform (continuation_is_null));
3798
- result_mem->init_req (_true_path, _gvn.transform (updated_pin_count_memory ));
3799
+ result_mem->init_req (_true_path, _gvn.transform (reset_memory () ));
3799
3800
result_mem->init_req (_false_path, _gvn.transform (input_memory_state));
3800
3801
3801
3802
// Set output state.
0 commit comments