96
96
import com .oracle .graal .python .builtins .objects .bytes .BytesBuiltins ;
97
97
import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
98
98
import com .oracle .graal .python .builtins .objects .common .HashingStorageLibrary ;
99
- import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
99
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .EnsureCapacityNode ;
100
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .GetInternalArrayNode ;
101
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .GetInternalByteArrayNode ;
102
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .GetInternalObjectArrayNode ;
103
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .SetLenNode ;
100
104
import com .oracle .graal .python .builtins .objects .dict .PDict ;
101
105
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
102
106
import com .oracle .graal .python .lib .PyIndexCheckNode ;
@@ -204,7 +208,7 @@ Object exportsError(PBytesIO self, Object size) {
204
208
}
205
209
206
210
static PBytes readBytes (PBytesIO self , int size ,
207
- SequenceStorageNodes . GetInternalByteArrayNode getBytes ,
211
+ GetInternalByteArrayNode getBytes ,
208
212
PythonObjectFactory factory ) {
209
213
if (size == 0 ) {
210
214
return factory .createBytes (PythonUtils .EMPTY_BYTE_ARRAY );
@@ -235,7 +239,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
235
239
236
240
@ Specialization (guards = "self.hasBuf()" )
237
241
Object read (PBytesIO self , int len ,
238
- @ Cached SequenceStorageNodes . GetInternalByteArrayNode getBytes ) {
242
+ @ Cached GetInternalByteArrayNode getBytes ) {
239
243
int size = len ;
240
244
/* adjust invalid sizes */
241
245
int n = self .getStringSize () - self .getPos ();
@@ -261,7 +265,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
261
265
}
262
266
263
267
static int scanEOL (PBytesIO self , int l ,
264
- SequenceStorageNodes . GetInternalByteArrayNode getBytes ) {
268
+ GetInternalByteArrayNode getBytes ) {
265
269
assert (self .hasBuf ());
266
270
assert (self .getPos () >= 0 );
267
271
@@ -308,7 +312,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
308
312
309
313
@ Specialization (guards = "self.hasBuf()" )
310
314
Object readline (PBytesIO self , int size ,
311
- @ Cached SequenceStorageNodes . GetInternalByteArrayNode getBytes ) {
315
+ @ Cached GetInternalByteArrayNode getBytes ) {
312
316
int n = scanEOL (self , size , getBytes );
313
317
return readBytes (self , n , getBytes , factory ());
314
318
}
@@ -326,7 +330,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
326
330
327
331
@ Specialization (guards = "self.hasBuf()" )
328
332
Object readlines (PBytesIO self , int maxsize ,
329
- @ Cached SequenceStorageNodes . GetInternalByteArrayNode getBytes ) {
333
+ @ Cached GetInternalByteArrayNode getBytes ) {
330
334
ArrayBuilder <Object > result = new ArrayBuilder <>();
331
335
332
336
int n ;
@@ -396,15 +400,15 @@ protected ArgumentClinicProvider getArgumentClinic() {
396
400
397
401
@ Specialization (guards = {"self.hasBuf()" , "checkExports(self)" })
398
402
Object truncate (PBytesIO self , @ SuppressWarnings ("unused" ) PNone size ,
399
- @ Shared ("i" ) @ Cached SequenceStorageNodes . GetInternalArrayNode internalArray ,
400
- @ Shared ("l" ) @ Cached SequenceStorageNodes . SetLenNode setLenNode ) {
403
+ @ Shared ("i" ) @ Cached GetInternalArrayNode internalArray ,
404
+ @ Shared ("l" ) @ Cached SetLenNode setLenNode ) {
401
405
return truncate (self , self .getPos (), internalArray , setLenNode );
402
406
}
403
407
404
408
@ Specialization (guards = {"self.hasBuf()" , "checkExports(self)" , "size >= 0" , "size < self.getStringSize()" })
405
409
Object truncate (PBytesIO self , int size ,
406
- @ Shared ("i" ) @ Cached SequenceStorageNodes . GetInternalArrayNode internalArray ,
407
- @ Shared ("l" ) @ Cached SequenceStorageNodes . SetLenNode setLenNode ) {
410
+ @ Shared ("i" ) @ Cached GetInternalArrayNode internalArray ,
411
+ @ Shared ("l" ) @ Cached SetLenNode setLenNode ) {
408
412
self .setStringSize (size );
409
413
resizeBuffer (self , size , internalArray , factory ());
410
414
setLenNode .execute (self .getBuf ().getSequenceStorage (), size );
@@ -420,8 +424,8 @@ static Object same(@SuppressWarnings("unused") PBytesIO self, int size) {
420
424
Object obj (VirtualFrame frame , PBytesIO self , Object arg ,
421
425
@ Cached PyNumberAsSizeNode asSizeNode ,
422
426
@ Cached PyNumberIndexNode indexNode ,
423
- @ Shared ("i" ) @ Cached SequenceStorageNodes . GetInternalArrayNode internalArray ,
424
- @ Shared ("l" ) @ Cached SequenceStorageNodes . SetLenNode setLenNode ) {
427
+ @ Shared ("i" ) @ Cached GetInternalArrayNode internalArray ,
428
+ @ Shared ("l" ) @ Cached SetLenNode setLenNode ) {
425
429
int size = asSizeNode .executeExact (frame , indexNode .execute (frame , arg ), OverflowError );
426
430
if (size >= 0 ) {
427
431
if (size < self .getStringSize ()) {
@@ -459,14 +463,14 @@ protected static void unshareBuffer(PBytesIO self, int size, byte[] buf,
459
463
}
460
464
461
465
protected static void unshareBuffer (PBytesIO self , int size ,
462
- SequenceStorageNodes . GetInternalArrayNode internalArray ,
466
+ GetInternalArrayNode internalArray ,
463
467
PythonObjectFactory factory ) {
464
468
byte [] buf = (byte []) internalArray .execute (self .getBuf ().getSequenceStorage ());
465
469
unshareBuffer (self , size , buf , factory );
466
470
}
467
471
468
472
protected static void resizeBuffer (PBytesIO self , int size ,
469
- SequenceStorageNodes . GetInternalArrayNode internalArray ,
473
+ GetInternalArrayNode internalArray ,
470
474
PythonObjectFactory factory ) {
471
475
int alloc = self .getStringSize ();
472
476
if (size < alloc ) {
@@ -486,9 +490,9 @@ abstract static class WriteNode extends ClosedCheckPythonBinaryBuiltinNode {
486
490
Object doWrite (PBytesIO self , Object b ,
487
491
@ CachedLibrary ("b" ) PythonBufferAcquireLibrary acquireLib ,
488
492
@ CachedLibrary (limit = "2" ) PythonBufferAccessLibrary bufferLib ,
489
- @ Cached SequenceStorageNodes . GetInternalArrayNode internalArray ,
490
- @ Cached SequenceStorageNodes . EnsureCapacityNode ensureCapacityNode ,
491
- @ Cached SequenceStorageNodes . SetLenNode setLenNode ) {
493
+ @ Cached GetInternalArrayNode internalArray ,
494
+ @ Cached EnsureCapacityNode ensureCapacityNode ,
495
+ @ Cached SetLenNode setLenNode ) {
492
496
Object buffer = acquireLib .acquireReadonly (b );
493
497
try {
494
498
int len = bufferLib .getBufferLength (buffer );
@@ -661,7 +665,7 @@ Object closedError(PBytesIO self, int pos, int whence) {
661
665
abstract static class GetBufferNode extends ClosedCheckPythonUnaryBuiltinNode {
662
666
@ Specialization (guards = "self.hasBuf()" )
663
667
Object doit (VirtualFrame frame , PBytesIO self ,
664
- @ Cached SequenceStorageNodes . GetInternalArrayNode internalArray ,
668
+ @ Cached GetInternalArrayNode internalArray ,
665
669
@ Cached PyMemoryViewFromObject memoryViewNode ) {
666
670
// if (SHARED_BUF(b))
667
671
unshareBuffer (self , self .getStringSize (), internalArray , factory ());
@@ -686,7 +690,7 @@ protected static boolean shouldUnshare(PBytesIO self) {
686
690
687
691
@ Specialization (guards = {"self.hasBuf()" , "shouldCopy(self)" })
688
692
Object copy (PBytesIO self ,
689
- @ Cached SequenceStorageNodes . GetInternalByteArrayNode getBytes ) {
693
+ @ Cached GetInternalByteArrayNode getBytes ) {
690
694
byte [] buf = getBytes .execute (self .getBuf ().getSequenceStorage ());
691
695
return factory ().createBytes (PythonUtils .arrayCopyOf (buf , self .getStringSize ()));
692
696
}
@@ -698,7 +702,7 @@ static Object doit(PBytesIO self) {
698
702
699
703
@ Specialization (guards = {"self.hasBuf()" , "!shouldCopy(self)" , "shouldUnshare(self)" })
700
704
Object unshare (PBytesIO self ,
701
- @ Cached SequenceStorageNodes . GetInternalArrayNode internalArray ) {
705
+ @ Cached GetInternalArrayNode internalArray ) {
702
706
// if (SHARED_BUF(self))
703
707
unshareBuffer (self , self .getStringSize (), internalArray , factory ());
704
708
// else resize self.buf
@@ -724,7 +728,7 @@ Object doit(VirtualFrame frame, PBytesIO self,
724
728
abstract static class SetStateNode extends PythonBinaryBuiltinNode {
725
729
@ Specialization (guards = "checkExports(self)" )
726
730
Object doit (VirtualFrame frame , PBytesIO self , PTuple state ,
727
- @ Cached SequenceStorageNodes . GetInternalObjectArrayNode getArray ,
731
+ @ Cached GetInternalObjectArrayNode getArray ,
728
732
@ Cached WriteNode writeNode ,
729
733
@ Cached PyIndexCheckNode indexCheckNode ,
730
734
@ Cached PyNumberAsSizeNode asSizeNode ,
@@ -867,7 +871,7 @@ abstract static class IternextNode extends ClosedCheckPythonUnaryBuiltinNode {
867
871
868
872
@ Specialization (guards = "self.hasBuf()" )
869
873
Object doit (PBytesIO self ,
870
- @ Cached SequenceStorageNodes . GetInternalByteArrayNode getBytes ) {
874
+ @ Cached GetInternalByteArrayNode getBytes ) {
871
875
int n = scanEOL (self , -1 , getBytes );
872
876
if (n == 0 ) {
873
877
throw raise (StopIteration );
0 commit comments