Value Types for Java

Miles Sabin miles at milessabin.com
Tue Jun 17 00:20:11 PDT 2008


On Tue, Jun 17, 2008 at 5:42 AM, Ben Hutchison <benh at ibsglobalweb.com> wrote:
> Ive written up a post outlining my case for value type support:
> http://benhutchison.wordpress.com/2008/06/15/the-jvm-needs-value-types/

Surely, in that very article you describe the exact encoding that's
needed to get almost all of the benefits of value types that you list
without any JVM changes: inline value type fields into the enclosing
object, stack frame or argument list.

Arrays are a little less natural, but one array per field would seem
likely to do most of the job on the assumption that most value types
have few fields (so, eg. an array of (String, int) would be encoded as
an array of string and an array of Int). In cases where the fields are
all or partly of a homogeneous type the arrays of their encodings
could be fused (eg. and array of n complex doubles could be encoded as
an array of 2n doubles).

Obviously the language has to hide this from the programmer, but that
seems largely trivial. Interestingly, it seems quite possible that a
smart compiler could go a long way with types which are not explicitly
flagged as value types by inferring that particular objects could be
inlined in some situations (there's a small literature out there on
"object inlining").

So doesn't this get you what you want? What am I missing?

Cheers,


Miles



More information about the mlvm-dev mailing list