134134import com .oracle .graal .python .runtime .interop .InteropArray ;
135135import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
136136import 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 ;
137139import com .oracle .truffle .api .CompilerAsserts ;
138140import com .oracle .truffle .api .CompilerDirectives ;
139141import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
@@ -610,12 +612,22 @@ int doMaUsed(PDict object, @SuppressWarnings("unused") String key,
610612 }
611613
612614 @ 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+ }
614621 return new PySequenceArrayWrapper (object , 1 );
615622 }
616623
617624 @ 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+ }
619631 return new PySequenceArrayWrapper (object , 1 );
620632 }
621633
@@ -632,7 +644,12 @@ Object doObFval(Object object, @SuppressWarnings("unused") String key,
632644 }
633645
634646 @ 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+ }
636653 return new PySequenceArrayWrapper (object , 4 );
637654 }
638655
0 commit comments