On Wed, 2 Dec 2026 23:26:18 GMT, Vladimir Kozlov <[email protected]> wrote:

>> The test 
>> [java/util/concurrent/locks/Lock/OOMEInAQS.java](https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/concurrent/locks/Lock/OOMEInAQS.java)
>>  timed out when run with "-XX:-TieredCompilation 
>> -XX:+UnlockDiagnosticVMOptions -XX:CompileThresholdScaling=0.01" flags.
>> 
>> The test checks that AQS-based locks, conditions, and `CountDownLatches` do 
>> not fail when encountering OOME. It intentionally fills Java heap to get 
>> OOME.
>> 
>> With `-XX:CompileThresholdScaling=0.01` C2 compiles test's code and 
>> scalarize new `ConditionNode` object in 
>> `AbstractQueuedSynchronizer::newConditionNode()` using 
>> `ReduceAllocationMerges` optimization.
>> 
>> One of test's worker threads executes compiled code and hit uncommon trap. 
>> During deoptimization scalarized object rematerialization failed (heap is 
>> full) and VM throws OOME. The affected inlined frames are popped because we 
>> can't execute them without materialized objects (see 
>> [InterpreterRuntime::exception_handler_for_exception()](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/interpreter/interpreterRuntime.cpp#L522)).
>>  As result, the inlined OOME handler is bypassed.
>> 
>> The test worker thread which hit deoptimization exits through "catch 
>> (Throwable ex)" path without notifying other worker threads which hang on 
>> "cond.await()" and we got timeout.
>> 
>> I suggest using an allocation's JVMstate information to walk through inlined 
>> frames and check for OOME handlers. Don't eliminate the allocation If we 
>> find such handler.  Narrow this condition only for `ReduceAllocationMerges` 
>> optimization for this fix. I concern that general solution may introduce a 
>> performance regression.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Vladimir Kozlov has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Improve test more

Still good.

src/hotspot/share/opto/escape.cpp line 537:

> 535:   // Check NoEscape state instead of SR here otherwise later
> 536:   // can_reduce_phi() call can skip SR protected input and
> 537:   // add the Phi through another SR input.

Does this comment still make sense now that we check SR first above?

-------------

Marked as reviewed by dlong (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/33197#pullrequestreview-6199758714
PR Review Comment: https://git.openjdk.org/jdk/pull/33197#discussion_r4808437970

Reply via email to