RFR: 8324433: Introduce a way to determine if an expression is evaluated as a constant by the Jit compiler [v5]

Paul Sandoz psandoz at openjdk.org
Wed Jan 24 19:40:27 UTC 2024


On Wed, 24 Jan 2024 18:48:34 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> @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.

I agree. All values are produced by evaluating expressions. In this case we want to query whether a value produced by the compiler evaluating its expression is a constant value (inputs to the expression are constants and the expression had no material side-effects). Meaning if the method returns true then we could use that knowledge in subsequent expressions that may also produce constants or some specific behavior.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17527#discussion_r1465449454


More information about the hotspot-compiler-dev mailing list