hg: valhalla/valhalla/langtools: Add support for tracking 'any'-related opcodes
john.r.rose at oracle.com
Thu Jul 24 21:18:26 UTC 2014
On Jul 24, 2014, at 1:55 PM, Paul Benedict <pbenedict at apache.org> wrote:
> I was thinking the new types would be pure singletons
Absolutely pure singletons ( https://blogs.oracle.com/jrose/entry/fixnums_in_the_vm ) are tricky to implement, since you will need either uniquification logic or else pervasive type testing.
I prefer to think in terms of normal object references with restricted "value safe" semantics and/or usage ( https://blogs.oracle.com/jrose/entry/value_types_in_the_vm "The Rules" ).
You can have a good-enough set of rules, even where, by working hard enough, you can discover that two occurrences of '42' are in distinct boxes. It's "good-enough" if you'd have to break some rules of hygiene to observe the distinction. Absolutely hiding such distinctions has performance costs.
FTR, my most recent discussion of values is here: https://blogs.oracle.com/jrose/entry/value_types_in_the_vm1
As you can see, in order to clarify the design and implementation of value types relative to the existing JVM, we are positing pairs of types, boxed and unboxed, with different bytecodes and verification rules. The unboxed form is indistinguishable from a pure singleton. The boxed form is compatible with java.lang.Object (and arbitrary interfaces), and for that reason has a few caveats about purity.
More information about the valhalla-dev