Skip to content

[GR-45349] Make the core part of the serial GC uninterruptible. #6374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public UnsignedWord getCurrentHeapCapacity() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public UnsignedWord getSurvivorSpacesCapacity() {
assert VMOperation.isGCInProgress() : "use only during GC";
guaranteeSizeParametersInitialized();
Expand Down Expand Up @@ -290,6 +291,7 @@ public UnsignedWord getMaximumFreeAlignedChunksSize() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int getTenuringAge() {
assert VMOperation.isGCInProgress() : "use only during GC";
return tenuringThreshold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private AlignedHeapChunk() { // all static
public interface AlignedHeader extends HeapChunk.Header<AlignedHeader> {
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static void initialize(AlignedHeader chunk, UnsignedWord chunkSize) {
HeapChunk.initialize(chunk, AlignedHeapChunk.getObjectsStart(chunk), chunkSize);
}
Expand All @@ -101,6 +102,7 @@ public static Pointer getObjectsEnd(AlignedHeader that) {
}

/** Allocate uninitialized memory within this AlignedHeapChunk. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) {
Pointer result = WordFactory.nullPointer();
UnsignedWord available = HeapChunk.availableObjectMemory(that);
Expand Down Expand Up @@ -129,6 +131,7 @@ public static AlignedHeader getEnclosingChunkFromObjectPointer(Pointer ptr) {
}

/** Return the offset of an object within the objects part of a chunk. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static UnsignedWord getObjectOffset(AlignedHeader that, Pointer objectPointer) {
Pointer objectsStart = getObjectsStart(that);
return objectPointer.subtract(objectsStart);
Expand All @@ -139,6 +142,7 @@ static boolean walkObjects(AlignedHeader that, ObjectVisitor visitor) {
}

@AlwaysInline("GC performance")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static boolean walkObjectsInline(AlignedHeader that, ObjectVisitor visitor) {
return HeapChunk.walkObjectsFromInline(that, getObjectsStart(that), visitor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static AuxiliaryImageHeap singleton() {

boolean walkObjects(ObjectVisitor visitor);

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
boolean walkRegions(MemoryWalker.ImageHeapRegionVisitor visitor);

ImageHeapInfo getImageHeapInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.SubstrateGCOptions;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.heap.GCCause;
import com.oracle.svm.core.heap.PhysicalMemory;
import com.oracle.svm.core.heap.ReferenceAccess;
Expand All @@ -49,7 +50,7 @@ static int getMaxSurvivorSpaces(Integer userValue) {
private BasicCollectionPolicies() {
}

abstract static class BasicPolicy implements CollectionPolicy {
public abstract static class BasicPolicy implements CollectionPolicy {
protected static UnsignedWord m(long bytes) {
assert 0 <= bytes;
return WordFactory.unsigned(bytes).multiply(1024).multiply(1024);
Expand Down Expand Up @@ -167,6 +168,7 @@ public UnsignedWord getMaximumSurvivorSize() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public UnsignedWord getSurvivorSpacesCapacity() {
return WordFactory.zero();
}
Expand Down Expand Up @@ -202,6 +204,7 @@ public final UnsignedWord getMaximumFreeAlignedChunksSize() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int getTenuringAge() {
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ final class ChunksAccounting {
reset();
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public void reset() {
alignedCount = 0L;
unalignedCount = 0L;
unalignedChunkBytes = WordFactory.zero();
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public UnsignedWord getChunkBytes() {
return getAlignedChunkBytes().add(getUnalignedChunkBytes());
}
Expand Down Expand Up @@ -96,6 +98,7 @@ void noteAlignedHeapChunk() {
}
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void unnoteAlignedHeapChunk() {
alignedCount--;
if (parent != null) {
Expand All @@ -117,10 +120,12 @@ private void noteUnaligned(UnsignedWord size) {
}
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void unnoteUnalignedHeapChunk(UnalignedHeapChunk.UnalignedHeader chunk) {
unnoteUnaligned(UnalignedHeapChunk.getCommittedObjectMemory(chunk));
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
private void unnoteUnaligned(UnsignedWord size) {
unalignedCount--;
unalignedChunkBytes = unalignedChunkBytes.subtract(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.heap.GCCause;
import com.oracle.svm.core.heap.PhysicalMemory;
import com.oracle.svm.core.util.UserError;
Expand Down Expand Up @@ -176,6 +177,7 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
* survivor-to spaces of all ages. In other words, when copying during a collection, up to 2x
* this amount can be used for surviving objects.
*/
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
UnsignedWord getSurvivorSpacesCapacity();

/** The capacity of the young generation, comprising the eden and survivor spaces. */
Expand All @@ -200,6 +202,7 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
* 1 (straight from eden) and the {@linkplain HeapParameters#getMaxSurvivorSpaces() number of
* survivor spaces + 1}.
*/
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
int getTenuringAge();

/** Called at the beginning of a collection, in the safepoint operation. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public CompleteGarbageCollectorMXBean() {

@Override
public long getCollectionCount() {
return HeapImpl.getHeapImpl().getGCImpl().getAccounting().getCompleteCollectionCount();
return HeapImpl.getGCImpl().getAccounting().getCompleteCollectionCount();
}

@Override
public long getCollectionTime() {
long nanos = HeapImpl.getHeapImpl().getGCImpl().getAccounting().getCompleteCollectionTotalNanos();
long nanos = HeapImpl.getGCImpl().getAccounting().getCompleteCollectionTotalNanos();
return TimeUtils.roundNanosToMillis(nanos);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.AlwaysInline;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.log.Log;

/**
Expand Down Expand Up @@ -154,6 +155,7 @@ void beforeCollection(boolean completeCollection) {

/** Called after an object has been promoted from the young generation to the old generation. */
@AlwaysInline("GC performance")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void onSurvivorOverflowed() {
lastIncrementalCollectionOverflowedSurvivors = true;
}
Expand Down
Loading