Skip to content

Commit 35325d6

Browse files
Make the inner-most part of the GC uninterruptible.
1 parent 34ad44d commit 35325d6

Some content is hidden

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

46 files changed

+306
-119
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);
@@ -113,6 +115,7 @@ static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) {
113115
}
114116

115117
/** Retract the latest allocation. Used by parallel collector. */
118+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
116119
static Pointer retractAllocation(AlignedHeader that, UnsignedWord size) {
117120
Pointer newTop = HeapChunk.getTopPointer(that).subtract(size);
118121
assert newTop.aboveThan(HeapChunk.asPointer(that));
@@ -137,6 +140,7 @@ public static AlignedHeader getEnclosingChunkFromObjectPointer(Pointer ptr) {
137140
}
138141

139142
/** Return the offset of an object within the objects part of a chunk. */
143+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
140144
public static UnsignedWord getObjectOffset(AlignedHeader that, Pointer objectPointer) {
141145
Pointer objectsStart = getObjectsStart(that);
142146
return objectPointer.subtract(objectsStart);

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

Lines changed: 3 additions & 0 deletions
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;
@@ -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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void reset() {
6060
unalignedChunkBytes = WordFactory.zero();
6161
}
6262

63+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
6364
public UnsignedWord getChunkBytes() {
6465
return getAlignedChunkBytes().add(getUnalignedChunkBytes());
6566
}
@@ -117,10 +118,12 @@ private void noteUnaligned(UnsignedWord size) {
117118
}
118119
}
119120

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

126+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
124127
private void unnoteUnaligned(UnsignedWord size) {
125128
unalignedCount--;
126129
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/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
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ public void collectCompletely(GCCause cause) {
535535
collect(cause, true);
536536
}
537537

538+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
538539
public boolean isCompleteCollection() {
539540
return completeCollection;
540541
}
@@ -1085,6 +1086,7 @@ private static void scanGreyObjectsLoop() {
10851086
}
10861087

10871088
@AlwaysInline("GC performance")
1089+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
10881090
@SuppressWarnings("static-method")
10891091
Object promoteObject(Object original, UnsignedWord header) {
10901092
HeapImpl heap = HeapImpl.getHeapImpl();
@@ -1118,6 +1120,7 @@ Object promoteObject(Object original, UnsignedWord header) {
11181120
return result;
11191121
}
11201122

1123+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
11211124
private static Header<?> getChunk(Object obj, boolean isAligned) {
11221125
if (isAligned) {
11231126
return AlignedHeapChunk.getEnclosingChunk(obj);
@@ -1234,6 +1237,7 @@ public static boolean hasNeverCollectPolicy() {
12341237
return getPolicy() instanceof NeverCollect;
12351238
}
12361239

1240+
@Fold
12371241
public GreyToBlackObjectVisitor getGreyToBlackObjectVisitor() {
12381242
return greyToBlackObjectVisitor;
12391243
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.graalvm.nativeimage.Platform;
2828
import org.graalvm.nativeimage.Platforms;
2929

30+
import com.oracle.svm.core.AlwaysInline;
31+
import com.oracle.svm.core.Uninterruptible;
3032
import com.oracle.svm.core.heap.ObjectVisitor;
3133
import com.oracle.svm.core.log.Log;
3234

@@ -66,6 +68,8 @@ public String getName() {
6668
* promotion was done by copying, or {@code null} if there was insufficient capacity in
6769
* this generation.
6870
*/
71+
@AlwaysInline("GC performance")
72+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
6973
protected abstract Object promoteAlignedObject(Object original, AlignedHeapChunk.AlignedHeader originalChunk, Space originalSpace);
7074

7175
/**
@@ -79,6 +83,8 @@ public String getName() {
7983
* was promoted through HeapChunk motion, or {@code null} if there was insufficient
8084
* capacity in this generation.
8185
*/
86+
@AlwaysInline("GC performance")
87+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
8288
protected abstract Object promoteUnalignedObject(Object original, UnalignedHeapChunk.UnalignedHeader originalChunk, Space originalSpace);
8389

8490
/**

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

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

3232
import com.oracle.svm.core.AlwaysInline;
33+
import com.oracle.svm.core.Uninterruptible;
3334
import com.oracle.svm.core.genscavenge.remset.RememberedSet;
3435
import com.oracle.svm.core.heap.ObjectReferenceVisitor;
3536
import com.oracle.svm.core.heap.ReferenceAccess;
@@ -57,12 +58,14 @@ final class GreyToBlackObjRefVisitor implements ObjectReferenceVisitor {
5758
}
5859

5960
@Override
61+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
6062
public boolean visitObjectReference(Pointer objRef, boolean compressed, Object holderObject) {
6163
return visitObjectReferenceInline(objRef, 0, compressed, holderObject);
6264
}
6365

6466
@Override
6567
@AlwaysInline("GC performance")
68+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
6669
public boolean visitObjectReferenceInline(Pointer objRef, int innerOffset, boolean compressed, Object holderObject) {
6770
assert innerOffset >= 0;
6871
assert !objRef.isNull();
@@ -128,16 +131,22 @@ public interface Counters extends AutoCloseable {
128131
@Override
129132
void close();
130133

134+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
131135
void noteObjRef();
132136

137+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
133138
void noteNullReferent();
134139

140+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
135141
void noteForwardedReferent();
136142

143+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
137144
void noteNonHeapReferent();
138145

146+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
139147
void noteCopiedReferent();
140148

149+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
141150
void noteUnmodifiedReference();
142151

143152
void toLog();
@@ -182,32 +191,39 @@ public void close() {
182191
}
183192

184193
@Override
194+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
185195
public void noteObjRef() {
186196
objRef += 1L;
187197
}
188198

189199
@Override
200+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
190201
public void noteNullReferent() {
191202
nullReferent += 1L;
192203
}
193204

194205
@Override
206+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
195207
public void noteForwardedReferent() {
196208
forwardedReferent += 1L;
197209
}
198210

199211
@Override
212+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
200213
public void noteNonHeapReferent() {
201214
nonHeapReferent += 1L;
202215
}
203216

204217
@Override
218+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
205219
public void noteCopiedReferent() {
206220
copiedReferent += 1L;
207221
}
208222

209223
@Override
224+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
210225
public void noteUnmodifiedReference() {
226+
// TEMP (chaeubl): this counter would break
211227
unmodifiedReference += 1L;
212228
}
213229

@@ -241,26 +257,32 @@ public void close() {
241257
}
242258

243259
@Override
260+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
244261
public void noteObjRef() {
245262
}
246263

247264
@Override
265+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
248266
public void noteNullReferent() {
249267
}
250268

251269
@Override
270+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
252271
public void noteForwardedReferent() {
253272
}
254273

255274
@Override
275+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
256276
public void noteNonHeapReferent() {
257277
}
258278

259279
@Override
280+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
260281
public void noteCopiedReferent() {
261282
}
262283

263284
@Override
285+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
264286
public void noteUnmodifiedReference() {
265287
}
266288

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import com.oracle.svm.core.AlwaysInline;
3131
import com.oracle.svm.core.NeverInline;
32+
import com.oracle.svm.core.Uninterruptible;
3233
import com.oracle.svm.core.heap.ObjectVisitor;
3334
import com.oracle.svm.core.hub.InteriorObjRefWalker;
3435
import com.oracle.svm.core.util.VMError;
@@ -55,6 +56,7 @@ public boolean visitObject(Object o) {
5556

5657
@Override
5758
@AlwaysInline("GC performance")
59+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
5860
public boolean visitObjectInline(Object o) {
5961
ReferenceObjectProcessing.discoverIfReference(o, objRefVisitor);
6062
InteriorObjRefWalker.walkObjectInline(o, objRefVisitor);

0 commit comments

Comments
 (0)