|
41 | 41 | package com.oracle.graal.python.nodes.classes;
|
42 | 42 |
|
43 | 43 | import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___BASES__;
|
44 |
| -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTRIBUTE__; |
45 | 44 |
|
46 | 45 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
47 |
| -import com.oracle.graal.python.lib.PyObjectGetAttr; |
| 46 | +import com.oracle.graal.python.lib.PyObjectLookupAttr; |
48 | 47 | import com.oracle.graal.python.nodes.PNodeWithContext;
|
49 |
| -import com.oracle.graal.python.nodes.SpecialMethodNames; |
50 |
| -import com.oracle.graal.python.nodes.attributes.LookupInheritedAttributeNode; |
51 |
| -import com.oracle.graal.python.nodes.call.CallNode; |
52 |
| -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; |
53 |
| -import com.oracle.graal.python.runtime.exception.PException; |
54 |
| -import com.oracle.truffle.api.dsl.Bind; |
55 | 48 | import com.oracle.truffle.api.dsl.Cached;
|
56 |
| -import com.oracle.truffle.api.dsl.Cached.Exclusive; |
| 49 | +import com.oracle.truffle.api.dsl.GenerateCached; |
| 50 | +import com.oracle.truffle.api.dsl.GenerateInline; |
57 | 51 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
58 |
| -import com.oracle.truffle.api.dsl.ImportStatic; |
59 |
| -import com.oracle.truffle.api.dsl.NeverDefault; |
60 | 52 | import com.oracle.truffle.api.dsl.Specialization;
|
61 | 53 | import com.oracle.truffle.api.frame.Frame;
|
62 | 54 | import com.oracle.truffle.api.frame.VirtualFrame;
|
63 | 55 | import com.oracle.truffle.api.nodes.Node;
|
64 | 56 |
|
| 57 | +@GenerateInline |
| 58 | +@GenerateCached(false) |
65 | 59 | @GenerateUncached
|
66 |
| -@ImportStatic({SpecialMethodNames.class}) |
67 |
| -@SuppressWarnings("truffle-inlining") // footprint reduction 44 -> 26 |
68 | 60 | public abstract class AbstractObjectGetBasesNode extends PNodeWithContext {
|
69 |
| - @NeverDefault |
70 |
| - public static AbstractObjectGetBasesNode create() { |
71 |
| - return AbstractObjectGetBasesNodeGen.create(); |
72 |
| - } |
73 |
| - |
74 |
| - protected abstract PTuple executeInternal(Frame frame, Object cls); |
75 |
| - |
76 |
| - public final PTuple execute(VirtualFrame frame, Object cls) { |
77 |
| - return executeInternal(frame, cls); |
78 |
| - } |
79 | 61 |
|
80 |
| - @Specialization(guards = "!isUncachedNode()") |
81 |
| - static PTuple getBasesCached(VirtualFrame frame, Object cls, |
82 |
| - @Bind("this") Node inliningTarget, |
83 |
| - @Cached PyObjectGetAttr getAttributeNode, |
84 |
| - @Exclusive @Cached IsBuiltinObjectProfile exceptionMaskProfile) { |
85 |
| - try { |
86 |
| - Object bases = getAttributeNode.execute(frame, inliningTarget, cls, T___BASES__); |
87 |
| - if (bases instanceof PTuple) { |
88 |
| - return (PTuple) bases; |
89 |
| - } |
90 |
| - } catch (PException pe) { |
91 |
| - pe.expectAttributeError(inliningTarget, exceptionMaskProfile); |
92 |
| - } |
93 |
| - return null; |
94 |
| - } |
| 62 | + public abstract PTuple execute(Frame frame, Node inliningTarget, Object cls); |
95 | 63 |
|
96 |
| - @Specialization(replaces = "getBasesCached") |
97 |
| - static PTuple getBasesUncached(VirtualFrame frame, Object cls, |
98 |
| - @Bind("this") Node inliningTarget, |
99 |
| - @Cached LookupInheritedAttributeNode.Dynamic lookupGetattributeNode, |
100 |
| - @Cached CallNode callGetattributeNode, |
101 |
| - @Exclusive @Cached IsBuiltinObjectProfile exceptionMaskProfile) { |
102 |
| - Object getattr = lookupGetattributeNode.execute(inliningTarget, cls, T___GETATTRIBUTE__); |
103 |
| - try { |
104 |
| - Object bases = callGetattributeNode.execute(frame, getattr, cls, T___BASES__); |
105 |
| - if (bases instanceof PTuple) { |
106 |
| - return (PTuple) bases; |
107 |
| - } |
108 |
| - } catch (PException pe) { |
109 |
| - pe.expectAttributeError(inliningTarget, exceptionMaskProfile); |
| 64 | + @Specialization |
| 65 | + static PTuple getBasesCached(VirtualFrame frame, Node inliningTarget, Object cls, |
| 66 | + @Cached PyObjectLookupAttr lookupAttr) { |
| 67 | + Object bases = lookupAttr.execute(frame, inliningTarget, cls, T___BASES__); |
| 68 | + if (bases instanceof PTuple) { |
| 69 | + return (PTuple) bases; |
110 | 70 | }
|
111 | 71 | return null;
|
112 | 72 | }
|
|
0 commit comments