--- old/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java 2013-04-10 13:35:23.000000000 -0700 +++ new/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java 2013-04-10 13:35:22.000000000 -0700 @@ -25,6 +25,7 @@ import static com.oracle.graal.nodes.StructuredGraph.*; import static com.oracle.graal.phases.common.InliningUtil.*; +import java.lang.reflect.Modifier; import java.util.concurrent.*; import com.oracle.graal.api.code.*; @@ -133,6 +134,9 @@ TTY.println(String.format("%-6d Graal %-70s %-45s %-50s %s...", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature(), entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ")); } + if (GraalOptions.HotSpotPrintCompilation) { + printCompilation(); + } CompilationResult result = null; TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); @@ -183,6 +187,23 @@ stats.finish(method); } + /** + * Print a HotSpot-style compilation message to the console. + */ + private void printCompilation() { + final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; + final int mod = method.getModifiers(); + TTY.println(String.format("%7d %4d %c%c%c%c%c %s %s(%d bytes)", + 0, id, + isOSR ? '%' : ' ', + Modifier.isSynchronized(mod) ? 's' : ' ', + ' ', + ' ', + Modifier.isNative(mod) ? 'n' : ' ', + MetaUtil.format("%H::%n(%p)", method), + isOSR ? "@ " + entryBCI + " " : "", method.getCodeSize())); + } + private void installMethod(final CompilationResult compResult) { Debug.scope("CodeInstall", new Object[]{new DebugDumpScope(String.valueOf(id), true), graalRuntime.getRuntime(), method}, new Runnable() { --- old/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java 2013-04-10 13:35:24.000000000 -0700 +++ new/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java 2013-04-10 13:35:23.000000000 -0700 @@ -138,6 +138,10 @@ config = new HotSpotVMConfig(); compilerToVm.initializeConfiguration(config); config.check(); + + // Set some global options: + GraalOptions.HotSpotPrintCompilation = config.printCompilation; + GraalOptions.HotSpotPrintInlining = config.printInlining; if (Boolean.valueOf(System.getProperty("graal.printconfig"))) { printConfig(config); --- old/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java 2013-04-10 13:35:25.000000000 -0700 +++ new/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java 2013-04-10 13:35:25.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -37,6 +37,8 @@ public int codeEntryAlignment; public boolean verifyOops; public boolean ciTime; + public boolean printCompilation; + public boolean printInlining; public boolean useFastLocking; public boolean useTLAB; public boolean useBiasedLocking; --- old/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java 2013-04-10 13:35:26.000000000 -0700 +++ new/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java 2013-04-10 13:35:26.000000000 -0700 @@ -33,6 +33,7 @@ import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.HotSpotGraalRuntime; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -73,13 +74,55 @@ boolean isWorthInlining(InlineInfo info); } - public static boolean logNotInlinedMethod(InlineInfo info, String msg, Object... args) { + /** + * Print a HotSpot-style inlining message to the console. + */ + private static void printInlining(final InlineInfo info, final boolean success, final String msg, final Object... args) { + printInlining(info.methodAt(0), info.invoke(), success, msg, args); + } + + /** + * Print a HotSpot-style inlining message to the console. + */ + private static void printInlining(final ResolvedJavaMethod method, final Invoke invoke, final boolean success, final String msg, final Object... args) { + if (GraalOptions.HotSpotPrintInlining) { + final int mod = method.getModifiers(); + // 1234567 + TTY.print(" "); // print timestamp + // 1234 + TTY.print(" "); // print compilation number + // % s ! b n + TTY.print("%c%c%c%c%c ", + ' ', + Modifier.isSynchronized(mod) ? 's' : ' ', + ' ', + ' ', + Modifier.isNative(mod) ? 'n' : ' '); + TTY.print(" "); // more indent + TTY.print(" "); // initial inlining indent + final int level = computeInliningLevel(invoke); + for (int i = 0; i < level; i++) { + TTY.print(" "); + } + TTY.println(String.format("@ %d %s %s%s", + invoke.bci(), methodName(method, null), + success ? "" : "not inlining ", + String.format(msg, args))); + } + } + + public static boolean logInlinedMethod(InlineInfo info, String msg, Object... args) { + logInliningDecision(info, true, msg, args); + return true; + } + public static boolean logNotInlinedMethod(InlineInfo info, String msg, Object... args) { logInliningDecision(info, false, msg, args); return false; } public static void logInliningDecision(InlineInfo info, boolean success, String msg, final Object... args) { + printInlining(info, success, msg, args); if (shouldLogInliningDecision()) { logInliningDecision(methodName(info), success, msg, args); } @@ -94,11 +137,6 @@ }); } - public static boolean logInlinedMethod(InlineInfo info, String string, Object... args) { - logInliningDecision(info, true, string, args); - return true; - } - private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, String msg) { if (shouldLogInliningDecision()) { String methodString = invoke.toString() + (invoke.callTarget() == null ? " callTarget=null" : invoke.callTarget().targetName()); @@ -112,6 +150,7 @@ } private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, ResolvedJavaMethod method, String msg, Object... args) { + printInlining(method, invoke, false, msg, args); if (shouldLogInliningDecision()) { String methodString = methodName(method, invoke); logInliningDecision(methodString, false, msg, args); @@ -120,6 +159,7 @@ } private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, ResolvedJavaMethod method, String msg) { + printInlining(method, invoke, false, msg, new Object[0]); if (shouldLogInliningDecision()) { String methodString = methodName(method, invoke); logInliningDecision(methodString, false, msg, new Object[0]); --- old/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java 2013-04-10 13:35:27.000000000 -0700 +++ new/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java 2013-04-10 13:35:27.000000000 -0700 @@ -151,6 +151,10 @@ public static int TraceBytecodeParserLevel = 0; public static boolean ExitVMOnBailout = ____; public static boolean ExitVMOnException = true; + + // HotSpot command line options + public static boolean HotSpotPrintCompilation = ____; + public static boolean HotSpotPrintInlining = ____; // Register allocator debugging public static String RegisterPressure = null; --- old/src/share/vm/graal/graalCompilerToVM.cpp 2013-04-10 13:35:28.000000000 -0700 +++ new/src/share/vm/graal/graalCompilerToVM.cpp 2013-04-10 13:35:28.000000000 -0700 @@ -620,6 +620,8 @@ #endif set_boolean("verifyOops", VerifyOops); set_boolean("ciTime", CITime); + set_boolean("printCompilation", PrintCompilation); + set_boolean("printInlining", PrintInlining); set_boolean("useFastLocking", GraalUseFastLocking); set_boolean("useBiasedLocking", UseBiasedLocking); set_boolean("usePopCountInstruction", UsePopCountInstruction);