Skip to content

Commit fbe023e

Browse files
committed
Do not use small int wrappers if values exceed
1 parent b093f63 commit fbe023e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
118118
import com.oracle.truffle.api.dsl.Cached;
119119
import com.oracle.truffle.api.dsl.Fallback;
120-
import com.oracle.truffle.api.dsl.ImportStatic;
121120
import com.oracle.truffle.api.dsl.Specialization;
122121
import com.oracle.truffle.api.dsl.TypeSystemReference;
123122
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -1640,20 +1639,19 @@ static MaterializePrimitiveNode[] createMaterializeNodes(int length) {
16401639
* Special helper nodes that materializes any primitive that would leak the wrapper if the
16411640
* reference is owned by managed code only.
16421641
*/
1643-
@ImportStatic(CApiGuards.class)
16441642
@TypeSystemReference(PythonTypes.class)
16451643
abstract static class MaterializePrimitiveNode extends Node {
16461644

16471645
public abstract Object execute(PythonObjectFactory factory, Object object);
16481646

16491647
// NOTE: Booleans don't need to be materialized because they are singletons.
16501648

1651-
@Specialization(guards = "!isSmallInteger(i)")
1649+
@Specialization
16521650
static PInt doInteger(PythonObjectFactory factory, int i) {
16531651
return factory.createInt(i);
16541652
}
16551653

1656-
@Specialization(guards = "!isSmallLong(l)", replaces = "doInteger")
1654+
@Specialization(replaces = "doInteger")
16571655
static PInt doLong(PythonObjectFactory factory, long l) {
16581656
return factory.createInt(l);
16591657
}
@@ -1674,13 +1672,7 @@ static Object doObject(@SuppressWarnings("unused") PythonObjectFactory factory,
16741672
}
16751673

16761674
static boolean needsMaterialization(Object object) {
1677-
if (object instanceof Integer) {
1678-
return !CApiGuards.isSmallInteger((Integer) object);
1679-
}
1680-
if (object instanceof Long) {
1681-
return !CApiGuards.isSmallLong((Long) object);
1682-
}
1683-
return PGuards.isDouble(object) || object instanceof String;
1675+
return object instanceof Integer || object instanceof Long || PGuards.isDouble(object) || object instanceof String;
16841676
}
16851677
}
16861678

0 commit comments

Comments
 (0)