Search in sources :

Example 11 with Infopoint

use of jdk.vm.ci.code.site.Infopoint in project graal by oracle.

the class DeoptEntryOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb) {
    CompilationResult compilation = crb.compilationResult;
    /* Search for the previous added info point. */
    List<Infopoint> infoPoints = compilation.getInfopoints();
    int size = infoPoints.size();
    for (int idx = size - 1; idx >= 0; idx--) {
        Infopoint infopoint = infoPoints.get(idx);
        int entryOffset = CodeInfoEncoder.getEntryOffset(infopoint);
        if (entryOffset >= 0) {
            if (entryOffset == crb.asm.position()) {
                crb.asm.ensureUniquePC();
                break;
            }
        }
    }
    /* Register this location as a deopt infopoint. */
    compilation.addInfopoint(new DeoptEntryInfopoint(crb.asm.position(), state.debugInfo()));
    /* Add NOP so that the next infopoint (e.g., an invoke) gets a unique PC. */
    crb.asm.ensureUniquePC();
}
Also used : DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint) CompilationResult(org.graalvm.compiler.code.CompilationResult) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint) Infopoint(jdk.vm.ci.code.site.Infopoint)

Example 12 with Infopoint

use of jdk.vm.ci.code.site.Infopoint in project graal by oracle.

the class HotSpotCompiledCodeBuilder method getSortedSites.

/**
 * HotSpot expects sites to be presented in ascending order of PC (see
 * {@code DebugInformationRecorder::add_new_pc_offset}). In addition, it expects
 * {@link Infopoint} PCs to be unique.
 */
private static Site[] getSortedSites(CodeCacheProvider codeCache, CompilationResult target) {
    List<Site> sites = new ArrayList<>(target.getExceptionHandlers().size() + target.getInfopoints().size() + target.getDataPatches().size() + target.getMarks().size() + target.getSourceMappings().size());
    sites.addAll(target.getExceptionHandlers());
    sites.addAll(target.getInfopoints());
    sites.addAll(target.getDataPatches());
    sites.addAll(target.getMarks());
    if (codeCache.shouldDebugNonSafepoints()) {
        /*
             * Translate the source mapping into appropriate info points. In HotSpot only one
             * position can really be represented and recording the end PC seems to give the best
             * results and corresponds with what C1 and C2 do. HotSpot doesn't like to see these
             * unless -XX:+DebugNonSafepoints is enabled, so don't emit them in that case.
             */
        List<Site> sourcePositionSites = new ArrayList<>();
        for (SourceMapping source : target.getSourceMappings()) {
            NodeSourcePosition sourcePosition = source.getSourcePosition();
            if (sourcePosition.isPlaceholder() || sourcePosition.isSubstitution()) {
                // HotSpot doesn't understand any of the special positions so just drop them.
                continue;
            }
            assert sourcePosition.verify();
            sourcePosition = sourcePosition.trim();
            /*
                 * Don't add BYTECODE_POSITION info points that would potentially create conflicts.
                 * Under certain conditions the site's pc is not the pc that gets recorded by
                 * HotSpot (see @code {CodeInstaller::site_Call}). So, avoid adding any source
                 * positions that can potentially map to the same pc. To do that make sure that the
                 * source mapping doesn't contain a pc of any important Site.
                 */
            if (sourcePosition != null && !anyMatch(sites, s -> source.contains(s.pcOffset))) {
                sourcePositionSites.add(new Infopoint(source.getEndOffset(), new DebugInfo(sourcePosition), InfopointReason.BYTECODE_POSITION));
            }
        }
        sites.addAll(sourcePositionSites);
    }
    SiteComparator c = new SiteComparator();
    Collections.sort(sites, c);
    if (c.sawCollidingInfopoints) {
        Infopoint lastInfopoint = null;
        List<Site> copy = new ArrayList<>(sites.size());
        for (Site site : sites) {
            if (site instanceof Infopoint) {
                Infopoint info = (Infopoint) site;
                if (lastInfopoint == null || lastInfopoint.pcOffset != info.pcOffset) {
                    lastInfopoint = info;
                    copy.add(info);
                } else {
                    // Omit this colliding infopoint
                    assert lastInfopoint.reason.compareTo(info.reason) <= 0;
                }
            } else {
                copy.add(site);
            }
        }
        sites = copy;
    }
    return sites.toArray(new Site[sites.size()]);
}
Also used : Site(jdk.vm.ci.code.site.Site) ArrayList(java.util.ArrayList) Infopoint(jdk.vm.ci.code.site.Infopoint) SourceMapping(org.graalvm.compiler.code.SourceMapping) DebugInfo(jdk.vm.ci.code.DebugInfo) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 13 with Infopoint

use of jdk.vm.ci.code.site.Infopoint in project graal by oracle.

the class InfopointReasonTest method callInfopoints.

@Test
public void callInfopoints() {
    final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
    final StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
    final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, graph.getProfilingInfo(), createSuites(graph.getOptions()), createLIRSuites(graph.getOptions()), new CompilationResult(graph.compilationId()), CompilationResultBuilderFactory.Default);
    for (Infopoint sp : cr.getInfopoints()) {
        assertNotNull(sp.reason);
        if (sp instanceof Call) {
            assertDeepEquals(InfopointReason.CALL, sp.reason);
        }
    }
}
Also used : Call(jdk.vm.ci.code.site.Call) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Infopoint(jdk.vm.ci.code.site.Infopoint) CompilationResult(org.graalvm.compiler.code.CompilationResult) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test)

Aggregations

Infopoint (jdk.vm.ci.code.site.Infopoint)13 Call (jdk.vm.ci.code.site.Call)8 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)6 CompilationResult (org.graalvm.compiler.code.CompilationResult)5 DebugInfo (jdk.vm.ci.code.DebugInfo)3 DataPatch (jdk.vm.ci.code.site.DataPatch)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 ReferenceMapEncoder (com.oracle.svm.core.heap.ReferenceMapEncoder)2 HostedMethod (com.oracle.svm.hosted.meta.HostedMethod)2 HashMap (java.util.HashMap)2 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)2 ExceptionHandler (jdk.vm.ci.code.site.ExceptionHandler)2 Test (org.junit.Test)2 AMD64InstructionPatcher (com.oracle.svm.core.graal.code.amd64.AMD64InstructionPatcher)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DefaultRefMapFormatter (jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter)1