Skip to content

Commit 734355e

Browse files
committed
Generate inline for PyFloat check node
1 parent a33c4a0 commit 734355e

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static int typeCheck(Object obj,
343343
@Bind("this") Node inliningTarget,
344344
@Cached InlinedGetClassNode getClassNode,
345345
@CachedLibrary(limit = "3") InteropLibrary interopLibrary) {
346-
if (floatCheckNode.execute(obj)) {
346+
if (floatCheckNode.execute(inliningTarget, obj)) {
347347
return DOUBLE_TYPE;
348348
}
349349
if (longCheckNode.execute(obj)) {

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
package com.oracle.graal.python.lib;
4242

4343
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
44+
import com.oracle.graal.python.builtins.objects.floats.PFloat;
4445
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
45-
import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.InlineIsBuiltinClassProfile;
4646
import com.oracle.graal.python.nodes.object.InlinedGetClassNode;
47-
import com.oracle.truffle.api.dsl.Bind;
4847
import com.oracle.truffle.api.dsl.Cached;
48+
import com.oracle.truffle.api.dsl.GenerateInline;
4949
import com.oracle.truffle.api.dsl.GenerateUncached;
5050
import com.oracle.truffle.api.dsl.Specialization;
5151
import com.oracle.truffle.api.nodes.Node;
@@ -54,25 +54,26 @@
5454
* Equivalent of CPython's {@code PyFloat_Check}.
5555
*/
5656
@GenerateUncached
57+
@GenerateInline
5758
public abstract class PyFloatCheckNode extends Node {
58-
public abstract boolean execute(Object object);
59+
public abstract boolean execute(Node inliningTarget, Object object);
5960

6061
@Specialization
6162
static boolean doDouble(@SuppressWarnings("unused") Double object) {
6263
return true;
6364
}
6465

6566
@Specialization
66-
static boolean doGeneric(Object object,
67-
@Bind("this") Node inliningTarget,
68-
@Cached InlineIsBuiltinClassProfile isBuiltinClass,
67+
static boolean doPFloat(@SuppressWarnings("unused") PFloat object) {
68+
return true;
69+
}
70+
71+
@Specialization
72+
static boolean doGeneric(Node inliningTarget, Object object,
6973
@Cached InlinedGetClassNode getClassNode,
7074
@Cached IsSubtypeNode isSubtypeNode) {
71-
Object clazz = getClassNode.execute(inliningTarget, object);
72-
if (isBuiltinClass.profileIsBuiltinClass(inliningTarget, clazz, PythonBuiltinClassType.PFloat)) {
73-
return true;
74-
}
75-
return isSubtypeNode.execute(clazz, PythonBuiltinClassType.PFloat);
75+
// PyFloat_CheckExact is implicitly checked in IsSubtypeNode
76+
return isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PFloat);
7677
}
7778

7879
public static PyFloatCheckNode getUncached() {

0 commit comments

Comments
 (0)