Skip to content

Commit

Permalink
Merged substitutability fix in, more changes/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiHartmann committed Dec 7, 2023
1 parent 2487d1a commit 63b6023
Show file tree
Hide file tree
Showing 32 changed files with 176 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class InlineTypes {
"-XX:+EnablePrimitiveClasses",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:-UseACmpProfile",
"-XX:+AlwaysIncrementalInline",
Expand All @@ -54,7 +54,7 @@ public class InlineTypes {
"-XX:+EnablePrimitiveClasses",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:-UseACmpProfile",
"-XX:-UseCompressedOops",
Expand All @@ -70,7 +70,7 @@ public class InlineTypes {
"-XX:+EnablePrimitiveClasses",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:-UseACmpProfile",
"-XX:-UseCompressedOops",
Expand All @@ -87,7 +87,7 @@ public class InlineTypes {
"-XX:+EnablePrimitiveClasses",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:+IgnoreUnrecognizedVMOptions",
"-DVerifyIR=false",
"-XX:+AlwaysIncrementalInline",
Expand All @@ -102,7 +102,7 @@ public class InlineTypes {
"-XX:+EnablePrimitiveClasses",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:+IgnoreUnrecognizedVMOptions",
"-DVerifyIR=false",
"-XX:FlatArrayElementMaxOops=-1",
Expand All @@ -117,7 +117,7 @@ public class InlineTypes {
"-XX:+EnablePrimitiveClasses",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:-UseACmpProfile",
"-XX:+AlwaysIncrementalInline",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
* @summary Verify that certain array accesses do not trigger deoptimization.
* @library /test/lib
* @compile --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED
* --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
* --add-exports java.base/jdk.internal.value=ALL-UNNAMED
* TestArrayAccessDeopt.java
* @run main/othervm -XX:+EnableValhalla
* --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED
* --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
* --add-exports java.base/jdk.internal.value=ALL-UNNAMED
* TestArrayAccessDeopt
*/

Expand All @@ -39,7 +39,7 @@
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

import jdk.internal.misc.VM;
import jdk.internal.value.ValueClass;
import jdk.internal.vm.annotation.ImplicitlyConstructible;
import jdk.internal.vm.annotation.LooselyConsistentValue;
import jdk.internal.vm.annotation.NullRestricted;
Expand Down Expand Up @@ -99,14 +99,14 @@ public static void test11(MyValue1[] va) {
static public void main(String[] args) throws Exception {
if (args.length == 0) {
// Run test in new VM instance
String[] arg = {"-XX:+EnableValhalla", "--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
String[] arg = {"-XX:+EnableValhalla", "--add-exports", "java.base/jdk.internal.vm.annotation=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.value=ALL-UNNAMED",
"-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,TestArrayAccessDeopt::test*", "-XX:-UseArrayLoadStoreProfile",
"-XX:+TraceDeoptimization", "-Xbatch", "-XX:-MonomorphicArrayCheck", "-Xmixed", "-XX:+ProfileInterpreter", "TestArrayAccessDeopt", "run"};
OutputAnalyzer oa = ProcessTools.executeTestJvm(arg);
String output = oa.getOutput();
oa.shouldNotContain("Uncommon trap occurred");
} else {
MyValue1[] va = (MyValue1[])VM.newNullRestrictedArray(MyValue1.class, 1);
MyValue1[] va = (MyValue1[])ValueClass.newNullRestrictedArray(MyValue1.class, 1);
MyValue1[] vaB = new MyValue1[1];
MyValue1 vt = new MyValue1();
for (int i = 0; i < 10_000; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
* @summary Verify that arraycopy intrinsics properly handle flat value class arrays with oop fields.
* @library /test/lib
* @compile --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED
* --add-exports java.base/jdk.internal.misc=ALL-UNNAMED TestArrayCopyWithOops.java
* --add-exports java.base/jdk.internal.value=ALL-UNNAMED TestArrayCopyWithOops.java
* @run main/othervm -XX:+EnableValhalla
* --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED
* --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
* --add-exports java.base/jdk.internal.value=ALL-UNNAMED
* -XX:CompileCommand=dontinline,compiler.valhalla.inlinetypes.TestArrayCopyWithOops::test*
* -XX:CompileCommand=dontinline,compiler.valhalla.inlinetypes.TestArrayCopyWithOops::create*
* -Xbatch
* compiler.valhalla.inlinetypes.TestArrayCopyWithOops
* @run main/othervm -XX:+EnableValhalla
* --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED
* --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
* --add-exports java.base/jdk.internal.value=ALL-UNNAMED
* -XX:CompileCommand=dontinline,compiler.valhalla.inlinetypes.TestArrayCopyWithOops::test*
* -XX:CompileCommand=dontinline,compiler.valhalla.inlinetypes.TestArrayCopyWithOops::create*
* -Xbatch -XX:FlatArrayElementMaxSize=0
Expand All @@ -50,7 +50,7 @@

import jdk.test.lib.Asserts;

import jdk.internal.misc.VM;
import jdk.internal.value.ValueClass;
import jdk.internal.vm.annotation.ImplicitlyConstructible;
import jdk.internal.vm.annotation.LooselyConsistentValue;
import jdk.internal.vm.annotation.NullRestricted;
Expand All @@ -76,7 +76,7 @@ long hash() {
}

static ManyOops[] createValueClassArray() {
ManyOops[] array = (ManyOops[])VM.newNullRestrictedArray(ManyOops.class, LEN);
ManyOops[] array = (ManyOops[])ValueClass.newNullRestrictedArray(ManyOops.class, LEN);
for (int i = 0; i < LEN; ++i) {
array[i] = new ManyOops();
}
Expand Down Expand Up @@ -112,7 +112,7 @@ static void test4(Object[] dst) {
// System.arraycopy tests (tightly coupled with allocation of dst array)

static Object[] test5() {
ManyOops[] dst = (ManyOops[])VM.newNullRestrictedArray(ManyOops.class, LEN);
ManyOops[] dst = (ManyOops[])ValueClass.newNullRestrictedArray(ManyOops.class, LEN);
System.arraycopy(createValueClassArray(), 0, dst, 0, LEN);
return dst;
}
Expand All @@ -124,7 +124,7 @@ static Object[] test6() {
}

static Object[] test7() {
ManyOops[] dst = (ManyOops[])VM.newNullRestrictedArray(ManyOops.class, LEN);
ManyOops[] dst = (ManyOops[])ValueClass.newNullRestrictedArray(ManyOops.class, LEN);
System.arraycopy(createObjectArray(), 0, dst, 0, LEN);
return dst;
}
Expand Down
49 changes: 21 additions & 28 deletions test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestArrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import compiler.lib.ir_framework.*;
import jdk.test.lib.Asserts;

import jdk.internal.misc.VM;
import jdk.internal.value.ValueClass;
import jdk.internal.vm.annotation.ImplicitlyConstructible;
import jdk.internal.vm.annotation.LooselyConsistentValue;
import jdk.internal.vm.annotation.NullRestricted;
Expand All @@ -44,11 +44,10 @@
* @test
* @key randomness
* @summary Test value class arrays.
* @modules java.base/jdk.internal.misc
* @library /test/lib /
* @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
* @compile -XDenablePrimitiveClasses --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED
* --add-exports java.base/jdk.internal.misc=ALL-UNNAMED TestArrays.java
* --add-exports java.base/jdk.internal.value=ALL-UNNAMED TestArrays.java
* @run main/othervm/timeout=300 -XX:+EnableValhalla -XX:+EnablePrimitiveClasses compiler.valhalla.inlinetypes.TestArrays
*/

Expand Down Expand Up @@ -1905,7 +1904,7 @@ public Object test80(Object[] array, int i) {
@Run(test = "test80")
public void test80_verifier() {
NotFlattenable vt = new NotFlattenable();
NotFlattenable[] array = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 2);
NotFlattenable[] array = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 2);
array[1] = vt;
Object result = test80(array, 1);
Asserts.assertEquals(result, vt);
Expand Down Expand Up @@ -1957,7 +1956,7 @@ public Object test82(Object[] array, NotFlattenable vt, Object o, int i) {
@Run(test = "test82")
public void test82_verifier() {
NotFlattenable vt = new NotFlattenable();
NotFlattenable[] array1 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 3);
NotFlattenable[] array1 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 3);
Object[] array2 = new Object[3];
Object result = test82(array1, vt, vt, 0);
Asserts.assertEquals(array1[0], vt);
Expand Down Expand Up @@ -2015,7 +2014,7 @@ public void test84_verifier(RunInfo info) {
Asserts.assertEquals(array2[0], null);
Asserts.assertEquals(result, null);
if (!info.isWarmUp()) {
NotFlattenable[] array3 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 2);
NotFlattenable[] array3 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 2);
try {
test84(array3, 1);
throw new RuntimeException("Should throw NullPointerException");
Expand Down Expand Up @@ -2052,7 +2051,7 @@ public void test85_verifier(RunInfo info) {
test85(array2, null, false);
Asserts.assertEquals(array2[1], null);
if (!info.isWarmUp()) {
NotFlattenable[] array3 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 2);
NotFlattenable[] array3 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 2);
try {
test85(array3, null, true);
throw new RuntimeException("Should throw NullPointerException");
Expand Down Expand Up @@ -2088,7 +2087,7 @@ public void test86_verifier(RunInfo info) {
test86(array1, null, false);
Asserts.assertEquals(array1[1], null);
if (!info.isWarmUp()) {
NotFlattenable[] array2 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 2);
NotFlattenable[] array2 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 2);
try {
test86(array2, null, true);
throw new RuntimeException("Should throw NullPointerException");
Expand Down Expand Up @@ -2246,7 +2245,7 @@ public int test91(Test91Value[] array, int lo, int val) {
@Run(test = "test91")
@Warmup(0)
public void test91_verifier() {
Test91Value[] array = (Test91Value[])VM.newNullRestrictedArray(Test91Value.class, 5);
Test91Value[] array = (Test91Value[])ValueClass.newNullRestrictedArray(Test91Value.class, 5);
for (int i = 0; i < 5; ++i) {
array[i] = new Test91Value(i);
array[i].verify();
Expand Down Expand Up @@ -2425,7 +2424,7 @@ public MyValue1[] test98(Object[] array) {
@Run(test = "test98")
public void test98_verifier() {
MyValue1[] array1 = new MyValue1[1];
NotFlattenable[] array2 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 1);
NotFlattenable[] array2 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 1);
try {
test98(array1);
throw new RuntimeException("Should throw ArrayStoreException");
Expand Down Expand Up @@ -2455,7 +2454,7 @@ public boolean test99(Object[] array) {
@Run(test = "test99")
public void test99_verifier() {
MyValue1[] array1 = new MyValue1[1];
NotFlattenable[] array2 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 1);
NotFlattenable[] array2 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 1);
try {
test99(array1);
throw new RuntimeException("Should throw ArrayStoreException");
Expand Down Expand Up @@ -2484,7 +2483,7 @@ public boolean test100(Object[] array) {
@Run(test = "test100")
public void test100_verifier() {
MyValue1[] array1 = new MyValue1[1];
NotFlattenable[] array2 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 1);
NotFlattenable[] array2 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 1);
try {
test100(array1);
throw new RuntimeException("Should throw ArrayStoreException");
Expand All @@ -2505,7 +2504,7 @@ public boolean test101(Object[] array) {
@Run(test = "test101")
public void test101_verifier() {
MyValue1[] array1 = new MyValue1[1];
NotFlattenable[] array2 = (NotFlattenable[])VM.newNullRestrictedArray(NotFlattenable.class, 1);
NotFlattenable[] array2 = (NotFlattenable[])ValueClass.newNullRestrictedArray(NotFlattenable.class, 1);
Asserts.assertTrue(test101(array1));
Asserts.assertFalse(test101(array2));
}
Expand Down Expand Up @@ -3101,7 +3100,7 @@ public MyValueEmpty test130(MyValueEmpty[] array) {
@Run(test = "test130")
public void test130_verifier() {
MyValueEmpty empty = new MyValueEmpty();
MyValueEmpty[] array = (MyValueEmpty[])VM.newNullRestrictedArray(MyValueEmpty.class, 2);
MyValueEmpty[] array = (MyValueEmpty[])ValueClass.newNullRestrictedArray(MyValueEmpty.class, 2);
MyValueEmpty res = test130(array);
Asserts.assertEquals(array[0], empty);
Asserts.assertEquals(res, empty);
Expand All @@ -3114,8 +3113,6 @@ static value class EmptyContainer {
MyValueEmpty empty = new MyValueEmpty();
}

// TODO fails because of substitutability test
/*
// Empty value class container array access
@Test
// TODO we need profiling for null-free arrays
Expand All @@ -3127,12 +3124,12 @@ public MyValueEmpty test131(EmptyContainer[] array) {

@Run(test = "test131")
public void test131_verifier() {
EmptyContainer[] array = (EmptyContainer[])VM.newNullRestrictedArray(EmptyContainer.class, 2);
EmptyContainer[] array = (EmptyContainer[])ValueClass.newNullRestrictedArray(EmptyContainer.class, 2);
MyValueEmpty res = test131(array);
Asserts.assertEquals(array[0], new EmptyContainer());
Asserts.assertEquals(res, new MyValueEmpty());
}
*/

// Empty value class array access with unknown array type
@Test
public Object test132(Object[] array) {
Expand All @@ -3143,7 +3140,7 @@ public Object test132(Object[] array) {
@Run(test = "test132")
public void test132_verifier() {
MyValueEmpty empty = new MyValueEmpty();
Object[] array = (MyValueEmpty[])VM.newNullRestrictedArray(MyValueEmpty.class, 2);
Object[] array = (MyValueEmpty[])ValueClass.newNullRestrictedArray(MyValueEmpty.class, 2);
Object res = test132(array);
Asserts.assertEquals(array[0], empty);
Asserts.assertEquals(res, empty);
Expand All @@ -3153,8 +3150,6 @@ public void test132_verifier() {
Asserts.assertEquals(res, null);
}

// TODO fails because of substitutability test
/*
// Empty value class container array access with unknown array type
@Test
public Object test133(Object[] array) {
Expand All @@ -3165,7 +3160,7 @@ public Object test133(Object[] array) {
@Run(test = "test133")
public void test133_verifier() {
EmptyContainer empty = new EmptyContainer();
Object[] array = (EmptyContainer[])VM.newNullRestrictedArray(EmptyContainer.class, 2);
Object[] array = (EmptyContainer[])ValueClass.newNullRestrictedArray(EmptyContainer.class, 2);
Object res = test133(array);
Asserts.assertEquals(array[0], empty);
Asserts.assertEquals(res, empty);
Expand All @@ -3174,7 +3169,7 @@ public void test133_verifier() {
Asserts.assertEquals(array[0], empty);
Asserts.assertEquals(res, null);
}
*/

// Non-escaping empty value class array access
@Test
@IR(failOn = {ALLOC, ALLOCA, LOAD, STORE})
Expand Down Expand Up @@ -3463,8 +3458,6 @@ public void test144_verifier() {
test144();
}

// TODO fails because of substitutability test
/*
// Test that array load slow path correctly initializes non-flattened field of empty value class
@Test
public Object test145(Object[] array) {
Expand All @@ -3473,11 +3466,11 @@ public Object test145(Object[] array) {

@Run(test = "test145")
public void test145_verifier() {
Object[] array = (EmptyContainer[])VM.newNullRestrictedArray(EmptyContainer.class, 1);
Object[] array = (EmptyContainer[])ValueClass.newNullRestrictedArray(EmptyContainer.class, 1);
EmptyContainer empty = (EmptyContainer)test145(array);
Asserts.assertEquals(empty, new EmptyContainer());
}
*/

// Test that non-flattened array does not block scalarization
@Test
@IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE})
Expand Down Expand Up @@ -3594,7 +3587,7 @@ static value class Test150Value {
// Test that optimizing a checkcast of a load from a flat array works as expected
@Test
static String test150() {
Test150Value[] array = (Test150Value[])VM.newNullRestrictedArray(Test150Value.class, 1);
Test150Value[] array = (Test150Value[])ValueClass.newNullRestrictedArray(Test150Value.class, 1);
array[0] = new Test150Value();
return (String)array[0].s;
}
Expand Down
Loading

0 comments on commit 63b6023

Please sign in to comment.