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