# HG changeset patch # User Gilles Duboscq # Date 1357833942 -3600 # Node ID d91529efc642f4f9cf0e29d7f7d279aa89efcb31 # Parent c5a9bcd9493dc58917897f89427da49d8999e474# Parent 88b3b9b9a47bdadc6b5b26b2df84261646767dbc Merge diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java --- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Thu Jan 10 17:05:31 2013 +0100 +++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Thu Jan 10 17:05:42 2013 +0100 @@ -58,6 +58,22 @@ countEdges(startBlock, null); computeOrder(startBlock); + + + List newCodeEmittingOrder = new ArrayList<>(); + List outOfLine = new ArrayList<>(); + for (Block b : codeEmittingOrder) { + if (b.getBeginNode().probability() > 0.07) { + newCodeEmittingOrder.add(b); + } else { + outOfLine.add(b); + } + } + + for (Block b : outOfLine) { + newCodeEmittingOrder.add(b); + } + codeEmittingOrder = newCodeEmittingOrder; } /** diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Jan 10 17:05:31 2013 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Jan 10 17:05:42 2013 +0100 @@ -40,7 +40,6 @@ import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; -import com.oracle.graal.lir.StandardOp.LabelOp; import com.oracle.graal.lir.amd64.AMD64Arithmetic.DivOp; import com.oracle.graal.lir.amd64.AMD64Arithmetic.Op1Reg; import com.oracle.graal.lir.amd64.AMD64Arithmetic.Op1Stack; @@ -221,11 +220,6 @@ } @Override - public void emitLabel(Label label, boolean align) { - append(new LabelOp(label, align)); - } - - @Override public void emitJump(LabelRef label, LIRFrameState info) { append(new JumpOp(label, info)); } diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Jan 10 17:05:31 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Jan 10 17:05:42 2013 +0100 @@ -670,7 +670,6 @@ } - public abstract void emitLabel(Label label, boolean align); public abstract void emitJump(LabelRef label, LIRFrameState info); public abstract void emitBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info); public abstract Variable emitCMove(Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue); diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DebugFilter.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DebugFilter.java Thu Jan 10 17:05:31 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +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. - */ -package com.oracle.graal.hotspot; - -import static com.oracle.graal.hotspot.MethodFilter.*; - -import java.util.*; -import java.util.regex.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.internal.*; -import com.oracle.graal.phases.*; - -/** - * Implements the filter specified by the {@link GraalOptions#Dump}, - * {@link GraalOptions#Log}, {@link GraalOptions#Meter} and {@link GraalOptions#Time} - * options. - *

- * These options enable the associated debug facility if their filter - * matches the {@linkplain DebugScope#getQualifiedName() name} of the - * {@linkplain Debug#currentScope() current scope}. - *

- * A filter is a list of comma-separated terms. Each term is interpreted - * as a glob pattern if it contains a "*" or "?" character. Otherwise, it is - * interpreted as a substring. If a term starts with "~", then it is an - * positive term. An input is matched by a filter if any of its positive - * terms match the input (or it has no positive terms) AND none of its - * negative terms match the input (or it has no negative terms). - *

- * Examples of filters include: - *

- *

    - *
  • ""
    - * Matches any scope.
  • - *
  • "*"
    - * Matches any scope.
  • - *
  • "CodeGen,CodeInstall"
    - * Matches a scope whose name contains "CodeGen" or "CodeInstall".
  • - *
  • "Code*"
    - * Matches a scope whose name starts with "Code".
  • - *
  • "Code,~Dead"
    - * Matches a scope whose name contains "Code" but does not contain "Dead".
  • - *
- */ -class DebugFilter { - - public static DebugFilter parse(String spec) { - if (spec == null) { - return null; - } - return new DebugFilter(spec.split(",")); - } - - final Term[] positive; - final Term[] negative; - - DebugFilter(String[] terms) { - List pos = new ArrayList<>(terms.length); - List neg = new ArrayList<>(terms.length); - for (int i = 0; i < terms.length; i++) { - String t = terms[i]; - if (t.startsWith("~")) { - neg.add(new Term(t.substring(1))); - } else { - pos.add(new Term(t)); - } - } - this.positive = pos.isEmpty() ? null : pos.toArray(new Term[pos.size()]); - this.negative = neg.isEmpty() ? null : neg.toArray(new Term[neg.size()]); - } - - /** - * Determines if a given input is matched by this filter. - */ - public boolean matches(String input) { - boolean match = true; - if (positive != null) { - match = false; - for (Term t : positive) { - if (t.matches(input)) { - match = true; - break; - } - } - } - if (match && negative != null) { - for (Term t : negative) { - if (t.matches(input)) { - match = false; - break; - } - } - } -// if (match) { -// System.out.println(this + " matches " + input); -// } - return match; - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("DebugFilter["); - String sep = ""; - if (positive != null) { - buf.append(sep).append("pos=").append(Arrays.toString(positive)); - sep = ", "; - } - if (negative != null) { - buf.append(sep).append("neg=").append(Arrays.toString(negative)); - sep = ", "; - } - return buf.append("]").toString(); - } - - static class Term { - - final Pattern pattern; - - public Term(String filter) { - if (filter.isEmpty()) { - this.pattern = null; - } else if (filter.contains("*") || filter.contains("?")) { - this.pattern = Pattern.compile(createGlobString(filter)); - } else { - this.pattern = Pattern.compile(".*" + createGlobString(filter) + ".*"); - } - } - - /** - * Determines if a given input is matched by this filter. - */ - public boolean matches(String input) { - return pattern == null || pattern.matcher(input).matches(); - } - - @Override - public String toString() { - return pattern == null ? ".*" : pattern.toString(); - } - } -} diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java Thu Jan 10 17:05:31 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +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. - */ -package com.oracle.graal.hotspot; - -import java.io.*; -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.util.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.printer.*; - -public class HotSpotDebugConfig implements DebugConfig { - - private final DebugFilter logFilter; - private final DebugFilter meterFilter; - private final DebugFilter timerFilter; - private final DebugFilter dumpFilter; - private final MethodFilter[] methodFilter; - private final List dumpHandlers = new ArrayList<>(); - private final PrintStream output; - private final Set extraFilters = new HashSet<>(); - - public HotSpotDebugConfig(String logFilter, String meterFilter, String timerFilter, String dumpFilter, String methodFilter, PrintStream output) { - this.logFilter = DebugFilter.parse(logFilter); - this.meterFilter = DebugFilter.parse(meterFilter); - this.timerFilter = DebugFilter.parse(timerFilter); - this.dumpFilter = DebugFilter.parse(dumpFilter); - if (methodFilter == null || methodFilter.isEmpty()) { - this.methodFilter = null; - } else { - String[] filters = methodFilter.split(","); - this.methodFilter = new MethodFilter[filters.length]; - for (int i = 0; i < filters.length; i++) { - this.methodFilter[i] = new MethodFilter(filters[i]); - } - } - - // Report the filters that have been configured so the user can verify it's what they expect - if (logFilter != null || meterFilter != null || timerFilter != null || dumpFilter != null || methodFilter != null) { - TTY.println(Thread.currentThread().getName() + ": " + toString()); - } - dumpHandlers.add(new GraphPrinterDumpHandler()); - if (GraalOptions.PrintCFG) { - if (GraalOptions.PrintBinaryGraphs) { - TTY.println("CFG dumping slows down PrintBinaryGraphs: use -G:-PrintCFG to disable it"); - } - dumpHandlers.add(new CFGPrinterObserver()); - } - this.output = output; - } - - public boolean isLogEnabled() { - return isEnabled(logFilter); - } - - public boolean isMeterEnabled() { - return isEnabled(meterFilter); - } - - public boolean isDumpEnabled() { - return isEnabled(dumpFilter); - } - - public boolean isTimeEnabled() { - return isEnabled(timerFilter); - } - - public PrintStream output() { - return output; - } - - private boolean isEnabled(DebugFilter filter) { - return checkDebugFilter(Debug.currentScope(), filter) && checkMethodFilter(); - } - - private static boolean checkDebugFilter(String currentScope, DebugFilter filter) { - return filter != null && filter.matches(currentScope); - } - - private boolean checkMethodFilter() { - if (methodFilter == null && extraFilters.isEmpty()) { - return true; - } else { - for (Object o : Debug.context()) { - if (extraFilters.contains(o)) { - return true; - } else if (methodFilter != null) { - if (o instanceof JavaMethod) { - for (MethodFilter filter : methodFilter) { - if (filter.matches((JavaMethod) o)) { - return true; - } - } - } - } - } - return false; - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Debug config:"); - add(sb, "Log", logFilter); - add(sb, "Meter", meterFilter); - add(sb, "Time", timerFilter); - add(sb, "Dump", dumpFilter); - add(sb, "MethodFilter", methodFilter); - return sb.toString(); - } - - private static void add(StringBuilder sb, String name, Object filter) { - if (filter != null) { - sb.append(' '); - sb.append(name); - sb.append('='); - if (filter instanceof Object[]) { - sb.append(Arrays.toString((Object[]) filter)); - } else { - sb.append(String.valueOf(filter)); - } - } - } - - @Override - public RuntimeException interceptException(Throwable e) { - if (e instanceof BailoutException) { - return null; - } - Debug.setConfig(Debug.fixedConfig(true, true, false, false, dumpHandlers, output)); - Debug.log(String.format("Exception occurred in scope: %s", Debug.currentScope())); - for (Object o : Debug.context()) { - if (o instanceof Graph) { - Debug.log("Context obj %s", o); - if (GraalOptions.DumpOnError) { - Debug.dump(o, "Exception graph"); - } else { - Debug.log("Use -G:+DumpOnError to enable dumping of graphs on this error"); - } - } else if (o instanceof Node) { - String location = GraphUtil.approxSourceLocation((Node) o); - if (location != null) { - Debug.log("Context obj %s (approx. location: %s)", o, location); - } else { - Debug.log("Context obj %s", o); - } - } else { - Debug.log("Context obj %s", o); - } - } - return null; - } - - @Override - public Collection dumpHandlers() { - return dumpHandlers; - } - - @Override - public void addToContext(Object o) { - extraFilters.add(o); - } - - @Override - public void removeFromContext(Object o) { - extraFilters.remove(o); - } -} diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java Thu Jan 10 17:05:31 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +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. - */ -package com.oracle.graal.hotspot; - -import java.util.*; -import java.util.regex.*; - -import com.oracle.graal.api.meta.*; - -/** - * This class implements a method filter that can filter based on class name, method name and parameters. - * The syntax for the source pattern that is passed to the constructor is as follows: - * - *
- * SourcePattern = [ Class "." ] method [ "(" [ Parameter { ";" Parameter } ] ")" ] .
- * Parameter = Class | "int" | "long" | "float" | "double" | "short" | "char" | "boolean" .
- * Class = { package "." } class .
- * 
- * - * - * Glob pattern matching (*, ?) is allowed in all parts of the source pattern. Examples for valid filters are: - * - *
    - *
  • visit(Argument;BlockScope)
    - * Matches all methods named "visit", with the first parameter of type "Argument", and the second parameter of type "BlockScope". - * The packages of the parameter types are irrelevant.
  • - *
  • arraycopy(Object;;;;)
    - * Matches all methods named "arraycopy", with the first parameter of type "Object", and four more parameters of any type. - * The packages of the parameter types are irrelevant.
  • - *
  • com.oracle.graal.compiler.graph.PostOrderNodeIterator.*
    - * Matches all methods in the class "com.oracle.graal.compiler.graph.PostOrderNodeIterator".
  • - *
  • *
    - * Matches all methods in all classes
  • - *
  • com.oracle.graal.compiler.graph.*.visit
    - * Matches all methods named "visit" in classes in the package "com.oracle.graal.compiler.graph". - *
- */ -public class MethodFilter { - - private final Pattern clazz; - private final Pattern methodName; - private final Pattern[] signature; - - public MethodFilter(String sourcePattern) { - String pattern = sourcePattern.trim(); - - // extract parameter part - int pos = pattern.indexOf('('); - if (pos != -1) { - if (pattern.charAt(pattern.length() - 1) != ')') { - throw new IllegalArgumentException("missing ')' at end of method filter pattern: " + pattern); - } - String[] signatureClasses = pattern.substring(pos + 1, pattern.length() - 1).split(";", -1); - signature = new Pattern[signatureClasses.length]; - for (int i = 0; i < signatureClasses.length; i++) { - signature[i] = createClassGlobPattern(signatureClasses[i].trim()); - } - pattern = pattern.substring(0, pos); - } else { - signature = null; - } - - // If there is at least one "." then everything before the last "." is the class name. - // Otherwise, the pattern contains only the method name. - pos = pattern.lastIndexOf('.'); - if (pos != -1) { - clazz = createClassGlobPattern(pattern.substring(0, pos)); - methodName = Pattern.compile(createGlobString(pattern.substring(pos + 1))); - } else { - clazz = null; - methodName = Pattern.compile(createGlobString(pattern)); - } - } - - static String createGlobString(String pattern) { - return Pattern.quote(pattern).replace("?", "\\E.\\Q").replace("*", "\\E.*\\Q"); - } - - private static Pattern createClassGlobPattern(String pattern) { - if (pattern.length() == 0) { - return null; - } else if (pattern.contains(".")) { - return Pattern.compile(createGlobString(pattern)); - } else { - return Pattern.compile("([^\\.]*\\.)*" + createGlobString(pattern)); - } - } - - public boolean matches(JavaMethod o) { - // check method name first, since MetaUtil.toJavaName is expensive - if (methodName != null && !methodName.matcher(o.getName()).matches()) { - return false; - } - if (clazz != null && !clazz.matcher(MetaUtil.toJavaName(o.getDeclaringClass())).matches()) { - return false; - } - if (signature != null) { - Signature sig = o.getSignature(); - if (sig.getParameterCount(false) != signature.length) { - return false; - } - for (int i = 0; i < signature.length; i++) { - JavaType type = sig.getParameterType(i, null); - String javaName = MetaUtil.toJavaName(type); - if (signature[i] != null && !signature[i].matcher(javaName).matches()) { - return false; - } - } - } - return true; - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("MethodFilter["); - String sep = ""; - if (clazz != null) { - buf.append(sep).append("clazz=").append(clazz); - sep = ", "; - } - if (methodName != null) { - buf.append(sep).append("methodName=").append(methodName); - sep = ", "; - } - if (signature != null) { - buf.append(sep).append("signature=").append(Arrays.toString(signature)); - sep = ", "; - } - return buf.append("]").toString(); - } -} diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Jan 10 17:05:31 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Jan 10 17:05:42 2013 +0100 @@ -113,22 +113,6 @@ } assert lir.lir(block).get(0) instanceof StandardOp.LabelOp : "block must start with label"; - if (block.numberOfPreds() > 1) { - assert lir.lir(block).get(0) instanceof StandardOp.PhiLabelOp : "phi mapping required for multiple predecessors"; - Value[] phiDefinitions = ((StandardOp.PhiLabelOp) lir.lir(block).get(0)).getPhiDefinitions(); - if (!beforeRegisterAllocation) { - assert phiDefinitions.length == 0; - } - for (Block pred : block.getPredecessors()) { - assert pred.numberOfSux() == 1; - LIRInstruction last = lir.lir(pred).get(lir.lir(pred).size() - 1); - assert last instanceof StandardOp.PhiJumpOp : "phi mapping required for multiple successors"; - Value[] phiUses = ((StandardOp.PhiJumpOp) last).getPhiInputs(); - if (!beforeRegisterAllocation) { - assert phiUses.length == 0; - } - } - } if (block.numberOfSux() > 0) { LIRInstruction last = lir.lir(block).get(lir.lir(block).size() - 1); diff -r c5a9bcd9493d -r d91529efc642 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Jan 10 17:05:31 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Jan 10 17:05:42 2013 +0100 @@ -60,7 +60,7 @@ @Override public void emitCode(TargetMethodAssembler tasm) { if (align) { - tasm.asm.align(tasm.target.wordSize); + tasm.asm.align(tasm.target.wordSize * 2); } tasm.asm.bind(label); } @@ -70,23 +70,6 @@ } } - public static class PhiLabelOp extends LabelOp { - @Def({REG, STACK}) protected Value[] phiDefinitions; - - public PhiLabelOp(Label label, boolean align, Value[] phiDefinitions) { - super(label, align); - this.phiDefinitions = phiDefinitions; - } - - public void markResolved() { - phiDefinitions = EMPTY; - } - - public Value[] getPhiDefinitions() { - return phiDefinitions; - } - } - /** * LIR operation that is an unconditional jump to {@link #destination()}. * When the LIR is constructed, the last operation of every block must implement this interface. After