Skip to content

Commit 53af92c

Browse files
committed
Avoid branch in To(Sulong|NewRef)Node when converting primitives.
1 parent 0056591 commit 53af92c

File tree

1 file changed

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

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static PrimitiveNativeWrapper doIntegerSmall(@SuppressWarnings("unused") CExtCon
356356
@Specialization(replaces = "doIntegerSmall")
357357
static PrimitiveNativeWrapper doInteger(@SuppressWarnings("unused") CExtContext cextContext, int i,
358358
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
359-
if (CApiGuards.isSmallInteger(i)) {
359+
if (CompilerDirectives.inInterpreter() && CApiGuards.isSmallInteger(i)) {
360360
return doIntegerSmall(cextContext, i, contextRef);
361361
}
362362
return PrimitiveNativeWrapper.createInt(i);
@@ -375,7 +375,7 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
375375
@Specialization(replaces = "doLongSmall")
376376
static PrimitiveNativeWrapper doLong(@SuppressWarnings("unused") CExtContext cextContext, long l,
377377
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
378-
if (CApiGuards.isSmallLong(l)) {
378+
if (CompilerDirectives.inInterpreter() && CApiGuards.isSmallLong(l)) {
379379
return doLongSmall(cextContext, l, contextRef);
380380
}
381381
return PrimitiveNativeWrapper.createLong(l);
@@ -604,7 +604,7 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
604604
@Specialization(replaces = "doIntegerSmall")
605605
static PrimitiveNativeWrapper doInteger(CExtContext cextContext, int i,
606606
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
607-
if (CApiGuards.isSmallInteger(i)) {
607+
if (CompilerDirectives.inInterpreter() && CApiGuards.isSmallInteger(i)) {
608608
return doIntegerSmall(cextContext, i, contextRef);
609609
}
610610
return PrimitiveNativeWrapper.createInt(i);
@@ -613,7 +613,7 @@ static PrimitiveNativeWrapper doInteger(CExtContext cextContext, int i,
613613
@Specialization(replaces = "doLongSmall")
614614
static PrimitiveNativeWrapper doLong(CExtContext cextContext, long l,
615615
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
616-
if (CApiGuards.isSmallLong(l)) {
616+
if (CompilerDirectives.inInterpreter() && CApiGuards.isSmallLong(l)) {
617617
return doLongSmall(cextContext, l, contextRef);
618618
}
619619
return PrimitiveNativeWrapper.createLong(l);

0 commit comments

Comments
 (0)