[9] RFR (M): 8037209: Improvements and cleanups to bytecode assembly for lambda forms

Paul Sandoz paul.sandoz at oracle.com
Wed Apr 2 19:19:01 UTC 2014


On Apr 2, 2014, at 4:16 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
> 
>>>> Regarding redundant null check, do you have a test case so I can play with it myself?
>>>> 
>>> 
>>> I will send something to you later today or tomorrow.
>>> 
> 
> 
> Still plan to send you something today :-) but later on...
> 

See below for an inline trace, the assembler and the class that was executed with  -XX:-TieredCompilation using Java 8.

Paul.

Inlining _isInstance on constant Class java/lang/String
               !            @ 9   MHFieldTest::testLoopOne (25 bytes)   inline (hot)
                              @ 8   java.lang.invoke.LambdaForm$MH/617901222::invokeExact_MT (15 bytes)   inline (hot)
                                @ 2   java.lang.invoke.Invokers::checkExactType (30 bytes)   inline (hot)
                                  @ 11   java.lang.invoke.MethodHandle::type (5 bytes)   accessor
                                @ 11   java.lang.invoke.LambdaForm$MH/523429237::putObjectFieldCast (32 bytes)   inline (hot)
                                  @ 1   java.lang.invoke.DirectMethodHandle::fieldOffset (9 bytes)   inline (hot)
                                  @ 6   java.lang.invoke.DirectMethodHandle::checkBase (7 bytes)   inline (hot)
                                    @ 1   java.lang.Object::getClass (0 bytes)   (intrinsic)
                                  @ 13   java.lang.invoke.DirectMethodHandle::checkCast (9 bytes)   inline (hot)
                                    @ 5   java.lang.invoke.DirectMethodHandle$Accessor::checkCast (9 bytes)   inline (hot)
                                      @ 5   java.lang.Class::cast (27 bytes)   inline (hot)
                                        @ 6   java.lang.Class::isInstance (0 bytes)   (intrinsic)
                                  @ 28   sun.misc.Unsafe::putObject (0 bytes)   (intrinsic)

[Verified Entry Point]
  0x000000010ccf0da0: mov    %eax,-0x14000(%rsp)
  0x000000010ccf0da7: push   %rbp
  0x000000010ccf0da8: sub    $0x20,%rsp         ;*synchronization entry
                                                ; - MHFieldTest::testLoopOne at -1 (line 57)

  0x000000010ccf0dac: mov    0xc(%rsi),%r10d    ;*getfield a
                                                ; - MHFieldTest::testLoopOne at 5 (line 57)

  0x000000010ccf0db0: test   %r10d,%r10d
  0x000000010ccf0db3: je     0x000000010ccf0ddd  ;*ifnull
                                                ; - java.lang.Class::cast at 1 (line 3257)
                                                ; - java.lang.invoke.DirectMethodHandle$Accessor::checkCast at 5 (line 441)
                                                ; - java.lang.invoke.DirectMethodHandle::checkCast at 5 (line 510)
                                                ; - java.lang.invoke.LambdaForm$MH/640070680::putObjectFieldCast at 13
                                                ; - java.lang.invoke.LambdaForm$MH/789451787::invokeExact_MT at 11
                                                ; - MHFieldTest::testLoopOne at 8 (line 57)

  0x000000010ccf0db5: add    $0x10,%rsi
  0x000000010ccf0db9: mov    %r10d,(%rsi)
  0x000000010ccf0dbc: mov    %rsi,%r10
  0x000000010ccf0dbf: shr    $0x9,%r10
  0x000000010ccf0dc3: mov    $0x18f780000,%r11
  0x000000010ccf0dcd: mov    %r12b,(%r11,%r10,1)  ;*getfield a
                                                ; - MHFieldTest::testLoopOne at 5 (line 57)

  0x000000010ccf0dd1: add    $0x20,%rsp
  0x000000010ccf0dd5: pop    %rbp
  0x000000010ccf0dd6: test   %eax,-0x113ddc(%rip)        # 0x000000010cbdd000
                                                ;   {poll_return}
  0x000000010ccf0ddc: retq   
  0x000000010ccf0ddd: mov    %rsi,%rbp
  0x000000010ccf0de0: mov    %r10d,0x4(%rsp)
  0x000000010ccf0de5: mov    $0xffffffad,%esi
  0x000000010ccf0dea: nop    
  0x000000010ccf0deb: callq  0x000000010ccbc120  ; OopMap{rbp=Oop [4]=NarrowOop off=112}
                                                ;*ifnull
                                                ; - java.lang.Class::cast at 1 (line 3257)
                                                ; - java.lang.invoke.DirectMethodHandle$Accessor::checkCast at 5 (line 441)
                                                ; - java.lang.invoke.DirectMethodHandle::checkCast at 5 (line 510)
                                                ; - java.lang.invoke.LambdaForm$MH/640070680::putObjectFieldCast at 13
                                                ; - java.lang.invoke.LambdaForm$MH/789451787::invokeExact_MT at 11
                                                ; - MHFieldTest::testLoopOne at 8 (line 57)
                                                ;   {runtime_call}
  0x000000010ccf0df0: callq  0x000000010c07ace4  ;*ifnull
                                                ; - java.lang.Class::cast at 1 (line 3257)
                                                ; - java.lang.invoke.DirectMethodHandle$Accessor::checkCast at 5 (line 441)
                                                ; - java.lang.invoke.DirectMethodHandle::checkCast at 5 (line 510)
                                                ; - java.lang.invoke.LambdaForm$MH/640070680::putObjectFieldCast at 13
                                                ; - java.lang.invoke.LambdaForm$MH/789451787::invokeExact_MT at 11
                                                ; - MHFieldTest::testLoopOne at 8 (line 57)
                                                ;   {runtime_call}


import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

public class MHFieldTest {

    volatile String a = "A";
    public String b;

    static final MethodHandle b_setter;

    static {
        try {
            b_setter = MethodHandles.lookup().findSetter(MHFieldTest.class, "b", String.class);
        }
        catch (Exception e) {
            throw new Error(e);
        }
    }

    public static void main(String[] args) {
        new MHFieldTest().testLoop();
    }

    void testLoop() {
        for (int i = 0; i < 1000000; i++) {
            testLoopOne();
        }
    }

    void testLoopOne() {
        try {
            b_setter.invokeExact(this, a);
        } catch (Throwable t) {
            throw new Error(t);
        }
    }
}





More information about the core-libs-dev mailing list