# HG changeset patch # User Thomas Wuerthinger # Date 1307545276 -7200 # Node ID d577d07cedec65efc099ee95f25b422a22186866 # Parent be276884eec04d87c127ce67df47125dbb53561a Added time measurement for phases. diff -r be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java Wed Jun 08 17:01:16 2011 +0200 @@ -237,7 +237,7 @@ private void emitLIR() { if (GraalOptions.GenLIR) { - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LIR_CREATE.start(); } @@ -249,7 +249,7 @@ lirGenerator.doBlock(begin); } - if (GraalOptions.PrintTimers) { + if (GraalOptions.Time) { GraalTimers.LIR_CREATE.stop(); } @@ -289,7 +289,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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Wed Jun 08 17:01:16 2011 +0200 @@ -78,7 +78,7 @@ // Other printing settings public static boolean PrintMetrics = ____; - public static boolean PrintTimers = ____; + public static boolean Time = ____; public static boolean PrintCompilation = ____; public static boolean PrintXirTemplates = ____; public static boolean PrintIRWithLIR = ____; diff -r be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalTimers.java Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Wed Jun 08 17:01:16 2011 +0200 @@ -68,10 +68,6 @@ * 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, false).apply(compilation.graph); new DuplicationPhase().apply(compilation.graph); new DeadCodeEliminationPhase().apply(compilation.graph); @@ -80,9 +76,8 @@ new InliningPhase(compilation, this).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; @@ -95,6 +90,8 @@ Schedule schedule = new Schedule(); schedule.apply(graph); + + List blocks = schedule.getBlocks(); List lirBlocks = new ArrayList(); Map map = new HashMap(); @@ -139,10 +136,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(); } } @@ -154,16 +151,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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Wed Jun 08 17:01:16 2011 +0200 @@ -100,7 +100,6 @@ } DeadCodeEliminationPhase dce = new DeadCodeEliminationPhase(); dce.apply(graph); - ir.verifyAndPrint("After inlining iteration"); if (inliningSize > GraalOptions.MaximumInstructionCount) { if (GraalOptions.TraceInlining) { @@ -276,7 +275,7 @@ } if (GraalOptions.TraceInlining) { - 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 be276884eec0 -r d577d07cedec 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 Wed Jun 08 17:01:16 2011 +0200 @@ -0,0 +1,63 @@ +/* + * 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; + + 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(); + if (GraalOptions.Time) { + GraalTimers.get(getName()).start(); + } + run(graph); + if (GraalOptions.Time) { + GraalTimers.get(getName()).stop(); + } + int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount; + int nodeCount = graph.getNodeCount() - startNodeCount; + + // (Item|Graph|Phase|Value) + } + + public final String getName() { + return name; + } + + protected abstract void run(Graph graph); +} diff -r be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/Schedule.java Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Graph.java Wed Jun 08 17:01:16 2011 +0200 @@ -54,6 +54,10 @@ return deletedNodeCount; } + public int getNodeCount() { + return nodes.size() - getDeletedNodeCount(); + } + public List getNodes() { return Collections.unmodifiableList(nodes); } diff -r be276884eec0 -r d577d07cedec 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 14:50:55 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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/CompilerImpl.java Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExits.java Wed Jun 08 17:01:16 2011 +0200 @@ -57,4 +57,6 @@ CiConstant createCiConstantObject(Object object); + void shutdownCompiler(); + } diff -r be276884eec0 -r d577d07cedec 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 14:50:55 2011 +0200 +++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java Wed Jun 08 17:01:16 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.PrintMetrics) { + 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 be276884eec0 -r d577d07cedec runbootstrap.sh --- a/runbootstrap.sh Wed Jun 08 14:50:55 2011 +0200 +++ b/runbootstrap.sh Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec runtests.sh --- a/runtests.sh Wed Jun 08 14:50:55 2011 +0200 +++ b/runtests.sh Wed Jun 08 17:01:16 2011 +0200 @@ -12,4 +12,4 @@ exit 1; fi TESTDIR=${MAXINE}/com.oracle.max.vm/test -${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp -XX:+PrintCompilation -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $1 test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads +${JDK7}/bin/java -client -d64 -graal -ea -esa -Xcomp $* -XX:+PrintCompilation -XX:CompileOnly=jtt -Xbootclasspath/p:"${MAXINE}/com.oracle.max.vm/bin" -Xbootclasspath/p:"${MAXINE}/com.oracle.max.base/bin" $1 test.com.sun.max.vm.compiler.JavaTester -verbose=1 -gen-run-scheme=false -run-scheme-package=all ${TESTDIR}/jtt/bytecode ${TESTDIR}/jtt/except ${TESTDIR}/jtt/hotpath ${TESTDIR}/jtt/jdk ${TESTDIR}/jtt/lang ${TESTDIR}/jtt/loop ${TESTDIR}/jtt/micro ${TESTDIR}/jtt/optimize ${TESTDIR}/jtt/reflect ${TESTDIR}/jtt/threads diff -r be276884eec0 -r d577d07cedec src/share/vm/c1/c1_Runtime1.cpp --- a/src/share/vm/c1/c1_Runtime1.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/c1/c1_Runtime1.cpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/c1/c1_globals.hpp --- a/src/share/vm/c1/c1_globals.hpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/c1/c1_globals.hpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.hpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/graal/graalVMEntries.cpp --- a/src/share/vm/graal/graalVMEntries.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/graal/graalVMEntries.cpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/graal/graalVMExits.cpp --- a/src/share/vm/graal/graalVMExits.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/graal/graalVMExits.cpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/graal/graalVMExits.hpp --- a/src/share/vm/graal/graalVMExits.hpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/graal/graalVMExits.hpp Wed Jun 08 17:01:16 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 be276884eec0 -r d577d07cedec src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/prims/jni.cpp Wed Jun 08 17:01:16 2011 +0200 @@ -3345,7 +3345,7 @@ JvmtiExport::post_thread_start(thread); } - if (Bootstrapgraal) { + if (BootstrapGraal) { CompileBroker::bootstrap_graal(); } diff -r be276884eec0 -r d577d07cedec src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/runtime/arguments.cpp Wed Jun 08 17:01:16 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]; diff -r be276884eec0 -r d577d07cedec src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/vm/runtime/thread.cpp Wed Jun 08 17:01:16 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);