changeset 22869:d0000fb935b7

made inlined method recording unconditional during compilation
author Doug Simon <doug.simon@oracle.com>
date Thu, 22 Oct 2015 12:56:40 +0200
parents 6e1b3bbd2e1d
children be773541ce54
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EncodedGraph.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java mx.graal/suite.py
diffstat 13 files changed, 29 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Thu Oct 22 12:56:40 2015 +0200
@@ -29,7 +29,6 @@
 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.Optional;
 
 import java.util.List;
-import java.util.Set;
 
 import jdk.vm.ci.code.CallingConvention;
 import jdk.vm.ci.code.CompilationResult;
@@ -337,7 +336,7 @@
     }
 
     @SuppressWarnings("try")
-    public static void emitCode(Backend backend, Assumptions assumptions, ResolvedJavaMethod rootMethod, Set<ResolvedJavaMethod> inlinedMethods, int bytecodeSize, LIRGenerationResult lirGenRes,
+    public static void emitCode(Backend backend, Assumptions assumptions, ResolvedJavaMethod rootMethod, List<ResolvedJavaMethod> inlinedMethods, int bytecodeSize, LIRGenerationResult lirGenRes,
                     CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, CompilationResultBuilderFactory factory) {
         try (DebugCloseable a = EmitCode.start()) {
             FrameMap frameMap = lirGenRes.getFrameMap();
@@ -347,7 +346,7 @@
             if (assumptions != null && !assumptions.isEmpty()) {
                 compilationResult.setAssumptions(assumptions.toArray());
             }
-            if (inlinedMethods != null) {
+            if (rootMethod != null) {
                 compilationResult.setMethods(rootMethod, inlinedMethods);
                 compilationResult.setBytecodeSize(bytecodeSize);
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Thu Oct 22 12:56:40 2015 +0200
@@ -192,7 +192,7 @@
             try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(getId()), true))) {
                 // Begin the compilation event.
                 compilationEvent.begin();
-                result = compiler.compile(method, entryBCI, mustRecordMethodInlining(config));
+                result = compiler.compile(method, entryBCI);
             } catch (Throwable e) {
                 throw Debug.handle(e);
             } finally {
@@ -285,20 +285,6 @@
         }
     }
 
-    /**
-     * Determines whether to disable method inlining recording for the method being compiled.
-     */
-    private boolean mustRecordMethodInlining(HotSpotVMConfig config) {
-        if (config.ciTime || config.ciTimeEach || CompiledBytecodes.isEnabled()) {
-            return true;
-        }
-        long jvmciEnv = request.getJvmciEnv();
-        if (jvmciEnv == 0 || UNSAFE.getByte(jvmciEnv + config.jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) {
-            return true;
-        }
-        return false;
-    }
-
     private String getMethodDescription() {
         HotSpotResolvedJavaMethod method = getMethod();
         return String.format("%-6d JVMCI %-70s %-45s %-50s %s", getId(), method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(),
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompiler.java	Thu Oct 22 12:56:40 2015 +0200
@@ -104,7 +104,7 @@
         System.exit(0);
     }
 
-    public CompilationResult compile(ResolvedJavaMethod method, int entryBCI, boolean mustRecordMethodInlining) {
+    public CompilationResult compile(ResolvedJavaMethod method, int entryBCI) {
         HotSpotBackend backend = graalRuntime.getHostBackend();
         HotSpotProviders providers = backend.getProviders();
         final boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
@@ -116,9 +116,6 @@
                 speculationLog.collectFailedSpeculations();
             }
             graph = new StructuredGraph(method, entryBCI, AllowAssumptions.from(OptAssumptions.getValue()), speculationLog);
-            if (!mustRecordMethodInlining) {
-                graph.disableInlinedMethodRecording();
-            }
         }
 
         CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Thu Oct 22 12:56:40 2015 +0200
@@ -219,7 +219,6 @@
         boolean isObjectResult = !linkage.getOutgoingCallingConvention().getReturn().getLIRKind().isValue();
 
         StructuredGraph graph = new StructuredGraph(toString(), null, AllowAssumptions.NO);
-        graph.disableInlinedMethodRecording();
         graph.disableUnsafeAccessTracking();
 
         GraphKit kit = new GraphKit(graph, providers, wordTypes, providers.getGraphBuilderPlugins());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java	Thu Oct 22 12:56:40 2015 +0200
@@ -106,10 +106,8 @@
         GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
 
         // Stubs cannot have optimistic assumptions since they have
-        // to be valid for the entire run of the VM. Nor can they be
-        // evolved or have breakpoints.
+        // to be valid for the entire run of the VM.
         final StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO);
-        graph.disableInlinedMethodRecording();
         graph.disableUnsafeAccessTracking();
 
         if (SnippetGraphUnderConstruction != null) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Thu Oct 22 12:56:40 2015 +0200
@@ -165,10 +165,8 @@
             try (Scope d = Debug.sandbox("CompilingStub", DebugScope.getConfig(), providers.getCodeCache(), debugScopeContext())) {
                 final StructuredGraph graph = getGraph();
 
-                // Stubs cannot be recompiled so they cannot be compiled with
-                // assumptions and there is no point in recording evol_method dependencies
+                // Stubs cannot be recompiled so they cannot be compiled with assumptions
                 assert graph.getAssumptions() == null;
-                assert !graph.isInlinedMethodRecordingEnabled() : graph;
 
                 if (!(graph.start() instanceof StubStartNode)) {
                     StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
@@ -216,7 +214,6 @@
         // Stubs cannot be recompiled so they cannot be compiled with
         // assumptions and there is no point in recording evol_method dependencies
         assert compResult.getAssumptions() == null : "stubs should not use assumptions: " + this;
-        assert compResult.getMethods() == null : "stubs should not record evol_method dependencies: " + this;
 
         for (DataPatch data : compResult.getDataPatches()) {
             if (data.reference instanceof ConstantReference) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EncodedGraph.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EncodedGraph.java	Thu Oct 22 12:56:40 2015 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.nodes;
 
-import java.util.Set;
+import java.util.List;
 
 import jdk.vm.ci.meta.Assumptions;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -41,7 +41,7 @@
     private final Object[] objects;
     private final NodeClass<?>[] types;
     private final Assumptions assumptions;
-    private final Set<ResolvedJavaMethod> inlinedMethods;
+    private final List<ResolvedJavaMethod> inlinedMethods;
 
     /**
      * The "table of contents" of the encoded graph, i.e., the mapping from orderId numbers to the
@@ -49,7 +49,7 @@
      */
     protected long[] nodeStartOffsets;
 
-    public EncodedGraph(byte[] encoding, long startOffset, Object[] objects, NodeClass<?>[] types, Assumptions assumptions, Set<ResolvedJavaMethod> inlinedMethods) {
+    public EncodedGraph(byte[] encoding, long startOffset, Object[] objects, NodeClass<?>[] types, Assumptions assumptions, List<ResolvedJavaMethod> inlinedMethods) {
         this.encoding = encoding;
         this.startOffset = startOffset;
         this.objects = objects;
@@ -78,7 +78,7 @@
         return assumptions;
     }
 
-    public Set<ResolvedJavaMethod> getInlinedMethods() {
+    public List<ResolvedJavaMethod> getInlinedMethods() {
         return inlinedMethods;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Thu Oct 22 12:56:40 2015 +0200
@@ -22,11 +22,10 @@
  */
 package com.oracle.graal.nodes;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Consumer;
 
@@ -128,10 +127,10 @@
     private final SpeculationLog speculationLog;
 
     /**
-     * Records the methods that were inlined while constructing this graph along with how many times
-     * each method was inlined.
+     * Records the methods that were inlined while constructing this graph, one entry for each time
+     * a specific method is inlined.
      */
-    private Map<ResolvedJavaMethod, Integer> inlinedMethods = new HashMap<>();
+    private final List<ResolvedJavaMethod> inlinedMethods = new ArrayList<>();
 
     private static enum UnsafeAccessState {
         NO_ACCESS,
@@ -257,14 +256,10 @@
     @Override
     protected Graph copy(String newName, Consumer<Map<Node, Node>> duplicationMapCallback) {
         AllowAssumptions allowAssumptions = AllowAssumptions.from(assumptions != null);
-        boolean enableInlinedMethodRecording = isInlinedMethodRecordingEnabled();
         StructuredGraph copy = new StructuredGraph(newName, method, graphId, entryBCI, allowAssumptions, speculationLog);
         if (allowAssumptions == AllowAssumptions.YES && assumptions != null) {
             copy.assumptions.record(assumptions);
         }
-        if (!enableInlinedMethodRecording) {
-            copy.disableInlinedMethodRecording();
-        }
         copy.hasUnsafeAccess = hasUnsafeAccess;
         copy.setGuardsStage(getGuardsStage());
         copy.isAfterFloatingReadPhase = isAfterFloatingReadPhase;
@@ -546,83 +541,38 @@
     }
 
     /**
-     * Disables method inlining recording while constructing this graph. This can be done at most
-     * once and must be done before any inlined methods are recorded.
+     * Gets the methods that were inlined while constructing this graph.
      */
-    public void disableInlinedMethodRecording() {
-        assert inlinedMethods != null : "cannot disable method inlining recording more than once";
-        assert inlinedMethods.isEmpty() : "cannot disable method inlining recording once methods have been recorded";
-        inlinedMethods = null;
-    }
-
-    public boolean isInlinedMethodRecordingEnabled() {
-        return inlinedMethods != null;
-    }
-
-    /**
-     * Gets the methods that were inlined while constructing this graph.
-     *
-     * @return {@code null} if method inlining recording has been
-     *         {@linkplain #disableInlinedMethodRecording() disabled}
-     */
-    public Set<ResolvedJavaMethod> getInlinedMethods() {
-        return inlinedMethods == null ? null : inlinedMethods.keySet();
+    public List<ResolvedJavaMethod> getInlinedMethods() {
+        return inlinedMethods;
     }
 
     /**
-     * If method inlining recording has not been {@linkplain #disableInlinedMethodRecording()
-     * disabled}, records that {@code inlinedMethod} was inlined to this graph. Otherwise, this
-     * method does nothing.
+     * Records that {@code inlinedMethod} was inlined to this graph.
      */
     public void recordInlinedMethod(ResolvedJavaMethod inlinedMethod) {
-        if (inlinedMethods != null) {
-            Integer count = inlinedMethods.get(inlinedMethod);
-            if (count != null) {
-                inlinedMethods.put(inlinedMethod, count + 1);
-            } else {
-                inlinedMethods.put(inlinedMethod, 1);
-            }
-        }
+        inlinedMethods.add(inlinedMethod);
     }
 
     /**
-     * If method inlining recording has not been {@linkplain #disableInlinedMethodRecording()
-     * disabled}, updates the {@linkplain #getInlinedMethods() inlined methods} of this graph with
-     * the inlined methods of another graph. Otherwise, this method does nothing.
+     * Updates the {@linkplain #getInlinedMethods() inlined methods} of this graph with the inlined
+     * methods of another graph.
      */
     public void updateInlinedMethods(StructuredGraph other) {
-        if (inlinedMethods != null) {
-            assert this != other;
-            Map<ResolvedJavaMethod, Integer> otherInlinedMethods = other.inlinedMethods;
-            if (otherInlinedMethods != null) {
-                for (Map.Entry<ResolvedJavaMethod, Integer> e : otherInlinedMethods.entrySet()) {
-                    ResolvedJavaMethod key = e.getKey();
-                    Integer count = inlinedMethods.get(key);
-                    if (count != null) {
-                        inlinedMethods.put(key, count + e.getValue());
-                    } else {
-                        inlinedMethods.put(key, e.getValue());
-                    }
-                }
-            }
-        }
+        assert this != other;
+        this.inlinedMethods.addAll(other.inlinedMethods);
     }
 
     /**
      * Gets the input bytecode {@linkplain ResolvedJavaMethod#getCodeSize() size} from which this
      * graph is constructed. This ignores how many bytecodes in each constituent method are actually
      * parsed (which may be none for methods whose IR is retrieved from a cache or less than the
-     * full amount for any given method due to profile guided branch pruning). If method inlining
-     * recording has been {@linkplain #disableInlinedMethodRecording() disabled} for this graph,
-     * bytecode counts for inlined methods are not included in the returned value.
+     * full amount for any given method due to profile guided branch pruning).
      */
     public int getBytecodeSize() {
         int res = method.getCodeSize();
-        if (inlinedMethods != null) {
-            for (Map.Entry<ResolvedJavaMethod, Integer> e : inlinedMethods.entrySet()) {
-                int inlinedBytes = e.getValue() * e.getKey().getCodeSize();
-                res += inlinedBytes;
-            }
+        for (ResolvedJavaMethod e : inlinedMethods) {
+            res += e.getCodeSize();
         }
         return res;
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Thu Oct 22 12:56:40 2015 +0200
@@ -196,13 +196,6 @@
     private static StructuredGraph parseBytecodes(ResolvedJavaMethod method, HighTierContext context, CanonicalizerPhase canonicalizer, StructuredGraph caller) {
         StructuredGraph newGraph = new StructuredGraph(method, AllowAssumptions.from(caller.getAssumptions() != null));
         try (Debug.Scope s = Debug.scope("InlineGraph", newGraph)) {
-            if (!caller.isInlinedMethodRecordingEnabled()) {
-                // Don't record inlined methods in the callee if
-                // the caller doesn't want them. This decision is
-                // preserved in the graph cache (if used) which is
-                // ok since the graph cache is compilation local.
-                newGraph.disableInlinedMethodRecording();
-            }
             if (!caller.isUnsafeAccessTrackingEnabled()) {
                 newGraph.disableUnsafeAccessTracking();
             }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Oct 22 12:56:40 2015 +0200
@@ -598,8 +598,6 @@
             // to be valid for the entire run of the VM.
             final StructuredGraph graph = new StructuredGraph(methodToParse, AllowAssumptions.NO);
 
-            // They will also never evolve or have breakpoints set in them
-            graph.disableInlinedMethodRecording();
             // They are not user code so they do not participate in unsafe access tracking
             graph.disableUnsafeAccessTracking();
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Thu Oct 22 12:56:40 2015 +0200
@@ -655,9 +655,6 @@
         final StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method(), AllowAssumptions.NO);
 
         try (Debug.Scope scope = Debug.scope("SpecializeSnippet", snippetCopy)) {
-            if (!snippetGraph.isInlinedMethodRecordingEnabled()) {
-                snippetCopy.disableInlinedMethodRecording();
-            }
             if (!snippetGraph.isUnsafeAccessTrackingEnabled()) {
                 snippetCopy.disableUnsafeAccessTracking();
             }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java	Thu Oct 22 11:50:53 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java	Thu Oct 22 12:56:40 2015 +0200
@@ -192,12 +192,8 @@
 
         compilationNotify.notifyCompilationGraalTierFinished((OptimizedCallTarget) predefinedInstalledCode, graph);
 
-        if (graph.isInlinedMethodRecordingEnabled()) {
-            result.setMethods(graph.method(), graph.getInlinedMethods());
-            result.setBytecodeSize(graph.getBytecodeSize());
-        } else {
-            assert result.getMethods() == null;
-        }
+        result.setMethods(graph.method(), graph.getInlinedMethods());
+        result.setBytecodeSize(graph.getBytecodeSize());
 
         List<AssumptionValidAssumption> validAssumptions = new ArrayList<>();
         Set<Assumption> newAssumptions = new HashSet<>();
--- a/mx.graal/suite.py	Thu Oct 22 11:50:53 2015 +0200
+++ b/mx.graal/suite.py	Thu Oct 22 12:56:40 2015 +0200
@@ -6,7 +6,7 @@
     "suites": [
             {
                "name" : "jvmci",
-               "version" : "6b1cd334f3008aaf1823f511176d2b4f70e05847",
+               "version" : "15013021dbfa7c7cce4ff7fdbfabd5e118e0b0f6",
                "urls" : [
                     {"url" : "http://lafo.ssw.uni-linz.ac.at/hg/graal-jvmci-8", "kind" : "hg"},
                     {"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},