Search in sources :

Example 1 with HostedMetaAccess

use of com.oracle.svm.hosted.meta.HostedMetaAccess in project graal by oracle.

the class DeoptimizationFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    HostedMetaAccess metaAccess = config.getMetaAccess();
    DeoptimizationSupport.setDeoptStubPointer(MethodPointer.factory(metaAccess.lookupJavaMethod(deoptStubMethod)));
}
Also used : CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Example 2 with HostedMetaAccess

use of com.oracle.svm.hosted.meta.HostedMetaAccess in project graal by oracle.

the class FieldsOffsetsFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    for (FieldsOffsetsReplacement replacement : getReplacements().values()) {
        Fields fields = replacement.fields;
        long[] newOffsets = new long[fields.getCount()];
        for (int i = 0; i < newOffsets.length; i++) {
            Field field = findField(fields, i);
            assert UnsafeAccess.UNSAFE.objectFieldOffset(field) == fields.getOffsets()[i];
            newOffsets[i] = hMetaAccess.lookupJavaField(field).getLocation();
        }
        replacement.newOffsets = newOffsets;
        if (fields instanceof Edges) {
            Edges edges = (Edges) fields;
            replacement.newIterationInitMask = NodeClass.computeIterationMask(edges.type(), edges.getDirectCount(), newOffsets);
        }
        replacement.newValuesAvailable = true;
    }
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) Field(java.lang.reflect.Field) Fields(org.graalvm.compiler.core.common.Fields) CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) Edges(org.graalvm.compiler.graph.Edges) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Example 3 with HostedMetaAccess

use of com.oracle.svm.hosted.meta.HostedMetaAccess in project graal by oracle.

the class RuntimeStrengthenStampsPhase method beforeCompilation.

@Override
@SuppressWarnings("try")
public void beforeCompilation(BeforeCompilationAccess c) {
    CompilationAccessImpl config = (CompilationAccessImpl) c;
    if (Options.PrintRuntimeCompileMethods.getValue()) {
        printCallTree();
    }
    System.out.println(methods.size() + " method(s) included for runtime compilation");
    if (Options.PrintStaticTruffleBoundaries.getValue()) {
        printStaticTruffleBoundaries();
    }
    Integer maxMethods = Options.MaxRuntimeCompileMethods.getValue();
    if (maxMethods != 0 && methods.size() > maxMethods) {
        printDeepestLevelPath();
        throw VMError.shouldNotReachHere("Number of methods for runtime compilation exceeds the allowed limit: " + methods.size() + " > " + maxMethods);
    }
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    runtimeConfigBuilder.updateLazyState(hMetaAccess);
    /*
         * Start fresh with a new GraphEncoder, since we are going to optimize all graphs now that
         * the static analysis results are available.
         */
    graphEncoder = new GraphEncoder(ConfigurationValues.getTarget().arch);
    StrengthenStampsPhase strengthenStamps = new RuntimeStrengthenStampsPhase(config.getUniverse(), objectReplacer);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    PhaseContext phaseContext = new PhaseContext(hostedProviders);
    for (CallTreeNode node : methods.values()) {
        StructuredGraph graph = node.graph;
        if (graph != null) {
            DebugContext debug = graph.getDebug();
            try (DebugContext.Scope scope = debug.scope("RuntimeOptimize", graph)) {
                removeUnreachableInvokes(node);
                strengthenStamps.apply(graph);
                canonicalizer.apply(graph, phaseContext);
                GraalConfiguration.instance().runAdditionalCompilerPhases(graph, this);
                canonicalizer.apply(graph, phaseContext);
                graphEncoder.prepare(graph);
            } catch (Throwable ex) {
                debug.handle(ex);
            }
        }
    }
    graphEncoder.finishPrepare();
    for (CallTreeNode node : methods.values()) {
        if (node.graph != null) {
            registerDeoptEntries(node);
            long startOffset = graphEncoder.encode(node.graph);
            objectReplacer.createMethod(node.implementationMethod).setEncodedGraphStartOffset(startOffset);
            /* We do not need the graph anymore, let the GC do it's work. */
            node.graph = null;
        }
    }
    GraalSupport.setGraphEncoding(graphEncoder.getEncoding(), graphEncoder.getObjects(), graphEncoder.getNodeClasses());
    objectReplacer.updateDataDuringAnalysis((AnalysisMetaAccess) hMetaAccess.getWrapped());
}
Also used : CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) GraphEncoder(org.graalvm.compiler.nodes.GraphEncoder) DebugContext(org.graalvm.compiler.debug.DebugContext) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) StrengthenStampsPhase(com.oracle.svm.hosted.phases.StrengthenStampsPhase)

Example 4 with HostedMetaAccess

use of com.oracle.svm.hosted.meta.HostedMetaAccess in project graal by oracle.

the class RuntimeStrengthenStampsPhase method afterHeapLayout.

@Override
public void afterHeapLayout(AfterHeapLayoutAccess a) {
    AfterHeapLayoutAccessImpl config = (AfterHeapLayoutAccessImpl) a;
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    HostedUniverse hUniverse = (HostedUniverse) hMetaAccess.getUniverse();
    objectReplacer.updateSubstrateDataAfterHeapLayout(hUniverse);
}
Also used : AfterHeapLayoutAccessImpl(com.oracle.svm.hosted.FeatureImpl.AfterHeapLayoutAccessImpl) HostedUniverse(com.oracle.svm.hosted.meta.HostedUniverse) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Example 5 with HostedMetaAccess

use of com.oracle.svm.hosted.meta.HostedMetaAccess in project graal by oracle.

the class RuntimeStrengthenStampsPhase method afterCompilation.

@Override
public void afterCompilation(AfterCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    HostedUniverse hUniverse = (HostedUniverse) hMetaAccess.getUniverse();
    objectReplacer.updateSubstrateDataAfterCompilation(hUniverse);
    objectReplacer.registerImmutableObjects(config);
    GraalSupport.registerImmutableObjects(config);
    ((SubstrateReplacements) runtimeConfigBuilder.getRuntimeConfig().getProviders().getReplacements()).registerImmutableObjects(config);
}
Also used : SubstrateReplacements(com.oracle.svm.core.graal.meta.SubstrateReplacements) CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) HostedUniverse(com.oracle.svm.hosted.meta.HostedUniverse) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Aggregations

HostedMetaAccess (com.oracle.svm.hosted.meta.HostedMetaAccess)8 CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)4 HostedUniverse (com.oracle.svm.hosted.meta.HostedUniverse)4 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)2 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)2 AfterHeapLayoutAccessImpl (com.oracle.svm.hosted.FeatureImpl.AfterHeapLayoutAccessImpl)2 BeforeCompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl)2 AnalysisPolicy (com.oracle.graal.pointsto.AnalysisPolicy)1 UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)1 SubstitutionProcessor (com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor)1 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 TypeState (com.oracle.graal.pointsto.typestate.TypeState)1 Timer (com.oracle.graal.pointsto.util.Timer)1 StopTimer (com.oracle.graal.pointsto.util.Timer.StopTimer)1 AllocationCounter (com.oracle.svm.core.allocationprofile.AllocationCounter)1 AllocationSite (com.oracle.svm.core.allocationprofile.AllocationSite)1 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)1