Skip to content
Permalink
Browse files
8252040: [lworld] Execute compiler unit tests in random order
  • Loading branch information
TobiHartmann committed Aug 31, 2020
1 parent 3540dd4 commit 9bde3a446168d1ede6994c5d77c03aa3b2a91867
@@ -39,6 +39,8 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
@@ -122,6 +124,7 @@
// Random test values
public static final int rI = Utils.getRandomInstance().nextInt() % 1000;
public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
public static final double rD = Utils.getRandomInstance().nextDouble() % 1000;

// User defined settings
protected static final boolean XCOMP = Platform.isComp();
@@ -140,6 +143,7 @@
private static final boolean GC_AFTER = Boolean.parseBoolean(System.getProperty("GCAfter", "false"));
private static final int OSR_TEST_TIMEOUT = Integer.parseInt(System.getProperty("OSRTestTimeOut", "5000"));
protected static final boolean STRESS_CC = Boolean.parseBoolean(System.getProperty("StressCC", "false"));
private static final boolean SHUFFLE_TESTS = Boolean.parseBoolean(System.getProperty("ShuffleTests", "false"));

// "jtreg -DXcomp=true" runs all the scenarios with -Xcomp. This is faster than "jtreg -javaoptions:-Xcomp".
protected static final boolean RUN_SCENARIOS_WITH_XCOMP = Boolean.parseBoolean(System.getProperty("Xcomp", "false"));
@@ -177,7 +181,7 @@
protected static final int TypeProfileOn = 0x4000;
protected static final int TypeProfileOff = 0x8000;
protected static final boolean InlineTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("InlineTypePassFieldsAsArgs");
protected static final boolean InlineTypeArrayFlatten = (WHITE_BOX.getIntxVMFlag("FlatArrayElementMaxSize") == -1); // FIXME - fix this if default of FlatArrayElementMaxSize is changed
protected static final boolean InlineTypeArrayFlatten = (WHITE_BOX.getIntxVMFlag("FlatArrayElementMaxSize") == -1);
protected static final boolean InlineTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("InlineTypeReturnedAsFields");
protected static final boolean AlwaysIncrementalInline = (Boolean)WHITE_BOX.getVMFlag("AlwaysIncrementalInline");
protected static final boolean G1GC = (Boolean)WHITE_BOX.getVMFlag("UseG1GC");
@@ -216,6 +220,7 @@
protected static final String LOAD_UNKNOWN_INLINE = "(.*call_leaf,runtime load_unknown_inline.*" + END;
protected static final String STORE_UNKNOWN_INLINE = "(.*call_leaf,runtime store_unknown_inline.*" + END;
protected static final String INLINE_ARRAY_NULL_GUARD = "(.*call,static wrapper for: uncommon_trap.*reason='null_check' action='none'.*" + END;
protected static final String INTRINSIC_SLOW_PATH = "(.*call,static wrapper for: uncommon_trap.*reason='intrinsic_or_type_checked_inlining'.*" + END;
protected static final String CLASS_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*class_check" + END;
protected static final String NULL_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*null_check" + END;
protected static final String RANGE_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*range_check" + END;
@@ -404,6 +409,13 @@ protected InlineTypeTest() {
if (annos.length != 0 &&
((list == null || list.contains(m.getName())) && (exclude == null || !exclude.contains(m.getName())))) {
tests.put(getClass().getSimpleName() + "::" + m.getName(), m);
} else if (annos.length == 0 && m.getName().startsWith("test")) {
try {
getClass().getMethod(m.getName() + "_verifier", boolean.class);
throw new RuntimeException(m.getName() + " has a verifier method but no @Test annotation");
} catch (NoSuchMethodException e) {
// Expected
}
}
}
}
@@ -576,7 +588,7 @@ private void parseOutput(String output) throws Exception {
nodes += matcher.group() + "\n";
}
if (matchCount[i] < 0) {
Asserts.assertLTE(Math.abs(matchCount[i]), count, "Graph for '" + testName + "' contains different number of match nodes (expected <= " + matchCount[i] + " but got " + count + "):\n" + nodes);
Asserts.assertLTE(Math.abs(matchCount[i]), count, "Graph for '" + testName + "' contains different number of match nodes (expected >= " + Math.abs(matchCount[i]) + " but got " + count + "):\n" + nodes);
} else {
Asserts.assertEQ(matchCount[i], count, "Graph for '" + testName + "' contains different number of match nodes (expected " + matchCount[i] + " but got " + count + "):\n" + nodes);
}
@@ -657,9 +669,13 @@ private void run(Class<?>... classes) throws Exception {
setup(clazz);
}

// Execute tests
TreeMap<Long, String> durations = (PRINT_TIMES || VERBOSE) ? new TreeMap<Long, String>() : null;
for (Method test : tests.values()) {
List<Method> testList = new ArrayList<Method>(tests.values());
if (SHUFFLE_TESTS) {
// Execute tests in random order (execution sequence affects profiling)
Collections.shuffle(testList, Utils.getRandomInstance());
}
for (Method test : testList) {
if (VERBOSE) {
System.out.println("Starting " + test.getName());
}
@@ -33,7 +33,7 @@
final int[] oa;
final MyValue2 v1;
final MyValue2 v2;
static final MyValue2 v3 = MyValue2.createWithFieldsInline(InlineTypeTest.rI, true);
static final MyValue2 v3 = MyValue2.createWithFieldsInline(InlineTypeTest.rI, InlineTypeTest.rD);
final int c;

@ForceInline
@@ -73,8 +73,8 @@ static MyValue1 createWithFieldsInline(int x, long y) {
v = setO(v, new Integer(x));
int[] oa = {x};
v = setOA(v, oa);
v = setV1(v, MyValue2.createWithFieldsInline(x, y, true));
v = setV2(v, MyValue2.createWithFieldsInline(x, y, false));
v = setV1(v, MyValue2.createWithFieldsInline(x, y, InlineTypeTest.rD));
v = setV2(v, MyValue2.createWithFieldsInline(x, y, InlineTypeTest.rD+x));
v = setC(v, (int)(x+y));
return v;
}
@@ -24,23 +24,23 @@
package compiler.valhalla.inlinetypes;

final inline class MyValue2Inline {
final boolean b;
final long c;
final double d;
final long l;

@ForceInline
public MyValue2Inline(boolean b, long c) {
this.b = b;
this.c = c;
public MyValue2Inline(double d, long l) {
this.d = d;
this.l = l;
}

@ForceInline
static MyValue2Inline setB(MyValue2Inline v, boolean b) {
return new MyValue2Inline(b, v.c);
static MyValue2Inline setD(MyValue2Inline v, double d) {
return new MyValue2Inline(d, v.l);
}

@ForceInline
static MyValue2Inline setC(MyValue2Inline v, long c) {
return new MyValue2Inline(v.b, c);
static MyValue2Inline setL(MyValue2Inline v, long l) {
return new MyValue2Inline(v.d, l);
}

@ForceInline
@@ -49,24 +49,24 @@ public static MyValue2Inline createDefault() {
}

@ForceInline
public static MyValue2Inline createWithFieldsInline(boolean b, long c) {
public static MyValue2Inline createWithFieldsInline(double d, long l) {
MyValue2Inline v = MyValue2Inline.createDefault();
v = MyValue2Inline.setB(v, b);
v = MyValue2Inline.setC(v, c);
v = MyValue2Inline.setD(v, d);
v = MyValue2Inline.setL(v, l);
return v;
}
}

public final inline class MyValue2 extends MyAbstract {
final int x;
final byte y;
final MyValue2Inline v1;
final MyValue2Inline v;

@ForceInline
public MyValue2(int x, byte y, MyValue2Inline v1) {
public MyValue2(int x, byte y, MyValue2Inline v) {
this.x = x;
this.y = y;
this.v1 = v1;
this.v = v;
}

@ForceInline
@@ -75,59 +75,59 @@ public static MyValue2 createDefaultInline() {
}

@ForceInline
public static MyValue2 createWithFieldsInline(int x, long y, boolean b) {
public static MyValue2 createWithFieldsInline(int x, long y, double d) {
MyValue2 v = createDefaultInline();
v = setX(v, x);
v = setY(v, (byte)x);
v = setV1(v, MyValue2Inline.createWithFieldsInline(b, y));
v = setV(v, MyValue2Inline.createWithFieldsInline(d, y));
return v;
}

@ForceInline
public static MyValue2 createWithFieldsInline(int x, boolean b) {
public static MyValue2 createWithFieldsInline(int x, double d) {
MyValue2 v = createDefaultInline();
v = setX(v, x);
v = setY(v, (byte)x);
v = setV1(v, MyValue2Inline.createWithFieldsInline(b, InlineTypeTest.rL));
v = setV(v, MyValue2Inline.createWithFieldsInline(d, InlineTypeTest.rL));
return v;
}

@DontInline
public static MyValue2 createWithFieldsDontInline(int x, boolean b) {
public static MyValue2 createWithFieldsDontInline(int x, double d) {
MyValue2 v = createDefaultInline();
v = setX(v, x);
v = setY(v, (byte)x);
v = setV1(v, MyValue2Inline.createWithFieldsInline(b, InlineTypeTest.rL));
v = setV(v, MyValue2Inline.createWithFieldsInline(d, InlineTypeTest.rL));
return v;
}

@ForceInline
public long hash() {
return x + y + (v1.b ? 0 : 1) + v1.c;
return x + y + (long)v.d + v.l;
}

@DontInline
public long hashInterpreted() {
return x + y + (v1.b ? 0 : 1) + v1.c;
return x + y + (long)v.d + v.l;
}

@ForceInline
public void print() {
System.out.print("x=" + x + ", y=" + y + ", b=" + v1.b + ", c=" + v1.c);
System.out.print("x=" + x + ", y=" + y + ", d=" + v.d + ", l=" + v.l);
}

@ForceInline
static MyValue2 setX(MyValue2 v, int x) {
return new MyValue2(x, v.y, v.v1);
return new MyValue2(x, v.y, v.v);
}

@ForceInline
static MyValue2 setY(MyValue2 v, byte y) {
return new MyValue2(v.x, y, v.v1);
return new MyValue2(v.x, y, v.v);
}

@ForceInline
static MyValue2 setV1(MyValue2 v, MyValue2Inline v1) {
return new MyValue2(v.x, v.y, v1);
static MyValue2 setV(MyValue2 v, MyValue2Inline vi) {
return new MyValue2(v.x, v.y, vi);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -113,6 +113,7 @@ static public void main(String[] args) throws Exception {
test6(va, vt);
try {
test6(va, null);
throw new RuntimeException("NullPointerException expected");
} catch (NullPointerException npe) {
// Expected
}
@@ -122,6 +123,7 @@ static public void main(String[] args) throws Exception {
test9(va, vt);
try {
test9(va, null);
throw new RuntimeException("NullPointerException expected");
} catch (NullPointerException npe) {
// Expected
}

0 comments on commit 9bde3a4

Please sign in to comment.