Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8266088: compiler/arguments/TestPrintOptoAssemblyLineNumbers test should user driver mode #3726

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
@@ -1,5 +1,6 @@
/*
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,44 +29,46 @@
*
* @requires vm.compiler2.enabled & vm.debug == true
*
* @library /compiler/patches /test/lib
* @run main/othervm compiler.arguments.TestPrintOptoAssemblyLineNumbers
*/
* @library /test/lib
* @run driver compiler.arguments.TestPrintOptoAssemblyLineNumbers
*/

package compiler.arguments;

import jdk.test.lib.Asserts;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

// THIS TEST IS LINE NUMBER SENSITIVE

public class TestPrintOptoAssemblyLineNumbers {
public static void main(String[] args) throws Throwable {
// create subprocess to run some code with -XX:+PrintOptoAssembly enabled
String[] procArgs = new String[]{
String[] procArgs = new String[] {
"-XX:+UnlockDiagnosticVMOptions",
"-XX:-TieredCompilation",
"-XX:+PrintOptoAssembly",
"compiler.arguments.TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly"
};
CheckC2OptoAssembly.class.getName()
};

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
String output = new OutputAnalyzer(pb.start()).getOutput();
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
oa.shouldHaveExitValue(0);

if(output.contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")){
if (oa.getOutput().contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")) {
// if C2 optimizer invoked ensure output includes line numbers:
Asserts.assertTrue(output.contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 68)"));
oa.stdoutShouldContain("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 71)");
}
}

public static class CheckC2OptoAssembly{ // contents of this class serves to just invoke C2
public static boolean foo(String arg){
public static class CheckC2OptoAssembly { // contents of this class serves to just invoke C2
public static boolean foo(String arg) {
return arg.contains("45");
}

public static void main(String[] args){
public static void main(String[] args) {
int count = 0;
for(int x = 0; x < 200_000; x++){
if(foo("something" + x)){ // <- test expects this line of code to be on line 68
for (int x = 0; x < 200_000; x++) {
if (foo("something" + x)) { // <- test expects this line of code to be on line 71
count += 1;
}
}