Graal JVMCI Problem

Rémi Forax forax at univ-mlv.fr
Mon Jun 6 10:26:48 UTC 2016


Ok, good to know.

Regards,
Rémi


Le 5 juin 2016 17:03:03 CEST, Stefan Marr <java at stefan-marr.de> a écrit :
>Hi:
>
>Are you building Graal from the latest graal-core code?
>
>You’ll likely need extra arguments to the VM: -server
>-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -d64
>-Djvmci.Compiler=graal
>
>And possibly: -XX:+UseJVMCICompiler depending on whether all Java code
>should be compiled with it.
>
>To know what the correct way to invoke Java is, you can check mx.
>
>Something like `mx -Mjit -v vm -version` should print out the correct
>way of invoking the JVM with Graal enabled.
>
>
>Remi, the code at https://github.com/graalvm/graal-core build a Hotspot
>for JDK 8 with JVMCI.
>
>Best regards
>Stefan
>
>> On 05 Jun 2016, at 12:54, Bahram Yarahmadi
><bahram.yarahmadi at gmail.com> wrote:
>> 
>> Hello guys,
>> I made a very simple program ,which is :
>> 
>> mport java.lang.reflect.Method;
>> 
>> import com.oracle.graal.api.test.Graal;
>> import com.oracle.graal.code.CompilationResult;
>> import com.oracle.graal.compiler.GraalCompiler;
>> import com.oracle.graal.compiler.target.Backend;
>> import com.oracle.graal.lir.asm.CompilationResultBuilderFactory;
>> import com.oracle.graal.lir.phases.LIRSuites;
>> import com.oracle.graal.nodes.StructuredGraph;
>> import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
>> import com.oracle.graal.phases.OptimisticOptimizations;
>> import com.oracle.graal.phases.PhaseSuite;
>> import com.oracle.graal.phases.tiers.HighTierContext;
>> import com.oracle.graal.phases.tiers.Suites;
>> import com.oracle.graal.phases.util.Providers;
>> import com.oracle.graal.runtime.RuntimeProvider;
>> 
>> import jdk.vm.ci.code.CodeCacheProvider;
>> import jdk.vm.ci.code.CompiledCode;
>> import jdk.vm.ci.code.InstalledCode;
>> import jdk.vm.ci.meta.MetaAccessProvider;
>> import jdk.vm.ci.meta.ProfilingInfo;
>> import jdk.vm.ci.meta.ResolvedJavaMethod;
>> 
>> public class BahramMain {
>> public static RuntimeProvider
>> runetimeProvider=Graal.getRequiredCapability(RuntimeProvider.class);
>> public static Backend backend=runetimeProvider.getHostBackend();
>> public static MetaAccessProvider metaAccess=backend.getMetaAccess();
>> public static CodeCacheProvider codeCache=backend.getCodeCache();
>> public static Providers providers=backend.getProviders();
>> public static int addTwoIntegers(int x,int y){
>> if (x > y){
>> return x + y;
>> }
>> return x - y;
>> }
>> public static void main(String []args){
>> ResolvedJavaMethod method=findMethod(BahramMain.class,
>"addTwoIntegers");
>> StructuredGraph graph = new StructuredGraph(method,
>AllowAssumptions.YES);
>> 
>>       /*
>>        * The phases used to build the graph. Usually this is just the
>> GraphBuilderPhase. If
>>        * the graph already contains nodes, it is ignored.
>>        */
>>       PhaseSuite<HighTierContext> graphBuilderSuite =
>> backend.getSuites().getDefaultGraphBuilderSuite();
>> 
>>       /*
>>        * The optimization phases that are applied to the graph. This
>is
>> the main configuration
>>        * point for Graal. Add or remove phases to customize your
>> compilation.
>>        */
>>       Suites suites = backend.getSuites().getDefaultSuites();
>> 
>>       /*
>>        * The low-level phases that are applied to the low-level
>> representation.
>>        */
>>       LIRSuites lirSuites =
>backend.getSuites().getDefaultLIRSuites();
>> 
>>       /*
>>        * We want Graal to perform all speculative optimistic
>> optimizations, using the
>>        * profiling information that comes with the method (collected
>by
>> the interpreter) for
>>        * speculation.
>>        */
>>       OptimisticOptimizations optimisticOpts =
>> OptimisticOptimizations.ALL;
>>       ProfilingInfo profilingInfo = graph.getProfilingInfo(method);
>> 
>>       /* The default class and configuration for compilation results.
>*/
>>       CompilationResult compilationResult = new CompilationResult();
>>       CompilationResultBuilderFactory factory =
>> CompilationResultBuilderFactory.Default;
>> 
>>       /* Invoke the whole Graal compilation pipeline. */
>>       GraalCompiler.compileGraph(graph, method, providers, backend,
>> graphBuilderSuite, optimisticOpts, profilingInfo, suites, lirSuites,
>> compilationResult, factory);
>> 
>>       /*
>>        * Install the compilation result into the VM, i.e., copy the
>> byte[] array that contains
>>        * the machine code into an actual executable memory location.
>>        */
>>       CompiledCode compiledCode = backend.createCompiledCode(method,
>> compilationResult);
>>       InstalledCode installedCode = codeCache.addCode(method,
>> compiledCode, null, null);
>>       System.out.println("The number Of methods in the graph is "+
>> graph.getNodeCount());
>> 
>> }
>> public static ResolvedJavaMethod findMethod(Class<?> declaringClass,
>String
>> name) {
>>      Method reflectionMethod = null;
>>      for (Method m : declaringClass.getDeclaredMethods()) {
>>          if (m.getName().equals(name)) {
>>              assert reflectionMethod == null : "More than one method
>with
>> name " + name + " in class " + declaringClass.getName();
>>              reflectionMethod = m;
>>          }
>>      }
>>      assert reflectionMethod != null : "No method with name " + name
>+ "
>> in class " + declaringClass.getName();
>>      return metaAccess.lookupJavaMethod(reflectionMethod);
>>  }
>> 
>> }
>> but when I want to run it on eclipse with out unittest I get this
>error :
>> Exception in thread "main" java.lang.ExceptionInInitializerError
>> at BahramMain.<clinit>(BahramMain.java:26)
>> Caused by: java.lang.UnsupportedOperationException: The VM does not
>support
>> the JVMCI API.
>> Currently used Java home directory is
>> /home/bahram/graal/jvmci/jdk1.8.0_91/product/jre.
>> Currently used VM configuration is: OpenJDK 64-Bit Server VM
>> at jdk.vm.ci.runtime.JVMCI.getRuntime(JVMCI.java:50)
>> at com.oracle.graal.api.test.Graal.initializeRuntime(Graal.java:44)
>> at com.oracle.graal.api.test.Graal.<clinit>(Graal.java:40)
>> ... 1 more



More information about the graal-dev mailing list