# HG changeset patch # User Christian Haeubl # Date 1328841347 28800 # Node ID 7d0d849abf80fda6cfbb70d27e3b87e0504ca8be # Parent bc14f8e7d5ed75cbeaf96780f06a3b699584826f added option to summarize debug values diff -r bc14f8e7d5ed -r 7d0d849abf80 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:03:44 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Thu Feb 09 18:35:47 2012 -0800 @@ -97,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 bc14f8e7d5ed -r 7d0d849abf80 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:03:44 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Thu Feb 09 18:35:47 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 bc14f8e7d5ed -r 7d0d849abf80 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:03:44 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java Thu Feb 09 18:35:47 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);