Mercurial > hg > graal-compiler
diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java @ 21473:923c37b10fb4
compute compiled bytecodes using method inlining recording instead of a DebugMetric
remove complex initialization of DebugMetrics and DebugTimers to implement -XX:+CITime and -XX:+CITimeEach
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 24 May 2015 00:21:20 +0200 |
parents | cc3131ff7ce2 |
children | 73713483b8ac |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri May 22 23:11:17 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Sun May 24 00:21:20 2015 +0200 @@ -32,7 +32,6 @@ import static com.oracle.graal.hotspot.InitTimer.*; import static com.oracle.graal.hotspot.meta.HotSpotSuitesProvider.*; import static com.oracle.graal.nodes.StructuredGraph.*; -import static com.oracle.graal.phases.common.inlining.InliningUtil.*; import java.lang.management.*; import java.util.concurrent.*; @@ -126,7 +125,12 @@ /** * Time spent in compilation. */ - public static final DebugTimer CompilationTime = Debug.timer("CompilationTime"); + private static final DebugTimer CompilationTime = Debug.timer("CompilationTime"); + + /** + * Meters the {@linkplain StructuredGraph#getBytecodeSize() bytecodes} compiled. + */ + private static final DebugMetric CompiledBytecodes = Debug.metric("CompiledBytecodes"); public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation"); @@ -161,8 +165,7 @@ public void runCompilation() { HotSpotVMConfig config = backend.getRuntime().getConfig(); final long threadId = Thread.currentThread().getId(); - long previousInlinedBytecodes = InlinedBytecodes.getCurrentValue(); - long previousCompilationTime = CompilationTime.getCurrentValue(); + long startCompilationTime = System.nanoTime(); HotSpotInstalledCode installedCode = null; final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; @@ -193,14 +196,11 @@ // Begin the compilation event. compilationEvent.begin(); - boolean recordEvolMethodDeps = graalEnv == 0 || unsafe.getByte(graalEnv + config.graalEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0; - HotSpotProviders providers = backend.getProviders(); graph = new StructuredGraph(method, entryBCI, AllowAssumptions.from(OptAssumptions.getValue())); - if (!recordEvolMethodDeps) { + if (shouldDisableMethodInliningRecording(config)) { graph.disableInlinedMethodRecording(); } - InlinedBytecodes.add(method.getCodeSize()); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); if (graph.getEntryBCI() != StructuredGraph.INVOCATION_ENTRY_BCI) { // for OSR, only a pointer is passed to the method. @@ -280,7 +280,8 @@ System.exit(-1); } } finally { - final int processedBytes = (int) (InlinedBytecodes.getCurrentValue() - previousInlinedBytecodes); + final int compiledBytecodes = graph.getBytecodeSize(); + CompiledBytecodes.add(compiledBytecodes); // Log a compilation event. if (compilationEvent.shouldWrite() && installedCode != null) { @@ -290,25 +291,40 @@ compilationEvent.setSucceeded(true); compilationEvent.setIsOsr(isOSR); compilationEvent.setCodeSize(installedCode.getSize()); - compilationEvent.setInlinedBytes(processedBytes); + compilationEvent.setInlinedBytes(compiledBytecodes); compilationEvent.commit(); } if (graalEnv != 0) { long ctask = unsafe.getAddress(graalEnv + config.graalEnvTaskOffset); assert ctask != 0L; - unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, processedBytes); + unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, compiledBytecodes); } + long compilationTime = System.nanoTime() - startCompilationTime; if ((config.ciTime || config.ciTimeEach) && installedCode != null) { - long time = CompilationTime.getCurrentValue() - previousCompilationTime; - TimeUnit timeUnit = CompilationTime.getTimeUnit(); - long timeUnitsPerSecond = timeUnit.convert(1, TimeUnit.SECONDS); + long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); CompilerToVM c2vm = backend.getRuntime().getCompilerToVM(); - c2vm.notifyCompilationStatistics(id, method, entryBCI != INVOCATION_ENTRY_BCI, processedBytes, time, timeUnitsPerSecond, installedCode); + c2vm.notifyCompilationStatistics(id, method, entryBCI != INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode); } } } + /** + * Determines whether to {@linkplain StructuredGraph#disableInlinedMethodRecording() disable} + * method inlining recording for the method being compiled. + * + * @see StructuredGraph#getBytecodeSize() + */ + private boolean shouldDisableMethodInliningRecording(HotSpotVMConfig config) { + if (config.ciTime || config.ciTimeEach || CompiledBytecodes.isEnabled()) { + return false; + } + if (graalEnv == 0 || unsafe.getByte(graalEnv + config.graalEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) { + return false; + } + return true; + } + private String getMethodDescription() { return String.format("%-6d Graal %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(), entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ");