24
24
25
25
/*
26
26
* @test id=aot
27
- * @requires vm.cds.write.archived.java.heap
27
+ * @requires vm.cds.supports.aot.class.linking
28
+ * @comment work around JDK-8345635
29
+ * @requires !vm.jvmci.enabled
28
30
* @library /test/jdk/lib/testlibrary /test/lib
29
31
* @build EndTrainingOnMethodEntry
30
32
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar MyTestApp ShouldBeCached ShouldNotBeCached
33
35
34
36
/*
35
37
* @test id=leyden
36
- * @requires vm.cds.write.archived.java.heap
38
+ * @requires vm.cds.supports.aot.class.linking
39
+ * @comment work around JDK-8345635
40
+ * @requires !vm.jvmci.enabled
37
41
* @library /test/jdk/lib/testlibrary /test/lib
38
42
* @build EndTrainingOnMethodEntry
39
43
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar MyTestApp ShouldBeCached ShouldNotBeCached
@@ -49,16 +53,18 @@ public class EndTrainingOnMethodEntry {
49
53
static final String mainClass = "MyTestApp" ;
50
54
51
55
public static void main (String [] args ) throws Exception {
52
- (new Tester (false )).run (args );
53
- (new Tester (true )).run (args );
56
+ // We want to test the entry count implementation in both interpreter and compiler.
57
+ (new Tester (1 )).run (args );
58
+ (new Tester (10 )).run (args ); // the loop will probably be interpreted
59
+ (new Tester (10000 )).run (args ); // the loop will probably be compiled.
54
60
}
55
61
56
62
static class Tester extends CDSAppTester {
57
- boolean useCount ;
63
+ int count ;
58
64
59
- public Tester (boolean useCount ) {
65
+ public Tester (int count ) {
60
66
super (mainClass );
61
- this .useCount = useCount ;
67
+ this .count = count ;
62
68
}
63
69
64
70
@ Override
@@ -67,7 +73,7 @@ public String classpath(RunMode runMode) {
67
73
}
68
74
69
75
public String [] vmArgs (RunMode runMode ) {
70
- String stop = useCount ? ("stopTrainingOnMeWithCount,count=" + MyTestApp . COUNT ) : "stopTrainingOnMe" ;
76
+ String stop = count > 1 ? ("stopTrainingOnMeWithCount,count=" + count ) : "stopTrainingOnMe" ;
71
77
return new String [] {
72
78
"-Xlog:cds+class=debug" ,
73
79
"-XX:AOTEndTrainingOnMethodEntry=MyTestApp." + stop ,
@@ -77,14 +83,16 @@ public String[] vmArgs(RunMode runMode) {
77
83
@ Override
78
84
public String [] appCommandLine (RunMode runMode ) {
79
85
return new String [] {
80
- mainClass , runMode .name (), Boolean .toString (useCount ),
86
+ mainClass , runMode .name (), Integer .toString (count ),
81
87
};
82
88
}
83
89
84
90
@ Override
85
91
public void checkExecution (OutputAnalyzer out , RunMode runMode ) {
86
92
if (runMode .isApplicationExecuted ()) {
87
93
out .shouldContain ("Hello Leyden " + runMode .name ());
94
+ out .shouldContain ("ShouldBeCached.dummy()" );
95
+ out .shouldContain ("ShouldNotBeCached.dummy()" );
88
96
}
89
97
if (isDumping (runMode )) {
90
98
out .shouldMatch ("cds,class.* ShouldBeCached" );
@@ -95,11 +103,13 @@ public void checkExecution(OutputAnalyzer out, RunMode runMode) {
95
103
}
96
104
97
105
class MyTestApp {
98
- public static final int COUNT = 10 ; // FIXME (JDK-8351100): debug build crashes with COUNT = 10000;
99
- public static void main (String args []) {
100
- System .out .println ("Hello Leyden " + args [0 ] + ", useCount = " + args [1 ]);
101
- if (args [1 ].equals ("true" )) {
102
- for (int i = 0 ; i < COUNT + 10 ; i ++) {
106
+ public static int COUNT ;
107
+ public static void main (String args []) throws Exception {
108
+ System .out .println ("Hello Leyden " + args [0 ] + ", count = " + args [1 ]);
109
+ COUNT = Integer .parseInt (args [1 ]);
110
+ if (COUNT > 1 ) {
111
+ int max = COUNT + 10 ;
112
+ for (int i = 0 ; i < max ; i ++) {
103
113
stopTrainingOnMeWithCount (i );
104
114
}
105
115
} else {
@@ -117,7 +127,6 @@ static void stopTrainingOnMe() {
117
127
118
128
static void stopTrainingOnMeWithCount (int i ) {
119
129
if (i >= COUNT - 2 ) {
120
- System .out .println ("COUNT = " + COUNT + ", i = " + i );
121
130
ShouldBeCached .dummy ();
122
131
}
123
132
if (i >= COUNT ) {
0 commit comments