47
47
import com .oracle .graal .python .runtime .sequence .storage .SequenceStorage ;
48
48
import com .oracle .truffle .api .CompilerDirectives ;
49
49
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
50
- import com .oracle .truffle .api .dsl .Bind ;
51
50
import com .oracle .truffle .api .dsl .Cached ;
52
51
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
53
52
import com .oracle .truffle .api .dsl .Cached .Shared ;
@@ -152,15 +151,16 @@ static int nativeString(PString self, @SuppressWarnings("unused") ThreadState st
152
151
"isBuiltin(self, profile) || hasBuiltinLen(self, lookupSelf, lookupString)"
153
152
}, replaces = "nativeString" , limit = "1" )
154
153
static int nativeStringMat (PString self , @ SuppressWarnings ("unused" ) ThreadState state ,
155
- @ Bind ("getNativeCharSequence(self)" ) NativeCharSequence nativeCharSequence ,
156
154
@ SuppressWarnings ("unused" ) @ Shared ("builtinProfile" ) @ Cached IsBuiltinClassProfile profile ,
157
155
@ SuppressWarnings ("unused" ) @ Shared ("lookupSelf" ) @ Cached LookupInheritedAttributeNode .Dynamic lookupSelf ,
158
156
@ SuppressWarnings ("unused" ) @ Shared ("lookupString" ) @ Cached LookupAttributeInMRONode .Dynamic lookupString ,
159
- @ CachedLibrary ("nativeCharSequence.getPtr() " ) InteropLibrary lib ,
157
+ @ CachedLibrary (limit = "1 " ) InteropLibrary lib ,
160
158
@ Cached CastToJavaIntExactNode castToJavaIntNode ,
161
159
@ Shared ("stringMaterializeNode" ) @ Cached StringMaterializeNode materializeNode ) {
162
- if (lib .hasArrayElements (nativeCharSequence .getPtr ())) {
163
- return nativeCharSequence .length (lib , castToJavaIntNode );
160
+ // this cast is guaranteed by cast 'isNativeString(self.getCharSequence())'
161
+ NativeCharSequence value = (NativeCharSequence ) self .value ;
162
+ if (lib .hasArrayElements (value .getPtr ())) {
163
+ return value .length (lib , castToJavaIntNode );
164
164
} else {
165
165
return materializeNode .execute (self ).length ();
166
166
}
@@ -180,10 +180,6 @@ static int subclassedString(PString self, ThreadState state,
180
180
// call the generic implementation in the superclass
181
181
return self .lengthWithState (state , plib , methodLib , hasLen , ltZero , raiseNode , lib , toLong , ignoreOverflow , overflow );
182
182
}
183
-
184
- static NativeCharSequence getNativeCharSequence (PString self ) {
185
- return (NativeCharSequence ) self .value ;
186
- }
187
183
}
188
184
189
185
@ ExportMessage
0 commit comments