@@ -109,39 +109,44 @@ public class AOTCodeFlags {
109109 private static String gcName = null ;
110110 public static void main (String ... args ) throws Exception {
111111 Tester t = new Tester (args .length == 0 ? null : args [0 ]);
112- // Run only 2 modes (0 - no AOT code, 1 - AOT adapters) until JDK-8357398 is fixed
113- for (int mode = 0 ; mode < 4 ; mode ++) {
114- t .setTestMode (mode );
115- t .run (new String [] {"AOT" , "--two-step-training" });
112+ // mode bits 0 and 1 encode AOTAdapterCaching and AOTStubCaching settings
113+ // aMode is used for assembly run, pMode for production run
114+ for (int aMode = 0 ; aMode < 4 ; aMode ++) {
115+ for (int pMode = 0 ; pMode < 4 ; pMode ++) {
116+ t .setTestMode (aMode , pMode );
117+ t .run (new String [] {"AOT" , "--two-step-training" });
118+ }
116119 }
117120 }
118121 static class Tester extends CDSAppTester {
119- private int testMode ;
122+ private int aMode , pMode ;
120123 private String gcName ;
121124
122125 public Tester (String name ) {
123126 super ("AOTCodeFlags" );
124- testMode = 0 ;
127+ aMode = 0 ;
128+ pMode = 0 ;
125129 gcName = name ;
126130 }
127131
128- boolean isAdapterCachingOn () {
129- return (testMode & 0x1 ) != 0 ;
132+ boolean isAdapterCachingOn (int mode ) {
133+ return (mode & 0x1 ) != 0 ;
130134 }
131135
132- boolean isStubCachingOn () {
133- return (testMode & 0x2 ) != 0 ;
136+ boolean isStubCachingOn (int mode ) {
137+ return (mode & 0x2 ) != 0 ;
134138 }
135139
136- public void setTestMode (int mode ) {
137- testMode = mode ;
140+ public void setTestMode (int aMode , int pMode ) {
141+ this .aMode = aMode ;
142+ this .pMode = pMode ;
138143 }
139144
140- public List <String > getVMArgsForTestMode () {
145+ public List <String > getVMArgsForTestMode (int mode ) {
141146 List <String > list = new ArrayList <String >();
142147 list .add ("-XX:+UnlockDiagnosticVMOptions" );
143- list .add (isAdapterCachingOn () ? "-XX:+AOTAdapterCaching" : "-XX:-AOTAdapterCaching" );
144- list .add (isStubCachingOn () ? "-XX:+AOTStubCaching" : "-XX:-AOTStubCaching" );
148+ list .add (isAdapterCachingOn (mode ) ? "-XX:+AOTAdapterCaching" : "-XX:-AOTAdapterCaching" );
149+ list .add (isStubCachingOn (mode ) ? "-XX:+AOTStubCaching" : "-XX:-AOTStubCaching" );
145150 return list ;
146151 }
147152
@@ -170,79 +175,91 @@ public String classpath(RunMode runMode) {
170175
171176 @ Override
172177 public String [] vmArgs (RunMode runMode ) {
178+ List <String > args = getGCArgs ();
179+ args .addAll (List .of ("-Xlog:aot+codecache+init=debug" ,
180+ "-Xlog:aot+codecache+exit=debug" ,
181+ "-Xlog:aot+codecache+stubs=debug" ));
173182 switch (runMode ) {
174183 case RunMode .ASSEMBLY :
175- case RunMode . PRODUCTION : {
176- List < String > args = getVMArgsForTestMode () ;
177- args . addAll ( List . of ( "-Xlog:aot+codecache+init=debug" ,
178- "-Xlog:aot+codecache+exit=debug" ));
179- args . addAll ( getGCArgs ()) ;
180- return args . toArray ( new String [ 0 ]);
181- }
184+ args . addAll ( getVMArgsForTestMode ( aMode ));
185+ break ;
186+ case RunMode . PRODUCTION :
187+ args . addAll ( getVMArgsForTestMode ( pMode ));
188+ break ;
189+ default :
190+ break ;
182191 }
183- List <String > args = getGCArgs ();
184192 return args .toArray (new String [args .size ()]);
185193 }
186194
187195 @ Override
188196 public String [] appCommandLine (RunMode runMode ) {
189- return new String [] {
190- "JavacBenchApp" , "10"
191- };
197+ return new String [] { "JavacBenchApp" , "10" };
192198 }
193199
194200 @ Override
195201 public void checkExecution (OutputAnalyzer out , RunMode runMode ) throws Exception {
196- if (!isAdapterCachingOn () && !isStubCachingOn ()) { // this is equivalent to completely disable AOT code cache
197- switch (runMode ) {
198- case RunMode .ASSEMBLY :
199- case RunMode .PRODUCTION :
202+ if (runMode == RunMode .ASSEMBLY ) {
203+ if (!isAdapterCachingOn (aMode ) && !isStubCachingOn (aMode )) { // this is equivalent to completely disable AOT code cache
200204 out .shouldNotMatch ("Adapters:\\ s+total" );
201205 out .shouldNotMatch ("Shared Blobs:\\ s+total" );
202206 out .shouldNotMatch ("C1 Blobs:\\ s+total" );
203207 out .shouldNotMatch ("C2 Blobs:\\ s+total" );
204- break ;
205- }
206- } else {
207- if (isAdapterCachingOn ()) {
208- switch (runMode ) {
209- case RunMode .ASSEMBLY :
210- case RunMode .PRODUCTION :
211- // AOTAdapterCaching is on, non-zero adapters should be stored/loaded
212- out .shouldMatch ("Adapters:\\ s+total=[1-9][0-9]+" );
213- break ;
214- }
215208 } else {
216- switch (runMode ) {
217- case RunMode .ASSEMBLY :
218- case RunMode .PRODUCTION :
219- // AOTAdapterCaching is off, no adapters should be stored/loaded
209+ if (isAdapterCachingOn (aMode )) {
210+ // AOTAdapterCaching is on, non-zero adapters should be stored
211+ out .shouldMatch ("Adapters:\\ s+total=[1-9][0-9]+" );
212+ } else {
213+ // AOTAdapterCaching is off, no adapters should be stored
220214 out .shouldMatch ("Adapters:\\ s+total=0" );
221- break ;
222215 }
223- }
224- if (isStubCachingOn ()) {
225- switch (runMode ) {
226- case RunMode .ASSEMBLY :
227- case RunMode .PRODUCTION :
228- // AOTStubCaching is on, non-zero stubs should be stored/loaded
216+ if (isStubCachingOn (aMode )) {
217+ // AOTStubCaching is on, non-zero stubs should be stored
229218 out .shouldMatch ("Shared Blobs:\\ s+total=[1-9][0-9]+" );
230219 out .shouldMatch ("C1 Blobs:\\ s+total=[1-9][0-9]+" );
231220 // we do not currently load or store C2 stubs
232221 // because we are seeing weird memory errors
233222 // when loading them -- see JDK-8357593
234223 out .shouldMatch ("C2 Blobs:\\ s+total=0" );
235- break ;
236- }
237- } else {
238- switch (runMode ) {
239- case RunMode .ASSEMBLY :
240- case RunMode .PRODUCTION :
241- // AOTStubCaching is off, no stubs should be stored/loaded
224+ } else {
225+ // AOTStubCaching is off, no stubs should be stored
242226 out .shouldMatch ("Shared Blobs:\\ s+total=0" );
243227 out .shouldMatch ("C1 Blobs:\\ s+total=0" );
244228 out .shouldMatch ("C2 Blobs:\\ s+total=0" );
245- break ;
229+ }
230+ }
231+ } else if (runMode == RunMode .PRODUCTION ) {
232+ // Irrespective of assembly run mode, if both adapter and stub caching is disabled
233+ // in production run, then it is equivalent to completely disabling AOT code cache
234+ if (!isAdapterCachingOn (pMode ) && !isStubCachingOn (pMode )) {
235+ out .shouldNotMatch ("Adapters:\\ s+total" );
236+ out .shouldNotMatch ("Shared Blobs:\\ s+total" );
237+ out .shouldNotMatch ("C1 Blobs:\\ s+total" );
238+ out .shouldNotMatch ("C2 Blobs:\\ s+total" );
239+ } else {
240+ // If AOT code cache is effectively disabled in the assembly run, then production run
241+ // would emit empty code cache message.
242+ if (!isAdapterCachingOn (aMode ) && !isStubCachingOn (aMode )) {
243+ if (isAdapterCachingOn (pMode ) || isStubCachingOn (pMode )) {
244+ out .shouldMatch ("AOT Code Cache is empty" );
245+ }
246+ } else {
247+ if (isAdapterCachingOn (aMode )) {
248+ if (isAdapterCachingOn (pMode )) {
249+ out .shouldMatch ("Read blob.*kind=Adapter.*" );
250+ } else {
251+ out .shouldNotMatch ("Read blob.*kind=Adapter.*" );
252+ }
253+ }
254+ if (isStubCachingOn (aMode )) {
255+ if (isStubCachingOn (pMode )) {
256+ out .shouldMatch ("Read blob.*kind=SharedBlob.*" );
257+ out .shouldMatch ("Read blob.*kind=C1Blob.*" );
258+ } else {
259+ out .shouldNotMatch ("Read blob.*kind=SharedBlob.*" );
260+ out .shouldNotMatch ("Read blob.*kind=C1Blob.*" );
261+ }
262+ }
246263 }
247264 }
248265 }
0 commit comments