# HG changeset patch # User Lukas Stadler # Date 1355762547 -3600 # Node ID 73139223837c7ba8785b9f6372363d6d9acd22b0 # Parent c305a0315bea0e9a0ec17f6246051b96530c2881# Parent b903c1099f415efd2d0a9dde6e2c22f10b34dbc0 Merge diff -r c305a0315bea -r 73139223837c graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java Mon Dec 17 17:40:45 2012 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java Mon Dec 17 17:42:27 2012 +0100 @@ -22,9 +22,12 @@ */ package com.oracle.graal.debug.internal; +import java.lang.management.*; + import com.oracle.graal.debug.*; public final class TimerImpl extends DebugValue implements DebugTimer { + private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); public static final TimerCloseable VOID_CLOSEABLE = new TimerCloseable() { @Override @@ -41,20 +44,22 @@ @Override public TimerCloseable start() { if (Debug.isTimeEnabled()) { - final long startTime = System.nanoTime(); + long startTime; + if (threadMXBean.isCurrentThreadCpuTimeSupported()) { + startTime = threadMXBean.getCurrentThreadCpuTime(); + } else { + startTime = System.nanoTime(); + } if (valueToSubstract.get() == null) { valueToSubstract.set(0L); } - final long previousValueToSubstract = valueToSubstract.get(); - TimerCloseable result = new TimerCloseable() { - @Override - public void close() { - long timeSpan = System.nanoTime() - startTime; - long oldValueToSubstract = valueToSubstract.get(); - valueToSubstract.set(timeSpan + previousValueToSubstract); - TimerImpl.this.addToCurrentValue(timeSpan - oldValueToSubstract); - } - }; + long previousValueToSubstract = valueToSubstract.get(); + AbstractTimer result; + if (threadMXBean.isCurrentThreadCpuTimeSupported()) { + result = new CpuTimeTimer(startTime, previousValueToSubstract); + } else { + result = new SystemNanosTimer(startTime, previousValueToSubstract); + } valueToSubstract.set(0L); return result; } else { @@ -66,4 +71,46 @@ public String toString(long value) { return String.format("%d.%d ms", value / 1000000, (value / 100000) % 10); } + + private abstract class AbstractTimer implements TimerCloseable { + private final long startTime; + private final long previousValueToSubstract; + + private AbstractTimer(long startTime, long previousValueToSubstract) { + this.startTime = startTime; + this.previousValueToSubstract = previousValueToSubstract; + } + + @Override + public void close() { + long timeSpan = currentTime() - startTime; + long oldValueToSubstract = valueToSubstract.get(); + valueToSubstract.set(timeSpan + previousValueToSubstract); + TimerImpl.this.addToCurrentValue(timeSpan - oldValueToSubstract); + } + + protected abstract long currentTime(); + } + + private final class SystemNanosTimer extends AbstractTimer { + public SystemNanosTimer(long startTime, long previousValueToSubstract) { + super(startTime, previousValueToSubstract); + } + + @Override + protected long currentTime() { + return System.nanoTime(); + } + } + + private final class CpuTimeTimer extends AbstractTimer { + public CpuTimeTimer(long startTime, long previousValueToSubstract) { + super(startTime, previousValueToSubstract); + } + + @Override + protected long currentTime() { + return threadMXBean.getCurrentThreadCpuTime(); + } + } } diff -r c305a0315bea -r 73139223837c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Dec 17 17:40:45 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Dec 17 17:42:27 2012 +0100 @@ -339,13 +339,8 @@ 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; - } + total += map.getCurrentValue(index); + total += collectTotal(map.getChildren(), index); } return total; } diff -r c305a0315bea -r 73139223837c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java Mon Dec 17 17:40:45 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java Mon Dec 17 17:42:27 2012 +0100 @@ -82,6 +82,9 @@ assert predIndex != -1; deleteEnd(pred); for (PhiNode phi : phis().snapshot()) { + if (phi.isDeleted()) { + continue; + } ValueNode removedValue = phi.valueAt(predIndex); phi.removeInput(predIndex); if (removedValue != null && removedValue.isAlive() && removedValue.usages().isEmpty() && GraphUtil.isFloatingNode().apply(removedValue)) { diff -r c305a0315bea -r 73139223837c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Dec 17 17:40:45 2012 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Dec 17 17:42:27 2012 +0100 @@ -124,12 +124,12 @@ public static boolean PerThreadDebugValues = ____; public static boolean SummarizeDebugValues = ____; public static boolean SummarizePerPhase = ____; - public static String Dump = null; - public static String Meter = null; - public static String Time = null; - public static String Log = null; - public static String LogFile = null; - public static String MethodFilter = null; + public static String Dump = null; + public static String Meter = null; + public static String Time = null; + public static String Log = null; + public static String LogFile = null; + public static String MethodFilter = null; public static boolean DumpOnError = ____; // Ideal graph visualizer output settings