Skip to content

Commit

Permalink
Minor fixes and improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-hofer committed May 8, 2024
1 parent f1e4ec8 commit 63dd758
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public final class PlanningVisitor implements AlignedHeapChunk.Visitor {
public PlanningVisitor() {
}

public void init(Space space) {
allocChunk = space.getFirstAlignedHeapChunk();
allocPointer = AlignedHeapChunk.getObjectsStart(allocChunk);
}

@Override
public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
boolean sweeping = chunk.getShouldSweepInsteadOfCompact();
Expand All @@ -71,26 +76,26 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {

BrickTable.setEntry(chunk, brickIndex, objSeq);

Pointer p = AlignedHeapChunk.getObjectsStart(chunk);
Pointer p = objSeq;
while (p.belowThan(initialTop)) {
Word header = ObjectHeaderImpl.readHeaderFromPointer(p);
Object obj = p.toObject();

UnsignedWord objSize;
if (ObjectHeaderImpl.isForwardedHeader(header)) {
/*
* If an object was copied from a chunk that won't be swept and forwarding was put
* in place, it was because we needed to add an identity hash code field.
* in place, it was because we needed to add an identity hash code field to the
* object, and we need the object's original size here.
*/
assert !sweeping && ConfigurationValues.getObjectLayout().isIdentityHashFieldOptional();
Object forwardedObj = ObjectHeaderImpl.getObjectHeaderImpl().getForwardedObject(p, header);
objSize = LayoutEncoding.getSizeFromObjectWithoutOptionalIdHashFieldInGC(forwardedObj);
} else {
objSize = LayoutEncoding.getSizeFromObjectInlineInGC(obj);
objSize = LayoutEncoding.getSizeFromObjectInlineInGC(p.toObject());
}

if (ObjectHeaderImpl.isMarkedHeader(header)) {
ObjectHeaderImpl.unsetMarkedAndKeepRememberedSetBit(obj);
ObjectHeaderImpl.unsetMarkedAndKeepRememberedSetBit(p.toObject());

/*
* Adding the optional identity hash field would increase an object's size, so we
Expand Down Expand Up @@ -174,9 +179,4 @@ private Pointer allocate(UnsignedWord size) {
}
return p;
}

public void init(Space space) {
allocChunk = space.getFirstAlignedHeapChunk();
allocPointer = AlignedHeapChunk.getObjectsStart(allocChunk);
}
}

0 comments on commit 63dd758

Please sign in to comment.