Skip to content

Commit f78158f

Browse files
committed
Remove CharSequenceStorage
1 parent 60a65bc commit f78158f

File tree

4 files changed

+4
-274
lines changed

4 files changed

+4
-274
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java

Lines changed: 4 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
4444
import static com.oracle.graal.python.runtime.sequence.storage.SequenceStorage.ListStorageType.Boolean;
4545
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;
4746
import static com.oracle.graal.python.runtime.sequence.storage.SequenceStorage.ListStorageType.Double;
4847
import static com.oracle.graal.python.runtime.sequence.storage.SequenceStorage.ListStorageType.Empty;
4948
import static com.oracle.graal.python.runtime.sequence.storage.SequenceStorage.ListStorageType.Int;
@@ -133,7 +132,6 @@
133132
import com.oracle.graal.python.runtime.sequence.storage.BasicSequenceStorage;
134133
import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage;
135134
import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage;
136-
import com.oracle.graal.python.runtime.sequence.storage.CharSequenceStorage;
137135
import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage;
138136
import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage;
139137
import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage;
@@ -178,13 +176,13 @@
178176

179177
public abstract class SequenceStorageNodes {
180178

181-
public static interface GenNodeSupplier {
179+
public interface GenNodeSupplier {
182180
GeneralizationNode create();
183181

184182
GeneralizationNode getUncached();
185183
}
186184

187-
public static interface ContainerFactory {
185+
public interface ContainerFactory {
188186

189187
Object apply(SequenceStorage s, PythonObjectFactory factory);
190188
}
@@ -212,8 +210,6 @@ static boolean compatibleAssign(SequenceStorage lhs, SequenceStorage rhs,
212210
return rhsType == Boolean || rhsType == Byte || rhsType == Int || rhsType == Long || rhsType == Uninitialized || rhsType == Empty;
213211
case Double:
214212
return rhsType == Double || rhsType == Uninitialized || rhsType == Empty;
215-
case Char:
216-
return rhsType == Char || rhsType == Uninitialized || rhsType == Empty;
217213
case Tuple:
218214
return rhsType == Tuple || rhsType == Uninitialized || rhsType == Empty;
219215
case List:
@@ -257,8 +253,6 @@ static boolean compatibleAssign(SequenceStorage lhs, SequenceStorage rhs,
257253
return rhsType == Boolean || rhsType == Byte || rhsType == Int || rhsType == Long || rhsType == Uninitialized || rhsType == Empty;
258254
case Double:
259255
return rhsType == Double || rhsType == Uninitialized || rhsType == Empty;
260-
case Char:
261-
return rhsType == Char || rhsType == Uninitialized || rhsType == Empty;
262256
case Tuple:
263257
return rhsType == Tuple || rhsType == Uninitialized || rhsType == Empty;
264258
case List:
@@ -287,7 +281,7 @@ abstract static class SequenceStorageBaseNode extends PNodeWithContext {
287281

288282
protected static final int DEFAULT_CAPACITY = 8;
289283

290-
protected static final int MAX_SEQUENCE_STORAGES = 13;
284+
protected static final int MAX_SEQUENCE_STORAGES = 11;
291285
protected static final int MAX_ARRAY_STORAGES = 9;
292286

293287
protected static boolean isByteStorage(NativeSequenceStorage store) {
@@ -303,8 +297,6 @@ protected static boolean compatible(SequenceStorage left, NativeSequenceStorage
303297
return left instanceof BoolSequenceStorage;
304298
case Byte:
305299
return left instanceof ByteSequenceStorage;
306-
case Char:
307-
return left instanceof CharSequenceStorage;
308300
case Int:
309301
return left instanceof IntSequenceStorage;
310302
case Long:
@@ -338,10 +330,6 @@ protected static boolean isByteLike(GetElementType getElementTypeNode, SequenceS
338330
return isByte(getElementTypeNode, s) || isInt(getElementTypeNode, s) || isLong(getElementTypeNode, s);
339331
}
340332

341-
protected static boolean isChar(GetElementType getElementTypeNode, SequenceStorage s) {
342-
return getElementTypeNode.execute(s) == ListStorageType.Char;
343-
}
344-
345333
protected static boolean isInt(GetElementType getElementTypeNode, SequenceStorage s) {
346334
return getElementTypeNode.execute(s) == ListStorageType.Int;
347335
}
@@ -378,10 +366,6 @@ protected static boolean isByteLike(ListStorageType et) {
378366
return isByte(et) || isInt(et) || isLong(et);
379367
}
380368

381-
protected static boolean isChar(ListStorageType et) {
382-
return et == ListStorageType.Char;
383-
}
384-
385369
protected static boolean isInt(ListStorageType et) {
386370
return et == ListStorageType.Int;
387371
}
@@ -708,11 +692,6 @@ protected static int doByte(ByteSequenceStorage storage, int idx) {
708692
return storage.getIntItemNormalized(idx);
709693
}
710694

711-
@Specialization
712-
protected static char doChar(CharSequenceStorage storage, int idx) {
713-
return storage.getCharItemNormalized(idx);
714-
}
715-
716695
@Specialization
717696
protected static int doInt(IntSequenceStorage storage, int idx) {
718697
return storage.getIntItemNormalized(idx);
@@ -1224,11 +1203,6 @@ protected static void doByte(ByteSequenceStorage storage, int idx, Object value,
12241203
storage.setByteItemNormalized(idx, castToByteNode.execute(null, value));
12251204
}
12261205

1227-
@Specialization
1228-
protected static void doChar(CharSequenceStorage storage, int idx, char value) {
1229-
storage.setCharItemNormalized(idx, value);
1230-
}
1231-
12321206
@Specialization
12331207
protected static void doInt(IntSequenceStorage storage, int idx, int value) {
12341208
storage.setIntItemNormalized(idx, value);
@@ -1969,20 +1943,6 @@ boolean doByteStorage(ByteSequenceStorage left, ByteSequenceStorage right) {
19691943
return cmpOp.cmp(llen, rlen);
19701944
}
19711945

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-
19861946
@Specialization
19871947
boolean doIntStorage(IntSequenceStorage left, IntSequenceStorage right) {
19881948
int llen = left.length();
@@ -2200,7 +2160,7 @@ static void doByteSequenceStorage(byte[] src, int srcPos, ByteSequenceStorage de
22002160

22012161
@Specialization(guards = "isByteStorage(dest)")
22022162
static void doNativeByte(byte[] src, int srcPos, NativeSequenceStorage dest, int destPos, int lenght,
2203-
@Cached SetItemScalarNode setItemNode) {
2163+
@Cached SetItemScalarNode setItemNode) {
22042164
for (int i = 0; i < lenght; i++) {
22052165
setItemNode.execute(dest, destPos + i, src[srcPos + i]);
22062166
}
@@ -2629,24 +2589,6 @@ ByteSequenceStorage doByteSingleElement(ByteSequenceStorage s, int times,
26292589
}
26302590
}
26312591

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-
26502592
/* special but common case: something like '[0] * n' */
26512593
@Specialization(guards = {"s.length() == 1", "times > 0"})
26522594
IntSequenceStorage doIntSingleElement(IntSequenceStorage s, int times,
@@ -3262,10 +3204,6 @@ protected boolean isByteLike(SequenceStorage s) {
32623204
return isByte(s) || isInt(s) || isLong(s);
32633205
}
32643206

3265-
protected boolean isChar(SequenceStorage s) {
3266-
return getElementType(s) == ListStorageType.Char;
3267-
}
3268-
32693207
protected boolean isDouble(SequenceStorage s) {
32703208
return getElementType(s) == ListStorageType.Double;
32713209
}
@@ -3302,16 +3240,6 @@ static ByteSequenceStorage doByte(@SuppressWarnings("unused") SequenceStorage s,
33023240
return ss;
33033241
}
33043242

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-
33153243
@Specialization(guards = "isInt(s)")
33163244
static IntSequenceStorage doInt(@SuppressWarnings("unused") SequenceStorage s, int cap, int len) {
33173245
IntSequenceStorage ss = new IntSequenceStorage(cap);
@@ -3899,17 +3827,6 @@ int doByte(SequenceStorage s, byte item, int start, int end,
38993827
return -1;
39003828
}
39013829

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-
39133830
@Specialization(guards = "isInt(getElementType, s)")
39143831
int doInt(SequenceStorage s, int item, int start, int end,
39153832
@Cached @SuppressWarnings("unused") GetElementType getElementType) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/literal/SequenceLiteralNode.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ protected SequenceStorage createSequenceStorageForDirect(VirtualFrame frame) {
129129
storage = new ByteSequenceStorage(elements, values.length);
130130
break;
131131
}
132-
case Char: {
133-
// we don't support this directly, throw and continue
134-
// generically
135-
CompilerDirectives.transferToInterpreterAndInvalidate();
136-
throw new UnexpectedResultException(values[0].execute(frame));
137-
}
138132
case Int: {
139133
int[] elements = new int[getCapacityEstimate()];
140134
array = elements;

0 commit comments

Comments
 (0)