# HG changeset patch # User Doug Simon # Date 1395096380 -3600 # Node ID e3888db8b8a166ddb008b63a3c523ac5e6579dd0 # Parent 1d35a2b84553e481f44a29e857a324a34e3139c7 Backed out changeset: 1d35a2b84553 diff -r 1d35a2b84553 -r e3888db8b8a1 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/AllocationScope.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/AllocationScope.java Mon Mar 17 23:45:14 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.test; - -import static com.oracle.graal.debug.internal.DebugHistogramAsciiPrinter.*; - -import java.io.*; -import java.util.*; - -import com.google.monitoring.runtime.instrumentation.*; -import com.oracle.graal.debug.DebugHistogram.CountedValue; -import com.oracle.graal.debug.internal.*; - -class AllocationScope implements AutoCloseable { - final Object context; - final AllocationScope parent; - final Map bytesPerType = new HashMap<>(); - final Map instancesPerType = new HashMap<>(); - - public AllocationScope(Object context) { - this.context = context; - parent = allocationCounter.get(); - allocationCounter.set(this); - } - - private static List sortedValues(Map map) { - ArrayList res = new ArrayList<>(map.values()); - Collections.sort(res); - return res; - } - - public void close() { - allocationCounter.set(parent); - PrintStream out = System.out; - out.println("\n\nAllocation histograms for " + context); - DebugHistogramAsciiPrinter printer = new DebugHistogramAsciiPrinter(out, 20, DefaultNameSize, DefaultBarSize); - printer.print(sortedValues(instancesPerType), "InstancesPerType"); - printer.print(sortedValues(bytesPerType), "BytesPerType"); - } - - public CountedValue instancesPerType(String desc) { - CountedValue count = instancesPerType.get(desc); - if (count == null) { - count = new CountedValue(0, desc); - instancesPerType.put(desc, count); - } - return count; - } - - public CountedValue bytesPerType(String desc) { - CountedValue count = bytesPerType.get(desc); - if (count == null) { - count = new CountedValue(0, desc); - bytesPerType.put(desc, count); - } - return count; - } - - static ThreadLocal allocationCounter = new ThreadLocal<>(); - - static class AllocationSampler implements Sampler { - - public void sampleAllocation(int count, String desc, Object newObj, long size) { - AllocationScope c = allocationCounter.get(); - if (c != null) { - String type; - if (count != -1) { - type = desc + "[]"; - } else { - type = desc; - } - - c.instancesPerType(type).inc(); - c.bytesPerType(type).add((int) size); - } - } - - } - - static { - AllocationRecorder.addSampler(new AllocationSampler()); - } -} diff -r 1d35a2b84553 -r e3888db8b8a1 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Mar 17 23:45:14 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Mar 17 23:46:20 2014 +0100 @@ -630,7 +630,7 @@ final int id = compilationId.incrementAndGet(); InstalledCode installedCode = null; - try (AllocationScope c = new AllocationScope(method); Scope ds = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) { + try (Scope ds = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) { final boolean printCompilation = PrintCompilation.getValue() && !TTY.isSuppressed(); if (printCompilation) { TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s ...", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature())); diff -r 1d35a2b84553 -r e3888db8b8a1 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugHistogram.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugHistogram.java Mon Mar 17 23:45:14 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugHistogram.java Mon Mar 17 23:46:20 2014 +0100 @@ -72,10 +72,6 @@ count++; } - public void add(int n) { - count += n; - } - public int getCount() { return count; } diff -r 1d35a2b84553 -r e3888db8b8a1 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java Mon Mar 17 23:45:14 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java Mon Mar 17 23:46:20 2014 +0100 @@ -60,12 +60,9 @@ } public void print(DebugHistogram histogram) { - print(histogram.getValues(), histogram.getName()); - } - - public void print(List list, String name) { + List list = histogram.getValues(); if (list.isEmpty()) { - os.printf("%s is empty.%n", name); + os.printf("%s is empty.%n", histogram.getName()); return; } @@ -76,7 +73,7 @@ } // Print header. - os.printf("%s has %d unique elements and %d total elements:%n", name, list.size(), total); + os.printf("%s has %d unique elements and %d total elements:%n", histogram.getName(), list.size(), total); int max = list.get(0).getCount(); final int lineSize = nameSize + NumberSize + barSize + 10; diff -r 1d35a2b84553 -r e3888db8b8a1 mx/projects --- a/mx/projects Mon Mar 17 23:45:14 2014 +0100 +++ b/mx/projects Mon Mar 17 23:46:20 2014 +0100 @@ -38,11 +38,6 @@ library@OKRA_WITH_SIM@sourcePath=lib/okra-1.8-with-sim-src.jar library@OKRA_WITH_SIM@sourceUrls=http://cr.openjdk.java.net/~tdeneau/okra-1.8-with-sim-src.jar -library@ALLOCATION_INSTRUMENTATION@path=lib/allocation.jar -library@ALLOCATION_INSTRUMENTATION@urls=http://java-allocation-instrumenter.googlecode.com/files/allocation.jar -library@ALLOCATION_INSTRUMENTATION@sourcePath=lib/allocation-src.jar -library@ALLOCATION_INSTRUMENTATION@sourceUrls=https://java-allocation-instrumenter.googlecode.com/files/java-allocation-instrumenter-src.jar - distribution@GRAAL@path=graal.jar distribution@GRAAL@dependencies=\ com.oracle.graal.hotspot.amd64,\ @@ -524,7 +519,7 @@ # graal.compiler.test project@com.oracle.graal.compiler.test@subDir=graal project@com.oracle.graal.compiler.test@sourceDirs=src -project@com.oracle.graal.compiler.test@dependencies=com.oracle.graal.test,com.oracle.graal.printer,com.oracle.graal.runtime,com.oracle.graal.baseline,ALLOCATION_INSTRUMENTATION +project@com.oracle.graal.compiler.test@dependencies=com.oracle.graal.test,com.oracle.graal.printer,com.oracle.graal.runtime,com.oracle.graal.baseline project@com.oracle.graal.compiler.test@checkstyle=com.oracle.graal.graph project@com.oracle.graal.compiler.test@javaCompliance=1.7 project@com.oracle.graal.compiler.test@workingSets=Graal,Test