Mercurial > hg > graal-jvmci-8
changeset 13147:371db31081be
Merge
author | Erik Eckstein <erik.eckstein@oracle.com> |
---|---|
date | Mon, 25 Nov 2013 13:56:34 +0100 |
parents | ffbfc3e78746 (diff) 3f1c70baa3bd (current diff) |
children | dcb1f442ca98 |
files | |
diffstat | 12 files changed, 92 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Mon Nov 25 13:56:34 2013 +0100 @@ -116,7 +116,7 @@ probabilitySum += newNotRecorded; double factor = 1.0 / probabilitySum; // Normalize to 1.0 - assert factor > 1.0; + assert factor >= 1.0; ProfiledType[] newResult = new ProfiledType[result.size()]; for (int i = 0; i < newResult.length; ++i) { ProfiledType curType = result.get(i);
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Mon Nov 25 13:56:34 2013 +0100 @@ -231,7 +231,7 @@ } @Override - public Indent logIndent(String msg, Object... args) { + public Indent logAndIndent(String msg, Object... args) { return this; } @@ -240,6 +240,9 @@ return this; } + @Override + public void close() { + } } private static final NoLogger noLoggerInstance = new NoLogger(); @@ -281,9 +284,9 @@ * @param msg The format string of the log message * @param args The arguments referenced by the log message string * @return The new indentation level - * @see Indent#logIndent + * @see Indent#logAndIndent */ - public static Indent logIndent(String msg, Object... args) { + public static Indent logAndIndent(String msg, Object... args) { if (ENABLED) { DebugScope scope = DebugScope.getInstance(); scope.log(msg, args); @@ -300,7 +303,7 @@ * @param args The arguments referenced by the log message string * @return The new indentation level */ - public static Indent logIndent(boolean enabled, String msg, Object... args) { + public static Indent logAndIndent(boolean enabled, String msg, Object... args) { if (ENABLED) { DebugScope scope = DebugScope.getInstance(); boolean saveLogEnabled = scope.isLogEnabled();
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Indent.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Indent.java Mon Nov 25 13:56:34 2013 +0100 @@ -48,8 +48,20 @@ * in.outdent(); * } * </pre> + * + * Example usage with try-with-resources: + * + * <pre> + * + * try (Indent in = Debug.logIndent("header message")) { + * ... + * in.log("message"); + * ... + * } + * + * </pre> */ -public interface Indent { +public interface Indent extends AutoCloseable { /** * Prints an indented message to the DebugLevel's logging stream if logging is enabled. @@ -81,9 +93,9 @@ * @param msg The format string of the log message * @param args The arguments referenced by the log message string * @return The new indentation level - * @see Debug#logIndent + * @see Debug#logAndIndent */ - Indent logIndent(String msg, Object... args); + Indent logAndIndent(String msg, Object... args); /** * Restores the previous indent level. Calling this method is important to restore the correct @@ -92,4 +104,6 @@ * @return The indent level from which this Indent was created. */ Indent outdent(); + + void close(); }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Nov 25 13:56:34 2013 +0100 @@ -75,7 +75,7 @@ } @Override - public Indent logIndent(String msg, Object... args) { + public Indent logAndIndent(String msg, Object... args) { log(msg, args); return indent(); } @@ -87,6 +87,11 @@ } return lastUsedIndent; } + + @Override + public void close() { + outdent(); + } } private static ThreadLocal<DebugScope> instanceTL = new ThreadLocal<>(); @@ -231,7 +236,6 @@ public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, DebugConfig sandboxConfig, Object[] newContext) { DebugScope oldContext = getInstance(); DebugConfig oldConfig = getConfig(); - boolean oldLogEnabled = oldContext.isLogEnabled(); DebugScope newChild = null; if (sandbox) { newChild = new DebugScope(newName, newName, null, newContext); @@ -240,6 +244,7 @@ newChild = oldContext.createChild(newName, newContext); } instanceTL.set(newChild); + newChild.setLogEnabled(oldContext.isLogEnabled()); newChild.updateFlags(); try { return executeScope(runnable, callable); @@ -247,7 +252,6 @@ newChild.context = null; instanceTL.set(oldContext); setConfig(oldConfig); - setLogEnabled(oldLogEnabled); } } @@ -283,7 +287,6 @@ meterEnabled = false; timeEnabled = false; dumpEnabled = false; - setLogEnabled(false); // Be pragmatic: provide a default log stream to prevent a crash if the stream is not // set while logging @@ -293,7 +296,9 @@ timeEnabled = config.isTimeEnabled(); dumpEnabled = config.isDumpEnabled(); output = config.output(); - setLogEnabled(config.isLogEnabled()); + if (config.isLogEnabled()) { + setLogEnabled(true); + } } }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Mon Nov 25 13:56:34 2013 +0100 @@ -438,7 +438,7 @@ } } - private void storeStack(int i, ValueNode x) { + public void storeStack(int i, ValueNode x) { assert x == null || x.isAlive() && (stack[i] == null || x.kind() == stack[i].kind()) : "Method does not handle changes from one-slot to two-slot values or non-alive values"; stack[i] = x; }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Nov 25 13:56:34 2013 +0100 @@ -211,12 +211,14 @@ return map; } - private void build() { + protected void build() { if (PrintProfilingInformation.getValue()) { - TTY.println("Profiling info for " + MetaUtil.format("%H.%n(%p)", method)); + TTY.println("Profiling info for " + method); TTY.println(MetaUtil.indent(MetaUtil.profileToString(profilingInfo, method, CodeUtil.NEW_LINE), " ")); } + Indent indent = Debug.logAndIndent(false, "build graph for %s", method.toString()); + // compute the block map, setup exception handlers and get the entrypoint(s) BciBlockMapping blockMap = createBlockMap(); loopHeaders = blockMap.loopHeaders; @@ -275,6 +277,7 @@ n.safeDelete(); } } + indent.outdent(); } private Block unwindBlock(int bci) { @@ -1590,7 +1593,7 @@ Debug.log("Ignoring block %s", block); return; } - Debug.log("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader); + Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader); lastInstr = block.firstInstruction; frameState = block.entryState; @@ -1617,6 +1620,7 @@ frameState.setRethrowException(false); iterateBytecodesForBlock(block); } + indent.outdent(); } private void connectLoopEndToBegin() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java Mon Nov 25 13:56:34 2013 +0100 @@ -42,6 +42,19 @@ StructuredGraph getSnippet(ResolvedJavaMethod method); /** + * Registers a method as snippet. + */ + void registerSnippet(ResolvedJavaMethod method); + + /** + * Prepares the copy of a snippet graph immediately after instantiation. This can be used to do + * node intrinsification for example. + * + * @param snippetCopy The copy of the snippet graph. + */ + void prepareSnippetCopyAfterInstantiation(StructuredGraph snippetCopy); + + /** * Gets the graph that is a substitution for a given method. * * @return the graph, if any, that is a substitution for {@code method}
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BasicIdealGraphPrinter.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BasicIdealGraphPrinter.java Mon Nov 25 13:56:34 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.printer; import java.io.*; +import java.nio.charset.*; import java.util.*; import java.util.Map.Entry; @@ -90,7 +91,7 @@ } else { buffered = new BufferedOutputStream(stream, 256 * 1024); } - this.stream = new PrintStream(buffered, false, "US-ASCII"); + this.stream = new PrintStream(buffered, false, Charset.defaultCharset().name()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Mon Nov 25 13:56:34 2013 +0100 @@ -44,7 +44,7 @@ */ public class GraphPrinterDumpHandler implements DebugDumpHandler { - private GraphPrinter printer; + protected GraphPrinter printer; private List<String> previousInlineContext; private int[] dumpIds = {}; private int failuresCount; @@ -62,11 +62,15 @@ return; } previousInlineContext.clear(); - if (PrintIdealGraphFile.getValue()) { - initializeFilePrinter(); - } else { - initializeNetworkPrinter(); - } + createPrinter(); + } + } + + protected void createPrinter() { + if (PrintIdealGraphFile.getValue()) { + initializeFilePrinter(); + } else { + initializeNetworkPrinter(); } }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java Mon Nov 25 13:56:34 2013 +0100 @@ -40,7 +40,7 @@ * Generates a representation of {@link Graph Graphs} that can be visualized and inspected with the * <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. */ -class IdealGraphPrinter extends BasicIdealGraphPrinter implements GraphPrinter { +public class IdealGraphPrinter extends BasicIdealGraphPrinter implements GraphPrinter { /** * Creates a new {@link IdealGraphPrinter} that writes to the specified output stream.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Mon Nov 25 13:56:34 2013 +0100 @@ -60,11 +60,11 @@ /** * The preprocessed replacement graphs. */ - private final ConcurrentMap<ResolvedJavaMethod, StructuredGraph> graphs; + protected final ConcurrentMap<ResolvedJavaMethod, StructuredGraph> graphs; // These data structures are all fully initialized during single-threaded // compiler startup and so do not need to be concurrent. - private final Map<ResolvedJavaMethod, ResolvedJavaMethod> registeredMethodSubstitutions; + protected final Map<ResolvedJavaMethod, ResolvedJavaMethod> registeredMethodSubstitutions; private final Map<ResolvedJavaMethod, Class<? extends FixedWithNextNode>> registeredMacroSubstitutions; private final Set<ResolvedJavaMethod> forcedSubstitutions; private final Map<Class<? extends SnippetTemplateCache>, SnippetTemplateCache> snippetTemplateCache; @@ -83,6 +83,7 @@ private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true")); private static final DebugTimer SnippetPreparationTime = Debug.timer("SnippetPreparationTime"); + @Override public StructuredGraph getSnippet(ResolvedJavaMethod method) { assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName(); assert !Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers()) : "Snippet must not be abstract or native"; @@ -102,6 +103,22 @@ return graph; } + @Override + public void registerSnippet(ResolvedJavaMethod method) { + // No initialization needed as snippet graphs are created on demand in getSnippet + } + + @Override + public void prepareSnippetCopyAfterInstantiation(StructuredGraph snippetCopy) { + + // Do deferred intrinsification of node intrinsics + + new NodeIntrinsificationPhase(providers).apply(snippetCopy); + new CanonicalizerPhase(true).apply(snippetCopy, new PhaseContext(providers, assumptions)); + NodeIntrinsificationVerificationPhase.verify(snippetCopy); + } + + @Override public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original) { ResolvedJavaMethod substitute = registeredMethodSubstitutions.get(original); if (substitute == null) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Nov 25 12:46:45 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Nov 25 13:56:34 2013 +0100 @@ -398,7 +398,9 @@ } } assert found != null : "did not find @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName); - return new SnippetInfo(providers.getMetaAccess().lookupJavaMethod(found)); + ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(found); + providers.getReplacements().registerSnippet(javaMethod); + return new SnippetInfo(javaMethod); } /** @@ -512,12 +514,8 @@ Debug.dump(snippetCopy, "Before specialization"); if (!nodeReplacements.isEmpty()) { - // Do deferred intrinsification of node intrinsics - new CanonicalizerPhase(true).apply(snippetCopy, phaseContext); - new NodeIntrinsificationPhase(providers).apply(snippetCopy); - new CanonicalizerPhase(true).apply(snippetCopy, phaseContext); + providers.getReplacements().prepareSnippetCopyAfterInstantiation(snippetCopy); } - NodeIntrinsificationVerificationPhase.verify(snippetCopy); // Gather the template parameters parameters = new Object[parameterCount];