Mercurial > hg > graal-jvmci-8
changeset 4350:685cbfb8e08e
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 13 Jan 2012 18:46:56 +0100 |
parents | 7e974a026889 (diff) 62cb0e636094 (current diff) |
children | 279a43776f42 |
files | graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiCompiler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/stub/CompilerStub.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompilerStubEmitter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java mx/org.eclipse.jdt.core.prefs mx/org.eclipse.jdt.ui.prefs mx/projects src/share/vm/graal/graal_paths.hpp src/share/vm/runtime/arguments.cpp |
diffstat | 21 files changed, 320 insertions(+), 456 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiResult.java Thu Jan 12 13:48:27 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2009, 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.cri.ci; - -/** - * Represents the result of compiling a method. The result can include a target method with machine code and metadata, - * and/or statistics. If the compiler bailed out due to malformed bytecode, an internal error, or other cause, it will - * supply the bailout object. - */ -public class CiResult { - private final CiTargetMethod targetMethod; - private final CiBailout bailout; - - /** - * Creates a new compilation result. - * @param targetMethod the method that was produced, if any - * @param bailout the bailout condition that occurred - * @param stats statistics about the compilation - */ - public CiResult(CiTargetMethod targetMethod, CiBailout bailout) { - this.targetMethod = targetMethod; - this.bailout = bailout; - } - - /** - * Gets the target method that was produced by this compilation. If no target method was - * produced, but a bailout occured, then the bailout exception will be thrown at this point. - * @return the target method produced - * @throws {@link CiBailout} if a bailout occurred - */ - public CiTargetMethod targetMethod() { - if (bailout != null) { - throw bailout; - } - return targetMethod; - } - - /** - * Returns the bailout condition that occurred for this compilation, if any. - * @return the bailout - */ - public CiBailout bailout() { - return bailout; - } -}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Fri Jan 13 18:46:56 2012 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.max.graal.compiler; +import static com.oracle.max.graal.debug.Debug.*; + import java.util.*; import com.oracle.max.asm.*; @@ -40,6 +42,7 @@ import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.target.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -83,69 +86,17 @@ if (osrBCI != -1) { throw new CiBailout("No OSR supported"); } - context.timers.startScope(getClass()); - try { - long startTime = 0; - int index = context.metrics.CompiledMethods++; - final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); - if (printCompilation) { - TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", - index, - method.holder().name(), - method.name(), - method.signature().asString())); - startTime = System.nanoTime(); - } - TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); - - CiTargetMethod result = null; - context.observable.fireCompilationStarted(runtime, target, method); - try { - try { - CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null; - LIR lir = emitHIR(graph, assumptions, plan); - FrameMap frameMap = emitLIR(lir, graph, method); - result = emitCode(assumptions, method, lir, frameMap); - - if (GraalOptions.Meter) { - context.metrics.BytecodesCompiled += method.codeSize(); - } - } catch (CiBailout bailout) { - throw bailout; - } catch (Throwable t) { - throw new GraalInternalError(t); + final CiTargetMethod[] result = new CiTargetMethod[1]; + Debug.scope("CompileMethod", new Runnable() { + public void run() { + TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); + CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null; + LIR lir = emitHIR(graph, assumptions, plan); + FrameMap frameMap = emitLIR(lir, graph, method); + result[0] = emitCode(assumptions, method, lir, frameMap); } - } catch (GraalInternalError error) { - error.addContext("method", CiUtil.format("%H.%n(%p):%r", method)); - if (context.isObserved()) { - if (error.node() != null) { - context.observable.fireCompilationEvent("VerificationError on Node " + error.node(), CompilationEvent.ERROR, this, error.node().graph()); - } else if (error.graph() != null) { - context.observable.fireCompilationEvent("VerificationError on Graph " + error.graph(), CompilationEvent.ERROR, this, error.graph()); - } - } - throw error; - } finally { - context.observable.fireCompilationFinished(runtime, target, method); - filter.remove(); - if (printCompilation) { - long time = (System.nanoTime() - startTime) / 100000; - TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", - index, - "", - "", - "", - time / 10, - time % 10, - graph.getNodeCount(), - (result != null ? result.targetCodeSize() : -1))); - } - } - - return result; - } finally { - context.timers.endScope(); - } + }}, method); + return result[0]; } /**
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalContext.java Fri Jan 13 18:46:56 2012 +0100 @@ -35,7 +35,6 @@ public final ObservableContext observable = new ObservableContext(); public final GraalTimers timers = new GraalTimers(); - public final GraalMetrics metrics = new GraalMetrics(); private final String name; @@ -57,9 +56,6 @@ TTY.print('='); } TTY.println("\n========== " + name + " =========="); - if (GraalOptions.Meter) { - metrics.print(); - } if (GraalOptions.Time) { timers.print(); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java Thu Jan 12 13:48:27 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2009, 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; - -import java.lang.reflect.*; -import java.util.*; -import java.util.Map.Entry; - -import com.oracle.max.criutils.*; - - -/** - * This class contains a number of fields that collect metrics about compilation, particularly - * the number of times certain optimizations are performed. - */ -public final class GraalMetrics { - // Checkstyle: stop - public int CompiledMethods; - public int TargetMethods; - public int LocalValueNumberHits; - public int ValueMapResizes; - public int InlinedFinalizerChecks; - public int InlineForcedMethods; - public int InlineForbiddenMethods; - public int InlineConsidered; - public int InlinePerformed; - public int InlineUncompiledConsidered; - public int InlineUncompiledPerformed; - public int BlocksDeleted; - public int BytecodesCompiled; - public int CodeBytesEmitted; - public int SafepointsEmitted; - public int ExceptionHandlersEmitted; - public int DataPatches; - public int DirectCallSitesEmitted; - public int IndirectCallSitesEmitted; - public int LiveHIRInstructions; - public int LIRInstructions; - public int LIRVariables; - public int LIRXIRInstructions; - public int LIRMoveInstructions; - public int LSRAIntervalsCreated; - public int LSRASpills; - public int LoadConstantIterations; - public int CodeBufferCopies; - public int UniqueValueIdsAssigned; - public int FrameStatesCreated; - public int FrameStateValuesCreated; - public int LoopsPeeled; - public int LoopsInverted; - public int PartialUsageProbability; - public int FullUsageProbability; - public int Rematerializations; - public int GlobalValueNumberingHits; - public int ExplicitExceptions; - public int GuardsHoisted; - - - - /** - * The total number of bytes of bytecode parsed during this compilation, including any inlined methods. - */ - public int bytecodeCount; - - /** - * The number of internal graph nodes created during this compilation. - */ - public int nodeCount; - - /** - * The number of basic blocks created during this compilation. - */ - public int blockCount; - - /** - * The number of loops in the compiled method. - */ - public int loopCount; - - /** - * The number of methods inlined. - */ - public int inlineCount; - - /** - * The number of methods folded (i.e. evaluated). - */ - public int foldCount; - - /** - * The number of intrinsics inlined in this compilation. - */ - public int intrinsicCount; - - - // Checkstyle: resume - - public void print() { - for (Entry<String, MetricsEntry> m : map.entrySet()) { - printField(m.getKey(), m.getValue().value); - } - printFields(GraalMetrics.class); - } - - public static class MetricsEntry { - public int value; - - public void increment() { - increment(1); - } - - public void increment(int val) { - value += val; - } - } - - private LinkedHashMap<String, MetricsEntry> map = new LinkedHashMap<>(); - - public MetricsEntry get(String name) { - if (!map.containsKey(name)) { - map.put(name, new MetricsEntry()); - } - return map.get(name); - } - - public void printFields(Class<?> javaClass) { - final String className = javaClass.getSimpleName(); - TTY.println(className + " {"); - for (final Field field : javaClass.getFields()) { - printField(field, false); - } - TTY.println("}"); - } - - public void printField(final Field field, boolean tabbed) { - final String fieldName = String.format("%35s", field.getName()); - try { - String prefix = tabbed ? "" : " " + fieldName + " = "; - String postfix = tabbed ? "\t" : "\n"; - if (field.getType() == int.class) { - TTY.print(prefix + field.getInt(this) + postfix); - } else if (field.getType() == boolean.class) { - TTY.print(prefix + field.getBoolean(this) + postfix); - } else if (field.getType() == float.class) { - TTY.print(prefix + field.getFloat(this) + postfix); - } else if (field.getType() == String.class) { - TTY.print(prefix + field.get(this) + postfix); - } else if (field.getType() == Map.class) { - Map<?, ?> m = (Map<?, ?>) field.get(this); - TTY.print(prefix + printMap(m) + postfix); - } else { - TTY.print(prefix + field.get(this) + postfix); - } - } catch (IllegalAccessException e) { - // do nothing. - } - } - - private static String printMap(Map<?, ?> m) { - StringBuilder sb = new StringBuilder(); - - List<String> keys = new ArrayList<>(); - for (Object key : m.keySet()) { - keys.add((String) key); - } - Collections.sort(keys); - - for (String key : keys) { - sb.append(key); - sb.append("\t"); - sb.append(m.get(key)); - sb.append("\n"); - } - - return sb.toString(); - } - - private static void printField(String fieldName, long value) { - TTY.print(" " + fieldName + " = " + value + "\n"); - } -} -
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/ControlFlowOptimizer.java Fri Jan 13 18:46:56 2012 +0100 @@ -28,6 +28,7 @@ import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; /** * This class performs basic optimizations on the control flow graph after LIR generation. @@ -123,7 +124,7 @@ if (canDeleteBlock(block)) { // adjust successor and predecessor lists block.replaceWith(block.suxAt(0)); - context.metrics.BlocksDeleted++; + Debug.metric("BlocksDeleted").increment(); } else { // adjust position of this block in the block list if blocks before // have been deleted
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java Fri Jan 13 18:46:56 2012 +0100 @@ -31,6 +31,7 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; /** * Represents an interval in the {@linkplain LinearScan linear scan register allocator}. @@ -659,10 +660,10 @@ */ static final Interval EndMarker = new Interval(null, CiValue.IllegalValue, -1); + private static final Debug.Metric instanceMetric = Debug.metric("LSRAIntervalsCreated"); + Interval(GraalContext context, CiValue operand, int operandNumber) { - if (GraalOptions.Meter && context != null) { - context.metrics.LSRAIntervalsCreated++; - } + //instanceMetric.increment(); assert operand != null; this.operand = operand; this.operandNumber = operandNumber;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java Fri Jan 13 18:46:56 2012 +0100 @@ -288,7 +288,7 @@ } int numLoops() { - return ir.loopCount(); + return ir.numLoops(); } boolean isIntervalInLoop(int interval, int loop) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java Fri Jan 13 18:46:56 2012 +0100 @@ -34,6 +34,7 @@ import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.lir.LIR.SlowPath; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; public class TargetMethodAssembler { @@ -84,13 +85,11 @@ } } - if (GraalOptions.Meter) { - context.metrics.TargetMethods++; - context.metrics.CodeBytesEmitted += targetMethod.targetCodeSize(); - context.metrics.SafepointsEmitted += targetMethod.safepoints.size(); - context.metrics.DataPatches += targetMethod.dataReferences.size(); - context.metrics.ExceptionHandlersEmitted += targetMethod.exceptionHandlers.size(); - } + Debug.metric("TargetMethods").increment(); + Debug.metric("CodeBytesEmitted").add(targetMethod.targetCodeSize()); + Debug.metric("SafepointsEmitted").add(targetMethod.safepoints.size()); + Debug.metric("DataPatches").add(targetMethod.dataReferences.size()); + Debug.metric("ExceptionHandlersEmitted").add(targetMethod.exceptionHandlers.size()); if (GraalOptions.PrintAssembly && !TTY.isSuppressed() && !isStub) { Util.printSection("Target Method", Util.SECTION_CHARACTER);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Fri Jan 13 18:46:56 2012 +0100 @@ -49,6 +49,7 @@ import com.oracle.max.graal.compiler.lir.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; @@ -1316,9 +1317,7 @@ inputOperandArray, tempOperandArray, inputOperandIndicesArray, tempOperandIndicesArray, (allocatedResultOperand == IllegalValue) ? -1 : resultOperand.index, info, infoAfter, currentMethod)); - if (GraalOptions.Meter) { - context.metrics.LIRXIRInstructions++; - } + Debug.metric("LIRXIRInstructions").increment(); } return operandsArray[resultOperand.index];
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java Fri Jan 13 18:46:56 2012 +0100 @@ -64,9 +64,7 @@ public SlowPath methodEndMarker; private int numVariables; - - private final int loopCount; - + private final int numLoops; public interface SlowPath { void emitCode(TargetMethodAssembler tasm); @@ -77,11 +75,12 @@ * @param loopCount number of loops * @param compilation the compilation */ - public LIR(LIRBlock startBlock, List<LIRBlock> linearScanOrder, List<LIRBlock> codeEmittingOrder, NodeMap<LIRBlock> valueToBlock, int loopCount) { + public LIR(LIRBlock startBlock, List<LIRBlock> linearScanOrder, List<LIRBlock> codeEmittingOrder, NodeMap<LIRBlock> valueToBlock, int numLoops) { this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; this.startBlock = startBlock; this.valueToBlock = valueToBlock; + this.numLoops = numLoops; this.loopCount = loopCount; slowPaths = new ArrayList<>(); @@ -253,4 +252,8 @@ TTY.println(); } } + + public int numLoops() { + return numLoops; + } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GlobalValueNumberingPhase.java Fri Jan 13 18:46:56 2012 +0100 @@ -24,11 +24,14 @@ import com.oracle.max.criutils.*; import com.oracle.max.graal.compiler.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; public class GlobalValueNumberingPhase extends Phase { + public static final Debug.Metric metricGlobalValueNumberingHits = Debug.metric("GlobalValueNumberingHits"); + @Override protected void run(StructuredGraph graph) { NodeBitMap visited = graph.createNodeBitMap(); @@ -47,9 +50,7 @@ Node newNode = compilerGraph.findDuplicate(n); if (newNode != null) { n.replaceAndDelete(newNode); - if (GraalOptions.Meter) { - currentContext.metrics.GlobalValueNumberingHits++; - } + metricGlobalValueNumberingHits.increment(); if (GraalOptions.TraceGVN) { TTY.println("GVN applied and new node is " + newNode); }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Fri Jan 13 18:46:56 2012 +0100 @@ -33,6 +33,7 @@ import com.oracle.max.graal.compiler.util.InliningUtil.InlineInfo; import com.oracle.max.graal.compiler.util.InliningUtil.InliningCallback; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -54,6 +55,10 @@ private final PhasePlan plan; + // Metrics + private static final Debug.Metric metricInliningPerformed = Debug.metric("InliningPerformed"); + private static final Debug.Metric metricInliningConsidered = Debug.metric("InliningConsidered"); + public InliningPhase(CiTarget target, GraalRuntime runtime, Collection<Invoke> hints, CiAssumptions assumptions, PhasePlan plan) { this.target = target; this.runtime = runtime; @@ -105,9 +110,7 @@ if (GraalOptions.Intrinsify) { new IntrinsificationPhase(runtime).apply(graph, currentContext); } - if (GraalOptions.Meter) { - currentContext.metrics.InlinePerformed++; - } + metricInliningPerformed.increment(); } catch (CiBailout bailout) { // TODO determine if we should really bail out of the whole compilation. throw bailout; @@ -146,10 +149,7 @@ private void scanInvoke(Invoke invoke, int level) { InlineInfo info = InliningUtil.getInlineInfo(invoke, level, runtime, assumptions, this); if (info != null) { - if (GraalOptions.Meter) { - currentContext.metrics.InlineConsidered++; - } - + metricInliningConsidered.increment(); inlineCandidates.add(info); } }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Fri Jan 13 18:46:56 2012 +0100 @@ -22,9 +22,12 @@ */ package com.oracle.max.graal.compiler.phases; +import static com.oracle.max.graal.debug.Debug.*; + import com.oracle.max.cri.ci.*; import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.schedule.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; @@ -64,58 +67,61 @@ apply(graph, GraalContext.EMPTY_CONTEXT, plot); } - public final void apply(StructuredGraph graph, GraalContext context, boolean plot) { + public final void apply(final StructuredGraph graph, GraalContext context, boolean plot) { this.currentContext = context; - try { - assert graph != null && (!shouldVerify || graph.verify()); - } catch (GraalInternalError e) { - throw e.addContext("start of phase", getDetailedName()); - } + + Debug.scope(name, new Runnable() { public void run() { Phase.this.run(graph); }}); - int startDeletedNodeCount = graph.getDeletedNodeCount(); - int startNodeCount = graph.getNodeCount(); - if (context != null) { - context.timers.startScope(getName()); - } - try { - try { - run(graph); - } catch (CiBailout bailout) { - throw bailout; - } catch (AssertionError e) { - throw new GraalInternalError(e); - } catch (RuntimeException e) { - throw new GraalInternalError(e); - } finally { - if (context != null) { - context.timers.endScope(); - } - } - } catch (GraalInternalError e) { - throw e.addContext(graph).addContext("phase", getDetailedName()); - } - - if (context != null) { - if (GraalOptions.Meter) { - int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount; - int createdNodeCount = graph.getNodeCount() - startNodeCount + deletedNodeCount; - context.metrics.get(getName().concat(".executed")).increment(); - context.metrics.get(getName().concat(".deletedNodes")).increment(deletedNodeCount); - context.metrics.get(getName().concat(".createdNodes")).increment(createdNodeCount); - } - - boolean shouldFireCompilationEvents = context.isObserved() && this.getClass() != IdentifyBlocksPhase.class && (plot || GraalOptions.PlotVerbose); - if (shouldFireCompilationEvents && context.timers.currentLevel() < GraalOptions.PlotLevel) { - context.observable.fireCompilationEvent("After " + getName(), graph); - } - } - - try { - assert !shouldVerify || graph.verify(); - } catch (GraalInternalError e) { - throw e.addContext("end of phase", getDetailedName()); - } +// try { +// assert graph != null && (!shouldVerify || graph.verify()); +// } catch (GraalInternalError e) { +// throw e.addContext("start of phase", getDetailedName()); +// } +// +// int startDeletedNodeCount = graph.getDeletedNodeCount(); +// int startNodeCount = graph.getNodeCount(); +// if (context != null) { +// context.timers.startScope(getName()); +// } +// try { +// try { +// run(graph); +// } catch (CiBailout bailout) { +// throw bailout; +// } catch (AssertionError e) { +// throw new GraalInternalError(e); +// } catch (RuntimeException e) { +// throw new GraalInternalError(e); +// } finally { +// if (context != null) { +// context.timers.endScope(); +// } +// } +// } catch (GraalInternalError e) { +// throw e.addContext(graph).addContext("phase", getDetailedName()); +// } +// +// if (context != null) { +// if (GraalOptions.Meter) { +// int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount; +// int createdNodeCount = graph.getNodeCount() - startNodeCount + deletedNodeCount; +// context.metrics.get(getName().concat(".executed")).increment(); +// context.metrics.get(getName().concat(".deletedNodes")).increment(deletedNodeCount); +// context.metrics.get(getName().concat(".createdNodes")).increment(createdNodeCount); +// } +// +// boolean shouldFireCompilationEvents = context.isObserved() && this.getClass() != IdentifyBlocksPhase.class && (plot || GraalOptions.PlotVerbose); +// if (shouldFireCompilationEvents && context.timers.currentLevel() < GraalOptions.PlotLevel) { +// context.observable.fireCompilationEvent("After " + getName(), graph); +// } +// } +// +// try { +// assert !shouldVerify || graph.verify(); +// } catch (GraalInternalError e) { +// throw e.addContext("end of phase", getDetailedName()); +// } } public final String getName() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java Fri Jan 13 18:46:56 2012 +0100 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2012, 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.debug; + + +public class Debug { + public static boolean SCOPE = false; + public static boolean LOG = false; + public static boolean METER = false; + public static boolean TIME = false; + + public static void scope(String name, Runnable runnable, Object... context) { + if (SCOPE) { + DebugContext.getInstance().scope(name, runnable, context); + } else { + runnable.run(); + } + } + + public static void log(String msg, Object... args) { + if (LOG) { + DebugContext.getInstance().log(msg, args); + } + } + + public static Metric metric(String name) { + if (METER) { + return new MetricImpl(name); + } else { + return VOID_METRIC; + } + } + + public interface Metric { + void increment(); + void add(int value); + } + + private static final Metric VOID_METRIC = new Metric() { + public void increment() { } + public void add(int value) { } + }; + + public static Timer timer(String name) { + if (TIME) { + return new TimerImpl(name); + } else { + return VOID_TIMER; + } + } + + public interface Timer { + void start(); + void stop(); + } + + private static final Timer VOID_TIMER = new Timer() { + public void start() { }; + public void stop() { }; + }; + + private static final class MetricImpl extends ScopeChild implements Metric { + private MetricImpl(String name) { + super(name); + } + + public void increment() { + } + + public void add(int value) { + } + + } + + public static final class TimerImpl extends ScopeChild implements Timer { + private TimerImpl(String name) { + super(name); + } + + @Override + public void start() { + // TODO Auto-generated method stub + + } + + @Override + public void stop() { + // TODO Auto-generated method stub + + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/DebugContext.java Fri Jan 13 18:46:56 2012 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, 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.debug; + + +class DebugContext { + + private static ThreadLocal<DebugContext> instance = new ThreadLocal<>(); + + static DebugContext getInstance() { + if (instance.get() == null) { + instance.set(new DebugContext()); + } + return instance.get(); + } + + void log(String msg, Object... args) { + } + + void scope(String name, Runnable runnable, Object... context) { + runnable.run(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/ScopeChild.java Fri Jan 13 18:46:56 2012 +0100 @@ -0,0 +1,9 @@ +package com.oracle.max.graal.debug; + +class ScopeChild { + private String name; + + protected ScopeChild(String name) { + this.name = name; + } +} \ No newline at end of file
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Fri Jan 13 18:46:56 2012 +0100 @@ -45,6 +45,7 @@ public class VMToCompilerImpl implements VMToCompiler, Remote { private final Compiler compiler; + private int compiledMethodCount; public final HotSpotTypePrimitive typeBoolean; public final HotSpotTypePrimitive typeChar; @@ -169,7 +170,37 @@ PhasePlan plan = new PhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime()); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); - CiTargetMethod result = compiler.getCompiler().compileMethod(method, -1, plan); + long startTime = 0; + int index = compiledMethodCount++; + final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed(); + if (printCompilation) { + TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", + index, + method.holder().name(), + method.name(), + method.signature().asString())); + startTime = System.nanoTime(); + } + + CiTargetMethod result = null; + TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); + try { + result = compiler.getCompiler().compileMethod(method, -1, plan); + } finally { + filter.remove(); + if (printCompilation) { + long time = (System.nanoTime() - startTime) / 100000; + TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", + index, + "", + "", + "", + time / 10, + time % 10, + 0, + (result != null ? result.targetCodeSize() : -1))); + } + } HotSpotTargetMethod.installMethod(compiler, method, result, true); } catch (CiBailout bailout) { if (GraalOptions.ExitVMOnBailout) {
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Thu Jan 12 13:48:27 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Fri Jan 13 18:46:56 2012 +0100 @@ -36,6 +36,7 @@ import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.schedule.*; import com.oracle.max.graal.compiler.util.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.java.BlockMap.*; import com.oracle.max.graal.nodes.*; @@ -137,7 +138,6 @@ private BlockMap createBlockMap() { BlockMap map = new BlockMap(method, config.useBranchPrediction()); map.build(); - currentContext.metrics.bytecodeCount += method.code().length; if (currentContext.isObserved()) { String label = CiUtil.format("BlockListBuilder %f %R %H.%n(%P)", method); @@ -157,7 +157,6 @@ this.canTrapBitSet = blockMap.canTrap; exceptionHandlers = blockMap.exceptionHandlers(); - currentContext.metrics.blockCount += blockMap.blocks.size(); nextBlockNumber = blockMap.blocks.size(); @@ -199,7 +198,6 @@ } private int nextBlockNumber() { - currentContext.metrics.blockCount++; return nextBlockNumber++; } @@ -869,9 +867,7 @@ } else { exception.exceptionEdge.setNext(createTarget(unwindBlock(bci()), frameState.duplicateWithException(bci(), exception.exception))); } - if (GraalOptions.Meter) { - currentContext.metrics.ExplicitExceptions++; - } + Debug.metric("ExplicitExceptions").increment(); } }
--- a/mx/projects Thu Jan 12 13:48:27 2012 -0800 +++ b/mx/projects Fri Jan 13 18:46:56 2012 +0100 @@ -50,7 +50,12 @@ # graal.graph project@com.oracle.max.graal.graph@subDir=graal project@com.oracle.max.graal.graph@sourceDirs=src -project@com.oracle.max.graal.graph@dependencies=JUNIT +project@com.oracle.max.graal.graph@dependencies=com.oracle.max.graal.debug,JUNIT + +# graal.debug +project@com.oracle.max.graal.debug@subDir=graal +project@com.oracle.max.graal.debug@sourceDirs=src +project@com.oracle.max.graal.debug@checkstyle=com.oracle.max.graal.graph # graal.snippets project@com.oracle.max.graal.snippets@subDir=graal
--- a/src/share/vm/graal/graal_paths.hpp Thu Jan 12 13:48:27 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.cri"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.criutils"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asm"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.graph"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.nodes"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.compiler"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.java"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.printer"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.snippets"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.base"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asmdis"); - prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.hotspot");
--- a/src/share/vm/runtime/arguments.cpp Thu Jan 12 13:48:27 2012 -0800 +++ b/src/share/vm/runtime/arguments.cpp Fri Jan 13 18:46:56 2012 +0100 @@ -2096,9 +2096,22 @@ } } if (PrintVMOptions) tty->print_cr("GRAAL=%s", graal_dir); - + SysClassPath scp_compiler(Arguments::get_sysclasspath()); -#include "graal/graal_paths.hpp" + struct dirent* dentry; + char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(graal_dir)); + errno = 0; + DIR* graal_dir_handle = os::opendir(graal_dir); + while ((dentry = os::readdir(graal_dir_handle, (struct dirent *)tdbuf)) != NULL) { + if (strcmp(dentry->d_name, ".") != 0 && strcmp(dentry->d_name, "..")) { + prepend_to_graal_classpath(scp_compiler, graal_dir, dentry->d_name); + if (PrintVMOptions) { + tty->print_cr("Adding project directory %s to bootclasspath", dentry->d_name); + } + } + } + os::closedir(graal_dir_handle); + FREE_C_HEAP_ARRAY(char, tdbuf); scp_compiler.expand_endorsed(); Arguments::set_compilerclasspath(scp_compiler.combined_path());