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

nep_invoker_blob can be simplified more

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 22
    • 21
    • core-libs
    • None

    Description

      In FFM, native function would be called via `nep_invoker_blob`. If the function has two arguments, it would be following:

      ```
      Decoding RuntimeStub - nep_invoker_blob 0x00007fcae394cd10
      --------------------------------------------------------------------------------
        0x00007fcae394cd80: pushq %rbp
        0x00007fcae394cd81: movq %rsp, %rbp
        0x00007fcae394cd84: subq $0, %rsp
       ;; { argument shuffle
        0x00007fcae394cd88: movq %r8, %rax
        0x00007fcae394cd8b: movq %rsi, %r10
        0x00007fcae394cd8e: movq %rcx, %rsi
        0x00007fcae394cd91: movq %rdx, %rdi
       ;; } argument shuffle
        0x00007fcae394cd94: callq *%r10
        0x00007fcae394cd97: leave
        0x00007fcae394cd98: retq
      ```

      `subq $0, %rsp` is for shadow space on stack, and `movq %r8, %rax` is number of args for variadic function. So they are not necessary in some case. They should be remove following if they are not needed:

      ```
      Decoding RuntimeStub - nep_invoker_blob 0x00007fd8778e2810
      --------------------------------------------------------------------------------
        0x00007fd8778e2880: pushq %rbp
        0x00007fd8778e2881: movq %rsp, %rbp
       ;; { argument shuffle
        0x00007fd8778e2884: movq %rsi, %r10
        0x00007fd8778e2887: movq %rcx, %rsi
        0x00007fd8778e288a: movq %rdx, %rdi
       ;; } argument shuffle
        0x00007fd8778e288d: callq *%r10
        0x00007fd8778e2890: leave
        0x00007fd8778e2891: retq
      ```

      We can see these stub code on [ffmasm testcase](https://github.com/YaSuenag/ffmasm/tree/ef7a466ca9607164dbe7be7e68ea509d4bdac998/examples/cpumodel) with `-XX:+UnlockDiagnosticVMOptions -XX:+PrintStubCode` and hsdis library. This testcase linked the code with `Linker.Option.isTrivial()`.

      Attachments

        Issue Links

          Activity

            People

              ysuenaga Yasumasa Suenaga
              ysuenaga Yasumasa Suenaga
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: