@@ -3761,6 +3761,20 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) {
37613761 Node* test_pin_count_over_underflow = _gvn.transform (new BoolNode (pin_count_cmp, BoolTest::eq));
37623762 IfNode* iff_pin_count_over_underflow = create_and_map_if (control (), test_pin_count_over_underflow, PROB_MIN, COUNT_UNKNOWN);
37633763
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+
37643778 // False branch, no pin count over/underflow. Increment or decrement pin count and store back.
37653779 Node* valid_pin_count = _gvn.transform (new IfFalseNode (iff_pin_count_over_underflow));
37663780 set_control (valid_pin_count);
@@ -3772,20 +3786,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) {
37723786 next_pin_count = _gvn.transform (new AddINode (pin_count, _gvn.intcon (1 )));
37733787 }
37743788
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);
37893790
37903791 // Result of top level CFG and Memory.
37913792 RegionNode* result_rgn = new RegionNode (PATH_LIMIT);
@@ -3795,7 +3796,7 @@ bool LibraryCallKit::inline_native_Continuation_pinning(bool unpin) {
37953796
37963797 result_rgn->init_req (_true_path, _gvn.transform (valid_pin_count));
37973798 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 () ));
37993800 result_mem->init_req (_false_path, _gvn.transform (input_memory_state));
38003801
38013802 // Set output state.
0 commit comments