Skip to content

Commit b7a6d33

Browse files
committed
Add gc threshold values
1 parent 5560c3c commit b7a6d33

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
5858
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
5959
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
60-
import com.oracle.graal.python.nodes.function.builtins.PythonClinicBuiltinNode;
60+
import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode;
6161
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode;
6262
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
6363
import com.oracle.graal.python.runtime.GilNode;
@@ -112,7 +112,7 @@ public void initialize(Python3Core core) {
112112
@Builtin(name = "collect", parameterNames = {"$self", "generation"}, declaresExplicitSelf = true)
113113
@ArgumentClinic(name = "generation", conversion = ClinicConversion.Int, defaultValue = "2")
114114
@GenerateNodeFactory
115-
abstract static class GcCollectNode extends PythonClinicBuiltinNode {
115+
abstract static class GcCollectNode extends PythonBinaryClinicBuiltinNode {
116116
private static final NativeCAPISymbol SYMBOL = NativeCAPISymbol.FUN_GRAALPY_GC_COLLECT;
117117
private static final CApiTiming C_API_TIMING = CApiTiming.create(true, SYMBOL.getName());
118118

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,14 @@ private boolean verifyNativeSmallInts() {
499499
public Object createGCState() {
500500
CompilerAsserts.neverPartOfCompilation();
501501
assert gcState == null;
502+
PythonContext.GCState state = getContext().getGcState();
502503
Object ptr = CStructAccess.AllocateNode.allocUncached(CStructs.GCState);
503-
CStructAccess.WriteIntNode.writeUncached(ptr, CFields.GCState__enabled, PInt.intValue(getContext().getGcState().isEnabled()));
504-
CStructAccess.WriteIntNode.writeUncached(ptr, CFields.GCState__debug, getContext().getGcState().getDebug());
504+
CStructAccess.WriteIntNode.writeUncached(ptr, CFields.GCState__enabled, PInt.intValue(state.isEnabled()));
505+
CStructAccess.WriteIntNode.writeUncached(ptr, CFields.GCState__debug, state.getDebug());
506+
Object generations = CStructAccess.GetElementPtrNode.getUncached().getElementPtr(ptr, CFields.GCState__generations);
507+
for (int i = 0; i < state.getThresholds().length; i++) {
508+
CStructAccess.WriteIntNode.getUncached().writeStructArrayElement(generations, i, CFields.GCGeneration__threshold, state.getThresholds()[i]);
509+
}
505510
gcState = ptr;
506511
return gcState;
507512
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/structs/CFields.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ public enum CFields {
347347
GCState__generation0(Pointer),
348348
GCState__collecting(Int),
349349

350+
GCGeneration__threshold(Int),
350351
GCGeneration__count(Int),
351352

352353
PyGC_Head___gc_prev(UINTPTR_T),

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ public static final class GCState {
278278
private boolean enabled = true;
279279
private int debug;
280280

281+
private int[] thresholds = {
282+
700, // { .threshold = 700, },
283+
10, // { .threshold = 10, },
284+
10, // { .threshold = 10, },
285+
};
286+
281287
public boolean isEnabled() {
282288
return enabled;
283289
}
@@ -293,6 +299,10 @@ public int getDebug() {
293299
public void setDebug(int debug) {
294300
this.debug = debug;
295301
}
302+
303+
public int[] getThresholds() {
304+
return thresholds;
305+
}
296306
}
297307

298308
/**

0 commit comments

Comments
 (0)