On Wed, 24 Jan 2024 19:37:40 GMT, Paul Sandoz <psan...@openjdk.org> wrote:

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

> the method compilation has the expression in its original form

So the JIT analyses the bytecode used to place the result on the call stack, 
before the call, and from that determines if the expression were a constant? 
This kind of self-analysis is not something I was aware of.

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

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

Reply via email to