RFR: 8280481: Duplicated stubs to interpreter for static calls
Evgeny Astigeevich
duke at openjdk.org
Tue Jul 5 17:54:33 UTC 2022
On Fri, 17 Jun 2022 09:25:18 GMT, Andrew Haley <aph at openjdk.org> wrote:
>>> Based on your numbers (bytes saved / number of methods) I believe we're saving 16 bytes per method.
>>
>> How did you get 16?
>> dotty arm64: $ 820544 / 4592 = 179 $
>>
>>> How much more is there? What can we do with stubs besides duplicated static stubs removal?
>>
>> For arm64 we have: moving a pointer to metadata to a register and moving the address of the interpreter to a register.
>>
>> 0x0000ffff79bd2560: isb ; {static_stub}
>> 0x0000ffff79bd2564: mov x12, #0x388 // #904
>> ; {metadata({method} {0x0000ffff18400388} 'error' '(ILjava/lang/String;)V' in 'Test')}
>> 0x0000ffff79bd2568: movk x12, #0x1840, lsl #16
>> 0x0000ffff79bd256c: movk x12, #0xffff, lsl #32
>> 0x0000ffff79bd2570: mov x8, #0xe58c // #58764
>> 0x0000ffff79bd2574: movk x8, #0x793b, lsl #16
>> 0x0000ffff79bd2578: movk x8, #0xffff, lsl #32
>> 0x0000ffff79bd257c: br x8
>>
>> If we never patch the branch to the interpreter, we can optimize it at link time either to a direct branch or an adrp based far jump. I also created https://bugs.openjdk.org/browse/JDK-8286142 to reduce metadata mov instructions.
>>
>>> Is it possible (theoretically) to move the stub out of the calling method to share it between methods?
>>
>> It is possible but it complicates CodeCache maintenance. Stubs use a pointer to metadata. When a class and methods are unloaded, we will need to invalidate all corresponding stubs.
>>
>> I can check with benchmarks how many stubs can shared among methods.
>
>> If we never patch the branch to the interpreter, we can optimize it at link time either to a direct branch or an adrp based far jump. I also created https://bugs.openjdk.org/browse/JDK-8286142 to reduce metadata mov instructions.
>
> If we emit the address of the interpreter once, at the start of the stub section, we can replace the branch to the interpreter with
> `ldr rscratch1, adr; br rscratch1`.
Hi Andrew(@theRealAph),
Your comments are usually highly useful and help to identify missed issues.
Do you have any of them?
Thanks,
Evgeny
-------------
PR: https://git.openjdk.org/jdk/pull/8816
More information about the hotspot-compiler-dev
mailing list