|
44 | 44 | import com.oracle.graal.python.builtins.PythonBuiltinClassType;
|
45 | 45 | import com.oracle.graal.python.builtins.objects.function.PArguments;
|
46 | 46 | import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
|
47 |
| -import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetBaseClassesNode; |
48 | 47 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode;
|
49 | 48 | import com.oracle.graal.python.nodes.PRaiseNode;
|
50 | 49 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
|
56 | 55 | import com.oracle.truffle.api.dsl.NodeFactory;
|
57 | 56 | import com.oracle.truffle.api.frame.VirtualFrame;
|
58 | 57 | import com.oracle.truffle.api.nodes.NodeCost;
|
| 58 | +import com.oracle.truffle.api.profiles.ValueProfile; |
59 | 59 |
|
60 | 60 | /**
|
61 | 61 | * Implements cpython://Objects/typeobject.c#tp_new_wrapper.
|
62 | 62 | */
|
63 | 63 | public final class WrapTpNew extends SlotWrapper {
|
64 | 64 | @Child IsTypeNode isType;
|
65 | 65 | @Child IsSubtypeNode isSubtype;
|
66 |
| - @Child GetBaseClassesNode getBases; |
67 | 66 | @Child PRaiseNode raiseNode;
|
68 | 67 | @Child LookupAttributeInMRONode lookupNewNode;
|
| 68 | + @CompilationFinal ValueProfile builtinProfile; |
69 | 69 | @CompilationFinal byte state = 0;
|
70 | 70 | @CompilationFinal PythonBuiltinClassType owner;
|
71 | 71 |
|
@@ -122,12 +122,17 @@ public Object execute(VirtualFrame frame) {
|
122 | 122 | // we're in. We have our optimizations for this lookup that the compiler can then
|
123 | 123 | // (hopefully) merge with the initial lookup of the new method before entering it.
|
124 | 124 | if (lookupNewNode == null) {
|
| 125 | + reportPolymorphicSpecialize(); |
125 | 126 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
126 | 127 | lookupNewNode = insert(LookupAttributeInMRONode.createForLookupOfUnmanagedClasses(SpecialMethodNames.__NEW__));
|
127 | 128 | }
|
128 | 129 | Object newMethod = lookupNewNode.execute(arg0);
|
129 | 130 | if (newMethod instanceof PBuiltinFunction) {
|
130 |
| - NodeFactory<? extends PythonBuiltinBaseNode> factory = ((PBuiltinFunction) newMethod).getBuiltinNodeFactory(); |
| 131 | + if (builtinProfile == null) { |
| 132 | + CompilerDirectives.transferToInterpreterAndInvalidate(); |
| 133 | + builtinProfile = ValueProfile.createIdentityProfile(); |
| 134 | + } |
| 135 | + NodeFactory<? extends PythonBuiltinBaseNode> factory = ((PBuiltinFunction) builtinProfile.profile(newMethod)).getBuiltinNodeFactory(); |
131 | 136 | if (factory != null) {
|
132 | 137 | if (!factory.getNodeClass().isAssignableFrom(getNode().getClass())) {
|
133 | 138 | if ((state & IS_UNSAFE_STATE) == 0) {
|
|
0 commit comments