Skip to content

Commit bc32295

Browse files
committed
Don't implement buffer API in EmptySequenceStorage
1 parent 32b0bdb commit bc32295

File tree

6 files changed

+6
-77
lines changed

6 files changed

+6
-77
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PBytesLike.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public PBytesLike(Object cls, Shape instanceShape, byte[] bytes) {
6767

6868
public PBytesLike(Object cls, Shape instanceShape, SequenceStorage store) {
6969
super(cls, instanceShape);
70+
assert store instanceof ByteSequenceStorage || store instanceof NativeByteSequenceStorage;
7071
this.store = store;
7172
}
7273

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,7 @@ static Object[] doEmpty(@SuppressWarnings("unused") EmptySequenceStorage s) {
29022902

29032903
@Specialization
29042904
static Object[] doNative(NativeSequenceStorage s,
2905-
@Cached GetNativeItemScalarNode getNativeItemScalarNode) {
2905+
@Cached(inline = false) GetNativeItemScalarNode getNativeItemScalarNode) {
29062906
Object[] result = new Object[s.length()];
29072907
for (int i = 0; i < s.length(); i++) {
29082908
result[i] = getNativeItemScalarNode.execute(s, i);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/BasicSequenceStorage.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public abstract class BasicSequenceStorage extends SequenceStorage {
4040

4141
public abstract SequenceStorage copy();
4242

43+
public abstract SequenceStorage getSliceInBound(int start, int stop, int step, int len);
44+
45+
public abstract SequenceStorage generalizeFor(Object value, SequenceStorage other);
46+
4347
public abstract Object[] getInternalArray();
4448

4549
public abstract Object[] getCopyOfInternalArray();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/EmptySequenceStorage.java

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,13 @@
2525
*/
2626
package com.oracle.graal.python.runtime.sequence.storage;
2727

28-
import java.nio.ByteOrder;
29-
30-
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
3128
import com.oracle.graal.python.util.PythonUtils;
3229
import com.oracle.truffle.api.CompilerAsserts;
33-
import com.oracle.truffle.api.library.ExportLibrary;
34-
import com.oracle.truffle.api.library.ExportMessage;
3530

36-
@ExportLibrary(PythonBufferAccessLibrary.class)
3731
public final class EmptySequenceStorage extends SequenceStorage {
3832

3933
public static final EmptySequenceStorage INSTANCE = new EmptySequenceStorage();
4034

41-
@Override
4235
public SequenceStorage generalizeFor(Object value, SequenceStorage target) {
4336
final SequenceStorage generalized;
4437

@@ -72,12 +65,6 @@ public Object getIndicativeValue() {
7265
return null;
7366
}
7467

75-
@Override
76-
public SequenceStorage getSliceInBound(int start, int stop, int step, int len) {
77-
assert start == stop && stop == 0;
78-
return this;
79-
}
80-
8168
@Override
8269
public ListStorageType getElementType() {
8370
return ListStorageType.Empty;
@@ -88,52 +75,4 @@ public String toString() {
8875
CompilerAsserts.neverPartOfCompilation();
8976
return "EmptySequenceStorage[]";
9077
}
91-
92-
@ExportMessage
93-
@SuppressWarnings("static-method")
94-
boolean isBuffer() {
95-
return true;
96-
}
97-
98-
@ExportMessage
99-
@SuppressWarnings("static-method")
100-
int getBufferLength() {
101-
return 0;
102-
}
103-
104-
@ExportMessage
105-
@SuppressWarnings("static-method")
106-
byte readByte(@SuppressWarnings("unused") int byteOffset) throws IndexOutOfBoundsException {
107-
throw new IndexOutOfBoundsException("EmptySequenceStorage is always empty!");
108-
}
109-
110-
@ExportMessage
111-
@SuppressWarnings({"static-method", "unused"})
112-
short readShortByteOrder(int byteOffset, ByteOrder byteOrder) throws IndexOutOfBoundsException {
113-
throw new IndexOutOfBoundsException("EmptySequenceStorage is always empty!");
114-
}
115-
116-
@ExportMessage
117-
@SuppressWarnings({"static-method", "unused"})
118-
int readIntByteOrder(int byteOffset, ByteOrder byteOrder) throws IndexOutOfBoundsException {
119-
throw new IndexOutOfBoundsException("EmptySequenceStorage is always empty!");
120-
}
121-
122-
@ExportMessage
123-
@SuppressWarnings({"static-method", "unused"})
124-
long readLongByteOrder(int byteOffset, ByteOrder byteOrder) throws IndexOutOfBoundsException {
125-
throw new IndexOutOfBoundsException("EmptySequenceStorage is always empty!");
126-
}
127-
128-
@ExportMessage
129-
@SuppressWarnings({"static-method", "unused"})
130-
float readFloatByteOrder(int byteOffset, ByteOrder byteOrder) throws IndexOutOfBoundsException {
131-
throw new IndexOutOfBoundsException("EmptySequenceStorage is always empty!");
132-
}
133-
134-
@ExportMessage
135-
@SuppressWarnings({"static-method", "unused"})
136-
double readDoubleByteOrder(int byteOffset, ByteOrder byteOrder) throws IndexOutOfBoundsException {
137-
throw new IndexOutOfBoundsException("EmptySequenceStorage is always empty!");
138-
}
13978
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/NativeSequenceStorage.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext;
4747
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeStorageReference;
4848
import com.oracle.graal.python.util.PythonUtils;
49-
import com.oracle.truffle.api.CompilerDirectives;
5049
import com.oracle.truffle.api.TruffleLogger;
5150

5251
public abstract class NativeSequenceStorage extends SequenceStorage {
@@ -97,16 +96,6 @@ public final void setNewLength(int length) {
9796
}
9897
}
9998

100-
@Override
101-
public final SequenceStorage getSliceInBound(int start, int stop, int step, int len) {
102-
throw CompilerDirectives.shouldNotReachHere();
103-
}
104-
105-
@Override
106-
public final SequenceStorage generalizeFor(Object value, SequenceStorage other) {
107-
throw CompilerDirectives.shouldNotReachHere();
108-
}
109-
11099
@Override
111100
public final Object getIndicativeValue() {
112101
return null;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/SequenceStorage.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,5 @@ public final int getCapacity() {
7979

8080
public abstract ListStorageType getElementType();
8181

82-
public abstract SequenceStorage getSliceInBound(int start, int stop, int step, int len);
83-
84-
public abstract SequenceStorage generalizeFor(Object value, SequenceStorage other);
85-
8682
public abstract Object getIndicativeValue();
8783
}

0 commit comments

Comments
 (0)