Mercurial > hg > truffle
changeset 15217:ec7d8b646b9f
Truffle: Fixed display of installed code size.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 17 Apr 2014 23:25:42 +0200 |
parents | d59f48be0ed6 |
children | 24dbd4a59490 |
files | graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java |
diffstat | 3 files changed, 10 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java Thu Apr 17 23:16:21 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java Thu Apr 17 23:25:42 2014 +0200 @@ -38,8 +38,8 @@ * @param method a method to which the executable code is begin added * @param compResult the compilation result to be added * @param speculationLog the speculation log to be used - * @return a reference to the compiled and ready-to-run code or null if the code installation - * failed + * @return a reference to the compiled and ready-to-run code or throws a + * {@link BailoutException} if the code installation failed */ InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog speculationLog, InstalledCode predefinedInstalledCode);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Thu Apr 17 23:16:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Thu Apr 17 23:25:42 2014 +0200 @@ -228,7 +228,7 @@ } CodeInstallResult result = runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target, hotspotMethod, compResult), installedCode, log); if (result != CodeInstallResult.OK) { - return null; + throw new BailoutException("Code installation failed: " + result); } return logOrDump(installedCode, compResult); }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Thu Apr 17 23:16:21 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Thu Apr 17 23:25:42 2014 +0200 @@ -27,6 +27,7 @@ import static com.oracle.graal.truffle.TruffleCompilerOptions.*; import java.util.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.Assumptions.Assumption; import com.oracle.graal.api.code.CallingConvention.Type; @@ -101,7 +102,7 @@ public static final DebugTimer CompilationTime = Debug.timer("CompilationTime"); public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation"); - public InstalledCode compileMethodImpl(final OptimizedCallTarget compilable) { + public void compileMethodImpl(final OptimizedCallTarget compilable) { final StructuredGraph graph; if (TraceTruffleCompilation.getValue()) { @@ -115,21 +116,16 @@ } if (Thread.currentThread().isInterrupted()) { - return null; + return; } long timePartialEvaluationFinished = System.nanoTime(); int nodeCountPartialEval = graph.getNodeCount(); - InstalledCode compiledMethod = compileMethodHelper(graph, assumptions, compilable.toString(), compilable.getSpeculationLog(), compilable); + CompilationResult compilationResult = compileMethodHelper(graph, assumptions, compilable.toString(), compilable.getSpeculationLog(), compilable); long timeCompilationFinished = System.nanoTime(); int nodeCountLowered = graph.getNodeCount(); - if (!compiledMethod.isValid()) { - throw new BailoutException("Could not install method, code cache is full!"); - } - if (TraceTruffleCompilation.getValue()) { - byte[] code = compiledMethod.getCode(); int calls = OptimizedCallUtils.countCalls(compilable); int inlinedCalls = OptimizedCallUtils.countCallsInlined(compilable); int dispatchedCalls = calls - inlinedCalls; @@ -141,19 +137,18 @@ (timeCompilationFinished - timePartialEvaluationFinished) / 1e6)); properties.put("CallNodes", String.format("I %5d/D %5d", inlinedCalls, dispatchedCalls)); properties.put("GraalNodes", String.format("%5d/%5d", nodeCountPartialEval, nodeCountLowered)); - properties.put("CodeSize", code != null ? code.length : 0); + properties.put("CodeSize", compilationResult.getTargetCodeSize()); properties.put("Source", formatSourceSection(compilable.getRootNode().getSourceSection())); OptimizedCallTargetLog.logOptimizingDone(compilable, properties); } - return compiledMethod; } private static String formatSourceSection(SourceSection sourceSection) { return sourceSection != null ? sourceSection.toString() : "n/a"; } - public InstalledCode compileMethodHelper(StructuredGraph graph, Assumptions assumptions, String name, SpeculationLog speculationLog, InstalledCode predefinedInstalledCode) { + public CompilationResult compileMethodHelper(StructuredGraph graph, Assumptions assumptions, String name, SpeculationLog speculationLog, InstalledCode predefinedInstalledCode) { try (Scope s = Debug.scope("TruffleFinal")) { Debug.dump(graph, "After TruffleTier"); } catch (Throwable e) { @@ -201,7 +196,7 @@ if (Debug.isLogEnabled()) { Debug.log(providers.getCodeCache().disassemble(result, installedCode)); } - return installedCode; + return result; } private PhaseSuite<HighTierContext> createGraphBuilderSuite() {