# HG changeset patch # User Doug Simon # Date 1359043426 -3600 # Node ID a200d10867f1e0ae6c8752f48a126608879f4295 # Parent 68a59067974a13adaff99fbfb7d4f54c2dfe6da9# Parent 727e869891fcb951812030775237531c769390a9 Merge. diff -r 727e869891fc -r a200d10867f1 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java Thu Jan 24 10:37:43 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java Thu Jan 24 17:03:46 2013 +0100 @@ -22,24 +22,8 @@ */ package com.oracle.graal.debug.internal; -import java.util.*; -public abstract class DebugValue { - - public static final Comparator ORDER_BY_NAME = new Comparator() { - - @Override - public int compare(DebugValue o1, DebugValue o2) { - // this keeps the "Runs" metric at the top of the list - if (o1.getName().equals("Runs")) { - return o2.getName().equals("Runs") ? 0 : -1; - } - if (o2.getName().equals("Runs")) { - return o1.getName().equals("Runs") ? 0 : 1; - } - return o1.getName().compareTo(o2.getName()); - } - }; +public abstract class DebugValue implements Comparable { private String name; private int index; @@ -77,5 +61,9 @@ return name; } + public int compareTo(DebugValue o) { + return name.compareTo(o.name); + } + public abstract String toString(long value); } diff -r 727e869891fc -r a200d10867f1 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Thu Jan 24 10:37:43 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Thu Jan 24 17:03:46 2013 +0100 @@ -22,30 +22,33 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.graph.UnsafeAccess.*; +import static java.lang.Thread.*; + import java.io.*; import java.lang.annotation.*; +import java.lang.management.*; import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.meta.*; +import com.sun.management.ThreadMXBean; @SuppressWarnings("unused") public final class CompilationStatistics { private static final long RESOLUTION = 100000000; - private static final boolean TIMELINE_ENABLED = System.getProperty("stats.timeline.file") != null; - private static final boolean COMPILATIONSTATS_ENABLED = System.getProperty("stats.compilations.file") != null; - private static final boolean ENABLED = TIMELINE_ENABLED || COMPILATIONSTATS_ENABLED; + private static final boolean ENABLED = Boolean.getBoolean("graal.comp.stats"); - private static final CompilationStatistics DUMMY = new CompilationStatistics(null); + private static final CompilationStatistics DUMMY = new CompilationStatistics(null, false); private static ConcurrentLinkedDeque list = new ConcurrentLinkedDeque<>(); private static final ThreadLocal> current = new ThreadLocal>() { - @Override protected Deque initialValue() { return new ArrayDeque<>(); @@ -54,7 +57,7 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) - private static @interface AbsoluteTimeValue { + private static @interface NotReported { } @Retention(RetentionPolicy.RUNTIME) @@ -64,25 +67,40 @@ private static long zeroTime = System.nanoTime(); + private static long getThreadAllocatedBytes() { + ThreadMXBean thread = (ThreadMXBean) ManagementFactory.getThreadMXBean(); + return thread.getThreadAllocatedBytes(currentThread().getId()); + } + + @NotReported + private final long startTime; + @NotReported + private long threadAllocatedBytesStart; + @NotReported + private int startInvCount; + @NotReported + private int endInvCount; + + private int bytecodeCount; + private int codeSize; + @TimeValue + private long duration; + private long memoryUsed; + private final boolean osr; private final String holder; private final String name; private final String signature; - @AbsoluteTimeValue private final long startTime; - @TimeValue private long duration; - private int startInvCount; - private int endInvCount; - private int bytecodeCount; - private int codeSize; - private int deoptCount; - private CompilationStatistics(HotSpotResolvedJavaMethod method) { + private CompilationStatistics(HotSpotResolvedJavaMethod method, boolean osr) { + this.osr = osr; if (method != null) { - holder = MetaUtil.format("%H", method); + holder = method.getDeclaringClass().getName(); name = method.getName(); - signature = MetaUtil.format("%p", method); + signature = method.getSignature().getMethodDescriptor(); startTime = System.nanoTime(); startInvCount = method.invocationCount(); bytecodeCount = method.getCodeSize(); + threadAllocatedBytesStart = getThreadAllocatedBytes(); } else { holder = ""; name = ""; @@ -96,6 +114,7 @@ duration = System.nanoTime() - startTime; endInvCount = method.invocationCount(); codeSize = method.getCompiledCodeSize(); + memoryUsed = getThreadAllocatedBytes() - threadAllocatedBytesStart; if (current.get().getLast() != this) { throw new RuntimeException("mismatch in finish()"); } @@ -107,9 +126,9 @@ return current.get().isEmpty() ? null : current.get().getLast(); } - public static CompilationStatistics create(HotSpotResolvedJavaMethod method) { + public static CompilationStatistics create(HotSpotResolvedJavaMethod method, boolean isOSR) { if (ENABLED) { - CompilationStatistics stats = new CompilationStatistics(method); + CompilationStatistics stats = new CompilationStatistics(method, isOSR); list.add(stats); current.get().addLast(stats); return stats; @@ -131,42 +150,11 @@ zeroTime = System.nanoTime(); Date now = new Date(); - String dateString = (now.getYear() + 1900) + "_" + (now.getMonth() + 1) + "_" + now.getDate() + " " + now.getHours() + "_" + now.getMinutes() + "_" + now.getSeconds(); - try (PrintStream out = new PrintStream("compilations " + dateString + " " + dumpName + ".csv")) { - // output the list of all compilations + String dateString = (now.getYear() + 1900) + "-" + (now.getMonth() + 1) + "-" + now.getDate() + "-" + now.getHours() + "" + now.getMinutes(); - Field[] declaredFields = CompilationStatistics.class.getDeclaredFields(); - ArrayList fields = new ArrayList<>(); - for (Field field : declaredFields) { - if (!Modifier.isStatic(field.getModifiers())) { - fields.add(field); - } - } - for (Field field : fields) { - out.print(field.getName() + ";"); - } - out.println(); - for (CompilationStatistics stats : snapshot) { - for (Field field : fields) { - if (field.isAnnotationPresent(AbsoluteTimeValue.class)) { - double value = (field.getLong(stats) - snapshotZeroTime) / 1000000d; - out.print(String.format(Locale.ENGLISH, "%.3f", value) + ";"); - } else if (field.isAnnotationPresent(TimeValue.class)) { - double value = field.getLong(stats) / 1000000d; - out.print(String.format(Locale.ENGLISH, "%.3f", value) + ";"); - } else { - out.print(field.get(stats) + ";"); - } - } - out.println(); - } - } + dumpCompilations(snapshot, dumpName, dateString); - String timelineFile = System.getProperty("stats.timeline.file"); - if (timelineFile == null || timelineFile.isEmpty()) { - timelineFile = "timeline " + dateString; - } - try (FileOutputStream fos = new FileOutputStream(timelineFile + " " + dumpName + ".csv", true); PrintStream out = new PrintStream(fos)) { + try (FileOutputStream fos = new FileOutputStream("timeline_" + dateString + "_" + dumpName + ".csv", true); PrintStream out = new PrintStream(fos)) { long[] timeSpent = new long[10000]; int maxTick = 0; @@ -193,10 +181,10 @@ } String timelineName = System.getProperty("stats.timeline.name"); if (timelineName != null && !timelineName.isEmpty()) { - out.print(timelineName + ";"); + out.print(timelineName + "\t"); } for (int i = 0; i <= maxTick; i++) { - out.print((timeSpent[i] * 100 / RESOLUTION) + ";"); + out.print((timeSpent[i] * 100 / RESOLUTION) + "\t"); } out.println(); } @@ -205,7 +193,33 @@ } } - public void setDeoptCount(int count) { - this.deoptCount = count; + protected static void dumpCompilations(ConcurrentLinkedDeque snapshot, String dumpName, String dateString) throws IllegalAccessException, FileNotFoundException { + String fileName = "compilations_" + dateString + "_" + dumpName + ".csv"; + try (PrintStream out = new PrintStream(fileName)) { + // output the list of all compilations + + Field[] declaredFields = CompilationStatistics.class.getDeclaredFields(); + ArrayList fields = new ArrayList<>(); + for (Field field : declaredFields) { + if (!Modifier.isStatic(field.getModifiers()) && !field.isAnnotationPresent(NotReported.class)) { + fields.add(field); + } + } + for (Field field : fields) { + out.print(field.getName() + "\t"); + } + out.println(); + for (CompilationStatistics stats : snapshot) { + for (Field field : fields) { + if (field.isAnnotationPresent(TimeValue.class)) { + double value = field.getLong(stats) / 1000000d; + out.print(String.format(Locale.ENGLISH, "%.3f", value) + "\t"); + } else { + out.print(field.get(stats) + "\t"); + } + } + out.println(); + } + } } } diff -r 727e869891fc -r a200d10867f1 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 Thu Jan 24 10:37:43 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Jan 24 17:03:46 2013 +0100 @@ -113,7 +113,7 @@ } public void runCompilation() { - CompilationStatistics stats = CompilationStatistics.create(method); + CompilationStatistics stats = CompilationStatistics.create(method, entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI); try { final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); if (printCompilation) { diff -r 727e869891fc -r a200d10867f1 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 Thu Jan 24 10:37:43 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Jan 24 17:03:46 2013 +0100 @@ -281,7 +281,7 @@ List debugValues = KeyRegistry.getDebugValues(); if (debugValues.size() > 0) { ArrayList sortedValues = new ArrayList<>(debugValues); - Collections.sort(sortedValues, DebugValue.ORDER_BY_NAME); + Collections.sort(sortedValues); if (GraalOptions.SummarizeDebugValues) { printSummary(topLevelMaps, sortedValues); diff -r 727e869891fc -r a200d10867f1 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Thu Jan 24 10:37:43 2013 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Thu Jan 24 17:03:46 2013 +0100 @@ -50,7 +50,7 @@ public static final DebugMetric METRIC_MATERIALIZATIONS_UNHANDLED = Debug.metric("MaterializationsUnhandled"); public static final DebugMetric METRIC_MATERIALIZATIONS_LOOP_REITERATION = Debug.metric("MaterializationsLoopReiteration"); public static final DebugMetric METRIC_MATERIALIZATIONS_LOOP_END = Debug.metric("MaterializationsLoopEnd"); - public static final DebugMetric METRIC_ALLOCATION_REMOVED = Debug.metric("AllocationRemoved "); + public static final DebugMetric METRIC_ALLOCATION_REMOVED = Debug.metric("AllocationsRemoved"); private final NodeBitMap usages; private final SchedulePhase schedule; diff -r 727e869891fc -r a200d10867f1 mx/commands.py --- a/mx/commands.py Thu Jan 24 10:37:43 2013 +0100 +++ b/mx/commands.py Thu Jan 24 17:03:46 2013 +0100 @@ -574,6 +574,9 @@ # This removes the need to unzip the *.diz files before debugging in gdb env.setdefault('ZIP_DEBUGINFO_FILES', '0') + # We don't need to run the Queens test (i.e. test_gamma) + env.setdefault('TEST_IN_BUILD', 'false') + # Clear these 2 variables as having them set can cause very confusing build problems env.pop('LD_LIBRARY_PATH', None) env.pop('CLASSPATH', None)