Skip to content

Commit c6edd01

Browse files
committed
V2
1 parent 98e48a7 commit c6edd01

3 files changed

Lines changed: 29 additions & 22 deletions

File tree

src/hotspot/share/opto/callGenerator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ void CallGenerator::do_late_inline_helper() {
725725
ciType* return_type = inline_method->return_type();
726726
if (!call->tf()->returns_inline_type_as_fields() &&
727727
return_type->is_inlinetype() && return_type->as_inline_klass()->can_be_returned_as_fields()) {
728+
assert(is_mh_late_inline(), "Unexpected return type");
729+
728730
// Allocate a buffer for the inline type returned as fields because the caller expects an oop return.
729731
// Do this before the method handle call in case the buffer allocation triggers deoptimization and
730732
// we need to "re-execute" the call in the interpreter (to make sure the call is only executed once).

test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public class TestCallingConvention {
167167

168168
mt = MethodType.methodType(MyValue2.class, boolean.class);
169169
test56_mh = lookup.findVirtual(clazz, "test56_callee", mt);
170+
171+
mt = MethodType.methodType(MyValue2.class, MyValue2.class);
172+
test59_mh = lookup.findStatic(clazz, "test59_callee", mt);
170173
} catch (NoSuchMethodException | IllegalAccessException e) {
171174
e.printStackTrace();
172175
throw new RuntimeException("Method handle lookup failed");
@@ -1476,4 +1479,28 @@ public MyValue58C test58(MyValue58A arg1, MyValue58B arg2, MyValue58C arg3) {
14761479
public void test58_verifier() {
14771480
Asserts.assertEQ(test58(new MyValue58A(), new MyValue58B(), new MyValue58C()), new MyValue58C());
14781481
}
1482+
1483+
static MethodHandle test59_mh;
1484+
1485+
public static MyValue2 test59_callee(MyValue2 arg) {
1486+
int div = 0;
1487+
int res = 42 / div; // Always throws an ArithmeticException
1488+
return arg;
1489+
}
1490+
1491+
// Method handle with a scalarized return that will always throw an exception
1492+
@Test
1493+
public static MyValue2 test59(MyValue2 val) throws Throwable {
1494+
return (MyValue2)test59_mh.invokeExact(val);
1495+
}
1496+
1497+
@Run(test = "test59")
1498+
@Warmup(10000) // Trigger compilation of LambdaForm method
1499+
public void test59_verifier() throws Throwable {
1500+
try {
1501+
test59(null);
1502+
} catch (ArithmeticException e) {
1503+
// Expected
1504+
}
1505+
}
14791506
}

test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestValueConstruction.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,23 +1726,6 @@ public static MyValue1 testOsrLarvalLocal(int x) throws Throwable {
17261726
return (MyValue1) OSR_LARVAL_LOCAL.invokeExact(dummy, x);
17271727
}
17281728

1729-
// Method handle with a scalarized return that will always throw an exception
1730-
private static final MethodHandle TEST_THROWING_MH = InstructionHelper.buildMethodHandle(MethodHandles.lookup(),
1731-
"throwingMH",
1732-
MethodType.methodType(MyValue1.class, MyValue1.class),
1733-
CODE -> {
1734-
CODE.
1735-
iconst_0().
1736-
iconst_0().
1737-
idiv(). // Division by zero
1738-
aload(0).
1739-
areturn();
1740-
});
1741-
1742-
public static MyValue1 testThrowingMethodHandle() throws Throwable {
1743-
return (MyValue1) TEST_THROWING_MH.invokeExact((MyValue1)null);
1744-
}
1745-
17461729
public static void main(String[] args) throws Throwable {
17471730
Random rand = Utils.getRandomInstance();
17481731

@@ -1872,11 +1855,6 @@ private static void run(int x, boolean doCheck) throws Throwable {
18721855
check(testBackAndForthAbstract2(x), new MyValue16(x), doCheck);
18731856
check(testMultipleOccurrencesInJVMS(x), new MyValue1(x), doCheck);
18741857
check(testOsrLarvalLocal(x), new MyValue1(x), doCheck);
1875-
try {
1876-
testThrowingMethodHandle();
1877-
} catch (ArithmeticException e) {
1878-
// Expected
1879-
}
18801858
}
18811859

18821860
private static void check(Object testResult, Object expectedResult, boolean check) {

0 commit comments

Comments
 (0)