Skip to content

Commit b70503b

Browse files
navyxliuXin Liu
andauthored
[PEA] test add problemlist (openjdk#20)
* Replace auto.sh to auto.rb also remove executable property from those launch scripts. * JVM-1878: [PEA] refactor auto.sh to support problem-list. * Add BadGraphVolatile and put it in the problem list. --------- Co-authored-by: Xin Liu <xxinliu@amazon.com>
1 parent 3380411 commit b70503b

20 files changed

+102
-28
lines changed

PEA/BadGraphVolatile.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class BadGraphVolatile {
2+
// use volatile to force c2 to load it again
3+
volatile int value;
4+
5+
BadGraphVolatile(int value) {
6+
this.value = value;
7+
}
8+
9+
void blackhole(int field) {
10+
assert field == 42 :" wrong answer";
11+
}
12+
13+
public static void foo(int value) {
14+
var x = new BadGraphVolatile(value);
15+
x.blackhole(x.value);
16+
return;
17+
}
18+
19+
public static void main(String[] args) {
20+
for (int i = 0; i < 30_000; ++i) {
21+
foo(42);
22+
}
23+
}
24+
}

PEA/CrazyException.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,11 @@ public static Object foo(boolean cond) {
1313
}
1414
return x;
1515
}
16+
1617
public static void close() {}
1718
public static void main(String[] args) {
18-
int iterations = 0;
19-
try {
20-
while (iterations < 20_000) {
21-
CrazyException.foo(0 == (iterations & 0xf));
22-
iterations++;
23-
}
24-
} finally {
25-
System.err.println("Epsilon Test: " + iterations);
19+
for (int i = 0; i < 20_000; ++i) {
20+
CrazyException.foo(0 == ( i& 0xf));
2621
}
2722
}
2823
}

PEA/EscapeInInitializer.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
class EscapeInInitializer {
2+
private final int foo;
3+
private final int bar;
4+
private static EscapeInInitializer cache;
5+
6+
EscapeInInitializer() {
7+
this.foo = 1; // put a final field, set_alloc_with_final(obj)
8+
cache = this; // materialize this here.
9+
this.bar = 2; // put a final field again, set_alloc_with_final(obj)
10+
}
11+
12+
EscapeInInitializer(int i) {
13+
this.foo = 1; // put a final field, set_alloc_with_final(obj)
14+
this.bar = the_answer(); // invocation, either inline or not line may trigger materialization.
15+
}
16+
17+
EscapeInInitializer(boolean cond) {
18+
this.foo = 1; // put a final field, set_alloc_with_final(obj)
19+
this.bar = 2;
20+
if (cond) {
21+
cache = this; // materialize this here.
22+
}
23+
// we need to merge 'this' here, and then emit the trailing barrier for the phi.
24+
}
25+
26+
int the_answer() { // of life, the universe and everything...
27+
cache = this; // materialize 'this' here
28+
return 42;
29+
}
30+
31+
static void test(int i) {
32+
var kase = new EscapeInInitializer();
33+
var kase2 = new EscapeInInitializer(i);
34+
var kase3 = new EscapeInInitializer(0 == (i % 100));
35+
}
36+
37+
public static void main(String[] args) {
38+
for (int i = 0; i < 30_000; ++i) {
39+
test(i);
40+
}
41+
}
42+
}

PEA/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ all: set_jdk
2626
javac *.java
2727

2828
run: set_jdk
29-
./auto.sh
29+
./auto.rb
3030

3131
$(CTW_DIST):
3232
${MAKE} -C ${CTW_DIR} all

PEA/auto.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env ruby
2+
3+
JVM_FLAGS="-XX:+PrintEscapeAnalysis -XX:+PrintEliminateAllocations -XX:+PrintOptoAssembly -Xlog:gc -XX:+DoPartialEscapeAnalysis"
4+
PROBLEM_LIST = ["run1_generic.sh", "run_EscapeInInitializer.sh", "run_badgraph_volatile.sh"]
5+
6+
if $0 == __FILE__
7+
puts "using #{%x|which java|}"
8+
system("java --version")
9+
10+
Dir.glob("run*.sh").each do |t|
11+
print "[#{t}]"
12+
13+
ret = system("sh ./#{t} #{JVM_FLAGS} > #{t}.log")
14+
if ret == nil then
15+
puts "\t fail to execute."
16+
else
17+
# exitcode == 3 is out of memory. acceptable.
18+
if ret or $?.exitstatus == 3 then
19+
puts "\tpassed."
20+
elsif PROBLEM_LIST.include? t then
21+
puts "\ta known issue."
22+
else
23+
puts "\tfailed!"
24+
exit(1)
25+
end
26+
end
27+
end
28+
end

PEA/auto.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

PEA/run1.sh

100755100644
File mode changed.

PEA/run1_ivanov.sh

100755100644
File mode changed.

PEA/run2.sh

100755100644
File mode changed.

PEA/run2_1.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)