Hi everybody,

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[0] 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 [1]
 - 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" [2]
 - By J. Rose, B. Goetz and Guy Stele
 - Based on earlier ideas from "Value Types in the VM" [3]
 - 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 [4] about
support for generics over primitive and value types by B Goetz.
 - Discussed and developed in the OpenJDK "Valhalla" [5] 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 [8]
 - A pure Java, layout-optimized data structure package
 - Designed similar to "@ValueSafe"/"ValueType" in [3] and "Value-base
classes" in Java 8 [9]
 - 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 [10]

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 [10].

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
available.

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,
Volker


[0] https://fosdem.org/2015/schedule/event/packed_objects/
[1] http://openjdk.java.net/jeps/169
[2] http://cr.openjdk.java.net/~jrose/values/values-0.html
[3] https://blogs.oracle.com/jrose/entry/value_types_in_the_vm
[4] http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html
[5] http://openjdk.java.net/projects/valhalla
[6] 
http://www.slideshare.net/rsciampacone/javaone-2013-introduction-to-packedobjects?related=1
[7] http://medianetwork.oracle.com/video/player/2623645005001
[8] http://objectlayout.org
[9] http://docs.oracle.com/javase/8/docs/api/java/lang/doc-files/ValueBased.html
[10] 
https://github.com/simonis/ObjectLayout/tree/hotspot_intrinsification/hotspot
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to