69
69
import com .oracle .truffle .api .frame .Frame ;
70
70
import com .oracle .truffle .api .frame .VirtualFrame ;
71
71
import com .oracle .truffle .api .nodes .Node ;
72
+ import com .oracle .truffle .api .profiles .ConditionProfile ;
72
73
73
74
/**
74
75
* Equivalent to use for the various PyObject_LookupAttr* functions available in CPython. Note that
@@ -148,11 +149,13 @@ static final Object doBuiltinModule(VirtualFrame frame, Object object, String na
148
149
@ Cached ReadAttributeFromObjectNode readNode ,
149
150
@ Cached ReadAttributeFromObjectNode readGetattr ,
150
151
@ Shared ("errorProfile" ) @ Cached IsBuiltinClassProfile errorProfile ,
152
+ @ Cached ConditionProfile noValueFound ,
151
153
@ Cached CallNode callGetattr ) {
152
154
Object value = readNode .execute (object , cachedName );
153
- if (value == PNone .NO_VALUE ) {
155
+ if (noValueFound . profile ( value == PNone .NO_VALUE ) ) {
154
156
Object getAttr = readGetattr .execute (object , SpecialMethodNames .__GETATTR__ );
155
157
if (getAttr != PNone .NO_VALUE ) {
158
+ // (tfel): I'm not profiling this, since modules with __getattr__ are kind of rare
156
159
try {
157
160
return callGetattr .execute (frame , getAttr , name );
158
161
} catch (PException e ) {
@@ -179,15 +182,15 @@ static final Object doBuiltinType(VirtualFrame frame, Object object, String name
179
182
@ Cached ("create(name)" ) LookupAttributeInMRONode lookupName ,
180
183
@ Bind ("lookupName.execute(type)" ) Object descr ,
181
184
@ Cached ReadAttributeFromObjectNode readNode ,
182
- @ Cached ReadAttributeFromObjectNode readGetattr ,
185
+ @ Cached ConditionProfile valueFound ,
183
186
@ Cached ("create(__GET__)" ) LookupInheritedAttributeNode lookupValueGet ,
187
+ @ Cached ConditionProfile noGetMethod ,
184
188
@ Cached CallTernaryMethodNode invokeValueGet ,
185
- @ Shared ("errorProfile" ) @ Cached IsBuiltinClassProfile errorProfile ,
186
- @ Cached CallNode callGetattr ) {
189
+ @ Shared ("errorProfile" ) @ Cached IsBuiltinClassProfile errorProfile ) {
187
190
Object value = readNode .execute (object , cachedName );
188
- if (value != PNone .NO_VALUE ) {
191
+ if (valueFound . profile ( value != PNone .NO_VALUE ) ) {
189
192
Object valueGet = lookupValueGet .execute (value );
190
- if (valueGet == PNone .NO_VALUE ) {
193
+ if (noGetMethod . profile ( valueGet == PNone .NO_VALUE ) ) {
191
194
return value ;
192
195
} else if (PGuards .isCallable (valueGet )) {
193
196
try {
0 commit comments