Skip to content

Commit f5a0090

Browse files
committed
Add inlining cutoffs to complex builtins
1 parent 630b1d6 commit f5a0090

File tree

1 file changed

+16
-5
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex

1 file changed

+16
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
114114
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
115115
import com.oracle.truffle.api.CompilerDirectives.ValueType;
116+
import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
116117
import com.oracle.truffle.api.dsl.Bind;
117118
import com.oracle.truffle.api.dsl.Cached;
118119
import com.oracle.truffle.api.dsl.Cached.Exclusive;
@@ -168,6 +169,7 @@ static ComplexValue doComplex(PComplex v) {
168169
}
169170

170171
@Specialization(guards = "check.execute(inliningTarget, v)", limit = "1")
172+
@InliningCutoff
171173
static ComplexValue doNative(@SuppressWarnings("unused") Node inliningTarget, PythonAbstractNativeObject v,
172174
@SuppressWarnings("unused") @Cached PyComplexCheckNode check,
173175
@Cached(inline = false) CStructAccess.ReadDoubleNode read) {
@@ -187,13 +189,15 @@ static ComplexValue doDouble(double v) {
187189
}
188190

189191
@Specialization(guards = "check.execute(inliningTarget, v)", limit = "1")
192+
@InliningCutoff
190193
static ComplexValue doIntGeneric(Node inliningTarget, Object v,
191194
@SuppressWarnings("unused") @Cached PyLongCheckNode check,
192195
@Cached PyLongAsDoubleNode longAsDoubleNode) {
193196
return new ComplexValue(longAsDoubleNode.execute(inliningTarget, v), 0);
194197
}
195198

196199
@Specialization(guards = "check.execute(inliningTarget, v)", limit = "1")
200+
@InliningCutoff
197201
static ComplexValue doFloatGeneric(Node inliningTarget, Object v,
198202
@SuppressWarnings("unused") @Cached PyFloatCheckNode check,
199203
@Cached PyFloatAsDoubleNode floatAsDoubleNode) {
@@ -232,6 +236,7 @@ public abstract static class AbsNode extends PythonUnaryBuiltinNode {
232236
public abstract double executeDouble(Object arg);
233237

234238
@Specialization
239+
@InliningCutoff
235240
static double abs(Object self,
236241
@Bind("this") Node inliningTarget,
237242
@Cached ToComplexValueNode toComplexValueNode,
@@ -380,19 +385,19 @@ public static AbsNode create() {
380385
@GenerateNodeFactory
381386
abstract static class AddNode extends PythonBinaryBuiltinNode {
382387
@Specialization
383-
static PComplex doComplex(PComplex left, int right,
388+
static PComplex doInt(PComplex left, int right,
384389
@Shared @Cached PythonObjectFactory factory) {
385390
return factory.createComplex(left.getReal() + right, left.getImag());
386391
}
387392

388393
@Specialization
389-
static PComplex doComplex(PComplex left, double right,
394+
static PComplex doDouble(PComplex left, double right,
390395
@Shared @Cached PythonObjectFactory factory) {
391396
return factory.createComplex(left.getReal() + right, left.getImag());
392397
}
393398

394399
@Specialization
395-
static Object doComplex(Object leftObj, Object rightObj,
400+
static Object doGeneric(Object leftObj, Object rightObj,
396401
@Bind("this") Node inliningTarget,
397402
@Cached ToComplexValueNode toComplexLeft,
398403
@Cached ToComplexValueNode toComplexRight,
@@ -533,6 +538,7 @@ static Object doComplex(Object leftObj, Object rightObj,
533538
abstract static class PowerNode extends PythonTernaryBuiltinNode {
534539

535540
@Specialization
541+
@InliningCutoff
536542
static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unused") PNone mod,
537543
@Bind("this") Node inliningTarget,
538544
@Cached ToComplexValueNode toComplexLeft,
@@ -579,8 +585,9 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus
579585
}
580586

581587
@Specialization(guards = "!isPNone(mod)")
588+
@InliningCutoff
582589
@SuppressWarnings("unused")
583-
static Object doGeneric(Object left, Object right, Object mod,
590+
static Object error(Object left, Object right, Object mod,
584591
@Cached PRaiseNode raiseNode) {
585592
throw raiseNode.raise(ValueError, ErrorMessages.COMPLEX_MODULO);
586593
}
@@ -660,7 +667,7 @@ static boolean doComplexInt(Node inliningTarget, Object leftObj, PInt right,
660667

661668
@SuppressWarnings("unused")
662669
@Fallback
663-
static PNotImplemented doGeneric(Object left, Object right) {
670+
static PNotImplemented doNotImplemented(Object left, Object right) {
664671
return PNotImplemented.NOT_IMPLEMENTED;
665672
}
666673
}
@@ -735,6 +742,7 @@ static PNotImplemented doGeneric(Object left, Object right) {
735742
@Builtin(name = J___REPR__, minNumOfPositionalArgs = 1)
736743
abstract static class ReprNode extends PythonUnaryBuiltinNode {
737744
@Specialization
745+
@InliningCutoff
738746
static TruffleString repr(Object self,
739747
@Bind("this") Node inliningTarget,
740748
@Cached ToComplexValueNode toComplexValueNode) {
@@ -760,6 +768,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
760768
}
761769

762770
@Specialization
771+
@InliningCutoff
763772
static TruffleString format(Object self, TruffleString formatString,
764773
@Bind("this") Node inliningTarget,
765774
@Cached ToComplexValueNode toComplexValueNode,
@@ -849,6 +858,7 @@ static double get(PComplex self) {
849858
}
850859

851860
@Specialization
861+
@InliningCutoff
852862
static double getNative(PythonAbstractNativeObject self,
853863
@Cached CStructAccess.ReadDoubleNode read) {
854864
return read.readFromObj(self, PyComplexObject__cval__real);
@@ -864,6 +874,7 @@ static double get(PComplex self) {
864874
}
865875

866876
@Specialization
877+
@InliningCutoff
867878
static double getNative(PythonAbstractNativeObject self,
868879
@Cached CStructAccess.ReadDoubleNode read) {
869880
return read.readFromObj(self, PyComplexObject__cval__imag);

0 commit comments

Comments
 (0)