United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7058510 multinewarray with 6 dimensions uncommon traps in server compiler
JDK-7058510 : multinewarray with 6 dimensions uncommon traps in server compiler

Details
Type:
Enhancement
Submit Date:
2011-06-23
Status:
Closed
Updated Date:
2013-01-23
Project Name:
JDK
Resolved Date:
2011-09-30
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7u2 (b04)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
I noticed this code

	http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/5bb91b0db2c9/src/share/vm/opto/parse3.cpp
	410 void Parse::do_multianewarray() {
	411   int ndimensions = iter().get_dimensions();
	412 
	413   // the m-dimensional array
	414   bool will_link;
	415   ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
	416   assert(will_link, "multianewarray: typeflow responsibility");
	417 
	418   // Note:  Array classes are always initialized; no is_initialized check.
	419 
	420   enum { MAX_DIMENSION = 5 };
	421   if (ndimensions > MAX_DIMENSION || ndimensions <= 0) {
  !!	422     uncommon_trap(Deoptimization::Reason_unhandled,
	423                   Deoptimization::Action_none);
	424     return;
	425   }
	....
	507 }

and tried writing a test program that used an array with 6 dimensions and compared it to the same test using an array with 5 dimensions.  The results were surprising.  First the test with an array of 5 dimensions

        $ $Deployed/solaris-i586/JDK-7_b145/bin/javac MultiNewArray5.java
        $ $Deployed/solaris-i586/JDK-7_b145/bin/java -Xint MultiNewArray5
        That took 6.010 seconds.
        $ $Deployed/solaris-i586/JDK-7_b145/bin/java -client MultiNewArray5
        That took 3.048 seconds.
        $ $Deployed/solaris-i586/JDK-7_b145/bin/java -server MultiNewArray5
        That took 0.124 seconds.

So far so good.  But when I try an array with 6 dimensions

        $ $Deployed/solaris-i586/JDK-7_b145/bin/javac MultiNewArray6.java
        $ $Deployed/solaris-i586/JDK-7_b145/bin/java -Xint MultiNewArray6
        That took 6.645 seconds.
        $ $Deployed/solaris-i586/JDK-7_b145/bin/java -client MultiNewArray6
        That took 3.537 seconds.
        $ $Deployed/solaris-i586/JDK-7_b145/bin/java -server MultiNewArray6
        That took 63.718 seconds.

The uncommon trap causes the server code to run 10x slower than the interpreter, and 18x slower than the interpreter.  Wouldn't it be better to bail out of the compilation and mark the method as uncompilable so that it runs in the interpreter (or with the tier 1 client compilation)?

I've attached the MultiNewArray6.java (derived from a random number generator I was testing).  The change to MultiNewArray5.java is to delete one dimension of the array, and change the name of the classes from *6 to *5.

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/263247c478c5
                                     
2011-07-09
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/263247c478c5
                                     
2011-07-13
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/263247c478c5
                                     
2011-07-17
EVALUATION

See main CR
                                     
2011-08-30



Hardware and Software, Engineered to Work Together