Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8243626: [lworld] Co-evolve hotspot-runtime tests along with JDK-8237072 #28

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -65,14 +65,14 @@ static void testCastingFromObjectToVal(Object o) {
static void testCastingFromValToBox(Point p) {
boolean npe = false;
try {
Point? pb = p;
Point.ref pb = p;
} catch(NullPointerException e) {
npe = true;
}
Asserts.assertFalse(npe, "Casting from val to box should not throw an NPE");
}

static void testCastingFromBoxToVal(Point? p) {
static void testCastingFromBoxToVal(Point.ref p) {
boolean npe = false;
try {
Point pv = (Point) p;
Original file line number Diff line number Diff line change
@@ -44,16 +44,16 @@
*/
public class FlattenableSemanticTest {

static Point? nfsp;
static Point.ref nfsp;
static Point fsp;

Point? nfip;
Point.ref nfip;
Point fip;

static JumboValue? nfsj;
static JumboValue.ref nfsj;
static JumboValue fsj;

JumboValue? nfij;
JumboValue.ref nfij;
JumboValue fij;

static Object getNull() {
@@ -82,7 +82,7 @@ public static void main(String[] args) {
// Assigning null must be allowed for non flattenable inline fields
boolean exception = true;
try {
nfsp = (Point?)getNull();
nfsp = (Point.ref)getNull();
nfsp = null;
exception = false;
} catch (NullPointerException e) {
@@ -91,7 +91,7 @@ public static void main(String[] args) {
Asserts.assertFalse(exception, "Invalid NPE when assigning null to a non flattenable field");

try {
nfsj = (JumboValue?)getNull();
nfsj = (JumboValue.ref)getNull();
nfsj = null;
exception = false;
} catch (NullPointerException e) {
@@ -100,7 +100,7 @@ public static void main(String[] args) {
Asserts.assertFalse(exception, "Invalid NPE when assigning null to a non flattenable field");

try {
test.nfip = (Point?)getNull();
test.nfip = (Point.ref)getNull();
test.nfip = null;
exception = false;
} catch (NullPointerException e) {
@@ -109,7 +109,7 @@ public static void main(String[] args) {
Asserts.assertFalse(exception, "Invalid NPE when assigning null to a non flattenable field");

try {
test.nfij = (JumboValue?)getNull();
test.nfij = (JumboValue.ref)getNull();
test.nfij = null;
exception = false;
} catch (NullPointerException e) {
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
public class QuickeningTest {

static class Parent {
Point? nfp; /* Not flattenable inline field */
Point.ref nfp; /* Not flattenable inline field */
Point fp; /* Flattenable and flattened inline field */
JumboValue fj; /* Flattenable not flattened inline field */

@@ -48,7 +48,7 @@ static class Parent {

static class Child extends Parent {
// This class inherited fields from the Parent class
Point? nfp2; /* Not flattenable inline field */
Point.ref nfp2; /* Not flattenable inline field */
Point fp2; /* Flattenable and flattened inline field */
JumboValue fj2; /* Flattenable not flattened inline field */

@@ -58,7 +58,7 @@ static class Child extends Parent {
}

static final inline class Value {
final Point? nfp; /* Not flattenable inline field */
final Point.ref nfp; /* Not flattenable inline field */
final Point fp; /* Flattenable and flattened inline field */
final JumboValue fj; /* Flattenable not flattened inline field */

Original file line number Diff line number Diff line change
@@ -53,11 +53,11 @@ public MyBigValue() {
}

static inline class TestValue {
final MyValue? nullableField;
final MyValue.ref nullableField;
final MyValue nullfreeField; // flattened
final MyValue? nullField; // src of null
final MyValue.ref nullField; // src of null
final MyBigValue nullfreeBigField; // not flattened
final MyBigValue? nullBigField; // src of null
final MyBigValue.ref nullBigField; // src of null

public void test() {
Asserts.assertNull(nullField, "Invalid non null value for uninitialized non flattenable field");
@@ -94,11 +94,11 @@ public TestValue() {
}

static class TestClass {
MyValue? nullableField;
MyValue.ref nullableField;
MyValue nullfreeField; // flattened
MyValue? nullField;
MyValue.ref nullField;
MyBigValue nullfreeBigField; // not flattened
MyBigValue? nullBigField;
MyBigValue.ref nullBigField;

public void test() {
Asserts.assertNull(nullField, "Invalid non null value for uninitialized non flattenable field");
Original file line number Diff line number Diff line change
@@ -23,14 +23,14 @@
package runtime.valhalla.valuetypes;

final class ContainerValue1 {
static TestValue1? staticValueField;
static TestValue1.ref staticValueField;
TestValue1 nonStaticValueField;
TestValue1[] inlineArray;
}

public inline final class TestValue1 {

static TestValue1? staticValue = getInstance();
static TestValue1.ref staticValue = getInstance();

final int i;
final String name;
Original file line number Diff line number Diff line change
@@ -23,13 +23,13 @@
package runtime.valhalla.valuetypes;

final class ContainerValue2 {
static TestValue2? staticValueField;
static TestValue2.ref staticValueField;
TestValue2 nonStaticValueField;
TestValue2[] valueArray;
}

public inline final class TestValue2 {
static TestValue2? staticValue = getInstance();
static TestValue2.ref staticValue = getInstance();

final long l;
final double d;
Original file line number Diff line number Diff line change
@@ -23,14 +23,14 @@
package runtime.valhalla.valuetypes;

final class ContainerValue3 {
static TestValue3? staticValueField;
static TestValue3.ref staticValueField;
TestValue3 nonStaticValueField;
TestValue3[] valueArray;
}

public inline final class TestValue3 {

static TestValue3? staticValue = getInstance();
static TestValue3.ref staticValue = getInstance();

final byte b;

Original file line number Diff line number Diff line change
@@ -25,14 +25,14 @@
import java.nio.ByteBuffer;

final class ContainerValue4 {
static TestValue4? staticValueField;
static TestValue4.ref staticValueField;
TestValue4 nonStaticValueField;
TestValue4[] valueArray;
}

public inline final class TestValue4 {

static TestValue4? staticValue = getInstance();
static TestValue4.ref staticValue = getInstance();

final byte b1;
final byte b2;
Original file line number Diff line number Diff line change
@@ -33,15 +33,15 @@
* @run main/othervm -Xcomp -XX:ValueFieldMaxFlatSize=64 runtime.valhalla.valuetypes.UninitializedValueFieldsTest
*/
public class UninitializedValueFieldsTest {
static Point? nonFlattenableStaticPoint;
static Point.ref nonFlattenableStaticPoint;
static Point staticPoint;

Point instancePoint;

static JumboValue? sj1;
static JumboValue.ref sj1;
static JumboValue sj2;

JumboValue? j1;
JumboValue.ref j1;
JumboValue j2;

static Object getNull() {
46 changes: 23 additions & 23 deletions test/hotspot/jtreg/runtime/valhalla/valuetypes/ValueTypeArray.java
Original file line number Diff line number Diff line change
@@ -223,23 +223,23 @@ void testReflectArray() {

// Now create ObjArrays of ValueArray...
cls = (Class<?>) Point.class.asIndirectType();
Point?[][] barray = (Point?[][]) Array.newInstance(cls, 1, 2);
Point.ref[][] barray = (Point.ref[][]) Array.newInstance(cls, 1, 2);
assertEquals(barray.length, 1, "Incorrect length");
assertEquals(barray[0].length, 2, "Incorrect length");
barray[0][1] = Point.createPoint(1, 2);
Point? pb = barray[0][1];
Point.ref pb = barray[0][1];
int x = pb.getX();
assertEquals(x, 1, "Bad Point Value");
}

static final inline class MyInt implements Comparable<MyInt?> {
static final inline class MyInt implements Comparable<MyInt.ref> {
final int value;

private MyInt() { this(0); }
private MyInt(int v) { value = v; }
public int getValue() { return value; }
public String toString() { return "MyInt: " + getValue(); }
public int compareTo(MyInt? that) { return Integer.compare(this.getValue(), that.getValue()); }
public int compareTo(MyInt.ref that) { return Integer.compare(this.getValue(), that.getValue()); }
public boolean equals(Object o) {
if (o instanceof MyInt) {
return this.getValue() == ((MyInt) o).getValue();
@@ -252,9 +252,9 @@ public static MyInt create(int v) {
}

// Null-able fields here are a temp hack to avoid ClassCircularityError
public static final MyInt? MIN = MyInt.create(Integer.MIN_VALUE);
public static final MyInt? ZERO = MyInt.create(0);
public static final MyInt? MAX = MyInt.create(Integer.MAX_VALUE);
public static final MyInt.ref MIN = MyInt.create(Integer.MIN_VALUE);
public static final MyInt.ref ZERO = MyInt.create(0);
public static final MyInt.ref MAX = MyInt.create(Integer.MAX_VALUE);
}

static MyInt staticMyInt = MyInt.create(-1);
@@ -274,7 +274,7 @@ void testSanityCheckcasts() {
MyInt[] myInts = new MyInt[1];
assertTrue(myInts instanceof Object[]);
assertTrue(myInts instanceof Comparable[]);
assertTrue(myInts instanceof MyInt?[]);
assertTrue(myInts instanceof MyInt.ref[]);

Class<?> cls = MyInt.class;
assertTrue(cls.isInlineClass());
@@ -293,26 +293,26 @@ void testSanityCheckcasts() {
MyOtherInt[][] matrix = new MyOtherInt[1][1];
assertTrue(matrix[0] instanceof MyOtherInt[]);
assertTrue(matrix[0] instanceof SomeSecondaryType[]);
assertTrue(matrix[0] instanceof MyOtherInt?[]);
assertTrue(matrix[0] instanceof MyOtherInt.ref[]);

// Box types vs Inline...
MyInt?[] myValueRefs = new MyInt?[1];
assertTrue(myValueRefs instanceof MyInt?[]);
MyInt.ref[] myValueRefs = new MyInt.ref[1];
assertTrue(myValueRefs instanceof MyInt.ref[]);
assertTrue(myValueRefs instanceof Object[]);
assertTrue(myValueRefs instanceof Comparable[]);
assertFalse(myValueRefs instanceof MyInt[]);

MyInt?[][] myMdValueRefs = new MyInt?[1][1];
assertTrue(myMdValueRefs[0] instanceof MyInt?[]);
MyInt.ref[][] myMdValueRefs = new MyInt.ref[1][1];
assertTrue(myMdValueRefs[0] instanceof MyInt.ref[]);
assertTrue(myMdValueRefs[0] instanceof Object[]);
assertTrue(myMdValueRefs[0] instanceof Comparable[]);
assertFalse(myMdValueRefs[0] instanceof MyInt[]);

// Did we break checkcast...
MyInt?[] va1 = (MyInt?[])null;
MyInt?[] va2 = null;
MyInt?[][] va3 = (MyInt?[][])null;
MyInt?[][][] va4 = (MyInt?[][][])null;
MyInt.ref[] va1 = (MyInt.ref[])null;
MyInt.ref[] va2 = null;
MyInt.ref[][] va3 = (MyInt.ref[][])null;
MyInt.ref[][][] va4 = (MyInt.ref[][][])null;
MyInt[] va5 = null;
MyInt[] va6 = (MyInt[])null;
MyInt[][] va7 = (MyInt[][])null;
@@ -323,7 +323,7 @@ void testSanityCheckcasts() {
void testUtilArrays() {
// Sanity check j.u.Arrays

// cast to q-type temp effect of avoiding circularity error (decl static MyInt?)
// cast to q-type temp effect of avoiding circularity error (decl static MyInt.ref)
MyInt[] myInts = new MyInt[] { (MyInt) MyInt.MAX, (MyInt) MyInt.MIN };
// Sanity sort another copy
MyInt[] copyMyInts = Arrays.copyOf(myInts, myInts.length + 1);
@@ -385,12 +385,12 @@ void testSanityObjectArrays() {
comparables[1] = null;
assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?");

MyInt?[] myIntRefArray = new MyInt?[1];
MyInt.ref[] myIntRefArray = new MyInt.ref[1];
assertTrue(myIntRefArray[0] == null, "Got: " + myIntRefArray[0]);
myIntRefArray[0] = null;

MyInt?[] srcNulls = new MyInt?[2];
MyInt?[] dstNulls = new MyInt?[2];
MyInt.ref[] srcNulls = new MyInt.ref[2];
MyInt.ref[] dstNulls = new MyInt.ref[2];
System.arraycopy(srcNulls, 0, dstNulls, 0, 2);
checkArrayElementsEqual(srcNulls, dstNulls);
srcNulls[1] = MyInt.create(1);
@@ -432,7 +432,7 @@ void testMixedLayoutArrays() {
throw new RuntimeException("Expected ArrayStoreException");
} catch (ArrayStoreException ase) {}

MyInt?[] myIntRefArray = new MyInt?[3];
MyInt.ref[] myIntRefArray = new MyInt.ref[3];
System.arraycopy(valArray, 0, myIntRefArray, 0, 3);
checkArrayElementsEqual(valArray, myIntRefArray);

@@ -465,7 +465,7 @@ static MyPoint create(int x) {
static MyPoint create(int x, int y) {
return new MyPoint(x, y);
}
static final MyPoint? ORIGIN = create(0);
static final MyPoint.ref ORIGIN = create(0);
}

void testComposition() {
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ void testPerson() {

static final inline class StaticSelf {

static final StaticSelf? DEFAULT = create(0);
static final StaticSelf.ref DEFAULT = create(0);
final int f1;

private StaticSelf() { f1 = 0; }
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ static void testExecutionStackToFields(Class<?> inlineClass, Class<?> containerC
String sig = "()Q" + inlineClass.getName() + ";";
final String methodSignature = sig.replace('.', '/');
final String fieldQSignature = "Q" + inlineClass.getName().replace('.', '/') + ";";
final String fieldLSignature = "L" + inlineClass.getName().replace('.', '/') + ";";
final String fieldLSignature = "L" + inlineClass.getName().replace('.', '/') + "$ref;";
System.out.println(methodSignature);
MethodHandle fromExecStackToFields = MethodHandleBuilder.loadCode(
LOOKUP,
@@ -187,13 +187,15 @@ static void testExecutionStackToFields(Class<?> inlineClass, Class<?> containerC
.putstatic(containerClass, "staticValueField", fieldLSignature)
.invokestatic(System.class, "gc", "()V", false)
.getstatic(containerClass, "staticValueField", fieldLSignature)
.checkcast(inlineClass)
.invokevirtual(inlineClass, "verify", "()Z", false)
.iconst_1()
.ifcmp(TypeTag.I, CondKind.NE, "failed")
.invokestatic(inlineClass, "getNonBufferedInstance", methodSignature, false)
.putstatic(containerClass, "staticValueField", fieldLSignature)
.invokestatic(System.class, "gc", "()V", false)
.getstatic(containerClass, "staticValueField", fieldLSignature)
.checkcast(inlineClass)
.invokevirtual(inlineClass, "verify", "()Z", false)
.iconst_1()
.ifcmp(TypeTag.I, CondKind.NE, "failed")