Skip to content

Commit c114a3e

Browse files
committed
Merge complex code paths in PrimitiveNativeWrapper#toNative
1 parent 3cc5afb commit c114a3e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,17 @@ void toNative(
255255
@Bind Node inliningTarget,
256256
@Cached CApiTransitions.FirstToNativeNode firstToNativeNode) {
257257
if (!isNative()) {
258+
boolean immortal;
258259
if (isBool()) {
259260
assert (PythonContext.get(inliningTarget).getCApiContext().getCachedBooleanPrimitiveNativeWrapper(value != 0) == this);
260-
setNativePointer(firstToNativeNode.execute(inliningTarget, this, true /* immortal */));
261-
return;
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);
262268
}
263-
// small int values are cached and will be immortal
264-
boolean immortal = isIntLike() && CApiGuards.isSmallLong(value);
265-
// if this wrapper wraps a small int value, this wrapper is one of the cached primitive
266-
// native wrappers
267-
assert !immortal || (PythonContext.get(inliningTarget).getCApiContext().getCachedPrimitiveNativeWrapper(value) == this);
268269
setNativePointer(firstToNativeNode.execute(inliningTarget, this, immortal));
269270
}
270271
}

0 commit comments

Comments
 (0)