3535import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Byte ;
3636import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Double ;
3737import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Empty ;
38- import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Generic ;
3938import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Int ;
4039import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Long ;
4140import static com .oracle .graal .python .runtime .sequence .storage .SequenceStorage .ListStorageType .Uninitialized ;
@@ -245,38 +244,6 @@ abstract static class SequenceStorageBaseNode extends PNodeWithContext {
245244 protected static final int MAX_SEQUENCE_STORAGES = 9 ;
246245 protected static final int MAX_ARRAY_STORAGES = 7 ;
247246
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-
280247 protected static boolean isNative (SequenceStorage store ) {
281248 return store instanceof NativeSequenceStorage ;
282249 }
@@ -285,11 +252,6 @@ protected static boolean isEmpty(SequenceStorage left) {
285252 return left .length () == 0 ;
286253 }
287254
288- @ InliningCutoff
289- protected static boolean isObject (GetElementType getElementTypeNode , Node inliningTarget , SequenceStorage s ) {
290- return getElementTypeNode .execute (inliningTarget , s ) == ListStorageType .Generic ;
291- }
292-
293255 protected static boolean isBoolean (ListStorageType et ) {
294256 return et == ListStorageType .Boolean ;
295257 }
@@ -1697,8 +1659,8 @@ static byte[] doByteSequenceStorage(ByteSequenceStorage s) {
16971659 return s .getInternalByteArray ();
16981660 }
16991661
1700- @ Specialization ( guards = "isByteStorage(s)" )
1701- static byte [] doNativeByte (Node inliningTarget , NativeSequenceStorage s ,
1662+ @ Specialization
1663+ static byte [] doNativeByte (Node inliningTarget , NativeByteSequenceStorage s ,
17021664 @ Shared ("getItemNode" ) @ Cached GetItemScalarNode getItemNode ) {
17031665 byte [] barr = new byte [s .length ()];
17041666 for (int i = 0 ; i < barr .length ; i ++) {
@@ -2584,13 +2546,11 @@ static LongSequenceStorage doLongLong(LongSequenceStorage s, @SuppressWarnings("
25842546 return s ;
25852547 }
25862548
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 ) {
25892551 return s ;
25902552 }
25912553
2592- // TODO primitive native storages?
2593-
25942554 @ Specialization (guards = "isAssignCompatibleNode.execute(inliningTarget, s, indicationStorage)" )
25952555 static TypedSequenceStorage doTyped (@ SuppressWarnings ("unused" ) Node inliningTarget , TypedSequenceStorage s , @ SuppressWarnings ("unused" ) SequenceStorage indicationStorage ,
25962556 // dummy profile, so that we can @Share it to generate better code
@@ -2626,10 +2586,6 @@ protected static boolean isFallbackCase(Node inliningTarget, SequenceStorage s,
26262586 public static ListGeneralizationNode create () {
26272587 return ListGeneralizationNodeGen .create ();
26282588 }
2629-
2630- protected static boolean isObjectStorage (NativeSequenceStorage storage ) {
2631- return storage .getElementType () == Generic ;
2632- }
26332589 }
26342590
26352591 @ GenerateUncached
@@ -2797,7 +2753,7 @@ static NativeSequenceStorage doNativeByte(Node inliningTarget, NativeSequenceSto
27972753 newCapacity = cap ;
27982754 }
27992755 Object mem = s .getPtr ();
2800- long elementSize = s . getElementType () == Byte ? 1 : CStructAccess .POINTER_SIZE ;
2756+ long elementSize = s instanceof NativeByteSequenceStorage ? 1 : CStructAccess .POINTER_SIZE ;
28012757 long bytes = elementSize * newCapacity ;
28022758 Object newMem = alloc .alloc (bytes );
28032759 if (lib .isNull (newMem )) {
@@ -2850,8 +2806,8 @@ static SequenceStorage doSpecial(SequenceStorage s,
28502806 return CompilerDirectives .castExact (CompilerDirectives .castExact (s , cachedClass ).copy (), cachedClass );
28512807 }
28522808
2853- @ Specialization ( guards = "isNativeBytesStorage(s)" )
2854- static SequenceStorage doNativeBytes (NativeSequenceStorage s ,
2809+ @ Specialization
2810+ static SequenceStorage doNativeBytes (NativeByteSequenceStorage s ,
28552811 @ Shared @ Cached (inline = false ) GetNativeItemScalarNode getItem ) {
28562812 byte [] bytes = new byte [s .length ()];
28572813 for (int i = 0 ; i < s .length (); i ++) {
@@ -2860,8 +2816,8 @@ static SequenceStorage doNativeBytes(NativeSequenceStorage s,
28602816 return new ByteSequenceStorage (bytes );
28612817 }
28622818
2863- @ Specialization ( guards = "isNativeObjectsStorage(s)" )
2864- static SequenceStorage doNativeObjects (NativeSequenceStorage s ,
2819+ @ Specialization
2820+ static SequenceStorage doNativeObjects (NativeObjectSequenceStorage s ,
28652821 @ Shared @ Cached (inline = false ) GetNativeItemScalarNode getItem ) {
28662822 Object [] objects = new Object [s .length ()];
28672823 for (int i = 0 ; i < s .length (); i ++) {
@@ -2879,14 +2835,6 @@ static SequenceStorage doGeneric(SequenceStorage s) {
28792835 protected static boolean isNativeStorage (SequenceStorage storage ) {
28802836 return storage instanceof NativeSequenceStorage ;
28812837 }
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- }
28902838 }
28912839
28922840 @ GenerateUncached
0 commit comments