65
65
import com .oracle .truffle .api .dsl .Bind ;
66
66
import com .oracle .truffle .api .dsl .Cached ;
67
67
import com .oracle .truffle .api .dsl .Cached .Shared ;
68
+ import com .oracle .truffle .api .dsl .Fallback ;
68
69
import com .oracle .truffle .api .dsl .GenerateUncached ;
69
70
import com .oracle .truffle .api .dsl .ImportStatic ;
70
71
import com .oracle .truffle .api .dsl .Specialization ;
@@ -105,18 +106,8 @@ protected static boolean isObjectGetAttribute(Object lazyClass) {
105
106
return getattributeSlot == BuiltinMethodDescriptors .OBJ_GET_ATTRIBUTE && getattrSlot == PNone .NO_VALUE ;
106
107
}
107
108
108
- @ Specialization (guards = {"!isForeignObjectNode.execute(receiver)" , "!isObjectGetAttribute(lazyClass)" }, limit = "1" )
109
- static Object getGenericAttr (Frame frame , Object receiver , TruffleString name ,
110
- @ SuppressWarnings ("unused" ) @ Shared ("isForeign" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
111
- @ SuppressWarnings ("unused" ) @ Shared ("getClassNode" ) @ Cached GetClassNode getClass ,
112
- @ SuppressWarnings ("unused" ) @ Bind ("getClass.execute(receiver)" ) Object lazyClass ,
113
- @ Cached PyObjectGetAttr getAttr ) {
114
- return new BoundDescriptor (getAttr .execute (frame , receiver , name ));
115
- }
116
-
117
- @ Specialization (guards = {"!isForeignObjectNode.execute(receiver)" , "isObjectGetAttribute(lazyClass)" , "name == cachedName" }, limit = "1" )
109
+ @ Specialization (guards = {"isObjectGetAttribute(lazyClass)" /* Implies not foreign */ , "name == cachedName" }, limit = "1" )
118
110
static Object getFixedAttr (VirtualFrame frame , Object receiver , @ SuppressWarnings ("unused" ) TruffleString name ,
119
- @ SuppressWarnings ("unused" ) @ Shared ("isForeign" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
120
111
@ SuppressWarnings ("unused" ) @ Shared ("getClassNode" ) @ Cached GetClassNode getClass ,
121
112
@ Bind ("getClass.execute(receiver)" ) Object lazyClass ,
122
113
@ SuppressWarnings ("unused" ) @ Cached ("name" ) TruffleString cachedName ,
@@ -173,9 +164,8 @@ static Object getFixedAttr(VirtualFrame frame, Object receiver, @SuppressWarning
173
164
}
174
165
175
166
// No explicit branch profiling when we're looking up multiple things
176
- @ Specialization (guards = { "!isForeignObjectNode.execute(receiver)" , " isObjectGetAttribute(lazyClass)"} , replaces = "getFixedAttr" , limit = "1" )
167
+ @ Specialization (guards = " isObjectGetAttribute(lazyClass)" /* Implies not foreign */ , replaces = "getFixedAttr" , limit = "1" )
177
168
static Object getDynamicAttr (Frame frame , Object receiver , TruffleString name ,
178
- @ SuppressWarnings ("unused" ) @ Shared ("isForeign" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
179
169
@ SuppressWarnings ("unused" ) @ Shared ("getClassNode" ) @ Cached GetClassNode getClass ,
180
170
@ Bind ("getClass.execute(receiver)" ) Object lazyClass ,
181
171
@ Cached LookupAttributeInMRONode .Dynamic lookupNode ,
@@ -217,7 +207,7 @@ static Object getDynamicAttr(Frame frame, Object receiver, TruffleString name,
217
207
throw raiseNode .raise (AttributeError , ErrorMessages .OBJ_P_HAS_NO_ATTR_S , receiver , name );
218
208
}
219
209
220
- @ Specialization (guards = "isForeignObjectNode.execute(receiver)" , limit = "3 " )
210
+ @ Specialization (guards = "isForeignObjectNode.execute(receiver)" , limit = "1 " )
221
211
Object getForeignMethod (VirtualFrame frame , Object receiver , TruffleString name ,
222
212
@ SuppressWarnings ("unused" ) @ Cached IsForeignObjectNode isForeignObjectNode ,
223
213
@ Cached TruffleString .ToJavaStringNode toJavaString ,
@@ -238,4 +228,10 @@ Object getForeignMethod(VirtualFrame frame, Object receiver, TruffleString name,
238
228
return new BoundDescriptor (getAttr .execute (frame , receiver , name ));
239
229
}
240
230
}
231
+
232
+ @ Fallback
233
+ static Object getGenericAttr (Frame frame , Object receiver , TruffleString name ,
234
+ @ Cached PyObjectGetAttr getAttr ) {
235
+ return new BoundDescriptor (getAttr .execute (frame , receiver , name ));
236
+ }
241
237
}
0 commit comments