Skip to content

Commit f6dc2ce

Browse files
committed
Add regression test for BE deopt loop
1 parent 804a5e3 commit f6dc2ce

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/BoxingEliminationTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,38 @@ public void testAndSingle() {
21832183
assertStable(quickenings, node, 1L);
21842184
}
21852185

2186+
@Test
2187+
public void testNonBEableOperand() {
2188+
// return arg0 + arg1
2189+
BoxingEliminationTestRootNode node = (BoxingEliminationTestRootNode) parse(b -> {
2190+
b.beginRoot();
2191+
b.beginReturn();
2192+
b.beginAddWithNonBEableOperands();
2193+
b.emitLoadArgument(0);
2194+
b.emitLoadArgument(1);
2195+
b.endAddWithNonBEableOperands();
2196+
b.endReturn();
2197+
b.endRoot();
2198+
}).getRootNode();
2199+
2200+
assertInstructions(node,
2201+
"load.argument",
2202+
"load.argument",
2203+
"c.AddWithNonBEableOperands",
2204+
"return");
2205+
2206+
node.getCallTarget().call(42, 3.14f);
2207+
2208+
assertInstructions(node,
2209+
"load.argument$Int",
2210+
"load.argument",
2211+
"c.AddWithNonBEableOperands$IntFloat",
2212+
"return");
2213+
2214+
var quickenings = assertQuickenings(node, 3, 1);
2215+
assertStable(quickenings, node, 123, 4.56f);
2216+
}
2217+
21862218
@GenerateBytecode(languageClass = BytecodeDSLTestLanguage.class, //
21872219
enableYield = true, enableSerialization = true, //
21882220
enableQuickening = true, //
@@ -2651,6 +2683,22 @@ public static Object doInt(int constant1, Object dynamic, int constant2, @Cached
26512683
}
26522684
}
26532685

2686+
@Operation
2687+
static final class AddWithNonBEableOperands {
2688+
/**
2689+
* Regression test: the code for boxing elimination would incorrectly try to boxing
2690+
* eliminate the float operand because another specialization had a BE-able operand at
2691+
* the same operand index.
2692+
*/
2693+
@Specialization
2694+
public static Object doIntFloat(int x, float y) {
2695+
return x + y;
2696+
}
2697+
@Specialization
2698+
public static Object doFloatInt(float x, int y) {
2699+
return x + y;
2700+
}
2701+
}
26542702
}
26552703

26562704
}

0 commit comments

Comments
 (0)