Skip to content

Commit e948662

Browse files
committed
changed specialization value to int instead of object in some PythonCextBuiltins nodes
1 parent b984090 commit e948662

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ protected boolean isDictSubtype(VirtualFrame frame, Object obj, GetClassNode get
702702
@GenerateNodeFactory
703703
public abstract static class PyDictSizeNode extends PythonUnaryBuiltinNode {
704704
@Specialization(limit = "3")
705-
public Object size(PDict dict,
705+
public int size(PDict dict,
706706
@CachedLibrary("dict.getDictStorage()") HashingStorageLibrary lib,
707707
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
708708
try {
@@ -979,12 +979,12 @@ protected boolean isDictSubtype(VirtualFrame frame, Object obj, GetClassNode get
979979
@GenerateNodeFactory
980980
public abstract static class PyDictContainsNode extends PythonBinaryBuiltinNode {
981981
@Specialization(limit = "3")
982-
public Object contains(VirtualFrame frame, PDict dict, Object key,
982+
public int contains(VirtualFrame frame, PDict dict, Object key,
983983
@Cached ConditionProfile hasFrame,
984984
@CachedLibrary("dict.getDictStorage()") HashingStorageLibrary lib,
985985
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
986986
try {
987-
return lib.hasKeyWithFrame(dict.getDictStorage(), key, hasFrame, frame);
987+
return PInt.intValue(lib.hasKeyWithFrame(dict.getDictStorage(), key, hasFrame, frame));
988988
} catch (PException e) {
989989
transformExceptionToNativeNode.execute(e);
990990
return -1;
@@ -1348,29 +1348,29 @@ public Object newSet(PNone iterable) {
13481348
@GenerateNodeFactory
13491349
public abstract static class PySetContainsNode extends PythonBinaryBuiltinNode {
13501350
@Specialization(limit = "3")
1351-
public Object contains(VirtualFrame frame, PSet anyset, Object item,
1351+
public int contains(VirtualFrame frame, PSet anyset, Object item,
13521352
@Cached ConditionProfile hasFrameProfile,
13531353
@CachedLibrary("anyset.getDictStorage()") HashingStorageLibrary lib,
13541354
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
13551355
try {
13561356
HashingStorage storage = anyset.getDictStorage();
13571357
// TODO: FIXME: this might call __hash__ twice
1358-
return lib.hasKeyWithFrame(storage, item, hasFrameProfile, frame);
1358+
return PInt.intValue(lib.hasKeyWithFrame(storage, item, hasFrameProfile, frame));
13591359
} catch (PException e) {
13601360
transformExceptionToNativeNode.execute(e);
13611361
return -1;
13621362
}
13631363
}
13641364

13651365
@Specialization(limit = "3")
1366-
public Object contains(VirtualFrame frame, PFrozenSet anyset, Object item,
1366+
public int contains(VirtualFrame frame, PFrozenSet anyset, Object item,
13671367
@CachedLibrary("anyset.getDictStorage()") HashingStorageLibrary lib,
13681368
@Cached ConditionProfile hasFrameProfile,
13691369
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
13701370
try {
13711371
HashingStorage storage = anyset.getDictStorage();
13721372
// TODO: FIXME: this might call __hash__ twice
1373-
return lib.hasKeyWithFrame(storage, item, hasFrameProfile, frame);
1373+
return PInt.intValue(lib.hasKeyWithFrame(storage, item, hasFrameProfile, frame));
13741374
} catch (PException e) {
13751375
transformExceptionToNativeNode.execute(e);
13761376
return -1;
@@ -1583,21 +1583,21 @@ protected boolean isSetSubtype(VirtualFrame frame, Object obj, GetClassNode getC
15831583
@GenerateNodeFactory
15841584
public abstract static class PyBytesSizeNode extends PythonUnaryBuiltinNode {
15851585
@Specialization
1586-
public Object size(VirtualFrame frame, PBytes obj,
1586+
public int size(VirtualFrame frame, PBytes obj,
15871587
@Cached PyObjectSizeNode sizeNode) {
15881588
return sizeNode.execute(frame, obj);
15891589
}
15901590

15911591
@Specialization(guards = {"!isPBytes(obj)", "isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)"})
1592-
public Object sizeNative(VirtualFrame frame, @SuppressWarnings("unused") Object obj,
1592+
public int sizeNative(VirtualFrame frame, @SuppressWarnings("unused") Object obj,
15931593
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
15941594
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
15951595
@Cached PRaiseNativeNode raiseNativeNode) {
15961596
return raiseNativeNode.raiseInt(frame, -1, PythonBuiltinClassType.NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, "bytes");
15971597
}
15981598

15991599
@Specialization(guards = {"!isPBytes(obj)", "!isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)"})
1600-
public Object size(VirtualFrame frame, Object obj,
1600+
public int size(VirtualFrame frame, Object obj,
16011601
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
16021602
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
16031603
@Cached StrNode strNode,

0 commit comments

Comments
 (0)