JDK-7125896 : Eliminate nested locks
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8-pool
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-12-29
  • Updated: 2021-05-29
  • Resolved: 2012-03-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u4Fixed 8Fixed hs23Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Eliminated nested locks of the same object:

    synchronized (reader) { // we synchronize on reader
    if (reader.getCount() > 0) { // calling synchronized method getCount() while already holding the lock
       reader.incrementReserveCount(1);
    }

Comments
EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/e9a5e0a812c8
22-03-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/e9a5e0a812c8
18-01-2012

EVALUATION Nested locks elimination done before lock nodes expansion by looking for outer locks of the same object. Commoning (GVN) of BoxLock nodes is switched off because nested locks elimination requires separate BoxLock node for each locked region to generated correct debug info for deoptimization. As result there could be merges (and Phi nodes) of BoxLock nodes. One such merge generated by ciTypeFlow (cloning loop head) is avoided but there could be other cases so new code is added to handle it. New code is under new product flag EliminateNestedLocks. Added new enum field AbstractLockNode::_kind (I tried to avoid _type name) and corresponding methods instead of boolean fields. Added new method LockNode::is_nested_lock_region() to find if it is nested. Added new method BoxLockNode::is_simple_lock_region() to check if Box node is used to lock only one object and to avoid replacing this Box with clone in macro.cpp. Added new method PhaseMacroExpand::mark_eliminated_box() to move EA eliminated marking code from mark_eliminated_locking_nodes(). Also added missed KILL effect for box register in fastlock and fastunlock mach nodes definitions.
09-01-2012

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/e9a5e0a812c8
07-01-2012