This document proposes ObjectLayout as a way to close the speed gap between Java and C by enabling Java objects to have optimized memory layouts like C structs. It describes three forms - arrays of structs, structs containing other structs, and structs with arrays at the end. Vanilla Java classes called StructuredArray, intrinsic objects, and subclassable arrays are presented to capture the semantics of these forms. Optimized JDK implementations are proposed to lay out objects contiguously for improved speed. The goal is to add ObjectLayout to Java SE without requiring language or JVM changes by providing both vanilla and optimized versions.
4. Value
types
Speed!
For any Object
ObjectLayout
Packed
objects
&
JNR/FFI
On Heap
precise layout
control
Off Heap
Sharing data
Immutable
Return values
On-stack
Objects
usable by
all existing
On Heap
New code code
Array of
small-footprint
values
New code