Skip to content

Commit 9528681

Browse files
committed
Adjust library limit for ReadAttributeFromObjectNode
1 parent 5c2de30 commit 9528681

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/ReadAttributeFromObjectNode.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ public static ReadAttributeFromObjectNode getUncachedForceType() {
9696

9797
public abstract Object execute(Object object, Object key);
9898

99+
protected static final int MAX_DICT_TYPES = 2;
100+
99101
// read from the DynamicObject store
100102
@Specialization(guards = {
101103
"!lib.hasDict(object) || isHiddenKey(key)"
102-
}, limit = "1")
104+
})
103105
protected Object readFromDynamicStorage(PythonObject object, Object key,
104-
@SuppressWarnings("unused") @CachedLibrary("object") PythonObjectLibrary lib,
106+
@SuppressWarnings("unused") @CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary lib,
105107
@Cached("create()") ReadAttributeFromDynamicObjectNode readAttributeFromDynamicObjectNode) {
106108
return readAttributeFromDynamicObjectNode.execute(object.getStorage(), key);
107109
}
@@ -144,14 +146,14 @@ protected Object readFromBuiltinModuleDict(PythonModule object, String key,
144146
}
145147

146148
// 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)"})
148150
protected Object readFromBuiltinDict(PythonObject object, String key,
149-
@CachedLibrary("object") PythonObjectLibrary lib,
151+
@CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary lib,
150152
@Cached HashingCollectionNodes.GetDictStorageNode getDictStorageNode,
151153
@SuppressWarnings("unused") @Cached IsBuiltinClassProfile isBuiltinDict,
152154
@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) {
155157
Object value = hlib.getItem(getDictStorageNode.execute(lib.getDict(object)), key);
156158
if (value == null) {
157159
return PNone.NO_VALUE;
@@ -164,11 +166,11 @@ protected Object readFromBuiltinDict(PythonObject object, String key,
164166
@Specialization(guards = {
165167
"!isHiddenKey(key)",
166168
"lib.hasDict(object)"
167-
}, replaces = {"readFromBuiltinDict", "readFromBuiltinModuleDict"}, limit = "1")
169+
}, replaces = {"readFromBuiltinDict", "readFromBuiltinModuleDict"})
168170
protected Object readFromDict(PythonObject object, Object key,
169-
@CachedLibrary("object") PythonObjectLibrary lib,
171+
@CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary lib,
170172
@Cached HashingCollectionNodes.GetDictStorageNode getDictStorage,
171-
@CachedLibrary(limit = "1") HashingStorageLibrary hlib) {
173+
@CachedLibrary(limit = "MAX_DICT_TYPES") HashingStorageLibrary hlib) {
172174
Object value = hlib.getItem(getDictStorage.execute(lib.getDict(object)), key);
173175
if (value == null) {
174176
return PNone.NO_VALUE;
@@ -178,10 +180,10 @@ protected Object readFromDict(PythonObject object, Object key,
178180
}
179181

180182
// foreign Object
181-
@Specialization(guards = "plib.isForeignObject(object)", limit = "3")
183+
@Specialization(guards = "plib.isForeignObject(object)")
182184
protected Object readForeign(TruffleObject object, Object key,
183185
@Cached CastToJavaStringNode castNode,
184-
@SuppressWarnings("unused") @CachedLibrary("object") PythonObjectLibrary plib,
186+
@SuppressWarnings("unused") @CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary plib,
185187
@Cached PForeignToPTypeNode fromForeign,
186188
@CachedLibrary(limit = "getAttributeAccessInlineCacheMaxDepth()") InteropLibrary read) {
187189
try {
@@ -196,9 +198,9 @@ protected Object readForeign(TruffleObject object, Object key,
196198

197199
// not a Python or Foreign Object
198200
@SuppressWarnings("unused")
199-
@Specialization(guards = {"!isPythonObject(object)", "!isNativeObject(object)", "!plib.isForeignObject(object)"}, limit = "3")
201+
@Specialization(guards = {"!isPythonObject(object)", "!isNativeObject(object)", "!plib.isForeignObject(object)"})
200202
protected PNone readUnboxed(Object object, Object key,
201-
@SuppressWarnings("unused") @CachedLibrary("object") PythonObjectLibrary plib) {
203+
@SuppressWarnings("unused") @CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary plib) {
202204
return PNone.NO_VALUE;
203205
}
204206

@@ -208,11 +210,11 @@ protected PNone readUnboxed(Object object, Object key,
208210

209211
@GenerateUncached
210212
protected abstract static class ReadAttributeFromObjectNotTypeNode extends ReadAttributeFromObjectNode {
211-
@Specialization(guards = {"!isHiddenKey(key)"}, insertBefore = "readForeign", limit = "1")
213+
@Specialization(guards = {"!isHiddenKey(key)"}, insertBefore = "readForeign")
212214
protected Object readNativeObject(PythonAbstractNativeObject object, Object key,
213-
@CachedLibrary("object") PythonObjectLibrary lib,
215+
@CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary lib,
214216
@Cached HashingCollectionNodes.GetDictStorageNode getDictStorage,
215-
@CachedLibrary(limit = "1") HashingStorageLibrary hlib) {
217+
@CachedLibrary(limit = "3") HashingStorageLibrary hlib) {
216218
return readNative(key, lib.getDict(object), hlib, getDictStorage);
217219
}
218220

@@ -228,7 +230,7 @@ protected abstract static class ReadAttributeFromObjectTpDictNode extends ReadAt
228230
protected Object readNativeClass(PythonNativeClass object, Object key,
229231
@Cached HashingCollectionNodes.GetDictStorageNode getDictStorage,
230232
@Cached GetTypeMemberNode getNativeDict,
231-
@CachedLibrary(limit = "1") HashingStorageLibrary hlib) {
233+
@CachedLibrary(limit = "MAX_DICT_TYPES") HashingStorageLibrary hlib) {
232234
return readNative(key, getNativeDict.execute(object, NativeMember.TP_DICT), hlib, getDictStorage);
233235
}
234236

0 commit comments

Comments
 (0)