Skip to content

Commit 03f661c

Browse files
committed
Create GraalHPyHandle instance in HPyEnsureHandleNode for boxed handles
1 parent a20e4f8 commit 03f661c

File tree

1 file changed

+11
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,11 +1080,18 @@ static GraalHPyHandle doLong(@SuppressWarnings("unused") GraalHPyContext hpyCont
10801080
static GraalHPyHandle doBoxedPrimitive(GraalHPyContext hpyContext, long bits) {
10811081
/*
10821082
* In this case, the long value is a boxed primitive and we cannot resolve it to a
1083-
* GraalHPyHandle instance (because no instance has ever been created). We return Java
1084-
* null to indicate this. All users of this node *MUST* handle this case by either
1085-
* resolving the long value to the primitive or do some other special handling.
1083+
* GraalHPyHandle instance (because no instance has ever been created). We create a
1084+
* fresh GaalHPyHandle instance here.
10861085
*/
1087-
return null;
1086+
Object delegate;
1087+
if (GraalHPyBoxing.isBoxedInt(bits)) {
1088+
delegate = GraalHPyBoxing.unboxInt(bits);
1089+
} else if (GraalHPyBoxing.isBoxedDouble(bits)) {
1090+
delegate = GraalHPyBoxing.unboxDouble(bits);
1091+
} else {
1092+
throw CompilerDirectives.shouldNotReachHere();
1093+
}
1094+
return hpyContext.createHandle(delegate);
10881095
}
10891096
}
10901097

0 commit comments

Comments
 (0)