Skip to content

Commit 00c87cf

Browse files
committed
Use new slot nodes
1 parent 6ed8307 commit 00c87cf

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,16 @@
4242

4343
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
4444
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
45-
import static com.oracle.graal.python.nodes.SpecialMethodNames.__BOOL__;
46-
import static com.oracle.graal.python.nodes.SpecialMethodNames.__LEN__;
4745

4846
import com.oracle.graal.python.builtins.objects.PNone;
4947
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
5048
import com.oracle.graal.python.builtins.objects.list.PList;
5149
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
50+
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
5251
import com.oracle.graal.python.nodes.ErrorMessages;
5352
import com.oracle.graal.python.nodes.PNodeWithContext;
5453
import com.oracle.graal.python.nodes.PRaiseNode;
55-
import com.oracle.graal.python.nodes.SpecialMethodNames;
5654
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
57-
import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode;
5855
import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
5956
import com.oracle.graal.python.nodes.object.GetClassNode;
6057
import com.oracle.graal.python.nodes.util.CannotCastException;
@@ -76,7 +73,7 @@
7673
* to true if neither is defined.
7774
*/
7875
@GenerateUncached
79-
@ImportStatic(SpecialMethodNames.class)
76+
@ImportStatic(SpecialMethodSlot.class)
8077
public abstract class PyObjectIsTrueNode extends PNodeWithContext {
8178
public abstract boolean execute(Frame frame, Object object);
8279

@@ -129,15 +126,15 @@ static boolean doTuple(PTuple object,
129126
@Specialization(guards = {"!isBoolean(object)", "!isPNone(object)", "!isInteger(object)", "!isDouble(object)"}, rewriteOn = UnexpectedResultException.class)
130127
static boolean doObjectUnboxed(VirtualFrame frame, Object object,
131128
@Shared("getClassNode") @Cached GetClassNode getClassNode,
132-
@Cached("create(__BOOL__)") LookupSpecialMethodSlotNode lookupBool,
133-
@Cached("create(__LEN__)") LookupSpecialMethodSlotNode lookupLen,
134-
@Cached CallUnaryMethodNode callBool,
135-
@Cached CallUnaryMethodNode callLen,
136-
@Cached CastToJavaBooleanNode cast,
137-
@Cached PyNumberIndexNode indexNode,
138-
@Cached CastToJavaIntLossyNode castLossy,
139-
@Cached PyNumberAsSizeNode asSizeNode,
140-
@Cached PRaiseNode raiseNode) throws UnexpectedResultException {
129+
@Shared("lookupBool") @Cached(parameters = "Bool") LookupSpecialMethodSlotNode lookupBool,
130+
@Shared("lookupLen") @Cached(parameters = "Len") LookupSpecialMethodSlotNode lookupLen,
131+
@Shared("callBool") @Cached CallUnaryMethodNode callBool,
132+
@Shared("callLen") @Cached CallUnaryMethodNode callLen,
133+
@Shared("cast") @Cached CastToJavaBooleanNode cast,
134+
@Shared("index") @Cached PyNumberIndexNode indexNode,
135+
@Shared("castLossy") @Cached CastToJavaIntLossyNode castLossy,
136+
@Shared("asSize") @Cached PyNumberAsSizeNode asSizeNode,
137+
@Shared("raise") @Cached PRaiseNode raiseNode) throws UnexpectedResultException {
141138
Object type = getClassNode.execute(object);
142139
Object boolDescr = lookupBool.execute(frame, type, object);
143140
if (boolDescr != PNone.NO_VALUE) {
@@ -161,22 +158,22 @@ static boolean doObjectUnboxed(VirtualFrame frame, Object object,
161158
@Specialization(guards = {"!isBoolean(object)", "!isPNone(object)", "!isInteger(object)", "!isDouble(object)"}, replaces = "doObjectUnboxed")
162159
static boolean doObject(VirtualFrame frame, Object object,
163160
@Shared("getClassNode") @Cached GetClassNode getClassNode,
164-
@Cached LookupSpecialMethodNode.Dynamic lookupBool,
165-
@Cached LookupSpecialMethodNode.Dynamic lookupLen,
166-
@Cached CallUnaryMethodNode callBool,
167-
@Cached CallUnaryMethodNode callLen,
168-
@Cached CastToJavaBooleanNode cast,
169-
@Cached PyNumberIndexNode indexNode,
170-
@Cached CastToJavaIntLossyNode castLossy,
171-
@Cached PyNumberAsSizeNode asSizeNode,
172-
@Cached PRaiseNode raiseNode) {
161+
@Shared("lookupBool") @Cached(parameters = "Bool") LookupSpecialMethodSlotNode lookupBool,
162+
@Shared("lookupLen") @Cached(parameters = "Len") LookupSpecialMethodSlotNode lookupLen,
163+
@Shared("callBool") @Cached CallUnaryMethodNode callBool,
164+
@Shared("callLen") @Cached CallUnaryMethodNode callLen,
165+
@Shared("cast") @Cached CastToJavaBooleanNode cast,
166+
@Shared("index") @Cached PyNumberIndexNode indexNode,
167+
@Shared("castLossy") @Cached CastToJavaIntLossyNode castLossy,
168+
@Shared("asSize") @Cached PyNumberAsSizeNode asSizeNode,
169+
@Shared("raise") @Cached PRaiseNode raiseNode) {
173170
Object type = getClassNode.execute(object);
174-
Object boolDescr = lookupBool.execute(frame, type, __BOOL__, object, false);
171+
Object boolDescr = lookupBool.execute(frame, type, object);
175172
if (boolDescr != PNone.NO_VALUE) {
176173
Object result = callBool.executeObject(frame, boolDescr, object);
177174
return checkBoolResult(cast, raiseNode, result);
178175
}
179-
Object lenDescr = lookupLen.execute(frame, type, __LEN__, object, false);
176+
Object lenDescr = lookupLen.execute(frame, type, object);
180177
if (lenDescr != PNone.NO_VALUE) {
181178
Object result = callLen.executeObject(frame, lenDescr, object);
182179
int len = convertLen(frame, indexNode, castLossy, asSizeNode, result);

0 commit comments

Comments
 (0)