JDK-6958668 : repeated uncommon trapping for new of klass which is being initialized
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs19
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2010-06-04
  • Updated: 2013-06-19
  • Resolved: 2011-03-08
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 6 JDK 7 Other
6u21pFixed 7Fixed hs19Fixed
Description
That doesn't make much sense unless klass initialization hasn't been
completed yet.  Could all these copy calls be being made from a class
initializer?  This test case has the recompilation behaviour you're
seeing.

public class abs {
  public Object copy() {
      return new abs();
  }

  static {
      for (int i = 0; i < 10000000; i++) {
          abs qc = new abs();
          Object o = qc.copy();
      }
  }

  public static void main(String[] args) {
  }
}

The rules for dealing with classes that are in the being_initialized
state are somewhat complicated since only the initializing thread is
allowed to instantiate instances of that class while it's being
initialized.  Other threads must block so a dynamic check is required
before executing the new.  C2 just falls back to the interpreter through an uncommon trap with reason uninitialized which throws out the code and may end up recompiling.  It should really just emit a guarded new so you only end up with on extra uncommon trap once the init completes.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/3941674cc7fa
21-07-2010

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/3941674cc7fa
13-07-2010