Skip to content

Commit 470a5cb

Browse files
committed
Fix: consistently use NULL handle delegate
1 parent 88dc3d6 commit 470a5cb

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyHandle.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
public final class GraalHPyHandle implements TruffleObject {
7070
private static final int UNINITIALIZED = Integer.MIN_VALUE;
7171

72+
public static final Object NULL_HANDLE_DELEGATE = PNone.NO_VALUE;
7273
public static final GraalHPyHandle NULL_HANDLE = new GraalHPyHandle();
7374
public static final String I = "_i";
7475

@@ -87,7 +88,7 @@ public final class GraalHPyHandle implements TruffleObject {
8788
private int id;
8889

8990
private GraalHPyHandle() {
90-
this.delegate = PNone.NO_VALUE;
91+
this.delegate = NULL_HANDLE_DELEGATE;
9192
this.id = 0;
9293
}
9394

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ Object doHandleAllocated(GraalHPyContext hpyContext, GraalHPyHandle handle) {
11871187
@Specialization(guards = "isBoxedNullHandle(bits)")
11881188
@SuppressWarnings("unused")
11891189
static Object doNullLong(GraalHPyContext hpyContext, long bits) {
1190-
return null;
1190+
return GraalHPyHandle.NULL_HANDLE_DELEGATE;
11911191
}
11921192

11931193
@Specialization(guards = {"!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"})
@@ -1224,7 +1224,7 @@ static long asPointer(Object handle, InteropLibrary lib) {
12241224
static Object doNullOther(GraalHPyContext hpyContext, Object value,
12251225
@Shared("lib") @CachedLibrary(limit = "2") InteropLibrary lib,
12261226
@Bind("asPointer(value, lib)") long bits) {
1227-
return null;
1227+
return GraalHPyHandle.NULL_HANDLE_DELEGATE;
12281228
}
12291229

12301230
@Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"})
@@ -1289,7 +1289,7 @@ static Object doValidHandle(GraalHPyContext hpyContext, GraalHPyHandle handle) {
12891289
@Specialization(guards = "isBoxedNullHandle(bits)")
12901290
@SuppressWarnings("unused")
12911291
static Object doNullLong(GraalHPyContext hpyContext, long bits) {
1292-
return PNone.NO_VALUE;
1292+
return GraalHPyHandle.NULL_HANDLE_DELEGATE;
12931293
}
12941294

12951295
@Specialization(guards = {"!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"})
@@ -1321,7 +1321,7 @@ static long asPointer(Object handle, InteropLibrary lib) {
13211321
static Object doNullOther(@SuppressWarnings("unused") GraalHPyContext hpyContext, @SuppressWarnings("unused") Object value,
13221322
@Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib,
13231323
@Bind("asPointer(value, lib)") @SuppressWarnings("unused") long bits) {
1324-
return PNone.NO_VALUE;
1324+
return GraalHPyHandle.NULL_HANDLE_DELEGATE;
13251325
}
13261326

13271327
@Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"})

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ Object doLongNull(PythonThreadState pythonThreadState, @SuppressWarnings("unused
10871087
@Cached PythonObjectFactory factory,
10881088
@Cached PRaiseNode raiseNode) {
10891089
Object delegate = closeAndGetHandleNode.execute(nativeContext, value);
1090-
checkFunctionResult(name, isNullProfile.profile(delegate == null), pythonThreadState, raiseNode, factory);
1090+
checkFunctionResult(name, isNullProfile.profile(delegate == GraalHPyHandle.NULL_HANDLE_DELEGATE), pythonThreadState, raiseNode, factory);
10911091
return delegate;
10921092
}
10931093
}

0 commit comments

Comments
 (0)