[vector] Intrinsics for fromByteArray, fromByteBuffer, intoByteArray, intoByteBuffer
John Rose
john.r.rose at oracle.com
Thu May 3 02:41:01 UTC 2018
On May 2, 2018, at 11:18 AM, Lupusoru, Razvan A <razvan.a.lupusoru at intel.com> wrote:
>
> Is it possible that "address" field of ByteBuffer is not properly initialized even if it has a proper backing array? What extra checks do we need in implementation to ensure that a vector store to that raw address will be safe?
The address field is always properly initialized by the buffer constructor.
It is either an unscaled byte offset into the non-null "hb" array object,
or else a raw virtual address off-heap (and "hb" is null). In all cases,
the unsafe addressing modes work uniformly. To get the first byte of
a buffer, Unsafe.getUnsafe().getByte(b.hb, b.address) should always
work. And the unsafe addressing instructions do compile directly
to two-register (or register-displaced or absolute) addressing modes,
with the hb and the address operands being the two register values.
So forming an address into a buffer started by adding an offset
(after range checking, naturally) to b.address, and then ensuring
that the code generator will add that to b.hb (or ignore b.hb if
it is null, which amounts to the same thing).
HTH
— John
More information about the panama-dev
mailing list