United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7029152 Ideal nodes for String intrinsics miss memory edge optimization
7029152 : Ideal nodes for String intrinsics miss memory edge optimization

Details
Type:
Bug
Submit Date:
2011-03-18
Status:
Closed
Updated Date:
2011-04-25
Project Name:
JDK
Resolved Date:
2011-04-25
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
hs21
Fixed Versions:
hs21

Related Reports
Backport:
Relates:
Relates:
Relates:

Sub Tasks

Description
% cat Test.java
public class Test {

  static final String str = "11111xx11111xx1x";
  static int idx = 0;

  static int IndexOfTest(String str) {
    return str.indexOf("11111xx1x");
  }

  public static void main(String args[]) {
    final int ITERS=200000;

    for (int i=0; i<ITERS; i++) {
      idx = IndexOfTest(str);
    }
    System.out.println("IndexOf = " + idx);
  }
}

% gamma -Xbatch -XX:+PrintCompilation Test
Using java runtime at: /export/kvn/jdk6u22/jre
VM option '+PrintCompilation'
   1542   1   b   java.lang.String::indexOf (166 bytes)
   1640   2   b   java.lang.String::indexOf (29 bytes)
   1747   3   b   java.lang.String::indexOf (7 bytes)
   1795   4   b   Test::IndexOfTest (7 bytes)
   1803   1%  b   Test::main @ 2 (52 bytes)
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/superword.cpp:472
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/net/irkutsk.us.oracle.com/export/home/kvn/work2/hg/7004535/src/share/vm/opto/superword.cpp:472), pid=24278, tid=45
#  assert(out == prev || prev == NULL) failed: no branches off of store slice
#
# JRE version: 6.0_22-b03
# Java VM: OpenJDK Server VM (21.0-b04-internal-jvmg mixed mode solaris-x86 )
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/f9424955eb18
                                     
2011-03-31
PUBLIC COMMENTS

Superword optimization assumes that only Load nodes in loop or MergeMem outside
of loop could reference Store nodes. In bug case the loop has MergeMem nodes
used by StrIndexOf nodes which cause the failure:
# assert(out == prev || prev == NULL) failed: no branches off of store slice)

Added base class StrIntrinsicNode for String intrinsics nodes. In Ideal() method
look for TypeAryPtr::CHARS memory slice if memory is MergeMem.
Do not unroll a loop with String intrinsics code. String intrinsics are large
and have loops.
                                     
2011-03-31
WORK AROUND

-XX:-UseSupperWord
                                     
2011-03-22
EVALUATION

6942326 changes exposed this problem.

Ideal nodes for String intrinsics have memory alias type TypeAryPtr::CHARS. But they are not memory nodes so their memory dependance is not optimizated, step_through_mergemem() is not called. As result these nodes may have false dependance on wole memory (bottom). In the bug case after loop unroll we have integer Store followed by StrIndexOf node referencing MergeMem node which represent bottom memory:

 674    StoreI  ===  956  758  145  675  [[ 349  146 ]]  @precise klass IndexOfTest: 0x0853ae08:Constant:exact+356 *, name=pass, idx=8;  Memory: @precise klass IndexOfTest: 0x0853ae08:Constant:exact+356 *, name=pass, idx=8; !orig=146,[689] !jvms: IndexOfTest::main @ bci:69

 349    MergeMem        === _  1  7  1  1  1  1  1  674  [[ 141  658 ]]  { - - - - - N674:precise klass IndexOfTest: 0x0853ae08:Constant:exact+356 * }  Memory: @BotPTR *+bot, idx=Bot; !orig=[87] !jvms: IndexOfTest::main @ bci:62
 141    StrIndexOf      ===  956  349  131  109  139  111  [[ 146  655 ]]  !orig=[106] !jvms: IndexOfTest::runTest @ bci:2 IndexOfTest::main @ bci:66

 146    StoreI  ===  956  674  145  141  [[ 653  960 ]]  @precise klass IndexOfTest: 0x0853ae08:Constant:exact+356 *, name=pass, idx=8;  Memory: @precise klass IndexOfTest: 0x0853ae08:Constant:exact+356 *, name=pass, idx=8; !orig=[689] !jvms: IndexOfTest::main @ bci:69

Superword optimization assumes that only Load nodes could reference Store nodes in such situation and we have MergeMem node in the loop. This causes the assert.
                                     
2011-03-18



Hardware and Software, Engineered to Work Together