questions on Word operations
Deneau, Tom
tom.deneau at amd.com
Fri Sep 13 09:47:23 PDT 2013
I would like to add a new Word method that can be used from an allocation Snippet I am trying to write.
The new method would look like:
public Word atomicGetAndAddWord(int offset, int delta) {
}
So given a Word (address), this would do an atomic get and add of delta on the word located at the address this.rawValue + offset. Like j.u.c.atomic.getAndAdd, it would return the original word value at that address.
A couple of questions:
* Is the following a legal body for such a method? I see that it compiles but is it legal to call toObject() on a Word value? As used in the snippet the Word value would be the pointer returned by thread(). I noticed there is no unsafe.getAndAddLong(long address, long delta), only unsafe.getAndAddLong(Object o, long offset, long delta)
return box(unsafe.getAndAddLong(toObject(), offset, delta));
* I notice all the Word methods have @Operation annotations but I don't really understand the semantics of this annotation. What should be the annotation for this method?
* What is the purpose of the locationIdentity parameter on some of the word operations such as
@Operation(opcode = Opcode.READ)
public Word readWord(WordBase offset, LocationIdentity locationIdentity) {
return box(unsafe.getAddress(add((Word) offset).unbox()));
}
-- Tom
More information about the graal-dev
mailing list