As an additional data point: Ruby MRI works like that. Basically
integers (instances of class Fixnum) look like ordinary objects but
under the hood the value is encoded in the reference and there is no
object on the heap. You get a nice consistent model for the language
user but avoid the overhead of GC. Ruby is still not a racing car
compared with other PL - usual trade offs apply. The concept is
described here:
http://en.wikipedia.org/wiki/Tagged_pointer
It could require a signicifant (nice typo, sounds like an animal) change
in the JVM definition though.
AFAIK, in development versions of the JVM this is apparently already
being worked on (I remember seeing it being talked about a few months
back on one of the JVM development mailing lists). I am not really sure
about the implementation specifics though.
my own VM also has fixnums, although they don't use tagged pointers.
the VM uses inaccessible address-ranges as types.
on 32-bit x86 targets, this generally means the space between 0xC0000000
and 0xFFFFFFFF. on x86-64, a much bigger chunk of address space is used
(currently a roughly 56-bit wide region, but on current HW this could be
pushed actually to about 60 or 62 bits, given the actual accessible part
of the space is relatively tiny).
as-is, this currently means 28 bit fixnums on x86, and 48 bit fixnums on
x86-64, rather than the 30 and 62 bits possible via tagged pointers.
an advantage, however, is that this does not interfere with my ability
to make use of unaligned pointers: I wanted a system where I could point
a character pointer anywhere in a string, and still have the
type-checking able to figure out that it was a string, and more so, also
be able to tell me the address of the start of the string and the
relative offset therein.
it all works fairly well, although type-checking is potentially a little
more costly, given that most such operations need to identify the base
of the heap-object in question. luckily, these lookups are
"approximately" constant time (it is not really constant, but roughly
ranges from O(1) to O(log2 n) depending on various factors).
or such...