Mercurial > hg > truffle
changeset 7252:73139223837c
Merge
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 17 Dec 2012 17:42:27 +0100 |
parents | c305a0315bea (current diff) b903c1099f41 (diff) |
children | c66968130037 |
files | |
diffstat | 4 files changed, 69 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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(); + } + } }
--- 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; }
--- 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)) {
--- 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