Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8020469

Redundant class initialization check in lambda capture

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • hs25
    • hotspot
    • None
    • 8
    • generic
    • generic

      Having this code (complete test case attached):

              public static Function<Integer, Integer> fi;

      public static void getLambda() {
                  int one = 1;
                  fi = x -> x + one;
      }

      Compiling and disassembling with the latest hotspot-comp/Linux x86_64 produces the following part of the code:

        0x00007fbf60247b12: mov $0xefe4c046,%r10d ; {metadata('Test$$Lambda$1')}
        0x00007fbf60247b18: movzbl 0x186(%r12,%r10,8),%r11d
        0x00007fbf60247b21: add $0xfffffffffffffffc,%r11d
        0x00007fbf60247b25: test %r11d,%r11d
        0x00007fbf60247b28: jne 0x00007fbf60247b3f

      This is class initialization check, generated because of LambdaForm jsr292 implementation uses Unsafe.allocateInstance for lambda instance creation.
      According to how lambdas are generated - this check is redundant.

            Unassigned Unassigned
            skuksenko Sergey Kuksenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: