Search in sources :

Example 1 with CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl 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 CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl 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 CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl 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 CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl 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)

Example 5 with CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.

the class JNIAccessFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl access = (CompilationAccessImpl) a;
    for (JNIAccessibleClass clazz : JNIReflectionDictionary.singleton().getClasses()) {
        for (JNIAccessibleField field : clazz.getFields()) {
            field.fillOffset(access);
        }
        for (JNIAccessibleMethod method : clazz.getMethods()) {
            method.resolveJavaCallWrapper(access);
            // for constant address to use as identifier
            access.registerAsImmutable(method);
        }
    }
}
Also used : CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)

Aggregations

CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)7 HostedMetaAccess (com.oracle.svm.hosted.meta.HostedMetaAccess)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)1 SharedField (com.oracle.svm.core.meta.SharedField)1 FastThreadLocal (com.oracle.svm.core.threadlocal.FastThreadLocal)1 VMThreadLocalInfo (com.oracle.svm.core.threadlocal.VMThreadLocalInfo)1 HostedUniverse (com.oracle.svm.hosted.meta.HostedUniverse)1 StrengthenStampsPhase (com.oracle.svm.hosted.phases.StrengthenStampsPhase)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Fields (org.graalvm.compiler.core.common.Fields)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 Edges (org.graalvm.compiler.graph.Edges)1 GraphEncoder (org.graalvm.compiler.nodes.GraphEncoder)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)1 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)1