Graal JVMCI Problem
Remi Forax
forax at univ-mlv.fr
Sun Jun 5 14:35:28 UTC 2016
I may be wrong but i think that the JVMCI API was introduced in JDK 9,
so i think you need a JDK 9.
cheers,
Rémi
----- Mail original -----
> De: "Bahram Yarahmadi" <bahram.yarahmadi at gmail.com>
> À: graal-dev at openjdk.java.net
> Envoyé: Dimanche 5 Juin 2016 12:56:06
> Objet: Re: Graal JVMCI Problem
>
> What should I do ?
>
> Thanks ,
>
> Regards
>
> On Sun, Jun 5, 2016 at 3:24 PM, 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