43
43
import static com .oracle .graal .python .runtime .exception .PythonErrorType .ValueError ;
44
44
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Boolean ;
45
45
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Byte ;
46
- import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Char ;
47
46
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Double ;
48
47
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Empty ;
49
48
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Int ;
133
132
import com .oracle .graal .python .runtime .sequence .storage .BasicSequenceStorage ;
134
133
import com .oracle .graal .python .runtime .sequence .storage .BoolSequenceStorage ;
135
134
import com .oracle .graal .python .runtime .sequence .storage .ByteSequenceStorage ;
136
- import com .oracle .graal .python .runtime .sequence .storage .CharSequenceStorage ;
137
135
import com .oracle .graal .python .runtime .sequence .storage .DoubleSequenceStorage ;
138
136
import com .oracle .graal .python .runtime .sequence .storage .EmptySequenceStorage ;
139
137
import com .oracle .graal .python .runtime .sequence .storage .IntSequenceStorage ;
178
176
179
177
public abstract class SequenceStorageNodes {
180
178
181
- public static interface GenNodeSupplier {
179
+ public interface GenNodeSupplier {
182
180
GeneralizationNode create ();
183
181
184
182
GeneralizationNode getUncached ();
185
183
}
186
184
187
- public static interface ContainerFactory {
185
+ public interface ContainerFactory {
188
186
189
187
Object apply (SequenceStorage s , PythonObjectFactory factory );
190
188
}
@@ -212,8 +210,6 @@ static boolean compatibleAssign(SequenceStorage lhs, SequenceStorage rhs,
212
210
return rhsType == Boolean || rhsType == Byte || rhsType == Int || rhsType == Long || rhsType == Uninitialized || rhsType == Empty ;
213
211
case Double :
214
212
return rhsType == Double || rhsType == Uninitialized || rhsType == Empty ;
215
- case Char :
216
- return rhsType == Char || rhsType == Uninitialized || rhsType == Empty ;
217
213
case Tuple :
218
214
return rhsType == Tuple || rhsType == Uninitialized || rhsType == Empty ;
219
215
case List :
@@ -257,8 +253,6 @@ static boolean compatibleAssign(SequenceStorage lhs, SequenceStorage rhs,
257
253
return rhsType == Boolean || rhsType == Byte || rhsType == Int || rhsType == Long || rhsType == Uninitialized || rhsType == Empty ;
258
254
case Double :
259
255
return rhsType == Double || rhsType == Uninitialized || rhsType == Empty ;
260
- case Char :
261
- return rhsType == Char || rhsType == Uninitialized || rhsType == Empty ;
262
256
case Tuple :
263
257
return rhsType == Tuple || rhsType == Uninitialized || rhsType == Empty ;
264
258
case List :
@@ -287,7 +281,7 @@ abstract static class SequenceStorageBaseNode extends PNodeWithContext {
287
281
288
282
protected static final int DEFAULT_CAPACITY = 8 ;
289
283
290
- protected static final int MAX_SEQUENCE_STORAGES = 13 ;
284
+ protected static final int MAX_SEQUENCE_STORAGES = 11 ;
291
285
protected static final int MAX_ARRAY_STORAGES = 9 ;
292
286
293
287
protected static boolean isByteStorage (NativeSequenceStorage store ) {
@@ -303,8 +297,6 @@ protected static boolean compatible(SequenceStorage left, NativeSequenceStorage
303
297
return left instanceof BoolSequenceStorage ;
304
298
case Byte :
305
299
return left instanceof ByteSequenceStorage ;
306
- case Char :
307
- return left instanceof CharSequenceStorage ;
308
300
case Int :
309
301
return left instanceof IntSequenceStorage ;
310
302
case Long :
@@ -338,10 +330,6 @@ protected static boolean isByteLike(GetElementType getElementTypeNode, SequenceS
338
330
return isByte (getElementTypeNode , s ) || isInt (getElementTypeNode , s ) || isLong (getElementTypeNode , s );
339
331
}
340
332
341
- protected static boolean isChar (GetElementType getElementTypeNode , SequenceStorage s ) {
342
- return getElementTypeNode .execute (s ) == ListStorageType .Char ;
343
- }
344
-
345
333
protected static boolean isInt (GetElementType getElementTypeNode , SequenceStorage s ) {
346
334
return getElementTypeNode .execute (s ) == ListStorageType .Int ;
347
335
}
@@ -378,10 +366,6 @@ protected static boolean isByteLike(ListStorageType et) {
378
366
return isByte (et ) || isInt (et ) || isLong (et );
379
367
}
380
368
381
- protected static boolean isChar (ListStorageType et ) {
382
- return et == ListStorageType .Char ;
383
- }
384
-
385
369
protected static boolean isInt (ListStorageType et ) {
386
370
return et == ListStorageType .Int ;
387
371
}
@@ -708,11 +692,6 @@ protected static int doByte(ByteSequenceStorage storage, int idx) {
708
692
return storage .getIntItemNormalized (idx );
709
693
}
710
694
711
- @ Specialization
712
- protected static char doChar (CharSequenceStorage storage , int idx ) {
713
- return storage .getCharItemNormalized (idx );
714
- }
715
-
716
695
@ Specialization
717
696
protected static int doInt (IntSequenceStorage storage , int idx ) {
718
697
return storage .getIntItemNormalized (idx );
@@ -1224,11 +1203,6 @@ protected static void doByte(ByteSequenceStorage storage, int idx, Object value,
1224
1203
storage .setByteItemNormalized (idx , castToByteNode .execute (null , value ));
1225
1204
}
1226
1205
1227
- @ Specialization
1228
- protected static void doChar (CharSequenceStorage storage , int idx , char value ) {
1229
- storage .setCharItemNormalized (idx , value );
1230
- }
1231
-
1232
1206
@ Specialization
1233
1207
protected static void doInt (IntSequenceStorage storage , int idx , int value ) {
1234
1208
storage .setIntItemNormalized (idx , value );
@@ -1969,20 +1943,6 @@ boolean doByteStorage(ByteSequenceStorage left, ByteSequenceStorage right) {
1969
1943
return cmpOp .cmp (llen , rlen );
1970
1944
}
1971
1945
1972
- @ Specialization
1973
- boolean doCharStorage (CharSequenceStorage left , CharSequenceStorage right ) {
1974
- int llen = left .length ();
1975
- int rlen = right .length ();
1976
- for (int i = 0 ; i < Math .min (llen , rlen ); i ++) {
1977
- char litem = left .getCharItemNormalized (i );
1978
- char ritem = right .getCharItemNormalized (i );
1979
- if (litem != ritem ) {
1980
- return cmpOp .cmp (litem , ritem );
1981
- }
1982
- }
1983
- return cmpOp .cmp (llen , rlen );
1984
- }
1985
-
1986
1946
@ Specialization
1987
1947
boolean doIntStorage (IntSequenceStorage left , IntSequenceStorage right ) {
1988
1948
int llen = left .length ();
@@ -2200,7 +2160,7 @@ static void doByteSequenceStorage(byte[] src, int srcPos, ByteSequenceStorage de
2200
2160
2201
2161
@ Specialization (guards = "isByteStorage(dest)" )
2202
2162
static void doNativeByte (byte [] src , int srcPos , NativeSequenceStorage dest , int destPos , int lenght ,
2203
- @ Cached SetItemScalarNode setItemNode ) {
2163
+ @ Cached SetItemScalarNode setItemNode ) {
2204
2164
for (int i = 0 ; i < lenght ; i ++) {
2205
2165
setItemNode .execute (dest , destPos + i , src [srcPos + i ]);
2206
2166
}
@@ -2629,24 +2589,6 @@ ByteSequenceStorage doByteSingleElement(ByteSequenceStorage s, int times,
2629
2589
}
2630
2590
}
2631
2591
2632
- /* special but common case: something like '["0"] * n' */
2633
- @ Specialization (guards = {"s.length() == 1" , "times > 0" })
2634
- CharSequenceStorage doCharSingleElement (CharSequenceStorage s , int times ,
2635
- @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ,
2636
- @ Cached BranchProfile outOfMemProfile ) {
2637
- try {
2638
- char [] repeated = new char [PythonUtils .multiplyExact (s .length (), times )];
2639
- Arrays .fill (repeated , s .getCharItemNormalized (0 ));
2640
- return new CharSequenceStorage (repeated );
2641
- } catch (OutOfMemoryError e ) {
2642
- outOfMemProfile .enter ();
2643
- throw raiseNode .raise (MemoryError );
2644
- } catch (OverflowException e ) {
2645
- outOfMemProfile .enter ();
2646
- throw raiseNode .raise (errorForOverflow );
2647
- }
2648
- }
2649
-
2650
2592
/* special but common case: something like '[0] * n' */
2651
2593
@ Specialization (guards = {"s.length() == 1" , "times > 0" })
2652
2594
IntSequenceStorage doIntSingleElement (IntSequenceStorage s , int times ,
@@ -3262,10 +3204,6 @@ protected boolean isByteLike(SequenceStorage s) {
3262
3204
return isByte (s ) || isInt (s ) || isLong (s );
3263
3205
}
3264
3206
3265
- protected boolean isChar (SequenceStorage s ) {
3266
- return getElementType (s ) == ListStorageType .Char ;
3267
- }
3268
-
3269
3207
protected boolean isDouble (SequenceStorage s ) {
3270
3208
return getElementType (s ) == ListStorageType .Double ;
3271
3209
}
@@ -3302,16 +3240,6 @@ static ByteSequenceStorage doByte(@SuppressWarnings("unused") SequenceStorage s,
3302
3240
return ss ;
3303
3241
}
3304
3242
3305
- @ Specialization (guards = "isChar(s)" )
3306
- static CharSequenceStorage doChar (@ SuppressWarnings ("unused" ) SequenceStorage s , int cap , int len ) {
3307
- CharSequenceStorage ss = new CharSequenceStorage (cap );
3308
- if (len != -1 ) {
3309
- ss .ensureCapacity (len );
3310
- ss .setNewLength (len );
3311
- }
3312
- return ss ;
3313
- }
3314
-
3315
3243
@ Specialization (guards = "isInt(s)" )
3316
3244
static IntSequenceStorage doInt (@ SuppressWarnings ("unused" ) SequenceStorage s , int cap , int len ) {
3317
3245
IntSequenceStorage ss = new IntSequenceStorage (cap );
@@ -3899,17 +3827,6 @@ int doByte(SequenceStorage s, byte item, int start, int end,
3899
3827
return -1 ;
3900
3828
}
3901
3829
3902
- @ Specialization (guards = "isChar(getElementType, s)" )
3903
- int doChar (SequenceStorage s , char item , int start , int end ,
3904
- @ Cached @ SuppressWarnings ("unused" ) GetElementType getElementType ) {
3905
- for (int i = start ; i < getLength (s , end ); i ++) {
3906
- if (getItemScalarNode ().executeChar (s , i ) == item ) {
3907
- return i ;
3908
- }
3909
- }
3910
- return -1 ;
3911
- }
3912
-
3913
3830
@ Specialization (guards = "isInt(getElementType, s)" )
3914
3831
int doInt (SequenceStorage s , int item , int start , int end ,
3915
3832
@ Cached @ SuppressWarnings ("unused" ) GetElementType getElementType ) {
0 commit comments