# HG changeset patch # User Christian Haeubl # Date 1328841371 28800 # Node ID daba89671d29c0d28a1c356f55330ff723fc8c66 # Parent 7d0d849abf80fda6cfbb70d27e3b87e0504ca8be# Parent e065aa86d077252fb21861aaf0ea0cefcfc65428 Merge diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java Thu Feb 09 18:36:11 2012 -0800 @@ -24,9 +24,10 @@ /** - * Represents profiling information for one specific method. - * Every accessor method returns the information that is available at the time of its invocation. - * If a method is invoked multiple times, it may return a significantly different results for every invocation. + * Provides access to the profiling information of one specific method. + * Every accessor method returns the information that is available at the time of invocation. + * If a method is invoked multiple times, it may return significantly different results for every invocation + * as the profiling information may be changed by other Java threads at any time. */ public interface RiProfilingInfo { /** diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Thu Feb 09 18:36:11 2012 -0800 @@ -70,6 +70,11 @@ // absolute probability analysis public static boolean ProbabilityAnalysis = true; + // profiling information + public static int MatureExecutionsBranch = 50; + public static int MatureExecutionsPerSwitchCase = 15; + public static int MatureExecutionsTypeProfile = 100; + //rematerialize settings public static float MinimumUsageProbability = 0.95f; @@ -92,6 +97,7 @@ // Debug settings: public static boolean Debug = true; + public static boolean SummarizeDebugValues = ____; public static String Dump = null; public static String Meter = null; public static String Time = null; diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java Thu Feb 09 18:36:11 2012 -0800 @@ -51,8 +51,6 @@ HotSpotMethodData RiMethod_methodData(HotSpotMethodResolved method); - boolean HotSpotMethodData_isMature(HotSpotMethodData methodData); - RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve); Object RiConstantPool_lookupConstant(HotSpotTypeResolved pool, int cpi); diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java Thu Feb 09 18:36:11 2012 -0800 @@ -114,9 +114,6 @@ public native HotSpotMethodData RiMethod_methodData(HotSpotMethodResolved method); @Override - public native boolean HotSpotMethodData_isMature(HotSpotMethodData methodData); - - @Override public native RiType getType(Class javaClass); @Override diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Thu Feb 09 18:36:11 2012 -0800 @@ -194,17 +194,48 @@ List topLevelMaps = DebugValueMap.getTopLevelMaps(); List debugValues = KeyRegistry.getDebugValues(); if (debugValues.size() > 0) { - for (DebugValueMap map : topLevelMaps) { - TTY.println("Showing the results for thread: " + map.getName()); - map.group(); - map.normalize(); - printMap(map, debugValues, 0); + if (GraalOptions.SummarizeDebugValues) { + printSummary(topLevelMaps, debugValues); + } else { + for (DebugValueMap map : topLevelMaps) { + TTY.println("Showing the results for thread: " + map.getName()); + map.group(); + map.normalize(); + printMap(map, debugValues, 0); + } } } } } - private void printMap(DebugValueMap map, List debugValues, int level) { + private static void printSummary(List topLevelMaps, List debugValues) { + DebugValueMap result = new DebugValueMap("Summary"); + for (int i = debugValues.size() - 1; i >= 0; i--) { + DebugValue debugValue = debugValues.get(i); + int index = debugValue.getIndex(); + long total = collectTotal(topLevelMaps, index); + result.setCurrentValue(index, total); + } + printMap(result, debugValues, 0); + } + + private static long collectTotal(List maps, int index) { + long total = 0; + for (int i = 0; i < maps.size(); i++) { + DebugValueMap map = maps.get(i); + // the top level accumulates some counters -> do not process the children if we find a value + long value = map.getCurrentValue(index); + if (value == 0) { + total += collectTotal(map.getChildren(), index); + } else { + total += value; + } + } + return total; + } + + + private static void printMap(DebugValueMap map, List debugValues, int level) { printIndent(level); TTY.println(map.getName()); diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Thu Feb 09 18:36:11 2012 -0800 @@ -27,6 +27,7 @@ import sun.misc.*; import com.oracle.max.cri.ri.*; +import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.hotspot.*; import com.oracle.max.graal.hotspot.Compiler; @@ -57,7 +58,6 @@ private Object hotspotMirror; private int normalDataSize; private int extraDataSize; - private boolean mature; private HotSpotMethodData(Compiler compiler) { super(compiler); @@ -76,19 +76,6 @@ return normalDataSize; } - public boolean isMature() { - // TODO (ch) maturity of profiling information is an issue in general. Not all optimizations require mature data as long as the code - // does deoptimize/recompile on violations (might decrease startup and increase peak performance). - // Maturity is currently used on several levels: - // 1) whole method data - // 2) individual branch/switch profiling data - // 3) MatureInvocationCount for eliminating exception edges - if (!mature) { - mature = compiler.getVMEntries().HotSpotMethodData_isMature(this); - } - return mature; - } - public boolean isWithin(int position) { return position >= 0 && position < normalDataSize + extraDataSize; } @@ -104,7 +91,7 @@ } public HotSpotMethodDataAccessor getExtraData(int position) { - if (position >= extraDataSize) { + if (position >= normalDataSize + extraDataSize) { return null; } return getData(position); @@ -381,7 +368,7 @@ RiResolvedType[] types; double[] probabilities; - if (entries <= 0) { + if (entries <= 0 || totalCount < GraalOptions.MatureExecutionsTypeProfile) { return null; } else if (entries < sparseTypes.length) { types = Arrays.copyOf(sparseTypes, entries); @@ -459,7 +446,6 @@ private static final int BRANCH_DATA_TAG = 7; private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3); private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(2); - private static final int BRANCH_DATA_MATURE_COUNT = 40; public BranchData() { super(BRANCH_DATA_TAG, BRANCH_DATA_SIZE); @@ -471,7 +457,7 @@ long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET); long total = takenCount + notTakenCount; - if (total < BRANCH_DATA_MATURE_COUNT) { + if (total < GraalOptions.MatureExecutionsBranch) { return -1; } else { return takenCount / (double) total; @@ -536,7 +522,7 @@ result[i - 1] = count; } - if (totalCount < 10 * (length + 2)) { + if (totalCount < GraalOptions.MatureExecutionsPerSwitchCase * length) { return null; } else { for (int i = 0; i < length; i++) { diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Thu Feb 09 18:36:11 2012 -0800 @@ -203,7 +203,7 @@ methodData = compiler.getVMEntries().RiMethod_methodData(this); } - if (methodData == null || !methodData.isMature()) { + if (methodData == null) { return new HotSpotNoProfilingInfo(compiler); } else { return new HotSpotProfilingInfo(compiler, methodData); diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java Thu Feb 09 18:36:11 2012 -0800 @@ -26,13 +26,17 @@ import com.oracle.max.graal.hotspot.*; import com.oracle.max.graal.hotspot.Compiler; - +/** + * Dummy profiling information in case that a method was not executed frequently enough so that + * no profiling information does exist yet. + */ public final class HotSpotNoProfilingInfo extends CompilerObject implements RiProfilingInfo { /** * */ private static final long serialVersionUID = 4357945025049704109L; - private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataExceptionPossibleAccessor(); + // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in case of a deoptimization. + private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataNoExceptionAccessor(); public HotSpotNoProfilingInfo(Compiler compiler) { super(compiler); diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java Thu Feb 09 18:36:11 2012 -0800 @@ -23,6 +23,7 @@ package com.oracle.max.graal.hotspot.ri; import com.oracle.max.cri.ri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.hotspot.*; import com.oracle.max.graal.hotspot.Compiler; @@ -108,7 +109,10 @@ currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); } - exceptionPossiblyNotRecorded = !methodData.isWithin(currentPosition); + if (!methodData.isWithin(currentPosition)) { + exceptionPossiblyNotRecorded = true; + Debug.metric("InsufficientSpaceForProfilingData").increment(); + } } noDataFound(exceptionPossiblyNotRecorded); diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java --- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java Thu Feb 09 18:36:11 2012 -0800 @@ -363,12 +363,6 @@ private static boolean canTrap(int opcode, int bci, RiProfilingInfo profilingInfo) { switch (opcode) { - case INVOKESTATIC: - case INVOKESPECIAL: - case INVOKEVIRTUAL: - case INVOKEINTERFACE: { - return true; - } case IASTORE: case LASTORE: case FASTORE: @@ -388,7 +382,7 @@ case PUTFIELD: case GETFIELD: { if (GraalOptions.AllowExplicitExceptionChecks) { - return profilingInfo.getExceptionSeen(bci) == RiExceptionSeen.TRUE; + return profilingInfo.getExceptionSeen(bci) != RiExceptionSeen.FALSE; } } } diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Thu Feb 09 18:36:11 2012 -0800 @@ -324,7 +324,7 @@ if (GraalOptions.UseExceptionProbability) { // be conservative if information was not recorded (could result in endless recompiles otherwise) - if (bci != FrameState.BEFORE_BCI && exceptionObject == null && profilingInfo.getExceptionSeen(bci) != RiExceptionSeen.TRUE) { + if (bci != FrameState.BEFORE_BCI && exceptionObject == null && profilingInfo.getExceptionSeen(bci) == RiExceptionSeen.FALSE) { return null; } else { Debug.log("Creating exception edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, profilingInfo.getExceptionSeen(bci)); diff -r e065aa86d077 -r daba89671d29 graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java --- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java Thu Feb 09 17:37:53 2012 -0800 +++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java Thu Feb 09 18:36:11 2012 -0800 @@ -24,7 +24,7 @@ import static com.oracle.max.graal.graph.iterators.NodePredicates.*; -import org.junit.Test; +import org.junit.*; import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.debug.*; diff -r e065aa86d077 -r daba89671d29 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Thu Feb 09 17:37:53 2012 -0800 +++ b/src/share/vm/graal/graalCompiler.cpp Thu Feb 09 18:36:11 2012 -0800 @@ -291,7 +291,6 @@ HotSpotMethodData::set_hotspotMirror(obj, method_data()); HotSpotMethodData::set_normalDataSize(obj, method_data()->data_size()); HotSpotMethodData::set_extraDataSize(obj, method_data()->extra_data_size()); - HotSpotMethodData::set_mature(obj, method_data()->is_mature()); method_data->set_graal_mirror(obj()); return obj; diff -r e065aa86d077 -r daba89671d29 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Thu Feb 09 17:37:53 2012 -0800 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Thu Feb 09 18:36:11 2012 -0800 @@ -200,13 +200,6 @@ } } -JNIEXPORT jboolean JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_HotSpotMethodData_1isMature(JNIEnv *, jobject, jobject hotspot_method_data) { - TRACE_graal_3("CompilerToVM::HotSpotMethodData_isMature"); - VM_ENTRY_MARK; - methodDataHandle method_data = getMethodDataFromHotSpotMethodData(hotspot_method_data); - return method_data->is_mature(); -} - // ------------------------------------------------------------------ // Adjust a CounterData count to be commensurate with // interpreter_invocation_count. If the MDO exists for @@ -951,7 +944,6 @@ {CC"RiMethod_uniqueConcreteMethod", CC"("RESOLVED_METHOD")"METHOD, FN_PTR(RiMethod_1uniqueConcreteMethod)}, {CC"getRiMethod", CC"("REFLECT_METHOD")"METHOD, FN_PTR(getRiMethod)}, {CC"RiMethod_methodData", CC"("RESOLVED_METHOD")"METHOD_DATA, FN_PTR(RiMethod_1methodData)}, - {CC"HotSpotMethodData_isMature", CC"("METHOD_DATA")Z", FN_PTR(HotSpotMethodData_1isMature)}, {CC"RiMethod_invocationCount", CC"("RESOLVED_METHOD")I", FN_PTR(RiMethod_1invocationCount)}, {CC"RiMethod_hasCompiledCode", CC"("RESOLVED_METHOD")Z", FN_PTR(RiMethod_1hasCompiledCode)}, {CC"RiMethod_getCompiledCodeSize", CC"("RESOLVED_METHOD")I", FN_PTR(RiMethod_1getCompiledCodeSize)}, diff -r e065aa86d077 -r daba89671d29 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Thu Feb 09 17:37:53 2012 -0800 +++ b/src/share/vm/graal/graalJavaAccess.hpp Thu Feb 09 18:36:11 2012 -0800 @@ -75,7 +75,6 @@ oop_field(HotSpotMethodData, hotspotMirror, "Ljava/lang/Object;") \ int_field(HotSpotMethodData, normalDataSize) \ int_field(HotSpotMethodData, extraDataSize) \ - boolean_field(HotSpotMethodData, mature) \ end_class \ start_class(HotSpotType) \ oop_field(HotSpotType, name, "Ljava/lang/String;") \