Skip to content

Commit 4160318

Browse files
committed
Use @NonIdempotent instead of passing an extra dynamic argument
1 parent dc9fc06 commit 4160318

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.oracle.truffle.api.dsl.GenerateUncached;
6666
import com.oracle.truffle.api.dsl.ImportStatic;
6767
import com.oracle.truffle.api.dsl.NeverDefault;
68+
import com.oracle.truffle.api.dsl.NonIdempotent;
6869
import com.oracle.truffle.api.dsl.ReportPolymorphism;
6970
import com.oracle.truffle.api.dsl.Specialization;
7071
import com.oracle.truffle.api.nodes.Node;
@@ -97,10 +98,8 @@ public static ReadAttributeFromObjectNode getUncachedForceType() {
9798

9899
public abstract Object execute(PythonModule object, TruffleString key);
99100

100-
/**
101-
* @param module Non-cached parameter to help the DSL produce a guard, not an assertion
102-
*/
103-
protected static HashingStorage getStorage(Object module, PHashingCollection cachedGlobals) {
101+
@NonIdempotent
102+
protected static HashingStorage getStorage(PHashingCollection cachedGlobals) {
104103
return cachedGlobals.getDictStorage();
105104
}
106105

@@ -111,15 +110,16 @@ protected static PDict getDict(Object object) {
111110
// special case for the very common module read
112111
@Specialization(guards = {"isSingleContext()",
113112
"cachedObject == object",
114-
// no need to check the cachedDict for equality, module.__dict__ is read-only
115-
"getStorage(object, cachedDict) == cachedStorage"
113+
// no need to check "getDict(object) == cachedDict", module.__dict__ is
114+
// read-only
115+
"getStorage(cachedDict) == cachedStorage"
116116
}, limit = "1")
117117
@SuppressWarnings("unused")
118118
protected static Object readFromBuiltinModuleDict(PythonModule object, TruffleString key,
119119
@Bind Node inliningTarget,
120120
@Cached(value = "object", weak = true) PythonModule cachedObject,
121121
@Cached(value = "getDict(object)", weak = true) PHashingCollection cachedDict,
122-
@Cached(value = "getStorage(object, getDict(object))", weak = true) HashingStorage cachedStorage,
122+
@Cached(value = "getStorage(getDict(object))", weak = true) HashingStorage cachedStorage,
123123
@Exclusive @Cached HashingStorageGetItem getItem) {
124124
// note that we don't need to pass the state here - string keys are hashable by definition
125125
Object value = getItem.execute(inliningTarget, cachedStorage, key);

0 commit comments

Comments
 (0)