Skip to content

Commit 33320ae

Browse files
[GR-45349] Make the core part of the serial GC uninterruptible.
PullRequest: graal/14264
2 parents d26d896 + 04e6759 commit 33320ae

File tree

69 files changed

+534
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+534
-200
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractCollectionPolicy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public UnsignedWord getCurrentHeapCapacity() {
243243
}
244244

245245
@Override
246+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
246247
public UnsignedWord getSurvivorSpacesCapacity() {
247248
assert VMOperation.isGCInProgress() : "use only during GC";
248249
guaranteeSizeParametersInitialized();
@@ -290,6 +291,7 @@ public UnsignedWord getMaximumFreeAlignedChunksSize() {
290291
}
291292

292293
@Override
294+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
293295
public int getTenuringAge() {
294296
assert VMOperation.isGCInProgress() : "use only during GC";
295297
return tenuringThreshold;

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ private AlignedHeapChunk() { // all static
8383
public interface AlignedHeader extends HeapChunk.Header<AlignedHeader> {
8484
}
8585

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

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

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

141144
@AlwaysInline("GC performance")
145+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
142146
static boolean walkObjectsInline(AlignedHeader that, ObjectVisitor visitor) {
143147
return HeapChunk.walkObjectsFromInline(that, getObjectsStart(that), visitor);
144148
}

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AuxiliaryImageHeap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static AuxiliaryImageHeap singleton() {
4848

4949
boolean walkObjects(ObjectVisitor visitor);
5050

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

5354
ImageHeapInfo getImageHeapInfo();

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/BasicCollectionPolicies.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.graalvm.word.WordFactory;
3333

3434
import com.oracle.svm.core.SubstrateGCOptions;
35+
import com.oracle.svm.core.Uninterruptible;
3536
import com.oracle.svm.core.heap.GCCause;
3637
import com.oracle.svm.core.heap.PhysicalMemory;
3738
import com.oracle.svm.core.heap.ReferenceAccess;
@@ -49,7 +50,7 @@ static int getMaxSurvivorSpaces(Integer userValue) {
4950
private BasicCollectionPolicies() {
5051
}
5152

52-
abstract static class BasicPolicy implements CollectionPolicy {
53+
public abstract static class BasicPolicy implements CollectionPolicy {
5354
protected static UnsignedWord m(long bytes) {
5455
assert 0 <= bytes;
5556
return WordFactory.unsigned(bytes).multiply(1024).multiply(1024);
@@ -167,6 +168,7 @@ public UnsignedWord getMaximumSurvivorSize() {
167168
}
168169

169170
@Override
171+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
170172
public UnsignedWord getSurvivorSpacesCapacity() {
171173
return WordFactory.zero();
172174
}
@@ -202,6 +204,7 @@ public final UnsignedWord getMaximumFreeAlignedChunksSize() {
202204
}
203205

204206
@Override
207+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
205208
public int getTenuringAge() {
206209
return 1;
207210
}

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ChunksAccounting.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ final class ChunksAccounting {
5454
reset();
5555
}
5656

57+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
5758
public void reset() {
5859
alignedCount = 0L;
5960
unalignedCount = 0L;
6061
unalignedChunkBytes = WordFactory.zero();
6162
}
6263

64+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
6365
public UnsignedWord getChunkBytes() {
6466
return getAlignedChunkBytes().add(getUnalignedChunkBytes());
6567
}
@@ -96,6 +98,7 @@ void noteAlignedHeapChunk() {
9698
}
9799
}
98100

101+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
99102
void unnoteAlignedHeapChunk() {
100103
alignedCount--;
101104
if (parent != null) {
@@ -117,10 +120,12 @@ private void noteUnaligned(UnsignedWord size) {
117120
}
118121
}
119122

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

128+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
124129
private void unnoteUnaligned(UnsignedWord size) {
125130
unalignedCount--;
126131
unalignedChunkBytes = unalignedChunkBytes.subtract(size);

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CollectionPolicy.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.graalvm.word.WordFactory;
3131

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

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

205208
/** Called at the beginning of a collection, in the safepoint operation. */

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CompleteGarbageCollectorMXBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public CompleteGarbageCollectorMXBean() {
4848

4949
@Override
5050
public long getCollectionCount() {
51-
return HeapImpl.getHeapImpl().getGCImpl().getAccounting().getCompleteCollectionCount();
51+
return HeapImpl.getGCImpl().getAccounting().getCompleteCollectionCount();
5252
}
5353

5454
@Override
5555
public long getCollectionTime() {
56-
long nanos = HeapImpl.getHeapImpl().getGCImpl().getAccounting().getCompleteCollectionTotalNanos();
56+
long nanos = HeapImpl.getGCImpl().getAccounting().getCompleteCollectionTotalNanos();
5757
return TimeUtils.roundNanosToMillis(nanos);
5858
}
5959

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCAccounting.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.graalvm.word.WordFactory;
3131

3232
import com.oracle.svm.core.AlwaysInline;
33+
import com.oracle.svm.core.Uninterruptible;
3334
import com.oracle.svm.core.log.Log;
3435

3536
/**
@@ -154,6 +155,7 @@ void beforeCollection(boolean completeCollection) {
154155

155156
/** Called after an object has been promoted from the young generation to the old generation. */
156157
@AlwaysInline("GC performance")
158+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
157159
void onSurvivorOverflowed() {
158160
lastIncrementalCollectionOverflowedSurvivors = true;
159161
}

0 commit comments

Comments
 (0)