# HG changeset patch # User Lukas Stadler # Date 1307609318 -7200 # Node ID 35fb2fef44f156e4720758c5556946b6176d749a # Parent 81dab15b45e5c4f228f2870621d2fd0284fb1011# Parent 0017f484608ce1f5518fa0e20aa7d02d45ecd608 merge diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Thu Jun 09 10:48:38 2011 +0200 @@ -205,7 +205,7 @@ emitLIR(); targetMethod = emitCode(); - if (GraalOptions.PrintMetrics) { + if (GraalOptions.Meter) { GraalMetrics.BytecodesCompiled += method.code().length; } } catch (CiBailout b) { @@ -241,7 +241,7 @@ private void emitLIR() { if (GraalOptions.GenLIR) { - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LIR_CREATE.start(); } @@ -253,7 +253,7 @@ lirGenerator.doBlock(begin); } - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LIR_CREATE.stop(); } @@ -293,7 +293,7 @@ compiler.fireCompilationEvent(new CompilationEvent(this, "After code generation", graph, false, true, targetMethod)); } - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.CODE_CREATE.stop(); } return targetMethod; diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java Thu Jun 09 10:48:38 2011 +0200 @@ -24,6 +24,7 @@ import java.lang.reflect.*; import java.util.*; +import java.util.Map.*; import com.oracle.max.graal.compiler.debug.*; @@ -32,7 +33,7 @@ * This class contains a number of fields that collect metrics about compilation, particularly * the number of times certain optimizations are performed. */ -public class GraalMetrics { +public final class GraalMetrics { public static int CompiledMethods; public static int TargetMethods; public static int LocalValueNumberHits; @@ -67,6 +68,33 @@ public static void print() { printClassFields(GraalMetrics.class); + for (Entry m : map.entrySet()) { + printField(m.getKey(), m.getValue().value); + } + } + + private static LinkedHashMap map = new LinkedHashMap(); + + public static GraalMetrics get(String name) { + if (!map.containsKey(name)) { + map.put(name, new GraalMetrics(name)); + } + return map.get(name); + } + + private GraalMetrics(String name) { + this.name = name; + } + + private int value; + private String name; + + public void increment() { + increment(1); + } + + public void increment(int val) { + value += val; } public static void printClassFields(Class javaClass) { diff -r 81dab15b45e5 -r 35fb2fef44f1 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 Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Thu Jun 09 10:48:38 2011 +0200 @@ -39,7 +39,7 @@ // Checkstyle: resume // inlining settings - public static boolean Inline = ____; + public static boolean Inline = true; public static int MaximumInstructionCount = 37000; public static float MaximumInlineRatio = 0.90f; public static int MaximumInlineSize = 35; @@ -77,8 +77,8 @@ public static int PrintIdealGraphPort = 4444; // Other printing settings - public static boolean PrintMetrics = ____; - public static boolean PrintTimers = ____; + public static boolean Meter = ____; + public static boolean Time = ____; public static boolean PrintCompilation = ____; public static boolean PrintXirTemplates = ____; public static boolean PrintIRWithLIR = ____; diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java Thu Jun 09 10:48:38 2011 +0200 @@ -22,24 +22,25 @@ */ package com.oracle.max.graal.compiler; +import java.util.*; +import java.util.Map.*; + import com.oracle.max.graal.compiler.debug.*; /** * This class contains timers that record the amount of time spent in various * parts of the compiler. - * - * @author Christian Wimmer */ -public enum GraalTimers { - HIR_CREATE("Create HIR"), - HIR_OPTIMIZE("Optimize HIR"), - NCE("Nullcheck elimination"), - LIR_CREATE("Create LIR"), - LIFETIME_ANALYSIS("Lifetime Analysis"), - LINEAR_SCAN("Linear Scan"), - RESOLUTION("Resolution"), - DEBUG_INFO("Create Debug Info"), - CODE_CREATE("Create Code"); +public final class GraalTimers { + private static LinkedHashMap map = new LinkedHashMap(); + + public static final GraalTimers COMPUTE_LINEAR_SCAN_ORDER = get("Compute Linear Scan Order"); + public static final GraalTimers LIR_CREATE = get("Create LIR"); + public static final GraalTimers LIFETIME_ANALYSIS = get("Lifetime Analysis"); + public static final GraalTimers LINEAR_SCAN = get("Linear Scan"); + public static final GraalTimers RESOLUTION = get("Resolution"); + public static final GraalTimers DEBUG_INFO = get("Create Debug Info"); + public static final GraalTimers CODE_CREATE = get("Create Code"); private final String name; private long start; @@ -49,6 +50,14 @@ this.name = name; } + + public static GraalTimers get(String name) { + if (!map.containsKey(name)) { + map.put(name, new GraalTimers(name)); + } + return map.get(name); + } + public void start() { start = System.nanoTime(); } @@ -58,23 +67,24 @@ } public static void reset() { - for (GraalTimers t : values()) { - t.total = 0; + for (Entry e : map.entrySet()) { + e.getValue().total = 0; } } public static void print() { long total = 0; - for (GraalTimers timer : GraalTimers.values()) { - total += timer.total; + for (Entry e : map.entrySet()) { + total += e.getValue().total; } if (total == 0) { return; } TTY.println(); - for (GraalTimers timer : GraalTimers.values()) { - TTY.println("%-20s: %7.4f s (%5.2f%%)", timer.name, timer.total / 1000000000.0, timer.total * 100.0 / total); + for (Entry e : map.entrySet()) { + GraalTimers timer = e.getValue(); + TTY.println("%-30s: %7.4f s (%5.2f%%)", timer.name, timer.total / 1000000000.0, timer.total * 100.0 / total); timer.total = 0; } TTY.println(); diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Thu Jun 09 10:48:38 2011 +0200 @@ -2019,7 +2019,7 @@ } public void allocate() { - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LIFETIME_ANALYSIS.start(); } @@ -2033,7 +2033,7 @@ buildIntervals(); sortIntervalsBeforeAllocation(); - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LIFETIME_ANALYSIS.stop(); GraalTimers.LINEAR_SCAN.start(); } @@ -2042,14 +2042,14 @@ allocateRegisters(); - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LINEAR_SCAN.stop(); GraalTimers.RESOLUTION.start(); } resolveDataFlow(); - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.RESOLUTION.stop(); GraalTimers.DEBUG_INFO.start(); } @@ -2075,7 +2075,7 @@ verifyIntervals(); } - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.DEBUG_INFO.stop(); GraalTimers.CODE_CREATE.start(); } diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Thu Jun 09 10:48:38 2011 +0200 @@ -68,7 +68,7 @@ } } - if (GraalOptions.PrintMetrics) { + if (GraalOptions.Meter) { GraalMetrics.TargetMethods++; GraalMetrics.CodeBytesEmitted += targetMethod.targetCodeSize(); GraalMetrics.SafepointsEmitted += targetMethod.safepoints.size(); diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Thu Jun 09 10:48:38 2011 +0200 @@ -68,37 +68,31 @@ * Builds the graph, optimizes it, and computes the linear scan block order. */ public void build() { - if (GraalOptions.PrintTimers) { - GraalTimers.HIR_CREATE.start(); - } - - new GraphBuilderPhase(compilation, compilation.method, true).apply(compilation.graph); - verifyAndPrint("After graph building"); -// new DuplicationPhase().apply(compilation.graph); + new GraphBuilderPhase(compilation, compilation.method, false, false).apply(compilation.graph); + new DuplicationPhase().apply(compilation.graph); new DeadCodeEliminationPhase().apply(compilation.graph); - verifyAndPrint("After dead code elimination"); if (GraalOptions.Inline) { new InliningPhase(compilation, this, GraalOptions.TraceInlining).apply(compilation.graph); } - if (GraalOptions.PrintTimers) { - GraalTimers.HIR_CREATE.stop(); - GraalTimers.HIR_OPTIMIZE.start(); + if (GraalOptions.Time) { + GraalTimers.COMPUTE_LINEAR_SCAN_ORDER.start(); } Graph graph = compilation.graph; if (GraalOptions.OptCanonicalizer) { new CanonicalizerPhase().apply(graph); - new DeadCodeEliminationPhase().apply(compilation.graph); - verifyAndPrint("After Canonicalization"); + printGraph("After Canonicalization", graph); } new SplitCriticalEdgesPhase().apply(graph); Schedule schedule = new Schedule(); schedule.apply(graph); + + List blocks = schedule.getBlocks(); List lirBlocks = new ArrayList(); Map map = new HashMap(); @@ -143,10 +137,10 @@ b.setLinearScanNumber(z++); } - verifyAndPrint("After linear scan order"); + printGraph("After linear scan order", compilation.graph); - if (GraalOptions.PrintTimers) { - GraalTimers.HIR_OPTIMIZE.stop(); + if (GraalOptions.Time) { + GraalTimers.COMPUTE_LINEAR_SCAN_ORDER.stop(); } } @@ -158,16 +152,6 @@ return orderedBlocks; } - /** - * Verifies the IR and prints it out if the relevant options are set. - * @param phase the name of the phase for printing - */ - public void verifyAndPrint(String phase) { - if (compilation.compiler.isObserved()) { - compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, compilation.graph, true, false)); - } - } - public void printGraph(String phase, Graph graph) { if (compilation.compiler.isObserved()) { compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, phase, graph, true, false)); diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java Thu Jun 09 10:48:38 2011 +0200 @@ -108,7 +108,8 @@ * @param ir the IR to build the graph into * @param graph */ - public GraphBuilderPhase(GraalCompilation compilation, RiMethod method, boolean createUnwind) { + public GraphBuilderPhase(GraalCompilation compilation, RiMethod method, boolean createUnwind, boolean inline) { + super(inline ? "BuildInlineGraph" : "BuildGraph"); this.compilation = compilation; this.runtime = compilation.runtime; @@ -200,11 +201,7 @@ // remove FrameStates for (Node n : graph.getNodes()) { if (n instanceof FrameState) { - boolean delete = false; if (n.usages().size() == 0 && n.predecessors().size() == 0) { - delete = true; - } - if (delete) { n.delete(); } } diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Thu Jun 09 10:48:38 2011 +0200 @@ -109,10 +109,8 @@ methodCount.put(method, methodCount.get(method) + 1); } } - ir.verifyAndPrint("After inlining iteration"); DeadCodeEliminationPhase dce = new DeadCodeEliminationPhase(); dce.apply(graph); - ir.verifyAndPrint("After inlining iteration DCE"); if (inliningSize > GraalOptions.MaximumInstructionCount) { if (trace) { @@ -184,7 +182,7 @@ } CompilerGraph graph = new CompilerGraph(); - new GraphBuilderPhase(compilation, method, true).apply(graph); + new GraphBuilderPhase(compilation, method, true, true).apply(graph); boolean withReceiver = !Modifier.isStatic(method.accessFlags()); @@ -306,7 +304,7 @@ } if (trace) { - ir.verifyAndPrint("After inlining " + CiUtil.format("%H.%n(%p):%r", method, false)); + ir.printGraph("After inlining " + CiUtil.format("%H.%n(%p):%r", method, false), compilation.graph); } } } diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Thu Jun 09 10:48:38 2011 +0200 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, 2011, 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.max.graal.compiler.phases; + +import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.graph.Graph; + +public abstract class Phase { + + private final String name; + private static final ThreadLocal currentPhase = new ThreadLocal(); + + public Phase() { + this.name = this.getClass().getSimpleName(); + } + + public Phase(String name) { + this.name = name; + } + + public final void apply(Graph graph) { + assert graph != null; + + int startDeletedNodeCount = graph.getDeletedNodeCount(); + int startNodeCount = graph.getNodeCount(); + Phase oldCurrentPhase = null; + if (GraalOptions.Time) { + oldCurrentPhase = currentPhase.get(); + currentPhase.set(this); + if (oldCurrentPhase != null) { + GraalTimers.get(oldCurrentPhase.getName()).stop(); + } + GraalTimers.get(getName()).start(); + } + run(graph); + if (GraalOptions.Time) { + GraalTimers.get(getName()).stop(); + if (oldCurrentPhase != null) { + GraalTimers.get(oldCurrentPhase.getName()).start(); + } + currentPhase.set(oldCurrentPhase); + } + if (GraalOptions.Meter) { + int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount; + int createdNodeCount = graph.getNodeCount() - startNodeCount; + GraalMetrics.get(getName().concat(".executed")).increment(); + GraalMetrics.get(getName().concat(".deletedNodes")).increment(deletedNodeCount); + GraalMetrics.get(getName().concat(".createdNodes")).increment(createdNodeCount); + } + + // (Item|Graph|Phase|Value) + } + + public final String getName() { + return name; + } + + protected abstract void run(Graph graph); +} diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Schedule.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Schedule.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Schedule.java Thu Jun 09 10:48:38 2011 +0200 @@ -26,6 +26,7 @@ import com.oracle.max.graal.compiler.debug.*; import com.oracle.max.graal.compiler.ir.*; +import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.value.*; import com.oracle.max.graal.graph.*; import com.sun.cri.ci.*; diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Graph.java --- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Graph.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Graph.java Thu Jun 09 10:48:38 2011 +0200 @@ -55,6 +55,10 @@ return deletedNodeCount; } + public int getNodeCount() { + return nodes.size() - getDeletedNodeCount(); + } + public List getNodes() { return Collections.unmodifiableList(nodes); } diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Phase.java --- a/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Phase.java Wed Jun 08 17:50:16 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2011, 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.max.graal.graph; - -public abstract class Phase { - - private final String name; - - public Phase() { - this.name = this.getClass().getSimpleName(); - } - - public Phase(String name) { - this.name = name; - } - - public final void apply(Graph graph) { - assert graph != null; - run(graph); - } - - public final String getName() { - return name; - } - - protected abstract void run(Graph graph); -} diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/CompilerImpl.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/CompilerImpl.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/CompilerImpl.java Thu Jun 09 10:48:38 2011 +0200 @@ -23,7 +23,6 @@ package com.oracle.max.graal.runtime; import java.io.*; -import java.lang.management.*; import java.net.*; import com.oracle.max.asm.target.amd64.*; @@ -40,7 +39,6 @@ public final class CompilerImpl implements Compiler, Remote { private static Compiler theInstance; - private static boolean PrintGCStats = false; public static Compiler getInstance() { return theInstance; @@ -71,54 +69,15 @@ } else { // ordinary local compilation theInstance = new CompilerImpl(null); - Runtime.getRuntime().addShutdownHook(new ShutdownThread()); } } public static Compiler initializeServer(VMEntries entries) { assert theInstance == null; theInstance = new CompilerImpl(entries); - Runtime.getRuntime().addShutdownHook(new ShutdownThread()); return theInstance; } - public static class ShutdownThread extends Thread { - - @Override - public void run() { - VMExitsNative.compileMethods = false; - if (GraalOptions.PrintMetrics) { - GraalMetrics.print(); - } - if (GraalOptions.PrintTimers) { - GraalTimers.print(); - } - if (PrintGCStats) { - printGCStats(); - } - } - } - - public static void printGCStats() { - long totalGarbageCollections = 0; - long garbageCollectionTime = 0; - - for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) { - long count = gc.getCollectionCount(); - if (count >= 0) { - totalGarbageCollections += count; - } - - long time = gc.getCollectionTime(); - if (time >= 0) { - garbageCollectionTime += time; - } - } - - System.out.println("Total Garbage Collections: " + totalGarbageCollections); - System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime); - } - private final VMEntries vmEntries; private final VMExits vmExits; private GraalCompiler compiler; diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotOptions.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotOptions.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotOptions.java Thu Jun 09 10:48:38 2011 +0200 @@ -52,10 +52,12 @@ } else { int index = option.indexOf('='); if (index == -1) { - return false; + fieldName = option; + valueString = null; + } else { + fieldName = option.substring(0, index); + valueString = option.substring(index + 1); } - fieldName = option.substring(0, index); - valueString = option.substring(index + 1); } Field f; @@ -70,7 +72,11 @@ } else if (f.getType() == Integer.TYPE) { value = Integer.parseInt(valueString); } else if (f.getType() == Boolean.TYPE) { - value = Boolean.parseBoolean(valueString); + if (valueString == null || valueString.length() == 0) { + value = true; + } else { + value = Boolean.parseBoolean(valueString); + } } else if (f.getType() == String.class) { value = valueString; } diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExits.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExits.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExits.java Thu Jun 09 10:48:38 2011 +0200 @@ -57,4 +57,6 @@ CiConstant createCiConstantObject(Object object); + void shutdownCompiler(); + } diff -r 81dab15b45e5 -r 35fb2fef44f1 graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java --- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java Wed Jun 08 17:50:16 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java Thu Jun 09 10:48:38 2011 +0200 @@ -24,6 +24,7 @@ package com.oracle.max.graal.runtime; import java.io.*; +import java.lang.management.*; import java.util.*; import com.oracle.max.graal.compiler.*; @@ -40,6 +41,7 @@ public static final boolean LogCompiledMethods = false; public static boolean compileMethods = true; + private static boolean PrintGCStats = false; private final Compiler compiler; @@ -69,6 +71,41 @@ private static Set compiledMethods = new HashSet(); + public void shutdownCompiler() { + compileMethods = false; + + if (GraalOptions.Meter) { + GraalMetrics.print(); + } + if (GraalOptions.Time) { + GraalTimers.print(); + } + if (PrintGCStats) { + printGCStats(); + } + } + + + public static void printGCStats() { + long totalGarbageCollections = 0; + long garbageCollectionTime = 0; + + for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) { + long count = gc.getCollectionCount(); + if (count >= 0) { + totalGarbageCollections += count; + } + + long time = gc.getCollectionTime(); + if (time >= 0) { + garbageCollectionTime += time; + } + } + + System.out.println("Total Garbage Collections: " + totalGarbageCollections); + System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime); + } + @Override public void compileMethod(long methodVmId, String name, int entryBCI) throws Throwable { if (!compileMethods) { diff -r 81dab15b45e5 -r 35fb2fef44f1 runbootstrap.sh --- a/runbootstrap.sh Wed Jun 08 17:50:16 2011 +0200 +++ b/runbootstrap.sh Thu Jun 09 10:48:38 2011 +0200 @@ -3,10 +3,6 @@ echo "JDK7 is not defined." exit 1; fi -if [ -z "${JDK7G}" ]; then - echo "JDK7G is not defined." - exit 1; -fi if [ -z "${MAXINE}" ]; then echo "MAXINE is not defined. It must point to a maxine repository directory." exit 1; @@ -15,5 +11,4 @@ echo "GRAAL is not defined. It must point to a maxine repository directory." exit 1; fi -${JDK7}/bin/java -client -d64 -graal -version -${JDK7G}/bin/java -client -d64 -graal -version +${JDK7}/bin/java -client -d64 -graal $* -version diff -r 81dab15b45e5 -r 35fb2fef44f1 runfop.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/runfop.sh Thu Jun 09 10:48:38 2011 +0200 @@ -0,0 +1,18 @@ +#!/bin/bash +if [ -z "${JDK7}" ]; then + echo "JDK7 is not defined." + exit 1; +fi +if [ -z "${MAXINE}" ]; then + echo "MAXINE is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${GRAAL}" ]; then + echo "GRAAL is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${DACAPO}" ]; then + echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." + exit 1; +fi +${JDK7}/bin/java -client -d64 -graal -XX:-GraalBailoutIsFatal -XX:+PrintCompilation -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar $* Harness --preserve fop diff -r 81dab15b45e5 -r 35fb2fef44f1 runscimark.sh --- a/runscimark.sh Wed Jun 08 17:50:16 2011 +0200 +++ b/runscimark.sh Thu Jun 09 10:48:38 2011 +0200 @@ -23,5 +23,5 @@ for (( i = 1; i <= ${COUNT}; i++ )) ### Outer for loop ### do echo "$i " - ${JDK7}/jre/bin/java -client -d64 -graal -esa -ea -Xms32m -Xmx100m -Xbootclasspath/a:${SCIMARK} -C1X:+PrintTimers $@ jnt.scimark2.commandline + ${JDK7}/jre/bin/java -client -d64 -graal -esa -ea -Xms32m -Xmx100m -Xbootclasspath/a:${SCIMARK} -G:+Time $@ jnt.scimark2.commandline done diff -r 81dab15b45e5 -r 35fb2fef44f1 runtests.sh diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/c1/c1_Runtime1.cpp --- a/src/share/vm/c1/c1_Runtime1.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/c1/c1_Runtime1.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -661,7 +661,7 @@ JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock)) NOT_PRODUCT(_monitorenter_slowcase_cnt++;) #ifdef ASSERT - if (Tracegraal >= 3) { + if (TraceGraal >= 3) { tty->print_cr("entered locking slow case with obj=" INTPTR_FORMAT " and lock= " INTPTR_FORMAT, obj, lock); } if (PrintBiasedLockingStatistics) { @@ -689,7 +689,7 @@ } } #ifdef ASSERT - if (Tracegraal >= 3) { + if (TraceGraal >= 3) { tty->print_cr("exiting locking lock state: obj=" INTPTR_FORMAT, lock->obj()); lock->lock()->print_on(tty); tty->print_cr(""); diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/c1/c1_globals.hpp --- a/src/share/vm/c1/c1_globals.hpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/c1/c1_globals.hpp Thu Jun 09 10:48:38 2011 +0200 @@ -57,9 +57,9 @@ "Use graal instead of C1") \ product(bool, GraalBailoutIsFatal, true, \ "Abort the VM on graal bailout") \ - product(bool, Bootstrapgraal, false, \ + product(bool, BootstrapGraal, false, \ "Bootstrap graal before running Java main method") \ - product(intx, Tracegraal, 0, \ + product(intx, TraceGraal, 0, \ "Trace level for graal") \ product(bool, TraceSignals, false, \ "Trace signals and implicit exception handling") \ diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Thu Jun 09 10:48:38 2011 +0200 @@ -296,6 +296,7 @@ template(com_sun_cri_ci_CiConstant, "com/sun/cri/ci/CiConstant") \ template(com_sun_cri_ci_CiKind, "com/sun/cri/ci/CiKind") \ template(com_sun_cri_ci_CiRuntimeCall, "com/sun/cri/ci/CiRuntimeCall") \ + template(shutdownCompiler_name, "shutdownCompiler") \ template(compileMethod_name, "compileMethod") \ template(compileMethod_signature, "(JLjava/lang/String;I)V") \ template(setOption_name, "setOption") \ diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -660,7 +660,7 @@ if (current->is_Compiler_thread()) { CompilerThread* comp_thread = current->as_CompilerThread(); if (comp_thread->is_compiling()) { - if (Tracegraal >= 4) { + if (TraceGraal >= 4) { tty->print_cr("Compile queue empty, but following thread is still compiling:"); comp_thread->print(); } @@ -673,7 +673,7 @@ break; } } - if (Tracegraal >= 5) { + if (TraceGraal >= 5) { _c1_method_queue->print(); } } diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -411,7 +411,7 @@ reexecute = Interpreter::bytecode_should_reexecute(code); } - if (Tracegraal >= 2) { + if (TraceGraal >= 2) { tty->print_cr("Recording scope pc_offset=%d bci=%d frame=%d", pc_offset, bci, frame); } @@ -427,7 +427,7 @@ GrowableArray* expressions = new GrowableArray (); GrowableArray* monitors = new GrowableArray (); - if (Tracegraal >= 2) { + if (TraceGraal >= 2) { tty->print_cr("Scope at bci %d with %d values", bci, values->length()); tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); } diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -119,6 +119,10 @@ TRACE_graal_2("GraalCompiler::compile_method exit"); } +void GraalCompiler::exit() { + VMExits::shutdownCompiler(); +} + // Print compilation timers and statistics void GraalCompiler::print_timers() { TRACE_graal_1("GraalCompiler::print_timers"); diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.hpp Thu Jun 09 10:48:38 2011 +0200 @@ -62,6 +62,8 @@ static oop createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS); + void exit(); + static BasicType kindToBasicType(jchar ch); static int to_cp_index_u2(int index) { @@ -79,19 +81,19 @@ // Tracing macros -#define IF_TRACE_graal_1 if (!(Tracegraal >= 1)) ; else -#define IF_TRACE_graal_2 if (!(Tracegraal >= 2)) ; else -#define IF_TRACE_graal_3 if (!(Tracegraal >= 3)) ; else -#define IF_TRACE_graal_4 if (!(Tracegraal >= 4)) ; else -#define IF_TRACE_graal_5 if (!(Tracegraal >= 5)) ; else +#define IF_TRACE_graal_1 if (!(TraceGraal >= 1)) ; else +#define IF_TRACE_graal_2 if (!(TraceGraal >= 2)) ; else +#define IF_TRACE_graal_3 if (!(TraceGraal >= 3)) ; else +#define IF_TRACE_graal_4 if (!(TraceGraal >= 4)) ; else +#define IF_TRACE_graal_5 if (!(TraceGraal >= 5)) ; else // using commas and else to keep one-instruction semantics -#define TRACE_graal_1 if (!(Tracegraal >= 1 && (tty->print("Tracegraal-1: "), true))) ; else tty->print_cr -#define TRACE_graal_2 if (!(Tracegraal >= 2 && (tty->print(" Tracegraal-2: "), true))) ; else tty->print_cr -#define TRACE_graal_3 if (!(Tracegraal >= 3 && (tty->print(" Tracegraal-3: "), true))) ; else tty->print_cr -#define TRACE_graal_4 if (!(Tracegraal >= 4 && (tty->print(" Tracegraal-4: "), true))) ; else tty->print_cr -#define TRACE_graal_5 if (!(Tracegraal >= 5 && (tty->print(" Tracegraal-5: "), true))) ; else tty->print_cr +#define TRACE_graal_1 if (!(TraceGraal >= 1 && (tty->print("TraceGraal-1: "), true))) ; else tty->print_cr +#define TRACE_graal_2 if (!(TraceGraal >= 2 && (tty->print(" TraceGraal-2: "), true))) ; else tty->print_cr +#define TRACE_graal_3 if (!(TraceGraal >= 3 && (tty->print(" TraceGraal-3: "), true))) ; else tty->print_cr +#define TRACE_graal_4 if (!(TraceGraal >= 4 && (tty->print(" TraceGraal-4: "), true))) ; else tty->print_cr +#define TRACE_graal_5 if (!(TraceGraal >= 5 && (tty->print(" TraceGraal-5: "), true))) ; else tty->print_cr diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/graal/graalVMEntries.cpp --- a/src/share/vm/graal/graalVMEntries.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/graal/graalVMEntries.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -383,7 +383,7 @@ Symbol* signature_symbol = VmIds::toSymbol(signature); methodOop method = klass->klass_part()->lookup_method(name_symbol, signature_symbol); if (method == NULL) { - if (Tracegraal >= 3) { + if (TraceGraal >= 3) { ResourceMark rm; tty->print_cr("Could not resolve method %s %s on klass %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), klass->klass_part()->name()->as_C_string()); } diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/graal/graalVMExits.cpp --- a/src/share/vm/graal/graalVMExits.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/graal/graalVMExits.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -110,6 +110,17 @@ check_pending_exception("Error while calling compileMethod"); } +void VMExits::shutdownCompiler() { + assert(!name.is_null(), "just checking"); + JavaThread* THREAD = JavaThread::current(); + JavaValue result(T_VOID); + JavaCallArguments args; + args.push_oop(instance()); + JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::shutdownCompiler_name(), vmSymbols::void_method_signature(), &args, THREAD); + check_pending_exception("Error while calling shutdownCompiler"); +} + + oop VMExits::createRiMethodResolved(jlong vmId, Handle name, TRAPS) { assert(!name.is_null(), "just checking"); JavaValue result(T_OBJECT); diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/graal/graalVMExits.hpp --- a/src/share/vm/graal/graalVMExits.hpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/graal/graalVMExits.hpp Thu Jun 09 10:48:38 2011 +0200 @@ -53,6 +53,9 @@ // public abstract void compileMethod(long vmId, String name, int entry_bci); static void compileMethod(jlong vmId, Handle name, int entry_bci); + // public abstract void shutdownCompiler(); + static void shutdownCompiler(); + // public abstract RiMethod createRiMethodResolved(long vmId, String name); static oop createRiMethodResolved(jlong vmId, Handle name, TRAPS); diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/prims/jni.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -3345,7 +3345,7 @@ JvmtiExport::post_thread_start(thread); } - if (Bootstrapgraal) { + if (BootstrapGraal) { CompileBroker::bootstrap_graal(); } diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/runtime/arguments.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -2669,7 +2669,7 @@ tty->print("Running Graal VM... "); } UseGraal = true; - Bootstrapgraal = true; + BootstrapGraal = true; const int BUFFER_SIZE = 1024; char maxine_dir[BUFFER_SIZE]; char graal_dir[BUFFER_SIZE]; @@ -2699,7 +2699,7 @@ sprintf(temp, "%s/graal/com.oracle.max.graal.graphviz/bin", graal_dir); scp_p->add_prefix(temp); *scp_assembly_required_p = true; - } else if (match_option(option, "-G:", &tail)) { // -graal:xxxx + } else if (match_option(option, "-G:", &tail)) { // -G:XXX // Option for the graal compiler. if (PrintVMOptions) { tty->print_cr("graal option %s", tail); diff -r 81dab15b45e5 -r 35fb2fef44f1 src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Wed Jun 08 17:50:16 2011 +0200 +++ b/src/share/vm/runtime/thread.cpp Thu Jun 09 10:48:38 2011 +0200 @@ -29,6 +29,7 @@ #include "classfile/vmSymbols.hpp" #include "code/scopeDesc.hpp" #include "compiler/compileBroker.hpp" +#include "graal/graalCompiler.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" #include "jvmtifiles/jvmtiEnv.hpp" @@ -3659,6 +3660,9 @@ thread->invoke_shutdown_hooks(); } + if (UseGraal) { + GraalCompiler::instance()->exit(); + } before_exit(thread); thread->exit(true);