hotspot-compiler-dev Digest, Vol 145, Issue 95
John Rose
john.r.rose at oracle.com
Mon Jul 22 01:41:55 UTC 2019
On Jul 21, 2019, at 6:15 AM, Erik Osterlund <erik.osterlund at oracle.com> wrote:
>
> So there are two separate problems:
>
> 1) The verifier isn’t intelligent enough to catch interface data flow errors because its type system is too simple (a tree, which doesnt reflect the reality of the Java type system), effectively ignoring interfaces.
>
> 2) The compiler can still know things about interfaces, as you describe. But due to the limitations of the verifier, there tends to be confusion around this. As you said, few people know that our own type system can’t be trusted because of that.
Correct. I lived the confusion back in the day, and don’t want to repeat it unnecessarily (see about “scars” in my previous).
And because the JVM feeds less (reliable) information about those types to the JIT, there’s less of an upside for the JIT to carefully track the little it *does* get.
> So ideally we would at least have an accurate mapping to where we do and do not know about interfaces, knowing the limitations of the verifier. That does not need to entail fixing the verifier, just being more honest in the type system about what we really know vs don’t know.
At that point it’s all a matter of priorities. We have known how to complete the C2 type system for years. What we lack is a reason to disrupt the code.
As a matter of priority, I would much rather see C2 gain better (bitwise) type inference for int and long values, or for pointer-chasing through (often immutable) structures. Both of those would IMO pay off better than the exercise (largely academic, I fear) of completing the interface lattice in C2.
> But ideally we would make the verifier more intelligent to make this whole situation less awkward. For example, maybe a lattice based type system in the verifier that jams in multiple interfaces with Dedekind-MacNeille completion tricks. Perhaps such a lattice based type system would also be more future-proof.
> And importantly, then we could trust our own type system, which makes me happy. And I would be utilizing that accuracy.
Ideally, yes. Practically… remains to be seen.
IMO there are interesting projects in the C2 type system with bigger upsides.
A personal favorite for me is bitwise type propagation (JDK-8001436).
You can lift most primitive operations to meaningfully track individual bits
from input to output. POC: http://cr.openjdk.java.net/~jrose/draft/BitTypes.zip
— John
More information about the hotspot-compiler-dev
mailing list