42
42
43
43
import static com .oracle .graal .python .runtime .exception .PythonErrorType .AttributeError ;
44
44
45
- import com .oracle .graal .python .PythonLanguage ;
46
45
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
47
46
import com .oracle .graal .python .builtins .objects .PNone ;
48
47
import com .oracle .graal .python .builtins .objects .function .BuiltinMethodDescriptor ;
52
51
import com .oracle .graal .python .builtins .objects .type .PythonManagedClass ;
53
52
import com .oracle .graal .python .builtins .objects .type .SpecialMethodSlot ;
54
53
import com .oracle .graal .python .builtins .objects .type .TypeBuiltins ;
54
+ import com .oracle .graal .python .nodes .PNodeWithContext ;
55
55
import com .oracle .graal .python .nodes .attributes .GetAttributeNodeFactory .GetFixedAttributeNodeGen ;
56
56
import com .oracle .graal .python .nodes .call .special .CallBinaryMethodNode ;
57
57
import com .oracle .graal .python .nodes .call .special .LookupAndCallBinaryNode ;
62
62
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
63
63
import com .oracle .graal .python .nodes .statement .StatementNode ;
64
64
import com .oracle .graal .python .runtime .exception .PException ;
65
- import com .oracle .truffle .api .Assumption ;
66
65
import com .oracle .truffle .api .CompilerDirectives ;
67
66
import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
68
67
import com .oracle .truffle .api .dsl .Cached ;
69
68
import com .oracle .truffle .api .dsl .Specialization ;
70
69
import com .oracle .truffle .api .frame .VirtualFrame ;
71
- import com .oracle .truffle .api .nodes .Node ;
72
70
import com .oracle .truffle .api .profiles .ConditionProfile ;
73
71
74
72
public final class GetAttributeNode extends ExpressionNode implements ReadNode {
@@ -111,7 +109,7 @@ public ExpressionNode getObject() {
111
109
return objectExpression ;
112
110
}
113
111
114
- abstract static class GetAttributeBaseNode extends Node {
112
+ abstract static class GetAttributeBaseNode extends PNodeWithContext {
115
113
116
114
@ Child protected LookupAndCallBinaryNode dispatchNode = LookupAndCallBinaryNode .create (SpecialMethodSlot .GetAttribute );
117
115
@ Child private IsBuiltinClassProfile isBuiltinClassProfile ;
@@ -175,10 +173,6 @@ protected Object getPythonClass(Object object) {
175
173
return getClassNode .execute (object );
176
174
}
177
175
178
- Assumption singleContextAssumption () {
179
- return PythonLanguage .get (this ).singleContextAssumption ;
180
- }
181
-
182
176
protected IsBuiltinClassProfile getErrorProfile () {
183
177
if (isBuiltinClassProfile == null ) {
184
178
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -235,7 +229,7 @@ protected static boolean isTypeGetAttribute(Object lazyClass) {
235
229
* it in single context mode.
236
230
*/
237
231
238
- @ Specialization (assumptions = "singleContextAssumption ()" )
232
+ @ Specialization (guards = "isSingleContext ()" )
239
233
final Object doSingleContext (VirtualFrame frame , Object object ) {
240
234
try {
241
235
return dispatchNode .executeObject (frame , object , key );
@@ -245,7 +239,7 @@ final Object doSingleContext(VirtualFrame frame, Object object) {
245
239
}
246
240
}
247
241
248
- @ Specialization (replaces = "doSingleContext " , guards = "isObjectGetAttribute(getPythonClass(object))" )
242
+ @ Specialization (guards = { "!isSingleContext() " , "isObjectGetAttribute(getPythonClass(object))" } )
249
243
final Object doBuiltinObject (VirtualFrame frame , Object object ,
250
244
@ Cached ObjectBuiltins .GetAttributeNode getAttributeNode ) {
251
245
try {
@@ -256,7 +250,7 @@ final Object doBuiltinObject(VirtualFrame frame, Object object,
256
250
}
257
251
}
258
252
259
- @ Specialization (replaces = "doSingleContext " , guards = "isTypeGetAttribute(getPythonClass(object))" )
253
+ @ Specialization (guards = { "!isSingleContext() " , "isTypeGetAttribute(getPythonClass(object))" } )
260
254
final Object doBuiltinType (VirtualFrame frame , Object object ,
261
255
@ Cached TypeBuiltins .GetattributeNode getAttributeNode ) {
262
256
try {
@@ -267,7 +261,7 @@ final Object doBuiltinType(VirtualFrame frame, Object object,
267
261
}
268
262
}
269
263
270
- @ Specialization (replaces = "doSingleContext " , guards = "isModuleGetAttribute(getPythonClass(object))" )
264
+ @ Specialization (guards = { "!isSingleContext() " , "isModuleGetAttribute(getPythonClass(object))" } )
271
265
final Object doBuiltinModule (VirtualFrame frame , Object object ,
272
266
@ Cached ModuleBuiltins .ModuleGetattritbuteNode getAttributeNode ) {
273
267
try {
@@ -278,7 +272,7 @@ final Object doBuiltinModule(VirtualFrame frame, Object object,
278
272
}
279
273
}
280
274
281
- @ Specialization (replaces = {"doBuiltinObject" , "doBuiltinType" , "doBuiltinModule" })
275
+ @ Specialization (guards = "!isSingleContext()" , replaces = {"doBuiltinObject" , "doBuiltinType" , "doBuiltinModule" })
282
276
final Object doGeneric (VirtualFrame frame , Object object ) {
283
277
try {
284
278
return dispatchNode .executeObject (frame , object , key );
0 commit comments