61
61
import com .oracle .truffle .api .Assumption ;
62
62
import com .oracle .truffle .api .CompilerAsserts ;
63
63
import com .oracle .truffle .api .CompilerDirectives ;
64
- import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
65
64
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
66
- import com .oracle .truffle .api .TruffleLanguage .ContextReference ;
67
65
import com .oracle .truffle .api .dsl .Bind ;
68
66
import com .oracle .truffle .api .dsl .Cached ;
69
67
import com .oracle .truffle .api .dsl .CachedContext ;
@@ -115,12 +113,9 @@ public static LookupAttributeInMRONode.Dynamic getUncached() {
115
113
116
114
private final boolean skipPythonClasses ;
117
115
protected final String key ;
118
- @ CompilationFinal private ContextReference <PythonContext > contextRef ;
119
116
@ Child private TypeNodes .IsSameTypeNode isSameTypeNode = IsSameTypeNodeGen .create ();
120
117
@ Child private GetMroStorageNode getMroNode ;
121
118
122
- protected static final int MAX_DICT_TYPES = ReadAttributeFromObjectNode .MAX_DICT_TYPES ;
123
-
124
119
public LookupAttributeInMRONode (String key , boolean skipPythonClasses ) {
125
120
this .key = key ;
126
121
this .skipPythonClasses = skipPythonClasses ;
@@ -158,7 +153,8 @@ public static Object findAttr(PythonCore core, PythonBuiltinClassType klass, Obj
158
153
@ Specialization (guards = {"klass == cachedKlass" }, limit = "getAttributeAccessInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
159
154
protected static Object lookupPBCTCached (@ SuppressWarnings ("unused" ) PythonBuiltinClassType klass ,
160
155
@ Cached ("klass" ) @ SuppressWarnings ("unused" ) PythonBuiltinClassType cachedKlass ,
161
- @ Cached ("findAttr(getCore(), cachedKlass, key)" ) Object cachedValue ) {
156
+ @ SuppressWarnings ("unused" ) @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
157
+ @ Cached ("findAttr(ctx.getCore(), cachedKlass, key)" ) Object cachedValue ) {
162
158
return cachedValue ;
163
159
}
164
160
@@ -173,7 +169,8 @@ protected static boolean canCache(Object value) {
173
169
@ Specialization (guards = {"klass == cachedKlass" , "canCache(cachedValue)" }, limit = "getAttributeAccessInlineCacheMaxDepth()" )
174
170
protected static Object lookupPBCTCachedMulti (@ SuppressWarnings ("unused" ) PythonBuiltinClassType klass ,
175
171
@ Cached ("klass" ) @ SuppressWarnings ("unused" ) PythonBuiltinClassType cachedKlass ,
176
- @ Cached ("findAttr(getCore(), cachedKlass, key)" ) Object cachedValue ) {
172
+ @ SuppressWarnings ("unused" ) @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
173
+ @ Cached ("findAttr(ctx.getCore(), cachedKlass, key)" ) Object cachedValue ) {
177
174
return cachedValue ;
178
175
}
179
176
@@ -192,19 +189,21 @@ public static PythonBuiltinClassType findOwnerInMro(PythonCore core, PythonBuilt
192
189
@ Specialization (replaces = "lookupPBCTCached" , guards = "klass == cachedKlass" , limit = "getAttributeAccessInlineCacheMaxDepth()" )
193
190
protected Object lookupPBCTCachedOwner (@ SuppressWarnings ("unused" ) PythonBuiltinClassType klass ,
194
191
@ Cached ("klass" ) @ SuppressWarnings ("unused" ) PythonBuiltinClassType cachedKlass ,
195
- @ Cached ("findOwnerInMro(getCore(), cachedKlass, key)" ) PythonBuiltinClassType ownerKlass ,
192
+ @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
193
+ @ Cached ("findOwnerInMro(ctx.getCore(), cachedKlass, key)" ) PythonBuiltinClassType ownerKlass ,
196
194
@ Cached ReadAttributeFromDynamicObjectNode readAttrNode ) {
197
195
if (ownerKlass == null ) {
198
196
return PNone .NO_VALUE ;
199
197
} else {
200
- return readAttrNode .execute (getCore ().lookupType (ownerKlass ), key );
198
+ return readAttrNode .execute (ctx . getCore ().lookupType (ownerKlass ), key );
201
199
}
202
200
}
203
201
204
202
@ Specialization (replaces = "lookupPBCTCachedOwner" )
205
203
protected Object lookupPBCTGeneric (PythonBuiltinClassType klass ,
204
+ @ CachedContext (PythonLanguage .class ) PythonContext ctx ,
206
205
@ Cached ReadAttributeFromDynamicObjectNode readAttrNode ) {
207
- return findAttr (getCore (), klass , key , readAttrNode );
206
+ return findAttr (ctx . getCore (), klass , key , readAttrNode );
208
207
}
209
208
210
209
static final class AttributeAssumptionPair {
0 commit comments