Skip to content

Commit 4ed28f0

Browse files
committed
Stop using small int cache since we're tagging now, but keep ABI compatible
1 parent 827558f commit 4ed28f0

File tree

11 files changed

+50
-221
lines changed

11 files changed

+50
-221
lines changed

graalpython/com.oracle.graal.python.cext/include/cpython/pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2020, 2024, Oracle and/or its affiliates.
1+
/* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2

graalpython/com.oracle.graal.python.cext/include/internal/pycore_long.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,22 @@ extern void _PyLong_FiniTypes(PyInterpreterState *interp);
6464
/* GraalVM change
6565
#define _PyLong_SMALL_INTS _Py_SINGLETON(small_ints)
6666
*/
67-
#define _PyLong_SMALL_INT_PTRS (PyThreadState_GET()->small_ints)
6867

6968
// Return a borrowed reference to the zero singleton.
7069
// The function cannot return NULL.
7170
static inline PyObject* _PyLong_GetZero(void)
7271
/* GraalVM change
7372
{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS]; }
7473
*/
75-
{ return _PyLong_SMALL_INT_PTRS[_PY_NSMALLNEGINTS]; }
74+
{ return int_to_pointer(0); }
7675

7776
// Return a borrowed reference to the one singleton.
7877
// The function cannot return NULL.
7978
static inline PyObject* _PyLong_GetOne(void)
8079
/* GraalVM change
8180
{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+1]; }
8281
*/
83-
{ return _PyLong_SMALL_INT_PTRS[_PY_NSMALLNEGINTS+1]; }
82+
{ return int_to_pointer(1); }
8483

8584
static inline PyObject* _PyLong_FromUnsignedChar(unsigned char i)
8685
{

graalpython/com.oracle.graal.python.cext/src/longobject.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class int "PyObject *" "&PyLong_Type"
5454

5555
#define medium_value(x) ((stwodigits)_PyLong_CompactValue(x))
5656

57-
#endif // GraalPy change
5857
#define IS_SMALL_INT(ival) (-_PY_NSMALLNEGINTS <= (ival) && (ival) < _PY_NSMALLPOSINTS)
5958
#define IS_SMALL_UINT(ival) ((ival) < _PY_NSMALLPOSINTS)
59+
#endif // GraalPy change
6060

6161
#define _MAX_STR_DIGITS_ERROR_FMT_TO_INT "Exceeds the limit (%d digits) for integer string conversion: value has %zd digits; use sys.set_int_max_str_digits() to increase the limit"
6262
#define _MAX_STR_DIGITS_ERROR_FMT_TO_STR "Exceeds the limit (%d digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit"
@@ -85,10 +85,8 @@ is_medium_int(stwodigits x)
8585
static PyObject *
8686
get_small_int(sdigit ival)
8787
{
88-
assert(IS_SMALL_INT(ival));
89-
// GraalPy change: use our array of pointers
90-
PyObject *v = _PyLong_SMALL_INT_PTRS[_PY_NSMALLNEGINTS + ival];
91-
return v;
88+
// GraalPy change - we tag 32-bit integers
89+
return int_to_pointer(ival);
9290
}
9391

9492
#if 0 // GraalPy change
@@ -334,9 +332,6 @@ PyObject *
334332
PyLong_FromLong(long ival)
335333
{
336334
// GraalPy change: different implementation
337-
if (IS_SMALL_INT(ival)) {
338-
return get_small_int((sdigit)ival);
339-
}
340335
return PyLong_FromLongLong((long long) ival);
341336
}
342337

@@ -983,9 +978,6 @@ PyObject *
983978
PyLong_FromLongLong(long long ival)
984979
{
985980
// GraalPy change: different implementation
986-
if (IS_SMALL_INT(ival)) {
987-
return get_small_int((sdigit)ival);
988-
}
989981
if ((int)ival == ival) {
990982
return int_to_pointer(ival);
991983
} else {
@@ -999,9 +991,6 @@ PyObject *
999991
PyLong_FromSsize_t(Py_ssize_t ival)
1000992
{
1001993
// GraalPy change: different implementation
1002-
if (IS_SMALL_INT(ival)) {
1003-
return get_small_int((sdigit)ival);
1004-
}
1005994
return PyLong_FromLongLong((long long) ival);
1006995
}
1007996

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,12 @@ static int doManaged(Object object) {
948948
if (object instanceof PythonAbstractNativeObject) {
949949
return -1;
950950
}
951-
PythonNativeWrapper nativeWrapper = GetNativeWrapperNode.executeUncached(object);
952-
return nativeWrapper.ref.getHandleTableIndex();
951+
Object nativeWrapper = GetNativeWrapperNode.executeUncached(object);
952+
if (nativeWrapper instanceof PythonNativeWrapper pn) {
953+
return pn.ref.getHandleTableIndex();
954+
} else {
955+
return -1;
956+
}
953957
}
954958
}
955959

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

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,16 @@
8787
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions;
8888
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.HandleContext;
8989
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonNode;
90-
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.ToPythonWrapperNode;
9190
import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes;
9291
import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EnsureExecutableNode;
9392
import com.oracle.graal.python.builtins.objects.cext.common.CExtContext;
9493
import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException;
9594
import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException;
9695
import com.oracle.graal.python.builtins.objects.cext.common.NativePointer;
9796
import com.oracle.graal.python.builtins.objects.cext.copying.NativeLibraryLocator;
98-
import com.oracle.graal.python.builtins.objects.cext.structs.CConstants;
9997
import com.oracle.graal.python.builtins.objects.cext.structs.CFields;
10098
import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess;
10199
import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess.FreeNode;
102-
import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess.ReadPointerNode;
103100
import com.oracle.graal.python.builtins.objects.cext.structs.CStructs;
104101
import com.oracle.graal.python.builtins.objects.dict.PDict;
105102
import com.oracle.graal.python.builtins.objects.frame.PFrame;
@@ -160,12 +157,6 @@ public final class CApiContext extends CExtContext {
160157

161158
public static final String LOGGER_CAPI_NAME = "capi";
162159

163-
/** Same as _PY_NSMALLNEGINTS */
164-
public static final int PY_NSMALLNEGINTS = 5;
165-
166-
/** Same as _PY_NSMALLPOSINTS */
167-
public static final int PY_NSMALLPOSINTS = 257;
168-
169160
/**
170161
* NFI source for Python module init functions (i.e. {@code "PyInit_modname"}).
171162
*/
@@ -177,23 +168,6 @@ public final class CApiContext extends CExtContext {
177168
/** Native wrappers for context-insensitive singletons like {@link PNone#NONE}. */
178169
@CompilationFinal(dimensions = 1) private final PythonAbstractObjectNativeWrapper[] singletonNativePtrs;
179170

180-
/**
181-
* This cache is used to cache native wrappers for frequently used primitives. This is strictly
182-
* defined to be the range {@code [-5, 256]}. CPython does exactly the same (see
183-
* {@code PyLong_FromLong}; implemented in macro {@code CHECK_SMALL_INT}).
184-
*/
185-
@CompilationFinal(dimensions = 1) private final PrimitiveNativeWrapper[] primitiveNativeWrapperCache;
186-
187-
/**
188-
* Pointer to a native array of long objects in interval
189-
* [{@link com.oracle.graal.python.builtins.objects.cext.structs.CConstants#_PY_NSMALLNEGINTS
190-
* -_PY_NSMALLNEGINTS},
191-
* {@link com.oracle.graal.python.builtins.objects.cext.structs.CConstants#_PY_NSMALLPOSINTS
192-
* _PY_NSMALLPOSINTS}[. This corresponds to CPython's {@code PyInterpreterState.small_ints} and
193-
* is actually a native mirror of {@link #primitiveNativeWrapperCache}.
194-
*/
195-
private Object nativeSmallIntsArray;
196-
197171
/**
198172
* Pointer to the native {@code GCState GC state}. This corresponds to CPython's
199173
* {@code PyInterpreterState.gc}.
@@ -386,14 +360,6 @@ public CApiContext(PythonContext context, Object library, NativeLibraryLocator l
386360
singletonNativePtrs[i] = new PythonObjectNativeWrapper(CONTEXT_INSENSITIVE_SINGLETONS[i]);
387361
}
388362

389-
// initialize primitive native wrapper cache
390-
primitiveNativeWrapperCache = new PrimitiveNativeWrapper[PY_NSMALLNEGINTS + PY_NSMALLPOSINTS];
391-
for (int i = 0; i < primitiveNativeWrapperCache.length; i++) {
392-
int value = i - PY_NSMALLNEGINTS;
393-
assert CApiGuards.isSmallInteger(value);
394-
primitiveNativeWrapperCache[i] = PrimitiveNativeWrapper.createInt(value);
395-
}
396-
397363
// initialize Py_True and Py_False
398364
context.getTrue().setNativeWrapper(PrimitiveNativeWrapper.createBool(true));
399365
context.getFalse().setNativeWrapper(PrimitiveNativeWrapper.createBool(false));
@@ -500,89 +466,12 @@ private void freeSingletonNativeWrappers(HandleContext handleContext) {
500466
}
501467
}
502468

503-
public PrimitiveNativeWrapper getCachedPrimitiveNativeWrapper(int i) {
504-
assert CApiGuards.isSmallInteger(i);
505-
PrimitiveNativeWrapper primitiveNativeWrapper = primitiveNativeWrapperCache[i + 5];
506-
assert primitiveNativeWrapper.getRefCount() > 0;
507-
return primitiveNativeWrapper;
508-
}
509-
510-
public PrimitiveNativeWrapper getCachedPrimitiveNativeWrapper(long l) {
511-
assert CApiGuards.isSmallLong(l);
512-
return getCachedPrimitiveNativeWrapper((int) l);
513-
}
514-
515469
public PrimitiveNativeWrapper getCachedBooleanPrimitiveNativeWrapper(boolean b) {
516470
PythonAbstractObjectNativeWrapper wrapper = b ? getContext().getTrue().getNativeWrapper() : getContext().getFalse().getNativeWrapper();
517471
assert wrapper.getRefCount() > 0;
518472
return (PrimitiveNativeWrapper) wrapper;
519473
}
520474

521-
/**
522-
* Returns or allocates (on demand) the native array {@code PyInterpreterState.small_ints} and
523-
* write all elements to it.
524-
*/
525-
Object getOrCreateSmallInts() {
526-
CompilerAsserts.neverPartOfCompilation();
527-
// TODO(fa): this should not require the GIL (GR-51314)
528-
assert getContext().ownsGil();
529-
if (nativeSmallIntsArray == null) {
530-
assert CConstants._PY_NSMALLNEGINTS.intValue() == PY_NSMALLNEGINTS;
531-
assert CConstants._PY_NSMALLPOSINTS.intValue() == PY_NSMALLPOSINTS;
532-
Object smallInts = CStructAccess.AllocateNode.callocUncached(PY_NSMALLNEGINTS + PY_NSMALLPOSINTS, CStructAccess.POINTER_SIZE);
533-
for (int i = 0; i < PY_NSMALLNEGINTS + PY_NSMALLPOSINTS; i++) {
534-
CStructAccess.WritePointerNode.writeUncached(smallInts, i, CApiTransitions.HandlePointerConverter.intToPointer(i - PY_NSMALLNEGINTS));
535-
}
536-
nativeSmallIntsArray = smallInts;
537-
}
538-
return nativeSmallIntsArray;
539-
}
540-
541-
/**
542-
* Deallocates the native small int array (pointer {@link #nativeSmallIntsArray}) and all
543-
* wrappers of the small ints (in {@link #primitiveNativeWrapperCache}) which are immortal and
544-
* must therefore be explicitly free'd. This method modifies the
545-
* {@link HandleContext#nativeStubLookup stub lookup table} but runs not guest code.
546-
*/
547-
private void freeSmallInts(HandleContext handleContext) {
548-
CompilerAsserts.neverPartOfCompilation();
549-
// TODO(fa): this should not require the GIL (GR-51314)
550-
assert getContext().ownsGil();
551-
if (nativeSmallIntsArray != null) {
552-
assert verifyNativeSmallInts();
553-
// free the native array used to store the stub pointers of the small int wrappers
554-
FreeNode.executeUncached(nativeSmallIntsArray);
555-
nativeSmallIntsArray = null;
556-
}
557-
for (PrimitiveNativeWrapper wrapper : primitiveNativeWrapperCache) {
558-
assert wrapper.isIntLike() && CApiGuards.isSmallLong(wrapper.getLong());
559-
assert !wrapper.isNative() || wrapper.getRefCount() == IMMORTAL_REFCNT;
560-
if (wrapper.ref != null) {
561-
CApiTransitions.nativeStubLookupRemove(handleContext, wrapper.ref);
562-
}
563-
}
564-
}
565-
566-
/**
567-
* Verifies integrity of the pointers stored in the native small int array. Each pointer must
568-
* denote the according small int wrapper. The objects are expected to be immortal.
569-
*/
570-
private boolean verifyNativeSmallInts() {
571-
// TODO(fa): this should not require the GIL (GR-51314)
572-
assert getContext().ownsGil();
573-
for (int i = 0; i < PY_NSMALLNEGINTS + PY_NSMALLPOSINTS; i++) {
574-
Object elementPtr = ReadPointerNode.getUncached().readArrayElement(nativeSmallIntsArray, i);
575-
PythonNativeWrapper wrapper = ToPythonWrapperNode.executeUncached(elementPtr, false);
576-
if (wrapper != primitiveNativeWrapperCache[i]) {
577-
return false;
578-
}
579-
if (primitiveNativeWrapperCache[i].isNative() && primitiveNativeWrapperCache[i].getRefCount() != IMMORTAL_REFCNT) {
580-
return false;
581-
}
582-
}
583-
return true;
584-
}
585-
586475
/**
587476
* Allocates the {@code GCState} which needs to happen very early in the C API initialization
588477
* phase. <it>Very early</it> means it needs to happen before the first object (that takes part
@@ -1227,7 +1116,6 @@ public void finalizeCApi() {
12271116
try {
12281117
// TODO(fa): remove GIL acquisition (GR-51314)
12291118
try (GilNode.UncachedAcquire ignored = GilNode.uncachedAcquire()) {
1230-
freeSmallInts(handleContext);
12311119
freeSingletonNativeWrappers(handleContext);
12321120
/*
12331121
* Clear all remaining native object stubs. This must be done after the small int

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -59,21 +59,4 @@ public static boolean isNativeNull(Object object) {
5959
public static boolean isSpecialSingleton(Object delegate) {
6060
return CApiContext.getSingletonNativeWrapperIdx(delegate) != -1;
6161
}
62-
63-
/**
64-
* This guard defines the range of integer values for which PInt objects (and in our particular
65-
* case, native wrappers) are cached.
66-
*/
67-
public static boolean isSmallInteger(int i) {
68-
return -CApiContext.PY_NSMALLNEGINTS <= i && i < CApiContext.PY_NSMALLPOSINTS;
69-
}
70-
71-
/** see {@link #isSmallInteger(int)} */
72-
public static boolean isSmallLong(long i) {
73-
return -CApiContext.PY_NSMALLNEGINTS <= i && i < CApiContext.PY_NSMALLPOSINTS;
74-
}
75-
76-
public static boolean isSmallIntegerWrapper(PrimitiveNativeWrapper nativeWrapper) {
77-
return nativeWrapper.isIntLike() && isSmallLong(nativeWrapper.getLong());
78-
}
7962
}

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.UpdateStrongRefNode;
108108
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory.NativeToPythonNodeGen;
109109
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory.PythonToNativeNodeGen;
110-
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.GetNativeWrapperNode;
111110
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CArrayWrapper;
112111
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper;
113112
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper;
@@ -1164,31 +1163,25 @@ static void doPythonAbstractObject(PythonAbstractObject delegate, PythonNativeWr
11641163

11651164
@Specialization(guards = "delegate == null")
11661165
static void doPrimitiveNativeWrapper(Node inliningTarget, @SuppressWarnings("unused") Object delegate, PrimitiveNativeWrapper nativeWrapper) {
1167-
assert !isSmallIntegerWrapperSingleton(nativeWrapper, PythonContext.get(inliningTarget)) : "clearing primitive native wrapper singleton of small integer";
1166+
// ignore
11681167
}
11691168

11701169
@Specialization(guards = "delegate != null")
11711170
static void doPrimitiveNativeWrapperMaterialized(Node inliningTarget, PythonAbstractObject delegate, PrimitiveNativeWrapper nativeWrapper,
11721171
@Cached InlinedConditionProfile profile) {
11731172
if (profile.profile(inliningTarget, delegate.getNativeWrapper() == nativeWrapper)) {
1174-
assert !isSmallIntegerWrapperSingleton(nativeWrapper, PythonContext.get(inliningTarget)) : "clearing primitive native wrapper singleton of small integer";
11751173
delegate.clearNativeWrapper();
11761174
}
11771175
}
11781176

11791177
@Specialization(guards = {"delegate != null", "!isAnyPythonObject(delegate)"})
11801178
static void doOther(@SuppressWarnings("unused") Object delegate, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper) {
1181-
assert !isPrimitiveNativeWrapper(nativeWrapper);
11821179
// ignore
11831180
}
11841181

11851182
static boolean isPrimitiveNativeWrapper(PythonNativeWrapper nativeWrapper) {
11861183
return nativeWrapper instanceof PrimitiveNativeWrapper;
11871184
}
1188-
1189-
private static boolean isSmallIntegerWrapperSingleton(PrimitiveNativeWrapper nativeWrapper, PythonContext context) {
1190-
return CApiGuards.isSmallIntegerWrapper(nativeWrapper) && GetNativeWrapperNode.doLongSmall(nativeWrapper.getLong(), context) == nativeWrapper;
1191-
}
11921185
}
11931186

11941187
@GenerateUncached

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import com.oracle.graal.python.PythonLanguage;
4444
import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper.PythonStructNativeWrapper;
45+
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions;
4546
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode;
4647
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory.PythonToNativeNodeGen;
4748
import com.oracle.graal.python.builtins.objects.cext.structs.CFields;
@@ -66,6 +67,12 @@
6667
*/
6768
public final class PThreadState extends PythonStructNativeWrapper {
6869

70+
/** Same as _PY_NSMALLNEGINTS */
71+
public static final int PY_NSMALLNEGINTS = 5;
72+
73+
/** Same as _PY_NSMALLPOSINTS */
74+
public static final int PY_NSMALLPOSINTS = 257;
75+
6976
@TruffleBoundary
7077
private PThreadState(PythonThreadState threadState) {
7178
super(threadState, true);
@@ -112,7 +119,11 @@ private static Object allocateCLayout(PythonThreadState threadState) {
112119
}
113120
writePtrNode.write(ptr, CFields.PyThreadState__dict, toNative.execute(threadStateDict));
114121
CApiContext cApiContext = pythonContext.getCApiContext();
115-
writePtrNode.write(ptr, CFields.PyThreadState__small_ints, cApiContext.getOrCreateSmallInts());
122+
Object smallInts = CStructAccess.AllocateNode.allocUncached((PY_NSMALLNEGINTS + PY_NSMALLPOSINTS) * CStructAccess.POINTER_SIZE);
123+
writePtrNode.write(ptr, CFields.PyThreadState__small_ints, smallInts);
124+
for (int i = -PY_NSMALLNEGINTS; i < PY_NSMALLPOSINTS; i++) {
125+
writePtrNode.writeArrayElement(smallInts, i + PY_NSMALLNEGINTS, CApiTransitions.HandlePointerConverter.intToPointer(i));
126+
}
116127
writePtrNode.write(ptr, CFields.PyThreadState__gc, cApiContext.getGCState());
117128
CStructAccess.WriteIntNode writeIntNode = CStructAccess.WriteIntNode.getUncached();
118129
// py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT (1000)

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,8 @@ void toNative(
255255
@Bind Node inliningTarget,
256256
@Cached CApiTransitions.FirstToNativeNode firstToNativeNode) {
257257
if (!isNative()) {
258-
boolean immortal;
259-
if (isBool()) {
260-
assert (PythonContext.get(inliningTarget).getCApiContext().getCachedBooleanPrimitiveNativeWrapper(value != 0) == this);
261-
immortal = true;
262-
} else {
263-
// small int values are cached and will be immortal
264-
immortal = isIntLike() && CApiGuards.isSmallLong(value);
265-
// if this wrapper wraps a small int value, this wrapper is one of the cached
266-
// primitive native wrappers
267-
assert !immortal || (PythonContext.get(inliningTarget).getCApiContext().getCachedPrimitiveNativeWrapper(value) == this);
268-
}
258+
boolean immortal = isBool();
259+
assert !isBool() || (PythonContext.get(inliningTarget).getCApiContext().getCachedBooleanPrimitiveNativeWrapper(value != 0) == this);
269260
setNativePointer(firstToNativeNode.execute(inliningTarget, this, immortal));
270261
}
271262
}

0 commit comments

Comments
 (0)