1 /* 2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package compiler.valhalla.valuetypes; 25 26 import compiler.whitebox.CompilerWhiteBoxTest; 27 import jdk.test.lib.Asserts; 28 import jdk.test.lib.management.InputArguments; 29 import jdk.test.lib.Platform; 30 import jdk.test.lib.process.ProcessTools; 31 import jdk.test.lib.process.OutputAnalyzer; 32 import jdk.test.lib.Utils; 33 import sun.hotspot.WhiteBox; 34 35 import java.lang.annotation.Retention; 36 import java.lang.annotation.RetentionPolicy; 37 import java.lang.annotation.Repeatable; 38 import java.lang.invoke.*; 39 import java.lang.reflect.Method; 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import java.util.Hashtable; 43 import java.util.LinkedHashMap; 44 import java.util.List; 45 import java.util.Map; 46 import java.util.regex.Matcher; 47 import java.util.regex.Pattern; 48 import java.util.TreeMap; 49 50 // Mark method as test 51 @Retention(RetentionPolicy.RUNTIME) 52 @Repeatable(Tests.class) 53 @interface Test { 54 // Regular expression used to match forbidden IR nodes 55 // in the C2 IR emitted for this test. 56 String failOn() default ""; 57 // Regular expressions used to match and count IR nodes. 58 String[] match() default { }; 59 int[] matchCount() default { }; 60 int valid() default ValueTypeTest.AllFlags; 61 } 62 63 @Retention(RetentionPolicy.RUNTIME) 64 @interface Tests { 65 Test[] value(); 66 } 67 68 // Force method inlining during compilation 69 @Retention(RetentionPolicy.RUNTIME) 70 @interface ForceInline { } 71 72 // Prevent method inlining during compilation 73 @Retention(RetentionPolicy.RUNTIME) 74 @interface DontInline { } 75 76 // Prevent method compilation 77 @Retention(RetentionPolicy.RUNTIME) 78 @interface DontCompile { } 79 80 // Number of warmup iterations 81 @Retention(RetentionPolicy.RUNTIME) 82 @interface Warmup { 83 int value(); 84 } 85 86 public abstract class ValueTypeTest { 87 // Run "jtreg -Dtest.c1=true" to enable experimental C1 testing. 88 static final boolean TEST_C1 = Boolean.getBoolean("test.c1"); 89 90 // Random test values 91 public static final int rI = Utils.getRandomInstance().nextInt() % 1000; 92 public static final long rL = Utils.getRandomInstance().nextLong() % 1000; 93 94 // User defined settings 95 private static final boolean PRINT_GRAPH = true; 96 private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false")); 97 private static boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && (!TEST_C1); 98 private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false")); 99 private static final String SCENARIOS = System.getProperty("Scenarios", ""); 100 private static final String TESTLIST = System.getProperty("Testlist", ""); 101 private static final String EXCLUDELIST = System.getProperty("Exclude", ""); 102 private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251")); 103 private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false")); 104 105 // Pre-defined settings 106 private static final List<String> defaultFlags = Arrays.asList( 107 "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1", 108 "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly", 109 "-XX:CompileCommand=quiet", 110 "-XX:CompileCommand=compileonly,java.lang.invoke.*::*", 111 "-XX:CompileCommand=compileonly,java.lang.Long::sum", 112 "-XX:CompileCommand=compileonly,java.lang.Object::<init>", 113 "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"); 114 private static final List<String> verifyFlags = Arrays.asList( 115 "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC", 116 "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing", "-XX:+StressValueTypeReturnedAsFields"); 117 118 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); 119 protected static final int ValueTypePassFieldsAsArgsOn = 0x1; 120 protected static final int ValueTypePassFieldsAsArgsOff = 0x2; 121 protected static final int ValueTypeArrayFlattenOn = 0x4; 122 protected static final int ValueTypeArrayFlattenOff = 0x8; 123 protected static final int ValueTypeReturnedAsFieldsOn = 0x10; 124 protected static final int ValueTypeReturnedAsFieldsOff = 0x20; 125 static final int AllFlags = ValueTypePassFieldsAsArgsOn | ValueTypePassFieldsAsArgsOff | ValueTypeArrayFlattenOn | ValueTypeArrayFlattenOff | ValueTypeReturnedAsFieldsOn; 126 protected static final boolean ValueTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs"); 127 protected static final boolean ValueTypeArrayFlatten = (Boolean)WHITE_BOX.getVMFlag("ValueArrayFlatten"); 128 protected static final boolean ValueTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("ValueTypeReturnedAsFields"); 129 protected static final boolean NullableValueTypes = (Boolean)WHITE_BOX.getVMFlag("NullableValueTypes"); 130 protected static final int COMP_LEVEL_ANY = -2; 131 protected static final int COMP_LEVEL_FULL_OPTIMIZATION = TEST_C1 ? 1 : 4; 132 protected static final Hashtable<String, Method> tests = new Hashtable<String, Method>(); 133 protected static final boolean USE_COMPILER = WHITE_BOX.getBooleanVMFlag("UseCompiler"); 134 protected static final boolean PRINT_IDEAL = WHITE_BOX.getBooleanVMFlag("PrintIdeal"); 135 protected static final boolean XCOMP = Platform.isComp(); 136 137 // Regular expressions used to match nodes in the PrintIdeal output 138 protected static final String START = "(\\d+\\t(.*"; 139 protected static final String MID = ".*)+\\t===.*"; 140 protected static final String END = ")|"; 141 protected static final String ALLOC = "(.*precise klass compiler/valhalla/valuetypes/MyValue.*\\R(.*(nop|spill).*\\R)*.*_new_instance_Java" + END; 142 protected static final String ALLOCA = "(.*precise klass \\[Lcompiler/valhalla/valuetypes/MyValue.*\\R(.*(nop|spill).*\\R)*.*_new_array_Java" + END; 143 protected static final String LOAD = START + "Load(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/valuetypes/MyValue.*" + END; 144 protected static final String LOADK = START + "LoadK" + MID + END; 145 protected static final String STORE = START + "Store(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/valuetypes/MyValue.*" + END; 146 protected static final String LOOP = START + "Loop" + MID + "" + END; 147 protected static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*(unstable_if|predicate)" + END; 148 protected static final String RETURN = START + "Return" + MID + "returns" + END; 149 protected static final String LINKTOSTATIC = START + "CallStaticJava" + MID + "linkToStatic" + END; 150 protected static final String NPE = START + "CallStaticJava" + MID + "null_check" + END; 151 protected static final String CALL = START + "CallStaticJava" + MID + END; 152 protected static final String STOREVALUETYPEFIELDS = START + "CallStaticJava" + MID + "store_value_type_fields" + END; 153 protected static final String SCOBJ = "(.*# ScObj.*" + END; 154 155 public static String[] concat(String prefix[], String... extra) { 156 ArrayList<String> list = new ArrayList<String>(); 157 if (prefix != null) { 158 for (String s : prefix) { 159 list.add(s); 160 } 161 } 162 if (extra != null) { 163 for (String s : extra) { 164 list.add(s); 165 } 166 } 167 168 return list.toArray(new String[list.size()]); 169 } 170 171 /** 172 * Override getNumScenarios and getVMParameters if you want to run with more than 173 * the 5 built-in scenarios 174 */ 175 public int getNumScenarios() { 176 if (TEST_C1) { 177 return 1; 178 } else { 179 return 5; 180 } 181 } 182 183 /** 184 * VM paramaters for the 5 built-in test scenarios. If your test needs to append 185 * extra parameters for (some of) these scenarios, override getExtraVMParameters(). 186 */ 187 public String[] getVMParameters(int scenario) { 188 if (TEST_C1) { 189 return new String[] { 190 "-XX:+EnableValhallaC1", 191 }; 192 } 193 194 switch (scenario) { 195 case 0: return new String[] { 196 "-XX:+AlwaysIncrementalInline", 197 "-XX:ValueArrayElemMaxFlatOops=-1", 198 "-XX:ValueArrayElemMaxFlatSize=-1", 199 "-XX:+ValueArrayFlatten", 200 "-XX:ValueFieldMaxFlatSize=-1", 201 "-XX:+ValueTypePassFieldsAsArgs", 202 "-XX:+ValueTypeReturnedAsFields"}; 203 case 1: return new String[] { 204 "-XX:-UseCompressedOops", 205 "-XX:ValueArrayElemMaxFlatOops=-1", 206 "-XX:ValueArrayElemMaxFlatSize=-1", 207 "-XX:+ValueArrayFlatten", 208 "-XX:ValueFieldMaxFlatSize=-1", 209 "-XX:-ValueTypePassFieldsAsArgs", 210 "-XX:-ValueTypeReturnedAsFields"}; 211 case 2: return new String[] { 212 "-DVerifyIR=false", 213 "-XX:-UseCompressedOops", 214 "-XX:ValueArrayElemMaxFlatOops=0", 215 "-XX:ValueArrayElemMaxFlatSize=0", 216 "-XX:-ValueArrayFlatten", 217 "-XX:ValueFieldMaxFlatSize=0", 218 "-XX:+ValueTypePassFieldsAsArgs", 219 "-XX:+ValueTypeReturnedAsFields"}; 220 case 3: return new String[] { 221 "-DVerifyIR=false", 222 "-XX:+AlwaysIncrementalInline", 223 "-XX:ValueArrayElemMaxFlatOops=0", 224 "-XX:ValueArrayElemMaxFlatSize=0", 225 "-XX:ValueFieldMaxFlatSize=0", 226 "-XX:-ValueTypePassFieldsAsArgs", 227 "-XX:-ValueTypeReturnedAsFields"}; 228 case 4: return new String[] { 229 "-DVerifyIR=false", 230 "-XX:ValueArrayElemMaxFlatOops=-1", 231 "-XX:ValueArrayElemMaxFlatSize=-1", 232 "-XX:+ValueArrayFlatten", 233 "-XX:ValueFieldMaxFlatSize=0", 234 "-XX:+ValueTypePassFieldsAsArgs", 235 "-XX:-ValueTypeReturnedAsFields"}; 236 } 237 238 return null; 239 } 240 241 /** 242 * Override this method to provide extra parameters for selected scenarios 243 */ 244 public String[] getExtraVMParameters(int scenario) { 245 return null; 246 } 247 248 public static void main(String[] args) throws Throwable { 249 if (args.length != 1) { 250 throw new RuntimeException("Usage: @run main/othervm/timeout=120 -Xbootclasspath/a:. -ea" + 251 " -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions" + 252 " -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla" + 253 " compiler.valhalla.valuetypes.ValueTypeTest <YourTestMainClass>"); 254 } 255 String testMainClassName = args[0]; 256 Class testMainClass = Class.forName(testMainClassName); 257 ValueTypeTest test = (ValueTypeTest)testMainClass.newInstance(); 258 List<String> scenarios = null; 259 if (!SCENARIOS.isEmpty()) { 260 scenarios = Arrays.asList(SCENARIOS.split(",")); 261 } 262 for (int i=0; i<test.getNumScenarios(); i++) { 263 if (scenarios == null || scenarios.contains(Integer.toString(i))) { 264 System.out.println("Scenario #" + i + " -------- "); 265 String[] cmds = InputArguments.getVmInputArgs(); 266 cmds = concat(cmds, test.getVMParameters(i)); 267 cmds = concat(cmds, test.getExtraVMParameters(i)); 268 cmds = concat(cmds, testMainClassName); 269 270 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); 271 String output = oa.getOutput(); 272 oa.shouldHaveExitValue(0); 273 System.out.println(output); 274 } else { 275 System.out.println("Scenario #" + i + " is skipped due to -Dscenarios=" + SCENARIOS); 276 } 277 } 278 } 279 280 protected ValueTypeTest() { 281 List<String> list = null; 282 List<String> exclude = null; 283 if (!TESTLIST.isEmpty()) { 284 list = Arrays.asList(TESTLIST.split(",")); 285 } 286 if (!EXCLUDELIST.isEmpty()) { 287 exclude = Arrays.asList(EXCLUDELIST.split(",")); 288 } 289 // Gather all test methods and put them in Hashtable 290 for (Method m : getClass().getDeclaredMethods()) { 291 Test[] annos = m.getAnnotationsByType(Test.class); 292 if (annos.length != 0 && 293 ((list == null || list.contains(m.getName())) && (exclude == null || !exclude.contains(m.getName())))) { 294 tests.put(getClass().getSimpleName() + "::" + m.getName(), m); 295 } 296 } 297 } 298 299 protected void run(String[] args, Class<?>... classes) throws Throwable { 300 if (args.length == 0) { 301 // Spawn a new VM instance 302 execute_vm(); 303 } else { 304 // Execute tests 305 run(classes); 306 } 307 } 308 309 private void execute_vm() throws Throwable { 310 Asserts.assertFalse(tests.isEmpty(), "no tests to execute"); 311 ArrayList<String> args = new ArrayList<String>(defaultFlags); 312 String[] vmInputArgs = InputArguments.getVmInputArgs(); 313 if (VERIFY_IR) { 314 for (String arg : vmInputArgs) { 315 if (arg.startsWith("-XX:CompileThreshold")) { 316 // Disable IR verification if 317 VERIFY_IR = false; 318 } 319 // Check if the JVM supports value type specific default arguments from the test's run commands 320 if (arg.startsWith("-XX:+ValueTypePassFieldsAsArgs") || 321 arg.startsWith("-XX:+ValueTypeReturnedAsFields")) { 322 Boolean value = (Boolean)WHITE_BOX.getVMFlag(arg.substring(5)); 323 if (!value) { 324 System.out.println("WARNING: could not enable " + arg.substring(5) + ". Skipping IR verification."); 325 VERIFY_IR = false; 326 } 327 } else if (arg.startsWith("-XX:-ValueTypePassFieldsAsArgs") || 328 arg.startsWith("-XX:-ValueTypeReturnedAsFields")) { 329 Boolean value = (Boolean)WHITE_BOX.getVMFlag(arg.substring(5)); 330 if (value) { 331 System.out.println("WARNING: could not disable " + arg.substring(5) + ". Skipping IR verification."); 332 VERIFY_IR = false; 333 } 334 } 335 } 336 // Always trap for exception throwing to not confuse IR verification 337 args.add("-XX:-OmitStackTraceInFastThrow"); 338 } 339 if (VERIFY_VM) { 340 args.addAll(verifyFlags); 341 } 342 // Run tests in own process and verify output 343 args.add(getClass().getName()); 344 args.add("run"); 345 // Spawn process with default JVM options from the test's run command 346 String[] cmds = Arrays.copyOf(vmInputArgs, vmInputArgs.length + args.size()); 347 System.arraycopy(args.toArray(), 0, cmds, vmInputArgs.length, args.size()); 348 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); 349 // If ideal graph printing is enabled/supported, verify output 350 String output = oa.getOutput(); 351 oa.shouldHaveExitValue(0); 352 if (VERIFY_IR) { 353 if (output.contains("PrintIdeal enabled")) { 354 parseOutput(output); 355 } else { 356 System.out.println(output); 357 System.out.println("WARNING: IR verification failed! Running with -Xint, -Xcomp or release build?"); 358 } 359 } 360 } 361 362 private void parseOutput(String output) throws Exception { 363 Pattern comp_re = Pattern.compile("\\n\\s+\\d+\\s+\\d+\\s+(%| )(s| )(!| )b(n| )\\s+\\S+\\.(?<name>[^.]+::\\S+)\\s+(?<osr>@ \\d+\\s+)?[(]\\d+ bytes[)]\\n"); 364 Matcher m = comp_re.matcher(output); 365 Map<String,String> compilations = new LinkedHashMap<>(); 366 int prev = 0; 367 String methodName = null; 368 while (m.find()) { 369 if (prev == 0) { 370 // Print header 371 System.out.print(output.substring(0, m.start()+1)); 372 } else if (methodName != null) { 373 compilations.put(methodName, output.substring(prev, m.start()+1)); 374 } 375 if (m.group("osr") != null) { 376 methodName = null; 377 } else { 378 methodName = m.group("name"); 379 } 380 prev = m.end(); 381 } 382 if (prev == 0) { 383 // Print header 384 System.out.print(output); 385 } else if (methodName != null) { 386 compilations.put(methodName, output.substring(prev)); 387 } 388 // Iterate over compilation output 389 for (String testName : compilations.keySet()) { 390 Method test = tests.get(testName); 391 if (test == null) { 392 // Skip helper methods 393 continue; 394 } 395 String graph = compilations.get(testName); 396 if (PRINT_GRAPH) { 397 System.out.println("\nGraph for " + testName + "\n" + graph); 398 } 399 // Parse graph using regular expressions to determine if it contains forbidden nodes 400 Test[] annos = test.getAnnotationsByType(Test.class); 401 Test anno = null; 402 for (Test a : annos) { 403 if ((a.valid() & ValueTypePassFieldsAsArgsOn) != 0 && ValueTypePassFieldsAsArgs) { 404 assert anno == null; 405 anno = a; 406 } else if ((a.valid() & ValueTypePassFieldsAsArgsOff) != 0 && !ValueTypePassFieldsAsArgs) { 407 assert anno == null; 408 anno = a; 409 } else if ((a.valid() & ValueTypeArrayFlattenOn) != 0 && ValueTypeArrayFlatten) { 410 assert anno == null; 411 anno = a; 412 } else if ((a.valid() & ValueTypeArrayFlattenOff) != 0 && !ValueTypeArrayFlatten) { 413 assert anno == null; 414 anno = a; 415 } else if ((a.valid() & ValueTypeReturnedAsFieldsOn) != 0 && ValueTypeReturnedAsFields) { 416 assert anno == null; 417 anno = a; 418 } else if ((a.valid() & ValueTypeReturnedAsFieldsOff) != 0 && !ValueTypeReturnedAsFields) { 419 assert anno == null; 420 anno = a; 421 } 422 } 423 assert anno != null; 424 String regexFail = anno.failOn(); 425 if (!regexFail.isEmpty()) { 426 Pattern pattern = Pattern.compile(regexFail.substring(0, regexFail.length()-1)); 427 Matcher matcher = pattern.matcher(graph); 428 boolean found = matcher.find(); 429 Asserts.assertFalse(found, "Graph for '" + testName + "' contains forbidden node:\n" + (found ? matcher.group() : "")); 430 } 431 String[] regexMatch = anno.match(); 432 int[] matchCount = anno.matchCount(); 433 for (int i = 0; i < regexMatch.length; ++i) { 434 Pattern pattern = Pattern.compile(regexMatch[i].substring(0, regexMatch[i].length()-1)); 435 Matcher matcher = pattern.matcher(graph); 436 int count = 0; 437 String nodes = ""; 438 while (matcher.find()) { 439 count++; 440 nodes += matcher.group() + "\n"; 441 } 442 if (matchCount[i] < 0) { 443 Asserts.assertLTE(Math.abs(matchCount[i]), count, "Graph for '" + testName + "' contains different number of match nodes:\n" + nodes); 444 } else { 445 Asserts.assertEQ(matchCount[i], count, "Graph for '" + testName + "' contains different number of match nodes:\n" + nodes); 446 } 447 } 448 tests.remove(testName); 449 System.out.println(testName + " passed"); 450 } 451 // Check if all tests were compiled 452 if (tests.size() != 0) { 453 for (String name : tests.keySet()) { 454 System.out.println("Test '" + name + "' not compiled!"); 455 } 456 throw new RuntimeException("Not all tests were compiled"); 457 } 458 } 459 460 private void setup(Class<?> clazz) { 461 if (XCOMP) { 462 // Don't control compilation if -Xcomp is enabled 463 return; 464 } 465 if (DUMP_REPLAY) { 466 // Generate replay compilation files 467 String directive = "[{ match: \"*.*\", DumpReplay: true }]"; 468 if (WHITE_BOX.addCompilerDirective(directive) != 1) { 469 throw new RuntimeException("Failed to add compiler directive"); 470 } 471 } 472 473 Method[] methods = clazz.getDeclaredMethods(); 474 for (Method m : methods) { 475 if (m.isAnnotationPresent(Test.class)) { 476 // Don't inline tests 477 WHITE_BOX.testSetDontInlineMethod(m, true); 478 } 479 if (m.isAnnotationPresent(DontCompile.class)) { 480 WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_ANY, true); 481 WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_ANY, false); 482 WHITE_BOX.testSetDontInlineMethod(m, true); 483 } 484 if (m.isAnnotationPresent(ForceInline.class)) { 485 WHITE_BOX.testSetForceInlineMethod(m, true); 486 } else if (m.isAnnotationPresent(DontInline.class)) { 487 WHITE_BOX.testSetDontInlineMethod(m, true); 488 } 489 } 490 491 // Compile class initializers 492 WHITE_BOX.enqueueInitializerForCompilation(clazz, COMP_LEVEL_FULL_OPTIMIZATION); 493 } 494 495 private void run(Class<?>... classes) throws Exception { 496 if (USE_COMPILER && PRINT_IDEAL && !XCOMP) { 497 System.out.println("PrintIdeal enabled"); 498 } 499 System.out.format("rI = %d, rL = %d\n", rI, rL); 500 501 setup(getClass()); 502 for (Class<?> clazz : classes) { 503 setup(clazz); 504 } 505 506 // Execute tests 507 TreeMap<Long, String> durations = PRINT_TIMES ? new TreeMap<Long, String>() : null; 508 for (Method test : tests.values()) { 509 long startTime = System.nanoTime(); 510 Method verifier = getClass().getMethod(test.getName() + "_verifier", boolean.class); 511 // Warmup using verifier method 512 Warmup anno = test.getAnnotation(Warmup.class); 513 int warmup = anno == null ? WARMUP : anno.value(); 514 for (int i = 0; i < warmup; ++i) { 515 verifier.invoke(this, true); 516 } 517 // Trigger compilation 518 WHITE_BOX.enqueueMethodForCompilation(test, COMP_LEVEL_FULL_OPTIMIZATION); 519 Asserts.assertTrue(!USE_COMPILER || WHITE_BOX.isMethodCompiled(test, false), test + " not compiled"); 520 // Check result 521 verifier.invoke(this, false); 522 if (PRINT_TIMES) { 523 long endTime = System.nanoTime(); 524 long duration = (endTime - startTime); 525 durations.put(duration, test.getName()); 526 } 527 } 528 529 // Print execution times 530 if (PRINT_TIMES) { 531 System.out.println("\n\nTest execution times:"); 532 for (Map.Entry<Long, String> entry : durations.entrySet()) { 533 System.out.format("%-10s%15d ns\n", entry.getValue() + ":", entry.getKey()); 534 } 535 } 536 } 537 }