Skip to content
Permalink
Browse files
8271544: [lworld] GraphBuilder::withfield should handle identity clas…
…s holder
  • Loading branch information
TobiHartmann committed Jul 30, 2021
1 parent 2ca8eba commit bdf27993723b0c9057db9a148a629b034ba3eb08
@@ -2074,7 +2074,7 @@ void GraphBuilder::withfield(int field_index) {
Value val = pop(type);
Value obj = apop();

if (!holder->is_loaded()) {
if (!holder->is_loaded() || !holder->is_inlinetype()) {
apush(append_split(new Deoptimize(holder, state_before)));
return;
}
@@ -2083,7 +2083,6 @@ void GraphBuilder::withfield(int field_index) {
const bool needs_patching = !field_modify->will_link(method(), Bytecodes::_withfield) ||
(!field_modify->is_flattened() && PatchALot);
const int offset_modify = !needs_patching ? field_modify->offset() : -1;
assert(holder->is_inlinetype(), "must be an inline klass");

scope()->set_wrote_final();
scope()->set_wrote_fields();
@@ -42,7 +42,7 @@
* @summary Test inline types in LWorld.
* @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common /
* @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper
* @build test.java.lang.invoke.lib.InstructionHelper
* @run driver/timeout=450 compiler.valhalla.inlinetypes.TestLWorld
*/

@@ -1079,6 +1079,7 @@ public void test35(MyValue1[] va, int index) throws Throwable {
}

@Run(test = "test35")
@Warmup(10000)
public void test35_verifier() throws Throwable {
int index = Math.abs(rI) % 3;
try {
@@ -1406,6 +1407,7 @@ public void test44(MyValue1[] va, int index, MyValue2 v) throws Throwable {
}

@Run(test = "test44")
@Warmup(10000)
public void test44_verifier() throws Throwable {
int index = Math.abs(rI) % 3;
try {
@@ -3909,4 +3911,34 @@ public void test142_verifier() {
long res = test142();
Asserts.assertEquals(res, testValue2.hash());
}

public int intField;

private static final MethodHandle withfieldWithInvalidHolder = InstructionHelper.loadCode(MethodHandles.lookup(),
"withfieldWithInvalidHolder",
MethodType.methodType(void.class, TestLWorld.class, int.class),
CODE -> {
CODE.
aload_0().
iload_1().
withfield(TestLWorld.class, "intField", "I").
return_();
});

// Test withfield on identity class
@Test
public void test143() throws Throwable {
withfieldWithInvalidHolder.invoke(this, 0);
}

@Run(test = "test143")
@Warmup(10000)
public void test143_verifier() throws Throwable {
try {
test143();
throw new RuntimeException("IncompatibleClassChangeError expected");
} catch (IncompatibleClassChangeError e) {
// Expected
}
}
}
@@ -27,7 +27,7 @@
* @summary test scenarios where getfield, putfield, and withfield access the
* same constant pool field_ref and test other withfield error cases.
* @compile withfieldTests.jcod
* @run main/othervm -Xverify:remote -Xint RunWithfieldTests
* @run main/othervm -Xverify:remote RunWithfieldTests
*/

public class RunWithfieldTests {

0 comments on commit bdf2799

Please sign in to comment.