223
223
import com .oracle .graal .python .builtins .objects .getsetdescriptor .GetSetDescriptor ;
224
224
import com .oracle .graal .python .builtins .objects .ints .PInt ;
225
225
import com .oracle .graal .python .builtins .objects .iterator .PSequenceIterator ;
226
- import com .oracle .graal .python .builtins .objects .list .ListBuiltins ;
227
226
import com .oracle .graal .python .builtins .objects .list .ListBuiltins .ListExtendNode ;
228
227
import com .oracle .graal .python .builtins .objects .list .ListBuiltins .ListInsertNode ;
229
228
import com .oracle .graal .python .builtins .objects .list .ListBuiltins .ListSortNode ;
@@ -1164,7 +1163,7 @@ public Object keys(VirtualFrame frame, PDict obj,
1164
1163
@ Cached KeysNode keysNode ,
1165
1164
@ Cached ConstructListNode listNode ,
1166
1165
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1167
- @ Cached GetNativeNullNode getNativeNullNode ) {
1166
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1168
1167
try {
1169
1168
return listNode .execute (frame , keysNode .execute (frame , obj ));
1170
1169
} catch (PException e ) {
@@ -1179,7 +1178,7 @@ public Object keys(VirtualFrame frame, Object obj,
1179
1178
@ Cached CallNode callNode ,
1180
1179
@ Cached ConstructListNode listNode ,
1181
1180
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1182
- @ Cached GetNativeNullNode getNativeNullNode ) {
1181
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1183
1182
try {
1184
1183
return getKeys (frame , obj , getAttrNode , callNode , listNode );
1185
1184
} catch (PException e ) {
@@ -1203,7 +1202,7 @@ public Object items(VirtualFrame frame, PDict obj,
1203
1202
@ Cached ItemsNode itemsNode ,
1204
1203
@ Cached ConstructListNode listNode ,
1205
1204
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1206
- @ Cached GetNativeNullNode getNativeNullNode ) {
1205
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1207
1206
try {
1208
1207
return listNode .execute (frame , itemsNode .execute (frame , obj ));
1209
1208
} catch (PException e ) {
@@ -1218,7 +1217,7 @@ public Object items(VirtualFrame frame, Object obj,
1218
1217
@ Cached CallNode callNode ,
1219
1218
@ Cached ConstructListNode listNode ,
1220
1219
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1221
- @ Cached GetNativeNullNode getNativeNullNode ) {
1220
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1222
1221
try {
1223
1222
Object attr = getAttrNode .execute (frame , obj , ITEMS );
1224
1223
return listNode .execute (frame , callNode .execute (frame , attr ));
@@ -1237,7 +1236,7 @@ public Object values(VirtualFrame frame, PDict obj,
1237
1236
@ Cached ConstructListNode listNode ,
1238
1237
@ Cached ValuesNode valuesNode ,
1239
1238
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1240
- @ Cached GetNativeNullNode getNativeNullNode ) {
1239
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1241
1240
try {
1242
1241
return listNode .execute (frame , valuesNode .execute (frame , obj ));
1243
1242
} catch (PException e ) {
@@ -1252,7 +1251,7 @@ public Object values(VirtualFrame frame, Object obj,
1252
1251
@ Cached CallNode callNode ,
1253
1252
@ Cached ConstructListNode listNode ,
1254
1253
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1255
- @ Cached GetNativeNullNode getNativeNullNode ) {
1254
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1256
1255
try {
1257
1256
Object attr = getAttrNode .execute (frame , obj , VALUES );
1258
1257
return listNode .execute (frame , callNode .execute (frame , attr ));
@@ -1410,20 +1409,20 @@ public Object contains(VirtualFrame frame, PFrozenSet anyset, Object item,
1410
1409
}
1411
1410
}
1412
1411
1413
- @ Specialization (guards = "isSetSubtype(frame, anyset, getClassNode, isSubtypeNode)" )
1412
+ @ Specialization (guards = "isSetSubtype(frame, anyset, getClassNode, isSubtypeNode)" , limit = "1" )
1414
1413
public Object containsNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object anyset , @ SuppressWarnings ("unused" ) Object item ,
1415
1414
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
1416
1415
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
1417
- @ Cached PRaiseNativeNode raiseNativeNode ) {
1416
+ @ Shared ( "raiseNative" ) @ Cached PRaiseNativeNode raiseNativeNode ) {
1418
1417
return raiseNativeNode .raiseInt (frame , -1 , PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "set" );
1419
1418
}
1420
1419
1421
- @ Specialization (guards = {"!isPSet(anyset)" , "!isPFrozenSet(anyset)" , "!isSetSubtype(frame, anyset, getClassNode, isSubtypeNode)" })
1420
+ @ Specialization (guards = {"!isPSet(anyset)" , "!isPFrozenSet(anyset)" , "!isSetSubtype(frame, anyset, getClassNode, isSubtypeNode)" }, limit = "1" )
1422
1421
public Object contains (VirtualFrame frame , Object anyset , @ SuppressWarnings ("unused" ) Object item ,
1423
1422
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
1424
1423
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
1425
1424
@ Cached StrNode strNode ,
1426
- @ Cached PRaiseNativeNode raiseNativeNode ) {
1425
+ @ Shared ( "raiseNative" ) @ Cached PRaiseNativeNode raiseNativeNode ) {
1427
1426
return raiseNativeNode .raiseInt (frame , -1 , SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , anyset ), anyset );
1428
1427
}
1429
1428
@@ -1679,17 +1678,19 @@ public Object concat(VirtualFrame frame, PBytes original, PBytes newPart,
1679
1678
public Object concatNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object obj ,
1680
1679
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
1681
1680
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
1681
+ @ Cached GetNativeNullNode getNativeNullNode ,
1682
1682
@ Cached PRaiseNativeNode raiseNativeNode ) {
1683
- return raiseNativeNode .raiseInt (frame , - 1 , PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
1683
+ return raiseNativeNode .raise (frame , getNativeNullNode . execute () , PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
1684
1684
}
1685
1685
1686
1686
@ Specialization (guards = {"!isPBytes(obj)" , "!isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)" })
1687
1687
public Object concat (VirtualFrame frame , Object obj ,
1688
1688
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
1689
1689
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
1690
1690
@ Cached StrNode strNode ,
1691
+ @ Cached GetNativeNullNode getNativeNullNode ,
1691
1692
@ Cached PRaiseNativeNode raiseNativeNode ) {
1692
- return raiseNativeNode .raiseInt (frame , - 1 , SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , obj ), obj );
1693
+ return raiseNativeNode .raise (frame , getNativeNullNode . execute () , SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , obj ), obj );
1693
1694
}
1694
1695
1695
1696
protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -1717,17 +1718,19 @@ public Object join(VirtualFrame frame, PBytes original, PBytes newPart,
1717
1718
public Object joinNative (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object obj ,
1718
1719
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
1719
1720
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
1720
- @ Cached PRaiseNativeNode raiseNativeNode ) {
1721
- return raiseNativeNode .raiseInt (frame , -1 , PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
1721
+ @ Cached PRaiseNativeNode raiseNativeNode ,
1722
+ @ Cached GetNativeNullNode getNativeNullNode ) {
1723
+ return raiseNativeNode .raise (frame , getNativeNullNode .execute (), PythonBuiltinClassType .NotImplementedError , NATIVE_S_SUBTYPES_NOT_IMPLEMENTED , "bytes" );
1722
1724
}
1723
1725
1724
1726
@ Specialization (guards = {"!isPBytes(obj)" , "!isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)" })
1725
1727
public Object join (VirtualFrame frame , Object obj ,
1726
1728
@ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
1727
1729
@ SuppressWarnings ("unused" ) @ Cached IsSubtypeNode isSubtypeNode ,
1728
1730
@ Cached StrNode strNode ,
1729
- @ Cached PRaiseNativeNode raiseNativeNode ) {
1730
- return raiseNativeNode .raiseInt (frame , -1 , SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , obj ), obj );
1731
+ @ Cached PRaiseNativeNode raiseNativeNode ,
1732
+ @ Cached GetNativeNullNode getNativeNullNode ) {
1733
+ return raiseNativeNode .raise (frame , getNativeNullNode .execute (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P , strNode .executeWith (frame , obj ), obj );
1731
1734
}
1732
1735
1733
1736
protected boolean isBytesSubtype (VirtualFrame frame , Object obj , GetClassNode getClassNode , IsSubtypeNode isSubtypeNode ) {
@@ -1809,15 +1812,15 @@ protected boolean isAcceptedSubtype(VirtualFrame frame, Object obj, GetClassNode
1809
1812
public abstract static class PyListNewNode extends PythonUnaryBuiltinNode {
1810
1813
@ Specialization (guards = "size < 0" )
1811
1814
public Object newList (VirtualFrame frame , int size ,
1812
- @ Cached PRaiseNativeNode raiseNativeNode ,
1813
- @ Cached GetNativeNullNode getNativeNullNode ) {
1815
+ @ Shared ( "raiseNative" ) @ Cached PRaiseNativeNode raiseNativeNode ,
1816
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1814
1817
return raiseNativeNode .raise (frame , getNativeNullNode .execute (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_S , size );
1815
1818
}
1816
1819
1817
1820
@ Specialization (guards = "size < 0" )
1818
1821
public Object newList (VirtualFrame frame , long size ,
1819
- @ Cached PRaiseNativeNode raiseNativeNode ,
1820
- @ Cached GetNativeNullNode getNativeNullNode ) {
1822
+ @ Shared ( "raiseNative" ) @ Cached PRaiseNativeNode raiseNativeNode ,
1823
+ @ Shared ( "nativeNull" ) @ Cached GetNativeNullNode getNativeNullNode ) {
1821
1824
return raiseNativeNode .raise (frame , getNativeNullNode .execute (), SystemError , BAD_ARG_TO_INTERNAL_FUNC_S , size );
1822
1825
}
1823
1826
@@ -1856,32 +1859,11 @@ Object getItem(VirtualFrame frame, @SuppressWarnings("unused") Object list, @Sup
1856
1859
return raiseNativeNode .raise (frame , getNativeNullNode .execute (), PythonBuiltinClassType .IndexError , LIST_INDEX_OUT_OF_RANGE );
1857
1860
}
1858
1861
1859
- @ SuppressWarnings ("unused" )
1860
- @ Specialization (guards = "pos < 0" )
1861
- Object getItem (VirtualFrame frame , @ SuppressWarnings ("unused" ) Object list , @ SuppressWarnings ("unused" ) int pos ,
1862
- @ Cached PRaiseNativeNode raiseNativeNode ,
1863
- @ Cached GetNativeNullNode getNativeNullNode ) {
1864
- return raiseNativeNode .raise (frame , getNativeNullNode .execute (), PythonBuiltinClassType .IndexError , LIST_INDEX_OUT_OF_RANGE );
1865
- }
1866
-
1867
- @ Specialization (guards = "pos >= 0" )
1868
- Object getItem (VirtualFrame frame , PList list , int pos ,
1869
- @ Cached com .oracle .graal .python .builtins .objects .list .ListBuiltins .GetItemNode getItemNode ,
1870
- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1871
- @ Cached GetNativeNullNode getNativeNullNode ) {
1872
- return getItemWithInt (frame , list , pos , getItemNode , transformExceptionToNativeNode , getNativeNullNode );
1873
- }
1874
-
1875
1862
@ Specialization (guards = "pos >= 0" )
1876
1863
Object getItem (VirtualFrame frame , PList list , long pos ,
1877
1864
@ Cached com .oracle .graal .python .builtins .objects .list .ListBuiltins .GetItemNode getItemNode ,
1878
1865
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
1879
1866
@ Cached GetNativeNullNode getNativeNullNode ) {
1880
- return getItemWithInt (frame , list , (int ) pos , getItemNode , transformExceptionToNativeNode , getNativeNullNode );
1881
- }
1882
-
1883
- private static Object getItemWithInt (VirtualFrame frame , PList list , int pos , ListBuiltins .GetItemNode getItemNode , TransformExceptionToNativeNode transformExceptionToNativeNode ,
1884
- GetNativeNullNode getNativeNullNode ) {
1885
1867
try {
1886
1868
return getItemNode .execute (frame , list , pos );
1887
1869
} catch (PException e ) {
@@ -2204,17 +2186,6 @@ abstract static class PyListInsertNode extends PythonTernaryBuiltinNode {
2204
2186
Object append (VirtualFrame frame , PList list , int i , Object item ,
2205
2187
@ Cached ListInsertNode insertNode ,
2206
2188
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
2207
- return insert (frame , list , i , item , insertNode , transformExceptionToNativeNode );
2208
- }
2209
-
2210
- @ Specialization
2211
- Object append (VirtualFrame frame , PList list , long i , Object item ,
2212
- @ Cached ListInsertNode insertNode ,
2213
- @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
2214
- return insert (frame , list , (int ) i , item , insertNode , transformExceptionToNativeNode );
2215
- }
2216
-
2217
- private static int insert (VirtualFrame frame , PList list , int i , Object item , ListInsertNode insertNode , TransformExceptionToNativeNode transformExceptionToNativeNode ) {
2218
2189
try {
2219
2190
insertNode .execute (frame , list , i , item );
2220
2191
return 0 ;
0 commit comments