Skip to content

Commit

Permalink
[GR-11141] Eliminate duplicate WordCastNodes in write barrier.
Browse files Browse the repository at this point in the history
PullRequest: graal/1979
  • Loading branch information
peter-hofer committed Aug 10, 2018
2 parents ddbf8fe + 5a027eb commit aa8a53e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,25 +256,25 @@ private static GCImpl.RememberedSetConstructor getRememberedSetConstructor() {
*
* This has to be fast, because it is used by the post-write barrier.
*/
public static void dirtyCardForObjectOfAlignedHeapChunk(Object obj) {
final AlignedHeader chunk = getEnclosingAlignedHeapChunk(obj);
public static void dirtyCardForObjectOfAlignedHeapChunk(Object object) {
final Pointer objectPointer = Word.objectToUntrackedPointer(object);
final AlignedHeader chunk = getEnclosingAlignedHeapChunkFromPointer(objectPointer);
final Pointer cardTableStart = getCardTableStart(chunk);
final UnsignedWord index = getObjectIndex(chunk, obj);
final UnsignedWord index = getObjectIndex(chunk, objectPointer);
CardTable.dirtyEntryAtIndex(cardTableStart, index);
}

/** Return the offset of an object within the objects part of a chunk. */
private static UnsignedWord getObjectOffset(AlignedHeader that, Object obj) {
private static UnsignedWord getObjectOffset(AlignedHeader that, Pointer objectPointer) {
final Pointer objectsStart = getObjectsStart(that);
final Pointer objectPointer = Word.objectToUntrackedPointer(obj);
assert objectsStart.belowOrEqual(objectPointer);
assert objectPointer.belowOrEqual(that.getEnd());
return objectPointer.subtract(objectsStart);
}

/** Return the index of an object within the tables of a chunk. */
private static UnsignedWord getObjectIndex(AlignedHeader that, Object obj) {
final UnsignedWord offset = getObjectOffset(that, obj);
private static UnsignedWord getObjectIndex(AlignedHeader that, Pointer objectPointer) {
final UnsignedWord offset = getObjectOffset(that, objectPointer);
return CardTable.memoryOffsetToIndex(offset);
}

Expand Down

0 comments on commit aa8a53e

Please sign in to comment.