Skip to content

Commit

Permalink
fixup! Revisit newly added files.
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-hofer committed May 8, 2024
1 parent e41b210 commit f1e4ec8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,16 @@
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.code.CodeInfo;
import com.oracle.svm.core.code.CodeInfoAccess;
import com.oracle.svm.core.code.RuntimeCodeCache.CodeInfoVisitor;
import com.oracle.svm.core.code.RuntimeCodeInfoAccess;
import com.oracle.svm.core.heap.ObjectReferenceVisitor;
import com.oracle.svm.core.genscavenge.compacting.ObjectRefFixupVisitor;

/**
* Before compaction, updates the same references that were visited by
* {@link RuntimeCodeCacheWalker} during the mark phase.
*/
/** Before compaction, updates references from {@link CodeInfo} structures. */
final class RuntimeCodeCacheFixupWalker implements CodeInfoVisitor {

private final ObjectReferenceVisitor visitor;
private final ObjectRefFixupVisitor visitor;

@Platforms(Platform.HOSTED_ONLY.class)
RuntimeCodeCacheFixupWalker(ObjectReferenceVisitor visitor) {
RuntimeCodeCacheFixupWalker(ObjectRefFixupVisitor visitor) {
this.visitor = visitor;
}

Expand All @@ -52,19 +47,10 @@ public boolean visitCode(CodeInfo codeInfo) {
return true;
}

int state = CodeInfoAccess.getState(codeInfo);
assert state != CodeInfo.STATE_INVALIDATED : "should not be observable here";
if (state == CodeInfo.STATE_UNREACHABLE || state == CodeInfo.STATE_READY_FOR_INVALIDATION) {
/*
* The code will be freed during this collection, but we need to make sure that all the
* objects that are accessed during the invalidation remain accessible. Those objects
* can only be collected in a subsequent garbage collection.
*/
RuntimeCodeInfoAccess.walkObjectFields(codeInfo, visitor);
return true;
}

/* The CodeInfo remains valid, so we need to fix up all references. */
/*
* Whether this CodeInfo remains valid or will be invalidated or freed during this GC, we
* update all its references, including clearing those to objects that do not survive.
*/
RuntimeCodeInfoAccess.walkStrongReferences(codeInfo, visitor);
RuntimeCodeInfoAccess.walkWeakReferences(codeInfo, visitor);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public final class ObjectMoveInfo {

static void setNewAddress(Pointer objSeqStart, Pointer newAddress) {
if (useCompressedLayout()) {
int alignment = ConfigurationValues.getObjectLayout().getAlignment();
UnsignedWord offset = newAddress.subtract(objSeqStart).unsignedDivide(alignment);
objSeqStart.writeInt(-8, (int) offset.rawValue());
long offset = newAddress.subtract(objSeqStart).rawValue();
offset /= ConfigurationValues.getObjectLayout().getAlignment();
objSeqStart.writeInt(-8, (int) offset);
} else {
objSeqStart.writeWord(-16, newAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
private Pointer allocate(UnsignedWord size) {
Pointer p = allocPointer;
allocPointer = allocPointer.add(size);
if (allocPointer.aboveOrEqual(AlignedHeapChunk.getObjectsEnd(allocChunk))) {
if (allocPointer.aboveThan(AlignedHeapChunk.getObjectsEnd(allocChunk))) {
allocChunk = HeapChunk.getNext(allocChunk);
assert allocChunk.isNonNull();

p = AlignedHeapChunk.getObjectsStart(allocChunk);
allocPointer = p.add(size);
}
Expand Down

0 comments on commit f1e4ec8

Please sign in to comment.