Skip to content

Commit 4e7390f

Browse files
committed
Reduce reporting of polymophism in CoerceToBooleanNode
1 parent 718b74a commit 4e7390f

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CoerceToBooleanNode.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
3030
import com.oracle.graal.python.nodes.expression.CoerceToBooleanNodeFactory.NotNodeGen;
3131
import com.oracle.graal.python.nodes.expression.CoerceToBooleanNodeFactory.YesNodeGen;
32-
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
33-
import com.oracle.truffle.api.dsl.ReportPolymorphism;
32+
import com.oracle.truffle.api.dsl.ReportPolymorphism.Megamorphic;
3433
import com.oracle.truffle.api.dsl.Specialization;
3534
import com.oracle.truffle.api.frame.VirtualFrame;
3635
import com.oracle.truffle.api.instrumentation.GenerateWrapper;
@@ -39,7 +38,6 @@
3938

4039
@GenerateWrapper
4140
public abstract class CoerceToBooleanNode extends UnaryOpNode {
42-
@Child protected IsBuiltinClassProfile isBuiltinClassProfile = IsBuiltinClassProfile.create();
4341

4442
@Override
4543
public WrapperNode createWrapper(ProbeNode probe) {
@@ -67,69 +65,69 @@ public static CoerceToBooleanNode createIfFalseNode(ExpressionNode operand) {
6765
@Override
6866
public abstract boolean executeBoolean(VirtualFrame frame);
6967

70-
@ReportPolymorphism
7168
public abstract static class YesNode extends CoerceToBooleanNode {
7269
@Specialization
73-
boolean doBoolean(boolean operand) {
70+
static boolean doBoolean(boolean operand) {
7471
return operand;
7572
}
7673

7774
@Specialization
78-
boolean doInteger(int operand) {
75+
static boolean doInteger(int operand) {
7976
return operand != 0;
8077
}
8178

8279
@Specialization
83-
boolean doLong(long operand) {
80+
static boolean doLong(long operand) {
8481
return operand != 0L;
8582
}
8683

8784
@Specialization
88-
boolean doDouble(double operand) {
85+
static boolean doDouble(double operand) {
8986
return operand != 0;
9087
}
9188

9289
@Specialization
93-
boolean doString(String operand) {
90+
static boolean doString(String operand) {
9491
return operand.length() != 0;
9592
}
9693

94+
@Megamorphic
9795
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()")
98-
boolean doObject(VirtualFrame frame, Object object,
96+
static boolean doObject(VirtualFrame frame, Object object,
9997
@CachedLibrary("object") PythonObjectLibrary lib) {
10098
return lib.isTrueWithState(object, PArguments.getThreadState(frame));
10199
}
102100
}
103101

104-
@ReportPolymorphism
105102
public abstract static class NotNode extends CoerceToBooleanNode {
106103
@Specialization
107-
boolean doBool(boolean operand) {
104+
static boolean doBool(boolean operand) {
108105
return !operand;
109106
}
110107

111108
@Specialization
112-
boolean doInteger(int operand) {
109+
static boolean doInteger(int operand) {
113110
return operand == 0;
114111
}
115112

116113
@Specialization
117-
boolean doLong(long operand) {
114+
static boolean doLong(long operand) {
118115
return operand == 0L;
119116
}
120117

121118
@Specialization
122-
boolean doDouble(double operand) {
119+
static boolean doDouble(double operand) {
123120
return operand == 0;
124121
}
125122

126123
@Specialization
127-
boolean doString(String operand) {
124+
static boolean doString(String operand) {
128125
return operand.length() == 0;
129126
}
130127

128+
@Megamorphic
131129
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()")
132-
boolean doObject(VirtualFrame frame, Object object,
130+
static boolean doObject(VirtualFrame frame, Object object,
133131
@CachedLibrary("object") PythonObjectLibrary lib) {
134132
return !lib.isTrueWithState(object, PArguments.getThreadState(frame));
135133
}

0 commit comments

Comments
 (0)