Compiler deoptimization behaviour

Andrew Haley aph at redhat.com
Tue Jun 19 13:31:34 UTC 2018


On 06/19/2018 02:17 PM, Andrew Haley wrote:
> Try  -XX:MaxInlineLevel=15.

And incidentally, if we do that and inline everything we get some truly
beautiful code:

Compiled method (c2)    4989  652       4       TestFrames::add2 (31 bytes)
  ...
  0x000003ffa8b2a4f4: ldr	x10, [x1,#16]
  0x000003ffa8b2a4f8: add	x10, x10, w2, sxtw
 ;; 0x14D6FBCFA76
  0x000003ffa8b2a4fc: mov	x11, #0xfa76                	// #64118
  0x000003ffa8b2a500: movk	x11, #0x6fbc, lsl #16
  0x000003ffa8b2a504: movk	x11, #0x14d, lsl #32
  0x000003ffa8b2a508: add	x10, x10, x11
  0x000003ffa8b2a50c: str	x10, [x1,#16]   ;*putfield var {reexecute=0 rethrow=0 return_oop=0}
                                                ; - TestFrames::add13 at 8 (line 103)
                                                ; - TestFrames::add12 at 22 (line 99)
                                                ; - TestFrames::add11 at 22 (line 93)
                                                ; - TestFrames::add10 at 22 (line 87)
                                                ; - TestFrames::add9 at 22 (line 81)
                                                ; - TestFrames::add8 at 22 (line 75)
                                                ; - TestFrames::add7 at 22 (line 69)
                                                ; - TestFrames::add6 at 22 (line 63)
                                                ; - TestFrames::add5 at 22 (line 57)
                                                ; - TestFrames::add4 at 21 (line 51)
                                                ; - TestFrames::add3 at 21 (line 45)
                                                ; - TestFrames::add2 at 21 (line 39)

  0x000003ffa8b2a510: ldp	xfp, xlr, [sp,#16]
  0x000003ffa8b2a514: add	sp, sp, #0x20
  0x000003ffa8b2a518: ldr	xscratch1, [xthread,#288]
  0x000003ffa8b2a51c: ldr	wzr, [xscratch1]  ;   {poll_return}
  0x000003ffa8b2a520: ret

Note that this is all of add2 and it contains no loops at all.  It
adds n to var, adds 0x14D6FBCFA76 to that, and stores the result in var.
It has optimized 10*12 operations to 1.  Now that's what I call
optimization!


-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the hotspot-dev mailing list