134
134
import com .oracle .graal .python .runtime .interop .InteropArray ;
135
135
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
136
136
import com .oracle .graal .python .runtime .sequence .PSequence ;
137
+ import com .oracle .graal .python .runtime .sequence .storage .NativeSequenceStorage ;
138
+ import com .oracle .graal .python .runtime .sequence .storage .SequenceStorage ;
137
139
import com .oracle .truffle .api .CompilerAsserts ;
138
140
import com .oracle .truffle .api .CompilerDirectives ;
139
141
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
@@ -610,12 +612,22 @@ int doMaUsed(PDict object, @SuppressWarnings("unused") String key,
610
612
}
611
613
612
614
@ Specialization (guards = "eq(OB_SVAL, key)" )
613
- Object doObSval (PBytes object , @ SuppressWarnings ("unused" ) String key ) {
615
+ Object doObSval (PBytes object , @ SuppressWarnings ("unused" ) String key ,
616
+ @ Cached ("createClassProfile()" ) ValueProfile classProfile ) {
617
+ SequenceStorage sequenceStorage = classProfile .profile (object .getSequenceStorage ());
618
+ if (sequenceStorage instanceof NativeSequenceStorage ) {
619
+ return ((NativeSequenceStorage ) sequenceStorage ).getPtr ();
620
+ }
614
621
return new PySequenceArrayWrapper (object , 1 );
615
622
}
616
623
617
624
@ Specialization (guards = "eq(OB_START, key)" )
618
- Object doObStart (PByteArray object , @ SuppressWarnings ("unused" ) String key ) {
625
+ Object doObStart (PByteArray object , @ SuppressWarnings ("unused" ) String key ,
626
+ @ Cached ("createClassProfile()" ) ValueProfile classProfile ) {
627
+ SequenceStorage sequenceStorage = classProfile .profile (object .getSequenceStorage ());
628
+ if (sequenceStorage instanceof NativeSequenceStorage ) {
629
+ return ((NativeSequenceStorage ) sequenceStorage ).getPtr ();
630
+ }
619
631
return new PySequenceArrayWrapper (object , 1 );
620
632
}
621
633
@@ -632,7 +644,12 @@ Object doObFval(Object object, @SuppressWarnings("unused") String key,
632
644
}
633
645
634
646
@ Specialization (guards = "eq(OB_ITEM, key)" )
635
- Object doObItem (PSequence object , @ SuppressWarnings ("unused" ) String key ) {
647
+ Object doObItem (PSequence object , @ SuppressWarnings ("unused" ) String key ,
648
+ @ Cached ("createClassProfile()" ) ValueProfile classProfile ) {
649
+ SequenceStorage sequenceStorage = classProfile .profile (object .getSequenceStorage ());
650
+ if (sequenceStorage instanceof NativeSequenceStorage ) {
651
+ return ((NativeSequenceStorage ) sequenceStorage ).getPtr ();
652
+ }
636
653
return new PySequenceArrayWrapper (object , 4 );
637
654
}
638
655
0 commit comments