29
29
import static com .oracle .graal .python .builtins .objects .cext .capi .NativeCAPISymbol .FUN_ADD_NATIVE_SLOTS ;
30
30
import static com .oracle .graal .python .builtins .objects .cext .capi .NativeCAPISymbol .FUN_PY_OBJECT_NEW ;
31
31
import static com .oracle .graal .python .builtins .objects .cext .capi .NativeCAPISymbol .FUN_PY_TRUFFLE_MEMORYVIEW_FROM_OBJECT ;
32
- import static com .oracle .graal .python .builtins .objects .range .RangeUtils .canBeInt ;
33
32
import static com .oracle .graal .python .builtins .objects .str .StringUtils .canEncodeUTF8 ;
34
33
import static com .oracle .graal .python .builtins .objects .str .StringUtils .containsNullCharacter ;
35
34
import static com .oracle .graal .python .builtins .objects .type .TypeBuiltins .TYPE_ITEMSIZE ;
264
263
import com .oracle .truffle .api .dsl .ReportPolymorphism .Megamorphic ;
265
264
import com .oracle .truffle .api .dsl .Specialization ;
266
265
import com .oracle .truffle .api .frame .VirtualFrame ;
267
- import com .oracle .truffle .api .interop .InteropLibrary ;
268
266
import com .oracle .truffle .api .interop .UnsupportedMessageException ;
269
267
import com .oracle .truffle .api .library .CachedLibrary ;
270
268
import com .oracle .truffle .api .nodes .UnexpectedResultException ;
@@ -1845,10 +1843,10 @@ Object doGenericStop(VirtualFrame frame, Object cls, Object stop, @SuppressWarni
1845
1843
@ Shared ("exceptionProfile" ) @ Cached BranchProfile exceptionProfile ,
1846
1844
@ Shared ("lenOfRangeNodeExact" ) @ Cached LenOfIntRangeNodeExact lenOfRangeNodeExact ,
1847
1845
@ Shared ("createBigRangeNode" ) @ Cached RangeNodes .CreateBigRangeNode createBigRangeNode ,
1848
- @ Shared ("asSizeNode " ) @ Cached PyNumberAsSizeNode asSizeNode ,
1849
- @ Shared ("indexNode " ) @ Cached PyNumberIndexNode indexNode ,
1850
- @ Shared ("libGeneric " ) @ CachedLibrary ( limit = "3" ) InteropLibrary lib ) {
1851
- return doGeneric (frame , cls , 0 , stop , 1 , stepZeroProfile , exceptionProfile , lenOfRangeNodeExact , createBigRangeNode , asSizeNode , indexNode , lib );
1846
+ @ Shared ("cast " ) @ Cached CastToJavaIntExactNode cast ,
1847
+ @ Shared ("overflowProfile " ) @ Cached IsBuiltinClassProfile overflowProfile ,
1848
+ @ Shared ("indexNode " ) @ Cached PyNumberIndexNode indexNode ) {
1849
+ return doGeneric (frame , cls , 0 , stop , 1 , stepZeroProfile , exceptionProfile , lenOfRangeNodeExact , createBigRangeNode , cast , overflowProfile , indexNode );
1852
1850
}
1853
1851
1854
1852
// start stop
@@ -1874,10 +1872,10 @@ Object doGenericStartStop(VirtualFrame frame, Object cls, Object start, Object s
1874
1872
@ Shared ("exceptionProfile" ) @ Cached BranchProfile exceptionProfile ,
1875
1873
@ Shared ("lenOfRangeNodeExact" ) @ Cached LenOfIntRangeNodeExact lenOfRangeNodeExact ,
1876
1874
@ Shared ("createBigRangeNode" ) @ Cached RangeNodes .CreateBigRangeNode createBigRangeNode ,
1877
- @ Shared ("asSizeNode " ) @ Cached PyNumberAsSizeNode asSizeNode ,
1878
- @ Shared ("indexNode " ) @ Cached PyNumberIndexNode indexNode ,
1879
- @ Shared ("libGeneric " ) @ CachedLibrary ( limit = "3" ) InteropLibrary lib ) {
1880
- return doGeneric (frame , cls , start , stop , 1 , stepZeroProfile , exceptionProfile , lenOfRangeNodeExact , createBigRangeNode , asSizeNode , indexNode , lib );
1875
+ @ Shared ("cast " ) @ Cached CastToJavaIntExactNode cast ,
1876
+ @ Shared ("overflowProfile " ) @ Cached IsBuiltinClassProfile overflowProfile ,
1877
+ @ Shared ("indexNode " ) @ Cached PyNumberIndexNode indexNode ) {
1878
+ return doGeneric (frame , cls , start , stop , 1 , stepZeroProfile , exceptionProfile , lenOfRangeNodeExact , createBigRangeNode , cast , overflowProfile , indexNode );
1881
1879
}
1882
1880
1883
1881
// start stop step
@@ -1916,19 +1914,20 @@ Object doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Obj
1916
1914
@ Shared ("exceptionProfile" ) @ Cached BranchProfile exceptionProfile ,
1917
1915
@ Shared ("lenOfRangeNodeExact" ) @ Cached LenOfIntRangeNodeExact lenOfRangeNodeExact ,
1918
1916
@ Shared ("createBigRangeNode" ) @ Cached RangeNodes .CreateBigRangeNode createBigRangeNode ,
1919
- @ Shared ("asSizeNode " ) @ Cached PyNumberAsSizeNode asSizeNode ,
1920
- @ Shared ("indexNode " ) @ Cached PyNumberIndexNode indexNode ,
1921
- @ Shared ("libGeneric " ) @ CachedLibrary ( limit = "3" ) InteropLibrary lib ) {
1917
+ @ Shared ("cast " ) @ Cached CastToJavaIntExactNode cast ,
1918
+ @ Shared ("overflowProfile " ) @ Cached IsBuiltinClassProfile overflowProfile ,
1919
+ @ Shared ("indexNode " ) @ Cached PyNumberIndexNode indexNode ) {
1922
1920
Object lstart = indexNode .execute (frame , start );
1923
1921
Object lstop = indexNode .execute (frame , stop );
1924
1922
Object lstep = indexNode .execute (frame , step );
1925
1923
1926
- if ( canBeInt ( lstart , lstop , lstep , lib )) {
1927
- int istart = asSizeNode . executeExact ( frame , lstart );
1928
- int istop = asSizeNode . executeExact ( frame , lstop );
1929
- int istep = asSizeNode . executeExact ( frame , lstep );
1924
+ try {
1925
+ int istart = cast . execute ( lstart );
1926
+ int istop = cast . execute ( lstop );
1927
+ int istep = cast . execute ( lstep );
1930
1928
return doInt (cls , istart , istop , istep , stepZeroProfile , exceptionProfile , lenOfRangeNodeExact , createBigRangeNode );
1931
- } else {
1929
+ } catch (PException e ) {
1930
+ e .expect (OverflowError , overflowProfile );
1932
1931
return createBigRangeNode .execute (lstart , lstop , lstep , factory ());
1933
1932
}
1934
1933
}
0 commit comments