35
35
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Byte ;
36
36
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Double ;
37
37
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Empty ;
38
- import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Generic ;
39
38
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Int ;
40
39
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Long ;
41
40
import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Uninitialized ;
@@ -245,38 +244,6 @@ abstract static class SequenceStorageBaseNode extends PNodeWithContext {
245
244
protected static final int MAX_SEQUENCE_STORAGES = 9 ;
246
245
protected static final int MAX_ARRAY_STORAGES = 7 ;
247
246
248
- @ InliningCutoff
249
- protected static boolean isByteStorage (NativeSequenceStorage store ) {
250
- return store .getElementType () == ListStorageType .Byte ;
251
- }
252
-
253
- @ InliningCutoff
254
- protected static boolean isObjectStorage (NativeSequenceStorage store ) {
255
- return store .getElementType () == ListStorageType .Generic ;
256
- }
257
-
258
- /**
259
- * Tests if {@code left} has the same element type as {@code right}.
260
- */
261
- protected static boolean compatible (SequenceStorage left , NativeSequenceStorage right ) {
262
- switch (right .getElementType ()) {
263
- case Boolean :
264
- return left instanceof BoolSequenceStorage ;
265
- case Byte :
266
- return left instanceof ByteSequenceStorage ;
267
- case Int :
268
- return left instanceof IntSequenceStorage ;
269
- case Long :
270
- return left instanceof LongSequenceStorage ;
271
- case Double :
272
- return left instanceof DoubleSequenceStorage ;
273
- case Generic :
274
- return left instanceof ObjectSequenceStorage ;
275
- }
276
- assert false : "should not reach" ;
277
- return false ;
278
- }
279
-
280
247
protected static boolean isNative (SequenceStorage store ) {
281
248
return store instanceof NativeSequenceStorage ;
282
249
}
@@ -285,11 +252,6 @@ protected static boolean isEmpty(SequenceStorage left) {
285
252
return left .length () == 0 ;
286
253
}
287
254
288
- @ InliningCutoff
289
- protected static boolean isObject (GetElementType getElementTypeNode , Node inliningTarget , SequenceStorage s ) {
290
- return getElementTypeNode .execute (inliningTarget , s ) == ListStorageType .Generic ;
291
- }
292
-
293
255
protected static boolean isBoolean (ListStorageType et ) {
294
256
return et == ListStorageType .Boolean ;
295
257
}
@@ -1697,8 +1659,8 @@ static byte[] doByteSequenceStorage(ByteSequenceStorage s) {
1697
1659
return s .getInternalByteArray ();
1698
1660
}
1699
1661
1700
- @ Specialization ( guards = "isByteStorage(s)" )
1701
- static byte [] doNativeByte (Node inliningTarget , NativeSequenceStorage s ,
1662
+ @ Specialization
1663
+ static byte [] doNativeByte (Node inliningTarget , NativeByteSequenceStorage s ,
1702
1664
@ Shared ("getItemNode" ) @ Cached GetItemScalarNode getItemNode ) {
1703
1665
byte [] barr = new byte [s .length ()];
1704
1666
for (int i = 0 ; i < barr .length ; i ++) {
@@ -2584,13 +2546,11 @@ static LongSequenceStorage doLongLong(LongSequenceStorage s, @SuppressWarnings("
2584
2546
return s ;
2585
2547
}
2586
2548
2587
- @ Specialization ( guards = "isObjectStorage(s)" )
2588
- static NativeSequenceStorage doNative (NativeSequenceStorage s , @ SuppressWarnings ("unused" ) Object val ) {
2549
+ @ Specialization
2550
+ static NativeObjectSequenceStorage doNative (NativeObjectSequenceStorage s , @ SuppressWarnings ("unused" ) Object val ) {
2589
2551
return s ;
2590
2552
}
2591
2553
2592
- // TODO primitive native storages?
2593
-
2594
2554
@ Specialization (guards = "isAssignCompatibleNode.execute(inliningTarget, s, indicationStorage)" )
2595
2555
static TypedSequenceStorage doTyped (@ SuppressWarnings ("unused" ) Node inliningTarget , TypedSequenceStorage s , @ SuppressWarnings ("unused" ) SequenceStorage indicationStorage ,
2596
2556
// dummy profile, so that we can @Share it to generate better code
@@ -2626,10 +2586,6 @@ protected static boolean isFallbackCase(Node inliningTarget, SequenceStorage s,
2626
2586
public static ListGeneralizationNode create () {
2627
2587
return ListGeneralizationNodeGen .create ();
2628
2588
}
2629
-
2630
- protected static boolean isObjectStorage (NativeSequenceStorage storage ) {
2631
- return storage .getElementType () == Generic ;
2632
- }
2633
2589
}
2634
2590
2635
2591
@ GenerateUncached
@@ -2797,7 +2753,7 @@ static NativeSequenceStorage doNativeByte(Node inliningTarget, NativeSequenceSto
2797
2753
newCapacity = cap ;
2798
2754
}
2799
2755
Object mem = s .getPtr ();
2800
- long elementSize = s . getElementType () == Byte ? 1 : CStructAccess .POINTER_SIZE ;
2756
+ long elementSize = s instanceof NativeByteSequenceStorage ? 1 : CStructAccess .POINTER_SIZE ;
2801
2757
long bytes = elementSize * newCapacity ;
2802
2758
Object newMem = alloc .alloc (bytes );
2803
2759
if (lib .isNull (newMem )) {
@@ -2850,8 +2806,8 @@ static SequenceStorage doSpecial(SequenceStorage s,
2850
2806
return CompilerDirectives .castExact (CompilerDirectives .castExact (s , cachedClass ).copy (), cachedClass );
2851
2807
}
2852
2808
2853
- @ Specialization ( guards = "isNativeBytesStorage(s)" )
2854
- static SequenceStorage doNativeBytes (NativeSequenceStorage s ,
2809
+ @ Specialization
2810
+ static SequenceStorage doNativeBytes (NativeByteSequenceStorage s ,
2855
2811
@ Shared @ Cached (inline = false ) GetNativeItemScalarNode getItem ) {
2856
2812
byte [] bytes = new byte [s .length ()];
2857
2813
for (int i = 0 ; i < s .length (); i ++) {
@@ -2860,8 +2816,8 @@ static SequenceStorage doNativeBytes(NativeSequenceStorage s,
2860
2816
return new ByteSequenceStorage (bytes );
2861
2817
}
2862
2818
2863
- @ Specialization ( guards = "isNativeObjectsStorage(s)" )
2864
- static SequenceStorage doNativeObjects (NativeSequenceStorage s ,
2819
+ @ Specialization
2820
+ static SequenceStorage doNativeObjects (NativeObjectSequenceStorage s ,
2865
2821
@ Shared @ Cached (inline = false ) GetNativeItemScalarNode getItem ) {
2866
2822
Object [] objects = new Object [s .length ()];
2867
2823
for (int i = 0 ; i < s .length (); i ++) {
@@ -2879,14 +2835,6 @@ static SequenceStorage doGeneric(SequenceStorage s) {
2879
2835
protected static boolean isNativeStorage (SequenceStorage storage ) {
2880
2836
return storage instanceof NativeSequenceStorage ;
2881
2837
}
2882
-
2883
- protected static boolean isNativeBytesStorage (NativeSequenceStorage storage ) {
2884
- return storage .getElementType () == Byte ;
2885
- }
2886
-
2887
- protected static boolean isNativeObjectsStorage (NativeSequenceStorage storage ) {
2888
- return storage .getElementType () == Generic ;
2889
- }
2890
2838
}
2891
2839
2892
2840
@ GenerateUncached
0 commit comments