|
1 | 1 | /*
|
2 | 2 | * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
|
| 3 | + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 5 | *
|
5 | 6 | * This code is free software; you can redistribute it and/or modify it
|
|
28 | 29 | *
|
29 | 30 | * @requires vm.compiler2.enabled & vm.debug == true
|
30 | 31 | *
|
31 |
| - * @library /compiler/patches /test/lib |
32 |
| - * @run main/othervm compiler.arguments.TestPrintOptoAssemblyLineNumbers |
33 |
| -*/ |
| 32 | + * @library /test/lib |
| 33 | + * @run driver compiler.arguments.TestPrintOptoAssemblyLineNumbers |
| 34 | + */ |
34 | 35 |
|
35 | 36 | package compiler.arguments;
|
36 | 37 |
|
37 |
| -import jdk.test.lib.Asserts; |
38 | 38 | import jdk.test.lib.process.OutputAnalyzer;
|
39 | 39 | import jdk.test.lib.process.ProcessTools;
|
40 | 40 |
|
| 41 | +// THIS TEST IS LINE NUMBER SENSITIVE |
| 42 | + |
41 | 43 | public class TestPrintOptoAssemblyLineNumbers {
|
42 | 44 | public static void main(String[] args) throws Throwable {
|
43 | 45 | // create subprocess to run some code with -XX:+PrintOptoAssembly enabled
|
44 |
| - String[] procArgs = new String[]{ |
| 46 | + String[] procArgs = new String[] { |
45 | 47 | "-XX:+UnlockDiagnosticVMOptions",
|
46 | 48 | "-XX:-TieredCompilation",
|
47 | 49 | "-XX:+PrintOptoAssembly",
|
48 |
| - "compiler.arguments.TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly" |
49 |
| - }; |
| 50 | + CheckC2OptoAssembly.class.getName() |
| 51 | + }; |
50 | 52 |
|
51 | 53 | ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
|
52 |
| - String output = new OutputAnalyzer(pb.start()).getOutput(); |
| 54 | + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); |
| 55 | + oa.shouldHaveExitValue(0); |
53 | 56 |
|
54 |
| - if(output.contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")){ |
| 57 | + if (oa.getOutput().contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")) { |
55 | 58 | // if C2 optimizer invoked ensure output includes line numbers:
|
56 |
| - Asserts.assertTrue(output.contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 68)")); |
| 59 | + oa.stdoutShouldContain("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 71)"); |
57 | 60 | }
|
58 | 61 | }
|
59 | 62 |
|
60 |
| - public static class CheckC2OptoAssembly{ // contents of this class serves to just invoke C2 |
61 |
| - public static boolean foo(String arg){ |
| 63 | + public static class CheckC2OptoAssembly { // contents of this class serves to just invoke C2 |
| 64 | + public static boolean foo(String arg) { |
62 | 65 | return arg.contains("45");
|
63 | 66 | }
|
64 | 67 |
|
65 |
| - public static void main(String[] args){ |
| 68 | + public static void main(String[] args) { |
66 | 69 | int count = 0;
|
67 |
| - for(int x = 0; x < 200_000; x++){ |
68 |
| - if(foo("something" + x)){ // <- test expects this line of code to be on line 68 |
| 70 | + for (int x = 0; x < 200_000; x++) { |
| 71 | + if (foo("something" + x)) { // <- test expects this line of code to be on line 71 |
69 | 72 | count += 1;
|
70 | 73 | }
|
71 | 74 | }
|
|
0 commit comments