Search in sources :

Example 1 with CompilationResult

use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.

the class HotSpotGraalCompiler method compile.

public CompilationResult compile(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
    StructuredGraph graph = createGraph(method, entryBCI, useProfilingInfo, compilationId, options, debug);
    CompilationResult result = new CompilationResult(compilationId);
    return compileHelper(CompilationResultBuilderFactory.Default, result, graph, method, entryBCI, useProfilingInfo, options);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CompilationResult(org.graalvm.compiler.code.CompilationResult)

Example 2 with CompilationResult

use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.

the class HotSpotGraalVMEventListener method notifyInstall.

@Override
public void notifyInstall(HotSpotCodeCacheProvider codeCache, InstalledCode installedCode, CompiledCode compiledCode) {
    DebugContext debug = DebugContext.forCurrentThread();
    if (debug.isDumpEnabled(DebugContext.BASIC_LEVEL)) {
        CompilationResult compResult = debug.contextLookup(CompilationResult.class);
        assert compResult != null : "can't dump installed code properly without CompilationResult";
        debug.dump(DebugContext.BASIC_LEVEL, installedCode, "After code installation");
    }
    if (debug.isLogEnabled()) {
        debug.log("%s", codeCache.disassemble(installedCode));
    }
    for (HotSpotCodeCacheListener listener : listeners) {
        listener.notifyInstall(codeCache, installedCode, compiledCode);
    }
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult)

Example 3 with CompilationResult

use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.

the class TruffleCompilerImpl method compilePEGraph.

/**
 * Compiles a graph produced by {@link PartialEvaluator#createGraph partial evaluation}.
 *
 * @param graph a graph resulting from partial evaluation
 * @param name the name to be used for the returned {@link CompilationResult#getName() result}
 * @param graphBuilderSuite phase suite to be used for creating new graphs during inlining
 * @param compilationRequest
 * @param listener
 */
@SuppressWarnings("try")
public CompilationResult compilePEGraph(StructuredGraph graph, String name, PhaseSuite<HighTierContext> graphBuilderSuite, CompilableTruffleAST compilable, CompilationRequest compilationRequest, TruffleCompilerListener listener) {
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope s = debug.scope("TruffleFinal")) {
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After TruffleTier");
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    CompilationResult result = null;
    try (DebugCloseable a = CompilationTime.start(debug);
        DebugContext.Scope s = debug.scope("TruffleGraal.GraalCompiler", graph, providers.getCodeCache());
        DebugCloseable c = CompilationMemUse.start(debug)) {
        CompilationResult compilationResult = createCompilationResult(name, graph.compilationId());
        result = GraalCompiler.compileGraph(graph, graph.method(), providers, backend, graphBuilderSuite, Optimizations, graph.getProfilingInfo(), suites, lirSuites, compilationResult, CompilationResultBuilderFactory.Default);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    if (listener != null) {
        listener.onGraalTierFinished(compilable, new GraphInfoImpl(graph));
    }
    try (DebugCloseable a = CodeInstallationTime.start(debug);
        DebugCloseable c = CodeInstallationMemUse.start(debug)) {
        InstalledCode installedCode = createInstalledCode(compilable);
        backend.createInstalledCode(debug, graph.method(), compilationRequest, result, graph.getSpeculationLog(), installedCode, false);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    return result;
}
Also used : Scope(org.graalvm.compiler.debug.DebugContext.Scope) InstalledCode(jdk.vm.ci.code.InstalledCode) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 4 with CompilationResult

use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.

the class HotSpotTruffleCompilerImpl method compileTruffleCallBoundaryMethod.

/**
 * Compiles a method denoted as a
 * {@linkplain HotSpotTruffleCompilerRuntime#getTruffleCallBoundaryMethods() Truffle call
 * boundary}. The compiled code has a special entry point generated by an
 * {@link TruffleCallBoundaryInstrumentationFactory}.
 */
private CompilationResult compileTruffleCallBoundaryMethod(ResolvedJavaMethod javaMethod, CompilationIdentifier compilationId, DebugContext debug) {
    Suites newSuites = this.suites.copy();
    removeInliningPhase(newSuites);
    OptionValues options = TruffleCompilerOptions.getOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.NO).method(javaMethod).compilationId(compilationId).build();
    MetaAccessProvider metaAccess = providers.getMetaAccess();
    Plugins plugins = new Plugins(new InvocationPlugins());
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) providers.getCodeCache();
    boolean infoPoints = codeCache.shouldDebugNonSafepoints();
    GraphBuilderConfiguration newConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true).withNodeSourcePosition(infoPoints);
    new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), newConfig, OptimisticOptimizations.ALL, null).apply(graph);
    PhaseSuite<HighTierContext> graphBuilderSuite = getGraphBuilderSuite(codeCache, backend.getSuites());
    CompilationResultBuilderFactory factory = getTruffleCallBoundaryInstrumentationFactory(backend.getTarget().arch.getName());
    return compileGraph(graph, javaMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), newSuites, lirSuites, new CompilationResult(compilationId), factory);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) OptionValues(org.graalvm.compiler.options.OptionValues) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) CompilationResultBuilderFactory(org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 5 with CompilationResult

use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.

the class BitOpsTest method tzcntlMemTest.

@Test
public void tzcntlMemTest() {
    if (tzcntSupported) {
        CodeGenTest test = new CodeGenTest() {

            @Override
            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
                AMD64Assembler asm = new AMD64Assembler(target);
                Register ret = registerConfig.getReturnRegister(JavaKind.Int);
                try {
                    Field f = IntField.class.getDeclaredField("x");
                    AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) UNSAFE.objectFieldOffset(f));
                    TZCNT.emit(asm, DWORD, ret, arg);
                    asm.ret(0);
                    return asm.close(true);
                } catch (Exception e) {
                    throw new RuntimeException("exception while trying to generate field access:", e);
                }
            }
        };
        assertReturn("intFieldStub", test, 31, new IntField(0x8000_0000));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Field(java.lang.reflect.Field) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) AMD64Assembler(org.graalvm.compiler.asm.amd64.AMD64Assembler) TargetDescription(jdk.vm.ci.code.TargetDescription) CompilationResult(org.graalvm.compiler.code.CompilationResult) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Aggregations

CompilationResult (org.graalvm.compiler.code.CompilationResult)46 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)20 Test (org.junit.Test)15 DebugContext (org.graalvm.compiler.debug.DebugContext)13 CallingConvention (jdk.vm.ci.code.CallingConvention)12 RegisterConfig (jdk.vm.ci.code.RegisterConfig)12 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)12 Register (jdk.vm.ci.code.Register)11 TargetDescription (jdk.vm.ci.code.TargetDescription)11 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)11 AMD64Assembler (org.graalvm.compiler.asm.amd64.AMD64Assembler)9 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)8 Infopoint (jdk.vm.ci.code.site.Infopoint)8 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)8 OptionValues (org.graalvm.compiler.options.OptionValues)8 InstalledCode (jdk.vm.ci.code.InstalledCode)7 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)6 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)6 CodeCacheProvider (jdk.vm.ci.code.CodeCacheProvider)5 LIRSuites (org.graalvm.compiler.lir.phases.LIRSuites)5