Categories
Non classé

How does it work?

Magicator generates GraalVM configuration files using an analysis method we invented.

GraalVM has the world’s best infrastructure for Java static analysis. But generating a native GraalVM image can be tricky since developers need to describe some of their application’s runtime behavior. For example, the program below won’t compile (using both the GraalVM compiler and Tracing Agent).

package io.manycore;
public class Main {
public static void main(String[] args) throws ClassNotFoundException {
boolean flag = false;
if (System.getenv("PROD").equals("1"));
flag = true;
if (flag) {
for (int methodToCallCount=0; methodToCallCount <= 7; methodToCallCount++) {
for (int classCount = 0; classCount <= 15; classCount++) {
Class thisClass = Class.forName("io.manycore.reflection.Meng" + classCount);
System.out.println(thisClass.toString());
}
}
}
}
}
view raw demo.java hosted with ❤ by GitHub

To generate the correct configuration files for the program, Magicator simplifies it, executes it, and captures its results.

for (int methodToCallCount=0; methodToCallCount <= 7; methodToCallCount++) {
for (int classCount = 0; classCount <= 15; classCount++) {
Class thisClass = Class.forName("io.manycore.reflection.Meng" + classCount);
capture(thisClass.toString());
}
}
view raw gistfile1.txt hosted with ❤ by GitHub
Program Simplification Example

Magicator has determined that running this simplified program will yield all the values of the dynamic instruction set. This simplification then allows it to generate the GraalVM configuration file.

Another exciting Magicator feature is that it runs several simplified programs to extract all of the initial program’s general properties. It’s not dynamic or static analysis, and it’s not symbolic or concolic execution. Instead, it’s a generalization of supercompilation and partial evaluation.

Sometimes, it’s impossible to gather all the possible values for a program. This is because some of them are undecidable. In that case, Magicator marks the element as “to be resolved manually”.

We’re excited by the possibilities unlocked by Magicator, and we’re just getting started. One apparent improvement for GraalVM will be to remove the initial code and replace it with its results.