Graal JVMCI Problem

Bahram Yarahmadi bahram.yarahmadi at gmail.com
Mon Jun 6 09:51:07 UTC 2016


Thanks Stefan
I tried to test all arguments that you mentioned but none of them worked
 `mx -Mjit -v vm -version`  output on my computer is :
Setting environment variable JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
from /home/bahram/graal/graal-core/mx.graal-core/env
Setting environment variable JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
from /home/bahram/graal/graal-core/mx.graal-core/env
[project jdk.vm.ci.hotspot.jfr was removed as dependency JFR is missing]
[jdk.vm.ci.hotspot.jfr was removed from distribution JVMCI_HOTSPOT]
/home/bahram/graal/jvmci/jdk1.8.0_91/product/bin/java -server
-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler
-d64 -Djvmci.Compiler=graal
-Xbootclasspath/p:/home/bahram/graal/truffle/mxbuild/dists/truffle-api.jar
-version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14)
OpenJDK 64-Bit Server VM (build 25.66-b00-internal-jvmci-0.9-dev, mixed
mode)

Since I don't use truffle framework I changed it to graal-api.jar location
but when I entered it as default vm argument in eclipse I get the same
error  ,finally I enterd jvmci-api.jar which is located in mx.build in
jvmci directory but I get this error
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.UnsupportedOperationException: The VM does not support
the Graal 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 com.oracle.graal.api.test.Graal.getRequiredCapability(Graal.java:78)
at BahramMain.<clinit>(BahramMain.java:26)

I have cloned Graal repo from github yesterday
I compiled it with mx --vm server build since 'mx build' does not ask me
which graal configuration I want to use anymore
and since I want to use graal just for some special methods which I specify
I have to use graal in a hosted mode (server)

What do you suggest me to do ?

Thanks again

Bahram




On Sun, Jun 5, 2016 at 7:33 PM, Stefan Marr <java at stefan-marr.de> wrote:

> 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
>
> --
> Stefan Marr
> Johannes Kepler Universität Linz
> http://stefan-marr.de/research/
>
>
>
>


More information about the graal-dev mailing list