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

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jan 25 12:55:36 UTC 2024


On Thu, 25 Jan 2024 07:41:27 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> > > Naive question: the right way to use this would be almost invariably be like this:
> > > ```
> > > if (isCompileConstant(foo) && fooHasCertainStaticProperties(foo)) {
> > >     // fast-path
> > > }
> > > // slow path
> > > ```
> > > 
> > > 
> > >     
> > >       
> > >     
> > > 
> > >       
> > >     
> > > 
> > >     
> > >   
> > > Right?
> > 
> > 
> > Yes, I think so.
> 
> But then whatever is in the fast path and `fooHasCertainStaticProperties` are never profiled because never executed by the interpreter or c1. So `fooHasCertainStaticProperties` will likely not be inlined and c2 will do a poor (or rather not as good as you'd like) job of compiling whatever is in the fast path.

I suppose perhaps it is implied that `fooHasCertainStaticProperties` should have `@ForceInline` ? But yes, there seems to be several assumptions in how this logic is supposed to be used, and at the moment, it seems to me more of a footgun than something actually useful (but I admit my ignorance on the subject).

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

PR Comment: https://git.openjdk.org/jdk/pull/17527#issuecomment-1910140980


More information about the core-libs-dev mailing list