Repository navigation
Conversation
|
👋 Welcome back asotona! A progress list of the required criteria for merging this PR into |
|
@asotona This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
| * variable. | ||
| *</ul> | ||
| * | ||
| * @apiNote Compiler-generated Java code models may inline constant-variable reads as {@link ConstantOp} operations. |
There was a problem hiding this comment.
We can link to the definition of "Java code model" in the jdk.incubator.code package doc and state:
Java code models(<- link) model access to a constant variable as a constant operation whose constant value is the same as the constant variable's value
| %88 : java.type:"boolean" = eq %86 %87; | ||
| yield %88; | ||
| (%85 : java.type:"int")java.type:"boolean" -> { | ||
| %86 : java.type:"int" = constant @11; |
There was a problem hiding this comment.
value %4 is not used, instead a new constant op is appended, is that deliberate ?
| case FIELD, ENUM_CONSTANT -> { | ||
| if (sym.name.equals(names._this) || sym.name.equals(names._super)) { | ||
| result = thisValue(); | ||
| } else if (top.localToOp.containsKey(sym)) { |
There was a problem hiding this comment.
else-if at line 1053 can be removed
…and inline constant captures
| Method intfMethod = funcIntfMethod(intfClass, mtd); | ||
| List<Value> captures = lop.capturedValues(); | ||
| // filter out constant captures | ||
| List<Value> captures = lop.capturedValues().stream().filter(v -> constants.evaluate(v).isEmpty()).toList(); |
There was a problem hiding this comment.
We should avoid evaluating constants three times.
There was a problem hiding this comment.
The evaluation cached in a map, there is no need to construct arbitrary maps on top of it.
There was a problem hiding this comment.
Ah, I missed that, although computing the captured values is not cached.
| lambdaMetafactory = DMHD_REFLECTABLE_LAMBDA_METAFACTORY; | ||
| intfMethodName = intfMethodName + "=" + modelName; | ||
| } | ||
| functions.add(lambdaToFuncOp(implName, lop).transform(this)); |
There was a problem hiding this comment.
It would be preferable to have just one lambda model to work from i.e. the quoting function model. That complicates the "purity" of the functions added and the bytecode transformation of those quoting functions, but I believe the quoting function model has all that is needed to generate the same bytecode. Follow on work?
| import jdk.incubator.code.dialect.java.JavaType; | ||
| import jdk.incubator.code.dialect.java.PrimitiveType; | ||
|
|
||
| public final class ConstantValueAnalysis { |
There was a problem hiding this comment.
As follow on work we can consider adding a method to JavaExpression that evaluates constants without a lookup, which shares the same underlying code as those that do.
| } | ||
|
|
||
| /** | ||
| * Embeds the given operation into a quoting code model whose behavior quotes the operation. |
There was a problem hiding this comment.
The specification needs adjustment to say how it uses embeddedConstants.
Let's rename embeddedConstants to capturedConstants, then it becomes easier to state that there is an intersection between the set of the lambda's captured values and the given key set of capturedConstants, and then what happens to the capture values that are members of that intersection.
|
|
||
| public final class ConstantValueAnalysis { | ||
| private final Function<Block, List<List<Value>>> incomingArguments; | ||
| private final Map<Value, Optional<Object>> cache = new IdentityHashMap<>(); |
There was a problem hiding this comment.
No need to use IdentityHashMap. Value instances and CodeElements instances are identity-based objects whose equals/hashCode methods use identity.
This PR puts constants known to javac directly into the model instead of loading them from variables or fields.
OpWriter required a fix related to byte and short constants.
Affected tests are updated.
Progress
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/babylon.git pull/1203/head:pull/1203$ git checkout pull/1203Update a local copy of the PR:
$ git checkout pull/1203$ git pull https://git.openjdk.org/babylon.git pull/1203/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1203View PR using the GUI difftool:
$ git pr show -t 1203Using diff file
Download this PR as a diff file:
https://git.openjdk.org/babylon/pull/1203.diff
Using Webrev
Link to Webrev Comment