On constant folding of final field loads

Andrew Haley aph at redhat.com
Tue Jul 21 10:53:11 UTC 2015

On 21/07/15 00:05, John Rose wrote:

>> > Andrew, can you comment on why you decided to stick with absolute
>> > offsets and not preserving Unsafe.getInt() addressing scheme?

> (The outcome is that the unaligned guys have the same signatures as
> the aligned ones.)

Indeed it does.

I had a look around at the way Unsafe.getXXX(Object, long) is used.
One of the most common usages is with arrays.  There, the offset is
the result of address arithmetic so it cannot be an opaque cookie, and
there is no way to make it so without breaking all usages with arrays.

Also there is the guarantee that you can use
Unsafe.getXXXUnaligned(null, address) to fetch data from an absolute
address in memory.  To discover that this latter usage is explicitly
allowed surprised me, but it does mean that the offset can not be an
opaque handle unless we special-case the null form.  And I think we
don't want to do that.


More information about the hotspot-compiler-dev mailing list