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

Shoaib Akram <[email protected]> Wed, 7 Dec 2016 01:56:04 +0100
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Your second hint is spot-on Eliot. The utility function I was using to get the size of an object included the bytes taken up by the header words. Since objectRef points to the first field of an object (or the length field in case of an array), I was accessing memory beyond the end of an object. Many thanks for making my task simpler ;) 

> On Dec 6, 2016, at 6:51 PM, Eliot Moss <[email protected]> wrote:
> 
> 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 <http://sdm.link/xeonphi>
> _______________________________________________
> Jikesrvm-researchers mailing list
> [email protected] <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers <https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers>

------------------------------------------------------------------------------
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

_______________________________________________
Jikesrvm-researchers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers