@@ -96,12 +96,14 @@ public static ReadAttributeFromObjectNode getUncachedForceType() {
96
96
97
97
public abstract Object execute (Object object , Object key );
98
98
99
+ protected static final int MAX_DICT_TYPES = 2 ;
100
+
99
101
// read from the DynamicObject store
100
102
@ Specialization (guards = {
101
103
"!lib.hasDict(object) || isHiddenKey(key)"
102
- }, limit = "1" )
104
+ })
103
105
protected Object readFromDynamicStorage (PythonObject object , Object key ,
104
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("object " ) PythonObjectLibrary lib ,
106
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "MAX_DICT_TYPES " ) PythonObjectLibrary lib ,
105
107
@ Cached ("create()" ) ReadAttributeFromDynamicObjectNode readAttributeFromDynamicObjectNode ) {
106
108
return readAttributeFromDynamicObjectNode .execute (object .getStorage (), key );
107
109
}
@@ -144,14 +146,14 @@ protected Object readFromBuiltinModuleDict(PythonModule object, String key,
144
146
}
145
147
146
148
// read from a builtin dict
147
- @ Specialization (guards = {"!isHiddenKey(key)" , "hasBuiltinDict(object, lib, isBuiltinDict, isBuiltinMappingproxy)" }, limit = "1" )
149
+ @ Specialization (guards = {"!isHiddenKey(key)" , "hasBuiltinDict(object, lib, isBuiltinDict, isBuiltinMappingproxy)" })
148
150
protected Object readFromBuiltinDict (PythonObject object , String key ,
149
- @ CachedLibrary ("object " ) PythonObjectLibrary lib ,
151
+ @ CachedLibrary (limit = "MAX_DICT_TYPES " ) PythonObjectLibrary lib ,
150
152
@ Cached HashingCollectionNodes .GetDictStorageNode getDictStorageNode ,
151
153
@ SuppressWarnings ("unused" ) @ Cached IsBuiltinClassProfile isBuiltinDict ,
152
154
@ SuppressWarnings ("unused" ) @ Cached IsBuiltinClassProfile isBuiltinMappingproxy ,
153
- @ CachedLibrary ( limit = "2" ) HashingStorageLibrary hlib ) { // limit 2: string
154
- // only or mixed dict
155
+ // limit 2: string only or mixed dict
156
+ @ CachedLibrary ( limit = "MAX_DICT_TYPES" ) HashingStorageLibrary hlib ) {
155
157
Object value = hlib .getItem (getDictStorageNode .execute (lib .getDict (object )), key );
156
158
if (value == null ) {
157
159
return PNone .NO_VALUE ;
@@ -164,11 +166,11 @@ protected Object readFromBuiltinDict(PythonObject object, String key,
164
166
@ Specialization (guards = {
165
167
"!isHiddenKey(key)" ,
166
168
"lib.hasDict(object)"
167
- }, replaces = {"readFromBuiltinDict" , "readFromBuiltinModuleDict" }, limit = "1" )
169
+ }, replaces = {"readFromBuiltinDict" , "readFromBuiltinModuleDict" })
168
170
protected Object readFromDict (PythonObject object , Object key ,
169
- @ CachedLibrary ("object " ) PythonObjectLibrary lib ,
171
+ @ CachedLibrary (limit = "MAX_DICT_TYPES " ) PythonObjectLibrary lib ,
170
172
@ Cached HashingCollectionNodes .GetDictStorageNode getDictStorage ,
171
- @ CachedLibrary (limit = "1 " ) HashingStorageLibrary hlib ) {
173
+ @ CachedLibrary (limit = "MAX_DICT_TYPES " ) HashingStorageLibrary hlib ) {
172
174
Object value = hlib .getItem (getDictStorage .execute (lib .getDict (object )), key );
173
175
if (value == null ) {
174
176
return PNone .NO_VALUE ;
@@ -178,10 +180,10 @@ protected Object readFromDict(PythonObject object, Object key,
178
180
}
179
181
180
182
// foreign Object
181
- @ Specialization (guards = "plib.isForeignObject(object)" , limit = "3" )
183
+ @ Specialization (guards = "plib.isForeignObject(object)" )
182
184
protected Object readForeign (TruffleObject object , Object key ,
183
185
@ Cached CastToJavaStringNode castNode ,
184
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("object " ) PythonObjectLibrary plib ,
186
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "MAX_DICT_TYPES " ) PythonObjectLibrary plib ,
185
187
@ Cached PForeignToPTypeNode fromForeign ,
186
188
@ CachedLibrary (limit = "getAttributeAccessInlineCacheMaxDepth()" ) InteropLibrary read ) {
187
189
try {
@@ -196,9 +198,9 @@ protected Object readForeign(TruffleObject object, Object key,
196
198
197
199
// not a Python or Foreign Object
198
200
@ SuppressWarnings ("unused" )
199
- @ Specialization (guards = {"!isPythonObject(object)" , "!isNativeObject(object)" , "!plib.isForeignObject(object)" }, limit = "3" )
201
+ @ Specialization (guards = {"!isPythonObject(object)" , "!isNativeObject(object)" , "!plib.isForeignObject(object)" })
200
202
protected PNone readUnboxed (Object object , Object key ,
201
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("object " ) PythonObjectLibrary plib ) {
203
+ @ SuppressWarnings ("unused" ) @ CachedLibrary (limit = "MAX_DICT_TYPES " ) PythonObjectLibrary plib ) {
202
204
return PNone .NO_VALUE ;
203
205
}
204
206
@@ -208,11 +210,11 @@ protected PNone readUnboxed(Object object, Object key,
208
210
209
211
@ GenerateUncached
210
212
protected abstract static class ReadAttributeFromObjectNotTypeNode extends ReadAttributeFromObjectNode {
211
- @ Specialization (guards = {"!isHiddenKey(key)" }, insertBefore = "readForeign" , limit = "1" )
213
+ @ Specialization (guards = {"!isHiddenKey(key)" }, insertBefore = "readForeign" )
212
214
protected Object readNativeObject (PythonAbstractNativeObject object , Object key ,
213
- @ CachedLibrary ("object " ) PythonObjectLibrary lib ,
215
+ @ CachedLibrary (limit = "MAX_DICT_TYPES " ) PythonObjectLibrary lib ,
214
216
@ Cached HashingCollectionNodes .GetDictStorageNode getDictStorage ,
215
- @ CachedLibrary (limit = "1 " ) HashingStorageLibrary hlib ) {
217
+ @ CachedLibrary (limit = "3 " ) HashingStorageLibrary hlib ) {
216
218
return readNative (key , lib .getDict (object ), hlib , getDictStorage );
217
219
}
218
220
@@ -228,7 +230,7 @@ protected abstract static class ReadAttributeFromObjectTpDictNode extends ReadAt
228
230
protected Object readNativeClass (PythonNativeClass object , Object key ,
229
231
@ Cached HashingCollectionNodes .GetDictStorageNode getDictStorage ,
230
232
@ Cached GetTypeMemberNode getNativeDict ,
231
- @ CachedLibrary (limit = "1 " ) HashingStorageLibrary hlib ) {
233
+ @ CachedLibrary (limit = "MAX_DICT_TYPES " ) HashingStorageLibrary hlib ) {
232
234
return readNative (key , getNativeDict .execute (object , NativeMember .TP_DICT ), hlib , getDictStorage );
233
235
}
234
236
0 commit comments