What's the status of / relation between "JEP 169: Value Objects" / "Value Types for Java" / "Object Layout"
volker.simonis at gmail.com
Wed Jan 28 20:40:49 UTC 2015
I've recently did some research on Java "value objects" / "value
types" / "object layout" (I'll be actually giving a short talk on the
topic at FOSDEM this weekend). I just want to quickly summarize my
current findings here and gently ask for feedback in case you think
I've totally misunderstood something. Of course any comments and
additional information is highly welcome as well.
1. JEP 169: Value Objects 
- Created by John Rose in 2012 (last update in Sep. 2014)
- Still in "Draft" state
- Proposes a new "lockPermanently()" operator which marks objects as immutable
- Seems to be only a little "helper functionality" to simplify
automatic boxing/unboxing and escape analysis
- Referenced the mlwm mailing list and repository but the mlwm repo
seems dead since about 15 month now
Question: is JEP 169 still under active development or has it been
merged into the more general "Value types for Java" proposal below?
2. "Value types for Java" / "State of the Values" 
- By J. Rose, B. Goetz and Guy Stele
- Based on earlier ideas from "Value Types in the VM" 
- Newest and most elaborate proposal
- Proposes general (i.e. function arguments, return values,
variables, arrays), "immutable" value types
- Requires fundamental changes to the VM as well as to the Java language
- Related to the "State of the Specialization" proposal  about
support for generics over primitive and value types by B Goetz.
- Discussed and developed in the OpenJDK "Valhalla"  project
- Still very early stage (i.e. no "code" available yet)
3. PackedObjects as provided by the IBM J9 [6,7]
- Flattens the memory layout of "@Packed" object fields and array
- Removes object headers of and references to "@Packed" objects
- Object headers can be generated on the fly (kind of "auto-boxing")
- Currently the most complete and mature solution
- Not Java-compatible (e.g. can not write to a nested "@Packed"
fields). Must be enabled as an experimental extension.
4. ObjectLayout 
- A pure Java, layout-optimized data structure package
- Designed similar to "@ValueSafe"/"ValueType" in  and "Value-base
classes" in Java 8 
- Designed such that it can be tranparently optimized within the VM
- VM can transparently layout "@Intrinsic" objects within other objects
- All objects are still complete Java object with valid header
- The Java part of the library is mature, first native
VM-optimizations on the way 
The "Value types for Java" approach clearly seems to be the most
general but also the most complex proposal. It's out of scope for Java
9 and still questionable for Java 10 and above. The "PackedObject" and
"ObjectLayout" approaches are clearly simpler and more limited in
scope as they only concentrate on better object layout. However the
"ObjectLayout" proposal demonstrates that this is still possible
within the current Java specification while the "PackedObjects"
proposal demonstrated that an optimizing implementation is feasible.
I've recently built a prototype which intrinsifies/optimizes some
parts of the "ObjectLayout" proposal in the HotSpot .
Question: is there a chance to get a some sort of Java-only but
transparently optimizable structure package like "ObjectLayout" into
Java early (i.e. Java 9)?
In my eyes this wouldn't contradict with a more general solution like
the one proposed in the "Value types for Java" approach while still
offering quite significant performance improvements for quite a big
range of problems. And if carefully designed, it could be easily
retrofitted to use the new, general "Value Types" once they are
Question: what would be the right place to propose something like the
"ObjectLayout" library for Java 9/10? Would that fit within the
umbrella of the Valhalla project or would it be done within its own
project / under it's own JEP?
Thanks for your patience,
More information about the valhalla-dev