57
57
import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes .NoGeneralizationNode ;
58
58
import com .oracle .graal .python .builtins .objects .list .PList ;
59
59
import com .oracle .graal .python .builtins .objects .mmap .PMMap ;
60
+ import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
60
61
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
61
62
import com .oracle .graal .python .nodes .SpecialMethodNames ;
62
63
import com .oracle .graal .python .nodes .attributes .LookupInheritedAttributeNode ;
63
64
import com .oracle .graal .python .nodes .call .CallNode ;
64
- import com .oracle .graal .python .nodes .call .special .LookupAndCallUnaryNode .LookupAndCallUnaryDynamicNode ;
65
65
import com .oracle .graal .python .nodes .truffle .PythonTypes ;
66
66
import com .oracle .graal .python .nodes .util .CoerceToJavaLongNode ;
67
+ import com .oracle .graal .python .runtime .PythonOptions ;
67
68
import com .oracle .graal .python .runtime .sequence .PSequence ;
68
69
import com .oracle .graal .python .runtime .sequence .storage .EmptySequenceStorage ;
69
70
import com .oracle .graal .python .runtime .sequence .storage .NativeSequenceStorage ;
@@ -138,9 +139,8 @@ public boolean equals(Object obj) {
138
139
@ ExportMessage
139
140
final long getArraySize (
140
141
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
141
- @ Shared ("callLenNode" ) @ Cached LookupAndCallUnaryDynamicNode callLenNode ,
142
- @ Shared ("castToLongNode" ) @ Cached CoerceToJavaLongNode castToLongNode ) {
143
- return castToLongNode .execute (callLenNode .executeObject (lib .getDelegate (this ), SpecialMethodNames .__LEN__ ));
142
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
143
+ return objectLib .length (lib .getDelegate (this ));
144
144
}
145
145
146
146
@ ExportMessage
@@ -156,13 +156,16 @@ final Object readArrayElement(long index,
156
156
return readArrayItemNode .execute (lib .getDelegate (this ), index );
157
157
}
158
158
159
+ static int getCallSiteInlineCacheMaxDepth () {
160
+ return PythonOptions .getCallSiteInlineCacheMaxDepth ();
161
+ }
162
+
159
163
@ ExportMessage
160
164
final boolean isArrayElementReadable (long identifier ,
161
165
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
162
- @ Shared ("callLenNode" ) @ Cached LookupAndCallUnaryDynamicNode callLenNode ,
163
- @ Shared ("castToLongNode" ) @ Cached CoerceToJavaLongNode castToLongNode ) {
166
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
164
167
// also include the implicit null-terminator
165
- return 0 <= identifier && identifier <= getArraySize (lib , callLenNode , castToLongNode );
168
+ return 0 <= identifier && identifier <= getArraySize (lib , objectLib );
166
169
}
167
170
168
171
@ ImportStatic ({SpecialMethodNames .class , PySequenceArrayWrapper .class })
@@ -302,25 +305,22 @@ public void removeArrayElement(@SuppressWarnings("unused") long index) throws Un
302
305
@ ExportMessage
303
306
public boolean isArrayElementModifiable (long index ,
304
307
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
305
- @ Shared ("callLenNode" ) @ Cached LookupAndCallUnaryDynamicNode callLenNode ,
306
- @ Shared ("castToLongNode" ) @ Cached CoerceToJavaLongNode castToLongNode ) {
307
- return 0 <= index && index <= getArraySize (lib , callLenNode , castToLongNode );
308
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
309
+ return 0 <= index && index <= getArraySize (lib , objectLib );
308
310
}
309
311
310
312
@ ExportMessage
311
313
public boolean isArrayElementInsertable (long index ,
312
314
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
313
- @ Shared ("callLenNode" ) @ Cached LookupAndCallUnaryDynamicNode callLenNode ,
314
- @ Shared ("castToLongNode" ) @ Cached CoerceToJavaLongNode castToLongNode ) {
315
- return 0 <= index && index <= getArraySize (lib , callLenNode , castToLongNode );
315
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
316
+ return 0 <= index && index <= getArraySize (lib , objectLib );
316
317
}
317
318
318
319
@ ExportMessage
319
320
public boolean isArrayElementRemovable (long index ,
320
321
@ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
321
- @ Shared ("callLenNode" ) @ Cached LookupAndCallUnaryDynamicNode callLenNode ,
322
- @ Shared ("castToLongNode" ) @ Cached CoerceToJavaLongNode castToLongNode ) {
323
- return 0 <= index && index <= getArraySize (lib , callLenNode , castToLongNode );
322
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) PythonObjectLibrary objectLib ) {
323
+ return 0 <= index && index <= getArraySize (lib , objectLib );
324
324
}
325
325
326
326
@ GenerateUncached
0 commit comments