# HG changeset patch # User Doug Simon # Date 1394831150 -3600 # Node ID 12eaf1a47a90a62a83e530ab8a45d49c0154c497 # Parent 084603b0bfbb51dee3a756a41c22b0361b05b5c1 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata) diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java Fri Mar 14 22:05:50 2014 +0100 @@ -99,4 +99,12 @@ public void setMature() { // Do nothing } + + public boolean setCompilerIRSize(Class irType, int nodeCount) { + return false; + } + + public int getCompilerIRSize(Class irType) { + return -1; + } } diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java Fri Mar 14 22:05:50 2014 +0100 @@ -114,6 +114,25 @@ int getDeoptimizationCount(DeoptimizationReason reason); /** + * Records the size of the compiler intermediate representation (IR) associated with this + * method. + * + * @param irType the IR type for which the size is being recorded + * @param irSize the IR size to be recorded. The unit depends on the IR. + * @return whether recording this information for {@code irType} is supported + */ + boolean setCompilerIRSize(Class irType, int irSize); + + /** + * Gets the size of the compiler intermediate representation (IR) associated with this method + * last recorded by {@link #setCompilerIRSize(Class, int)}. + * + * @param irType the IR type for which the size is being requested + * @return the requested IR size or -1 if it is unavailable for {@code irType} + */ + int getCompilerIRSize(Class irType); + + /** * Returns true if the profiling information can be assumed as sufficiently accurate. * * @return true if the profiling information was recorded often enough mature enough, false @@ -124,6 +143,5 @@ /** * Force data to be treated as mature if possible. */ - void setMature(); } diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Fri Mar 14 22:05:50 2014 +0100 @@ -24,7 +24,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import java.util.*; /** * Represents a resolved Java method. Methods, like fields and types, are resolved through @@ -144,12 +143,6 @@ void reprofile(); /** - * Returns a map that the compiler can use to store objects that should survive the current - * compilation. - */ - Map getCompilerStorage(); - - /** * Returns the constant pool of this method. */ ConstantPool getConstantPool(); diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri Mar 14 22:05:50 2014 +0100 @@ -198,11 +198,6 @@ suites.getLowTier().apply(graph, lowTierContext); graph.maybeCompress(); - // we do not want to store statistics about OSR compilations because it may prevent inlining - if (!graph.isOSR()) { - InliningPhase.storeStatisticsAfterLowTier(graph); - } - SchedulePhase schedule = new SchedulePhase(); schedule.apply(graph); Debug.dump(schedule, "final schedule"); diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri Mar 14 22:05:50 2014 +0100 @@ -279,6 +279,10 @@ try (TimerCloseable b = CodeInstallationTime.start()) { installedCode = installMethod(result); + if (!isOSR) { + ProfilingInfo profile = method.getProfilingInfo(); + profile.setCompilerIRSize(StructuredGraph.class, graph.getNodeCount()); + } } stats.finish(method); } catch (BailoutException bailout) { diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Fri Mar 14 22:05:50 2014 +0100 @@ -1189,6 +1189,7 @@ @HotSpotVMField(name = "MethodData::_data_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataDataSize; @HotSpotVMField(name = "MethodData::_data[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset; @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset; + @HotSpotVMField(name = "MethodData::_graal_node_count", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataGraalNodeCountOffset; @HotSpotVMField(name = "nmethod::_verified_entry_point", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset; @HotSpotVMField(name = "nmethod::_comp_level", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodCompLevelOffset; diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Fri Mar 14 22:05:50 2014 +0100 @@ -825,4 +825,12 @@ super(runtime().getConfig().dataLayoutArgInfoDataTag, ARG_INFO_DATA_SIZE); } } + + public void setCompiledGraphSize(int nodeCount) { + unsafe.putInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset, nodeCount); + } + + public int getCompiledGraphSize() { + return unsafe.getInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset); + } } diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Fri Mar 14 22:05:50 2014 +0100 @@ -43,7 +43,12 @@ private static final long serialVersionUID = -1784683588947054103L; + /** + * This (indirect) Method* reference is safe since class redefinition preserves all methods + * associated with nmethods in the code cache. + */ private final HotSpotResolvedJavaMethod method; + private final boolean isDefault; private final boolean isExternal; private final String name; diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Fri Mar 14 22:05:50 2014 +0100 @@ -25,6 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.nodes.*; public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo { @@ -205,4 +206,21 @@ public void setMature() { isMature = true; } + + @Override + public boolean setCompilerIRSize(Class irType, int size) { + if (irType == StructuredGraph.class) { + methodData.setCompiledGraphSize(size); + return true; + } + return false; + } + + @Override + public int getCompilerIRSize(Class irType) { + if (irType == StructuredGraph.class) { + return methodData.getCompiledGraphSize(); + } + return -1; + } } diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Fri Mar 14 22:05:50 2014 +0100 @@ -28,8 +28,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -59,7 +57,6 @@ private boolean forceInline; private boolean dontInline; private boolean ignoredBySecurityStackWalk; - private Map compilerStorage; private HotSpotMethodData methodData; private byte[] code; private SpeculationLog speculationLog; @@ -433,14 +430,6 @@ } @Override - public Map getCompilerStorage() { - if (compilerStorage == null) { - compilerStorage = new ConcurrentHashMap<>(); - } - return compilerStorage; - } - - @Override public ConstantPool getConstantPool() { return constantPool; } diff -r 084603b0bfbb -r 12eaf1a47a90 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Mar 14 18:10:59 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Mar 14 22:05:50 2014 +0100 @@ -91,14 +91,6 @@ return inliningCount; } - public static void storeStatisticsAfterLowTier(StructuredGraph graph) { - ResolvedJavaMethod method = graph.method(); - if (method != null) { - CompiledMethodInfo info = compiledMethodInfo(graph.method()); - info.setLowLevelNodeCount(graph.getNodeCount()); - } - } - @Override protected void run(final StructuredGraph graph, final HighTierContext context) { final InliningData data = new InliningData(graph, context.getAssumptions()); @@ -310,15 +302,6 @@ return newGraph; } - private static synchronized CompiledMethodInfo compiledMethodInfo(ResolvedJavaMethod m) { - CompiledMethodInfo info = (CompiledMethodInfo) m.getCompilerStorage().get(CompiledMethodInfo.class); - if (info == null) { - info = new CompiledMethodInfo(); - m.getCompilerStorage().put(CompiledMethodInfo.class, info); - } - return info; - } - private abstract static class AbstractInliningPolicy implements InliningPolicy { protected final Map hints; @@ -371,7 +354,12 @@ protected static int previousLowLevelGraphSize(InlineInfo info) { int size = 0; for (int i = 0; i < info.numberOfMethods(); i++) { - size += compiledMethodInfo(info.methodAt(i)).lowLevelNodeCount(); + ResolvedJavaMethod m = info.methodAt(i); + ProfilingInfo profile = m.getProfilingInfo(); + int compiledGraphSize = profile.getCompilerIRSize(StructuredGraph.class); + if (compiledGraphSize > 0) { + size += compiledGraphSize; + } } return size; } @@ -864,21 +852,4 @@ return (graph != null ? MetaUtil.format("%H.%n(%p)", method()) : "") + remainingInvokes; } } - - private static class CompiledMethodInfo { - - private int lowLevelNodes; - - public CompiledMethodInfo() { - } - - public int lowLevelNodeCount() { - return lowLevelNodes; - } - - public void setLowLevelNodeCount(int lowLevelNodes) { - this.lowLevelNodes = lowLevelNodes; - } - - } } diff -r 084603b0bfbb -r 12eaf1a47a90 src/share/vm/graal/vmStructs_graal.hpp --- a/src/share/vm/graal/vmStructs_graal.hpp Fri Mar 14 18:10:59 2014 +0100 +++ b/src/share/vm/graal/vmStructs_graal.hpp Fri Mar 14 22:05:50 2014 +0100 @@ -32,6 +32,7 @@ #define VM_STRUCTS_GRAAL(nonstatic_field, static_field) \ nonstatic_field(ThreadShadow, _pending_deoptimization, int) \ nonstatic_field(ThreadShadow, _pending_failed_speculation, oop) \ + nonstatic_field(MethodData, _graal_node_count, int) \ #define VM_TYPES_GRAAL(declare_type, declare_toplevel_type) \ diff -r 084603b0bfbb -r 12eaf1a47a90 src/share/vm/oops/methodData.cpp --- a/src/share/vm/oops/methodData.cpp Fri Mar 14 18:10:59 2014 +0100 +++ b/src/share/vm/oops/methodData.cpp Fri Mar 14 22:05:50 2014 +0100 @@ -1216,6 +1216,9 @@ _highest_comp_level = 0; _highest_osr_comp_level = 0; _would_profile = true; +#ifdef GRAAL + _graal_node_count = 0; +#endif // Initialize flags and trap history. _nof_decompiles = 0; diff -r 084603b0bfbb -r 12eaf1a47a90 src/share/vm/oops/methodData.hpp --- a/src/share/vm/oops/methodData.hpp Fri Mar 14 18:10:59 2014 +0100 +++ b/src/share/vm/oops/methodData.hpp Fri Mar 14 22:05:50 2014 +0100 @@ -2203,6 +2203,11 @@ // Does this method contain anything worth profiling? bool _would_profile; +#ifdef GRAAL + // Support for HotSpotMethodData.setCompiledGraphSize(int) + int _graal_node_count; +#endif + // Size of _data array in bytes. (Excludes header and extra_data fields.) int _data_size;