File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ private static void initializeBuiltinTypeSlotsImpl(PythonCore core) {
284
284
if (info != null ) {
285
285
typeSlots [slot .ordinal ()] = info ;
286
286
}
287
- } else if (PythonLanguage .canCache (value )) {
287
+ } else if (value instanceof BuiltinMethodDescriptor || PythonLanguage .canCache (value )) {
288
288
typeSlots [slot .ordinal ()] = value ;
289
289
}
290
290
}
@@ -673,14 +673,16 @@ public static boolean checkSlotOverrides(PythonCore core) {
673
673
Object typeValue = slot .getValue (type );
674
674
if (typeValue != null ) {
675
675
Object klassValue = slot .getValue (klass );
676
- if (typeValue instanceof BuiltinMethodDescriptor ) {
677
- if (!(klassValue instanceof PBuiltinFunction ) ||
678
- ((BuiltinMethodDescriptor ) typeValue ).getFactory () != ((PBuiltinFunction ) klassValue ).getBuiltinNodeFactory ()) {
679
- mismatches .add (type .getName () + "." + slot .getName ());
680
- }
681
- } else if (!typeValue .equals (klassValue )) {
682
- mismatches .add (type .getName () + "." + slot .getName ());
676
+ if (klassValue .equals (typeValue )) {
677
+ // values are same: OK
678
+ continue ;
683
679
}
680
+ if (typeValue instanceof BuiltinMethodDescriptor && klassValue instanceof PBuiltinFunction &&
681
+ ((BuiltinMethodDescriptor ) typeValue ).getFactory () == ((PBuiltinFunction ) klassValue ).getBuiltinNodeFactory ()) {
682
+ // BuiltinMethodDescriptor and matching PBuiltinFunction: OK
683
+ continue ;
684
+ }
685
+ mismatches .add (type .getName () + "." + slot .getName ());
684
686
}
685
687
}
686
688
}
Original file line number Diff line number Diff line change 52
52
import com .oracle .truffle .api .CompilerDirectives ;
53
53
import com .oracle .truffle .api .frame .VirtualFrame ;
54
54
import com .oracle .truffle .api .nodes .Node ;
55
+ import com .oracle .truffle .api .profiles .ValueProfile ;
55
56
56
57
public abstract class LookupSpecialBaseNode extends Node {
57
58
@ Child LookupInMROBaseNode lookupNode ; // this should be initialized by the subclass
58
59
private final boolean ignoreDescriptorException ;
59
60
@ Child private LookupInheritedAttributeNode lookupGet ;
60
61
@ Child private CallNode callGet ;
62
+ private final ValueProfile lookupResProfile = ValueProfile .createClassProfile ();
61
63
62
64
LookupSpecialBaseNode (boolean ignoreDescriptorException ) {
63
65
this .ignoreDescriptorException = ignoreDescriptorException ;
64
66
}
65
67
66
68
public final Object execute (VirtualFrame frame , Object type , Object receiver ) {
67
- Object descriptor = lookupNode .execute (type );
69
+ Object descriptor = lookupResProfile . profile ( lookupNode .execute (type ) );
68
70
if (descriptor == PNone .NO_VALUE || descriptor instanceof PBuiltinFunction || descriptor instanceof PFunction || descriptor instanceof BuiltinMethodDescriptor ) {
69
71
// Return unbound to avoid constructing the bound object
70
72
return descriptor ;
You can’t perform that action at this time.
0 commit comments