[code-reflection] RFR: Lower StringTemplateOp [v4]
Paul Sandoz
psandoz at openjdk.org
Mon Mar 18 16:01:51 UTC 2024
On Mon, 18 Mar 2024 10:32:02 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> The lowering of the StringTemplateOp. We chose not to have a block for every expression body, rather blocks will be created when necessary.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
>
> Lower each expression in a separate block
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java line 2807:
> 2805: also create a block for after expressions
> 2806: *
> 2807: * */
Suggestion:
// Creates a block for each expression and a last block
// to continue building from. An expression block branches
// to the next expression block or the last block
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java line 2826:
> 2824: if (exprIndex == 0) {
> 2825: b.op(branch(bb.successor()));
> 2826: }
Use a counted loop, rather than using `indexOf` inside the loop. You can hoist you the `b.op(branch(bb.successor()));` and place it in the above `else` branch of code.
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java line 2884:
> 2882: };
> 2883:
> 2884: private static Map<TypeElement, TypeElement> primitiveToWrapper() {
Recommend moving this functionality to `JavaType`. (You can store the result of Map.of in a static final field and reuse that rather than recompute on each call.)
When we improve the modeling of Java types we can improve further.
src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java line 2888:
> 2886: BYTE, J_L_BYTE,
> 2887: SHORT, J_L_SHORT,
> 2888: JavaType.INT, J_L_INTEGER,
Suggestion:
INT, J_L_INTEGER,
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/39#discussion_r1528811192
PR Review Comment: https://git.openjdk.org/babylon/pull/39#discussion_r1528817633
PR Review Comment: https://git.openjdk.org/babylon/pull/39#discussion_r1528836728
PR Review Comment: https://git.openjdk.org/babylon/pull/39#discussion_r1528829873
More information about the babylon-dev
mailing list