[code-reflection] RFR: Drop unused local variables from generated op method

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Apr 28 18:37:04 UTC 2025


On Mon, 28 Apr 2025 18:30:11 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> The generated op method contains some local variables that are never used.
>> This PR fixes that, further reducing the number of generated locals per synthetic op method.
>> While this is not a groundbreaking improvement, in some complex tests I've seen a reduction of locals up to 20%.
>
> src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/CodeModelToAST.java line 124:
> 
>> 122: 
>> 123:         java.util.List<Value> rootValues = funcOp.traverse(new ArrayList<>(), (l, ce) -> {
>> 124:             boolean isRoot = switch (ce) {
> 
> I've rewrote the code here, as the condition `uses().size() != 1` was very subtle, and picking up things with no usages which, in principle, should not be "roots". Now the list of root values we expect is captured explicitly in the code.

Array stores ops and return ops  were examples of ops implicitly picked up by the old code.

-------------

PR Review Comment: https://git.openjdk.org/babylon/pull/413#discussion_r2064262206


More information about the babylon-dev mailing list