RFR: 8324433: Introduce a way to determine if an expression is evaluated as a constant by the Jit compiler [v5]
Aleksey Shipilev
shade at openjdk.org
Wed Jan 24 18:51:31 UTC 2024
On Wed, 24 Jan 2024 07:15:12 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> This seems really weird to me for Java code. The method doesn't get the original "expression" it only gets the value of that expression after it has been evaluated. Is there some kind of weird "magic" happening here?
>
> @dholmes-ora Indeed it's a compiler magic, albeit not really weird. While the method execution only receives the evaluated value of `expr`, the method compilation has the expression in its original form. As a result, it can determine the result based on this information.
It is still weird to talk about expressions at this level. We really check if the value is constant, like the method name suggests now. Yes, this implicitly tests that the expression that produced that value is fully constant-folded. But that's a detail that we do not need to capture here. Let's rename `expr` -> `val`, and tighten up the javadoc for the method to mention we only test the constness of the final value.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17527#discussion_r1465401456
More information about the hotspot-compiler-dev
mailing list