United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7174928 JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
JDK-7174928 : JSR 292: unresolved invokedynamic call sites deopt and osr infinitely

Details
Type:
Bug
Submit Date:
2012-06-06
Status:
Closed
Updated Date:
2013-07-31
Project Name:
JDK
Resolved Date:
2012-06-16
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs23
Fixed Versions:
hs24 (b14)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
While testing a new flag I want to introduce (TraceOSR) I noticed that unresolved invokedynamic call sites compiled in C1 deoptimize and OSR infinitely.  The reason for that is we deoptimize but we don't have machinery in C1 to tell to throw the method out and recompile it.  So we just enter the same method again and hit the same unresolved call site.

                                    

Comments
SUGGESTED FIX

Conditionally jump to the deopt stub in generated code if the CallSite object is null.  Handling it this way it is not required to recompile the code.
                                     
2012-06-07
EVALUATION

JRuby's red-black benchmark is one that suffers heavily from this bug.  Fixing the problem shows a nice speedup:

cthaling@intelsdv01:~/mlvm/jruby$ jruby -J-showversion -J-d64 -J-XX:TieredStopAtLevel=1 -X+C bench/bench_red_black.rb
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b41)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b12, mixed mode)

17.83
GC.count = 1
17.301
GC.count = 2
17.39
GC.count = 3
17.5
GC.count = 3
17.408
GC.count = 4
17.439
GC.count = 5
17.252
GC.count = 6
17.43
GC.count = 7
18.086
GC.count = 7
17.71
GC.count = 8

cthaling@intelsdv01:~/mlvm/jruby$ jruby -J-showversion -J-d64 -J-XX:TieredStopAtLevel=1 -X+C bench/bench_red_black.rb 
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b41)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b12-internal, mixed mode)

7.099
GC.count = 1
6.967
GC.count = 2
6.821
GC.count = 3
6.925
GC.count = 3
6.884
GC.count = 4
6.812
GC.count = 5
6.772
GC.count = 6
6.996
GC.count = 7
6.929
GC.count = 7
6.807
GC.count = 8
                                     
2012-06-07
EVALUATION

Now the code sequence for an unresolved invokedynamic call site looks like this:

  0xfffffd7ff6106d9a: mov    %rsp,%rbp
  0xfffffd7ff6106d9d: mov    $0xfffffd7fd269bd28,%rsi  ;   {oop(cache [915] for constant pool [1576]/invokedynamic/operands[1798] for 'bench/bench_richards' cache=0xfffffd7fd269bd28)}
  0xfffffd7ff6106da7: mov    0x6028(%rsi),%rsi
  0xfffffd7ff6106dae: cmp    $0x0,%rsi
  ;;  838 branch [EQ] [DeoptimizeStub: 0x479ca18] [bci:79]
  0xfffffd7ff6106db2: je     0xfffffd7ff61095e6
  0xfffffd7ff6106db8: mov    0x20(%rsi),%rsi    ;*invokedynamic
                                                ; - bench.bench_richards::method__6$RUBY$release@79 (line 103)
  0xfffffd7ff6106dbc: nop    
  0xfffffd7ff6106dbd: nop    
  0xfffffd7ff6106dbe: nop    
  0xfffffd7ff6106dbf: callq  0xfffffd7ff58cdd60  ; OopMap{off=3172}
                                                ;*invokedynamic
                                                ; - bench.bench_richards::method__6$RUBY$release@79 (line 103)
                                                ;   {optimized virtual_call}
  0xfffffd7ff6106dc4: mov    %rbp,%rsp          ;*invokedynamic
                                                ; - bench.bench_richards::method__6$RUBY$release@79 (line 103)
                                     
2012-06-07
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/e2fe93124108
                                     
2012-06-13
EVALUATION

http://hg.openjdk.java.net/hsx/hsx23.2/hotspot/rev/ce8d9e20eded
                                     
2012-06-20
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/e2fe93124108
                                     
2012-06-29
Verified by comparing the performance of the benchmark suggested in the original bug comments in 7u40b31 and 7u4b15. 
Test: "jruby -J-showversion -J-d64 -J-XX:TieredStopAtLevel=1 -X+C bench_red_black.rb". 
Host: localhost, Windows 7, amd64.
                                     
2013-07-31



Hardware and Software, Engineered to Work Together