efficiency vs. immutability of inline classes

Brian Goetz brian.goetz at oracle.com
Fri Aug 21 16:18:53 UTC 2020

> Quick follow-up question: If the InlineType ctor contains a check that 
> y is valid - will the JIT omit that check if it sees that y hasn't 
> been mentioned in the `with` block?

Yes, we've discussed this.  Currently that is not the case, but it is 
the sort of targeted optimization that could be considered if it becomes 
a problem.   It requires putting together a number of things, none of 
which are impossible, but optimizations of this sort can be brittle in 
that they can exhibit "fall off the cliff" behaviors, where they work 
great for simple cases, but once you cross some threshold (such as 
inlining limits, or reordering the statements in the ctor), they start 

This is an example of work that the compiler has to "undo" because the 
code is working with over-large building blocks (like constructors) for 
reasons of human factors, not unlike previous generations of compilers 
had to struggle with identifying when loops could be vectorized.

More information about the valhalla-dev mailing list