6565import com .oracle .truffle .api .dsl .GenerateUncached ;
6666import com .oracle .truffle .api .dsl .ImportStatic ;
6767import com .oracle .truffle .api .dsl .NeverDefault ;
68+ import com .oracle .truffle .api .dsl .NonIdempotent ;
6869import com .oracle .truffle .api .dsl .ReportPolymorphism ;
6970import com .oracle .truffle .api .dsl .Specialization ;
7071import 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