[code-reflection] RFR: Bytecode locals compaction [v3]
Paul Sandoz
psandoz at openjdk.org
Tue Sep 10 23:30:32 UTC 2024
On Tue, 10 Sep 2024 15:16:35 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> `LocalsCompactor` is a bytecode transformation reducing generated method `maxLocals` by re-using local slots.
>> Roundtrip of lift and bytecode generation doubles the `maxLocals` value, while `LocalsCompactor` reduces the regression by 50%.
>>
>> Lifting of compacted locals revealed bugs in `LocalsTypeMapper` variables graph construction. This patch includes significantly refactored `LocalsTypeMapper` to support lifting of compacted locals.
>>
>> `BytecodeGenerator` has slightly improved performance (so `TestSmallCorpus` finishes in a reasonable time). However performance has not been main focus of this PR.
>>
>> `TestSmallCorpus` has been slightly refactored to provide better debugging feedback and compaction statistics. Overall stability is still >99%.
>>
>> Please review.
>>
>> Thanks,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> added comments
This is getting to a level of complexity that i cannot provide a useful review on the algorithmic details as I don't fully comprehend them. Once you reach a stable point it will be very useful to describe the approach.
src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java line 355:
> 353: // Some of the operations can be deferred
> 354: private boolean canDefer(Op op) {
> 355: Boolean can = deferCache.get(op);
Use `computeIfAbsent`?
src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeLift.java line 275:
> 273: }
> 274:
> 275: public static CoreOp.FuncOp lift(MethodModel methodModel, MethodHandles.Lookup lookup) {
Place the lookup as the first parameter, like for the bytecode generator and the interpreter
-------------
Marked as reviewed by psandoz (Lead).
PR Review: https://git.openjdk.org/babylon/pull/224#pullrequestreview-2294105665
PR Review Comment: https://git.openjdk.org/babylon/pull/224#discussion_r1752899280
PR Review Comment: https://git.openjdk.org/babylon/pull/224#discussion_r1752905979
More information about the babylon-dev
mailing list