Skip to content

Commit c7dd93c

Browse files
committed
Handle arithmetic on (long, double) and (double, long) inline
1 parent 2eb9b01 commit c7dd93c

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

src/main/java/org/truffleruby/core/inlined/InlinedAddNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ protected double floatAdd(double a, double b) {
4545
return a + b;
4646
}
4747

48+
@Specialization(assumptions = "assumptions")
49+
protected double longDouble(long a, double b) {
50+
return a + b;
51+
}
52+
53+
@Specialization(assumptions = "assumptions")
54+
protected double doubleLong(double a, long b) {
55+
return a + b;
56+
}
57+
4858
@Specialization
4959
protected Object fallback(VirtualFrame frame, Object a, Object b) {
5060
return rewriteAndCall(frame, a, b);

src/main/java/org/truffleruby/core/inlined/InlinedDivNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ protected double floatDiv(double a, double b) {
4343
return a / b;
4444
}
4545

46+
@Specialization(assumptions = "assumptions")
47+
protected double longDouble(long a, double b) {
48+
return a / b;
49+
}
50+
51+
@Specialization(assumptions = "assumptions")
52+
protected double doubleLong(double a, long b) {
53+
return a / b;
54+
}
55+
4656
@Specialization
4757
protected Object fallback(VirtualFrame frame, Object a, Object b) {
4858
return rewriteAndCall(frame, a, b);

src/main/java/org/truffleruby/core/inlined/InlinedMulNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ protected double floatMul(double a, double b) {
4545
return a * b;
4646
}
4747

48+
@Specialization(assumptions = "assumptions")
49+
protected double longDouble(long a, double b) {
50+
return a * b;
51+
}
52+
53+
@Specialization(assumptions = "assumptions")
54+
protected double doubleLong(double a, long b) {
55+
return a * b;
56+
}
57+
4858
@Specialization
4959
protected Object fallback(VirtualFrame frame, Object a, Object b) {
5060
return rewriteAndCall(frame, a, b);

src/main/java/org/truffleruby/core/inlined/InlinedSubNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ protected double floatSub(double a, double b) {
4545
return a - b;
4646
}
4747

48+
@Specialization(assumptions = "assumptions")
49+
protected double longDouble(long a, double b) {
50+
return a - b;
51+
}
52+
53+
@Specialization(assumptions = "assumptions")
54+
protected double doubleLong(double a, long b) {
55+
return a - b;
56+
}
57+
4858
@Specialization
4959
protected Object fallback(VirtualFrame frame, Object a, Object b) {
5060
return rewriteAndCall(frame, a, b);

0 commit comments

Comments
 (0)