Re: [rvm-research] question regarding raw memory access

Eliot Moss <[email protected]> Tue, 6 Dec 2016 12:51:42 -0500
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
On 12/6/2016 11:12 AM, Shoaib Akram wrote:
> Hi All,
>
> I am trying to access the bytes that make up an object using the utility function Magic.getByteAtOffset(Object, Offset). I am doing this during a GC pause after all edges in an object are processed in scanObject(ObjectReference). This procedure is useful, for instance, in creating a unique hash for each object. Given that idx is of type int ranging from 0 to sizeof_object_minus_one, offset is initialized to zero, and objectRef is of type ObjectReference, I use the following statement to access the bytes stored in each object in memory.
>
> byte next_byte = Magic.getByteAtOffset(objectRef.toObject(), offset.plus(idx));
>
> This statement results in a hardware trap (after a few GC pauses). Is this the correct and safe approach to access raw memory in this part of JikesRVM (SpecializedScanMethod::scanObject(ObjectReference))?

I can see two potential problems with that:

1) You need to make sure that objectRef is not null.

2) I wonder how you calculate size.  I observe that header words,
    and as I recall, even the first field, of objects occur at
    negative offsets.  You may be accessing beyond the end of an
    object ...

What you're trying to do may not be quite so simple :-) ...

Regards - Eliot Moss

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi