Skip to content

Commit 2ea06f8

Browse files
navyxliuXin Liu
andauthored
Add the unit test MergeAllVirts (openjdk#10)
Co-authored-by: Xin Liu <xxinliu@amazon.com>
1 parent 05d954a commit 2ea06f8

File tree

10 files changed

+89
-23
lines changed

10 files changed

+89
-23
lines changed

PEA/MergeAllVirts.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
class MergeAllVirts {
2+
int a;
3+
int b;
4+
int c = 100;
5+
6+
public MergeAllVirts() {}
7+
8+
public int sum() {
9+
return a + b + c;
10+
}
11+
12+
public static int add(boolean cond) {
13+
MergeAllVirts obj = new MergeAllVirts();
14+
if (cond) {
15+
obj.a = 1;
16+
} else {
17+
obj.b = 2;
18+
}
19+
//obj3 = phi(obj1, obj2);
20+
return obj.sum();
21+
}
22+
23+
public static MergeAllVirts cached;
24+
public static void escaped(boolean cond) {
25+
MergeAllVirts obj = new MergeAllVirts();
26+
27+
if (cond) {
28+
obj.a = 1;
29+
} else {
30+
obj.b = 2;
31+
}
32+
// return obj; we don't materialize at exit. if it's virtual, keep it virtual.
33+
cached = obj; // materialize here.
34+
}
35+
36+
static void check_result(boolean cond, int sum) {
37+
if ((cond && sum != 101) || (!cond && sum != 102)) {
38+
throw new RuntimeException("wrong answer: " + sum);
39+
}
40+
}
41+
public static void main(String[] args) {
42+
long iterations = 0;
43+
44+
try {
45+
while (true) {
46+
boolean cond = 0 == (iterations & 0xf);
47+
int sum = MergeAllVirts.add(cond);
48+
check_result(cond, sum);
49+
50+
MergeAllVirts.escaped(cond);
51+
check_result(cond, cached.sum());
52+
53+
iterations++;
54+
}
55+
} finally {
56+
System.err.println("Epsilon Test: " + iterations);
57+
}
58+
}
59+
}

PEA/auto.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
#!/bin/bash
2-
3-
set -x
4-
JVM_FLAGS="-XX:+PrintEscapeAnalysis -XX:+PrintEliminateAllocations -XX:+PrintOptoAssembly"
5-
./run1.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
6-
./run1_ivanov.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
7-
./run2.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
8-
./run2_merykitty.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
9-
./run2b.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
10-
./run2_1.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
11-
./run3_1.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
12-
./run3_2.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
13-
./run3.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
14-
./run_str.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis -XX:-UseTLAB $JVM_FLAGS
15-
./run_exception.sh -Xlog:gc -XX:+DoPartialEscapeAnalysis $JVM_FLAGS
1+
#!/bin/bash
2+
3+
JVM_FLAGS="-XX:+PrintEscapeAnalysis -XX:+PrintEliminateAllocations -XX:+PrintOptoAssembly -Xlog:gc -XX:+DoPartialEscapeAnalysis"
4+
5+
echo "using" `which java`
6+
java --version
7+
8+
for t in run*.sh
9+
do
10+
./$t $JVM_FLAGS > $t.log
11+
12+
exitcode=$?
13+
if [ $exitcode -eq 0 ] || [ $exitcode -eq 3 ]; then
14+
echo -e "[$t]\tpassed."
15+
else
16+
echo -e "[$t]\tfailed!"
17+
exit 1
18+
fi
19+
done

PEA/run1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/usr/bin/bash
2-
java -showversion -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:+UseTLAB -XX:CompileOnly='Example1.foo' -XX:CompileCommand=dontinline,Example1.blackhole $* Example1
1+
#!/usr/bin/bash
2+
java -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:+UseTLAB -XX:CompileOnly='Example1.foo' -XX:CompileCommand=dontinline,Example1.blackhole $* Example1

PEA/run1_ivanov.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/bash
22
java -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:+UseTLAB -XX:CompileOnly='Example1_ivanov.ivanov' -XX:CompileCommand=dontinline,Example1_ivanov.blackhole $* Example1_ivanov

PEA/run2.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/usr/bin/bash
2-
java -showversion -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:-UseTLAB -XX:CompileOnly='Example2.foo' -XX:CompileCommand=dontinline,Example2.blackhole $* Example2
1+
#!/usr/bin/bash
2+
java -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:-UseTLAB -XX:CompileOnly='Example2.foo' -XX:CompileCommand=dontinline,Example2.blackhole $* Example2

PEA/run2_1.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/bash
22
java -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:+UseTLAB -XX:CompileCommand='compileonly,Example2_1::foo*' -XX:CompileCommand=dontinline,Example2.blackhole $* Example2_1
33
java -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:+UseTLAB -XX:CompileCommand='compileonly,Example2_1::foo*' -XX:CompileCommand=dontinline,Example2.blackhole $* Example2_1

PEA/run2_merykitty.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/bash
22
java -ea -Xcomp -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:-UseTLAB -XX:CompileOnly='Example2_merykitty.foo' -XX:CompileCommand=dontinline,Example2_merykitty.blackhole $* Example2_merykitty

PEA/run3.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#!/usr/bin/bash
12
java -XX:+PrintCompilation -XX:CompileCommand='CompileOnly,Example3::confined_close' -XX:CompileCommand=quiet -XX:-UseOnStackReplacement -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xms32M -Xmx32M -XX:-TieredCompilation $* Example3

PEA/run_merge_all_virts.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/bash
2+
java -Xms32M -Xmx32M -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-UseTLAB -XX:CompileCommand='compileonly,MergeAllVirts::*' $* MergeAllVirts

PEA/run_str.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/bash
22
java -Xcomp -Xms16M -Xmx16M -XX:+UnlockExperimentalVMOptions -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseOnStackReplacement -XX:CompileOnly='Str.strBuilderRepro' -XX:-Inline $* Str

0 commit comments

Comments
 (0)