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

8337221: CompileFramework: test library to conveniently compile java and jasm sources for fuzzing #20184

Closed
wants to merge 79 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b468344
first version
eme64 Jul 15, 2024
d30601a
make IR test framework compile
eme64 Jul 17, 2024
5a0ebcb
make it compile and run, only annotations missing now
eme64 Jul 17, 2024
becfe95
add proper @compile
eme64 Jul 18, 2024
0763d9e
print class name
eme64 Jul 19, 2024
6769cd6
making it work
eme64 Jul 22, 2024
e85c98a
slimming it down a bit
eme64 Jul 22, 2024
68115cb
separate class for InMemoryCompiler
eme64 Jul 23, 2024
8829242
extract into lib
eme64 Jul 23, 2024
c688447
refactoring framework and adding tests
eme64 Jul 24, 2024
d225119
Beautify things
eme64 Jul 24, 2024
4335656
failing IR rule example
eme64 Jul 24, 2024
b63f1b4
catch IRViolationException outside
eme64 Jul 24, 2024
25463d8
bad compilation test
eme64 Jul 24, 2024
50a0fcc
multi-file example
eme64 Jul 24, 2024
0d10d8c
prep work for jasm
eme64 Jul 24, 2024
4c6ccda
refactor a bit
eme64 Jul 24, 2024
3196b92
refactor v2
eme64 Jul 24, 2024
5bb6b95
store jasm files before compile
eme64 Jul 25, 2024
8418d89
jasm compilation works
eme64 Jul 25, 2024
ab5e578
add package to MultiFileJavaExample.java
eme64 Jul 25, 2024
b8486a6
small fixes and MultiFileJasmExample.java
eme64 Jul 25, 2024
f7b4e6c
added CombinedJavaJasmExample.java
eme64 Jul 25, 2024
10286a0
compile all jasm together
eme64 Jul 25, 2024
41f4803
fix spelling
eme64 Jul 25, 2024
ad4da70
bad jasm example
eme64 Jul 25, 2024
de21e7f
SourceFile -> SourceCode
eme64 Jul 25, 2024
704dd94
simplify class loader seupt
eme64 Jul 25, 2024
01f9578
unify compilation
eme64 Jul 25, 2024
e3bea06
move some code around
eme64 Jul 25, 2024
78f907f
add internal exception
eme64 Jul 25, 2024
678532a
rm old file
eme64 Jul 25, 2024
baca5ef
fix TestFrameworkJavaExample.java
eme64 Jul 26, 2024
11d2269
add more classpaths
eme64 Jul 26, 2024
eafc7a2
string formatting
eme64 Jul 26, 2024
f3873c9
address Evgeny Nikitin's suggestions
eme64 Jul 29, 2024
5b086fe
verbose flag
eme64 Jul 29, 2024
6c49d89
use nio Files/Paths instead of string
eme64 Jul 29, 2024
e869cce
refactor invocation
eme64 Jul 29, 2024
21c53dd
rm some unnecessary imports
eme64 Jul 30, 2024
ecfe164
use Files.createTempDirectory for source directory
eme64 Jul 30, 2024
9a5ce69
make it multi-threading safe
eme64 Jul 30, 2024
a33a8d6
give javac the classesDir from jasm compilation, so java files can re…
eme64 Jul 30, 2024
18def3a
private source and classes directory per CompileFramework
eme64 Aug 1, 2024
59fb162
stub of TestMergeStoresFuzzer
eme64 Aug 1, 2024
98a0651
name timeout better
eme64 Aug 7, 2024
e2128b3
Merge branch 'master' into fuzzer-test
eme64 Aug 15, 2024
90e44b3
Merge branch 'master' into fuzzer-test
eme64 Sep 11, 2024
01f8e8e
rm unnecessary test
eme64 Sep 11, 2024
b38b652
increase compile timeut
eme64 Sep 11, 2024
881c76b
fix paths for windows, had compile issue
eme64 Sep 12, 2024
b2ed164
Merge branch 'master' into fuzzer-test
eme64 Sep 16, 2024
efe9476
Merge branch 'fuzzer-test' of https://github.com/eme64/jdk into fuzze…
eme64 Sep 16, 2024
09dc029
Apply suggestions from code review
eme64 Sep 16, 2024
03c3cea
fix syntax
eme64 Sep 16, 2024
d57b94a
rm some toString calls
eme64 Sep 16, 2024
0a3daf6
make SourceCode package private
eme64 Sep 16, 2024
5d700f1
split file into 4
eme64 Sep 16, 2024
0707ae1
refactoring continued
eme64 Sep 16, 2024
032952d
some refactor and comments
eme64 Sep 16, 2024
580ecf1
more documentation
eme64 Sep 16, 2024
46ce072
fix link brackets
eme64 Sep 16, 2024
e68b376
even more documentation
eme64 Sep 16, 2024
fc363c6
one more
eme64 Sep 16, 2024
45abaed
move some code around
eme64 Sep 16, 2024
647b8ac
fix up CompileFramework.java
eme64 Sep 17, 2024
5030e5d
Apply suggestions from code review
eme64 Sep 17, 2024
fb57e28
more fixup for Christian
eme64 Sep 17, 2024
237ce2e
another small suggestion from Christian
eme64 Sep 18, 2024
4636280
Apply suggestions from code review
eme64 Sep 23, 2024
7a525e0
more for Christian
eme64 Sep 23, 2024
041da5d
move some code for Christian
eme64 Sep 23, 2024
ad3865b
Apply suggestions from code review
eme64 Sep 23, 2024
2d4a8ff
Add example where I use the framework with VM flags
eme64 Oct 14, 2024
3df1c03
test refactoring
eme64 Oct 14, 2024
5178e7c
Merge branch 'master' into fuzzer-test
eme64 Oct 14, 2024
79269bf
Apply suggestions from code review
eme64 Oct 14, 2024
4eeab36
Update test/hotspot/jtreg/compiler/lib/compile_framework/README.md
eme64 Oct 14, 2024
d50b6e1
use JDKToolFinder for Evgeny
eme64 Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
import java.util.List;

/**
* Helper class for compilation of Java and Jasm {@code SourceCode}.
* Helper class for compilation of Java and Jasm {@link SourceCode}.
*/
class Compile {

Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@
* Access a class from the compiled code.
*
* @param name Name of the class to be retrieved.
* @return A class corresponding to the {@code name}.
* @return The class corresponding to the {@code name}.
*/
public Class<?> getClass(String name) {
try {
@@ -115,6 +115,7 @@

/**
* Invoke a static method from the compiled code.

Check failure on line 118 in test/hotspot/jtreg/compiler/lib/compile_framework/CompileFramework.java

openjdk / jcheck-openjdk/jdk-20184

Whitespace error

Column 0: trailing whitespace Column 1: trailing whitespace Column 2: trailing whitespace Column 3: trailing whitespace Column 4: trailing whitespace
* @param className Class name of a compiled class.
* @param methodName Method name of the class.
* @param args List of arguments for the method invocation.
@@ -154,10 +155,10 @@
}

/**
* Returns the classpath appended with the {@code classesDir}, where
* Returns the classpath appended with the {@link classesDir}, where
* the compiled classes are stored. This enables another VM to load
* the compiled classes. Note, the string is already backslash escaped,
* so that the windows paths which use backslashes can be used directly
* so that Windows paths which use backslashes can be used directly
* as strings.
*
* @return Classpath appended with the path to the compiled classes.
@@ -166,4 +167,3 @@
return Utils.getEscapedClassPathAndClassesDir(classesDir);
}
}

6 changes: 3 additions & 3 deletions test/hotspot/jtreg/compiler/lib/compile_framework/Utils.java
Original file line number Diff line number Diff line change
@@ -122,10 +122,10 @@ private static void writeCodeToFile(String code, Path path) {
}

/**
* Write sources to file.
* Write each source in {@code sources} to a file inside {@code sourceDir}.
*/
public static List<Path> writeSourcesToFile(List<SourceCode> sources, Path sourceDir) {
List<Path> storedFiles = new ArrayList<Path>();
public static List<Path> writeSourcesToFiles(List<SourceCode> sources, Path sourceDir) {
List<Path> storedFiles = new ArrayList<>();
for (SourceCode sourceCode : sources) {
Path path = sourceDir.resolve(sourceCode.filePathName());
writeCodeToFile(sourceCode.code(), path);
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ public static int mul3(int i) {
""";
}

public static void main(String args[]) {
public static void main(String[] args) {
// Create a new CompileFramework instance.
CompileFramework comp = new CompileFramework();

@@ -110,6 +110,5 @@ public static void test(CompileFramework comp, String className, String methodNa
if (i != expected) {
throw new RuntimeException("wrong value: " + i);
}

}
}
Original file line number Diff line number Diff line change
@@ -42,9 +42,9 @@
* The "@compile" command for JTREG is required so that the IRFramework is compiled, other javac
* might not compile it because it is not present in the class, only in the dynamically compiled
* code.
*
* <p>
* Additionally, we must set the classpath for the Test-VM, so that it has access to all compiled
* classes (see {@code getEscapedClassPathOfCompiledClasses}).
* classes (see {@link CompileFramework#getEscapedClassPathOfCompiledClasses}).
*/
public class IRFrameworkJavaExample {

@@ -126,7 +126,7 @@ static void test_X2() {
comp.compile();

// Load the compiled class.
Class c = comp.getClass("X2");
Class<?> c = comp.getClass("X2");

// Invoke the "X2.main" method from the compiled and loaded class.
try {
Original file line number Diff line number Diff line change
@@ -70,7 +70,6 @@ public static void main(String args[]) {
// Compile the source files.
comp.compile();


// Object ret = XYZ9.test();
Object ret = comp.invoke("p.xyz.XYZ9", "test", new Object[] {});