changeset 13233:8ea51438445c

consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
author Doug Simon <doug.simon@oracle.com>
date Tue, 03 Dec 2013 17:11:06 +0100
parents f1f33d1ff3e2
children 7e237378923d
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java
diffstat 6 files changed, 23 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Dec 03 16:53:21 2013 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Dec 03 17:11:06 2013 +0100
@@ -562,24 +562,10 @@
             }
 
             try (Scope s = Debug.scope("CodeInstall", getCodeCache(), method)) {
-                InstalledCode code = addMethod(method, compResult);
-                if (code == null) {
+                installedCode = addMethod(method, compResult);
+                if (installedCode == null) {
                     throw new GraalInternalError("Could not install code for " + MetaUtil.format("%H.%n(%p)", method));
                 }
-                if (Debug.isDumpEnabled()) {
-                    Debug.dump(new Object[]{compResult, code}, "After code installation");
-                }
-                if (Debug.isLogEnabled()) {
-                    DisassemblerProvider dis = backend.getDisassembler();
-                    if (dis != null) {
-                        String text = dis.disassemble(code);
-                        if (text != null) {
-                            Debug.log("Code installed for %s%n%s", method, text);
-                        }
-                    }
-                }
-
-                installedCode = code;
             } catch (Throwable e) {
                 throw Debug.handle(e);
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Tue Dec 03 16:53:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Tue Dec 03 17:11:06 2013 +0100
@@ -233,12 +233,6 @@
         HotSpotInstalledCode installedCode = null;
         try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) {
             installedCode = codeCache.installMethod(method, entryBCI, compResult);
-            if (Debug.isDumpEnabled()) {
-                Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
-            }
-            if (Debug.isLogEnabled()) {
-                Debug.log("%s", backend.getProviders().getDisassembler().disassemble(installedCode));
-            }
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Tue Dec 03 16:53:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Tue Dec 03 17:11:06 2013 +0100
@@ -32,6 +32,7 @@
 import com.oracle.graal.api.code.CompilationResult.Infopoint;
 import com.oracle.graal.api.code.CompilationResult.Mark;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.debug.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
@@ -157,10 +158,20 @@
         return runtime.getConfig().runtimeCallStackSize;
     }
 
+    public HotSpotInstalledCode logOrDump(HotSpotInstalledCode installedCode, CompilationResult compResult) {
+        if (Debug.isDumpEnabled()) {
+            Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
+        }
+        if (Debug.isLogEnabled()) {
+            Debug.log("%s", disassemble(installedCode));
+        }
+        return installedCode;
+    }
+
     public HotSpotInstalledCode installMethod(HotSpotResolvedJavaMethod method, int entryBCI, CompilationResult compResult) {
         HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), true);
         runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, entryBCI, compResult), installedCode, method.getSpeculationLog());
-        return installedCode;
+        return logOrDump(installedCode, compResult);
     }
 
     @Override
@@ -171,7 +182,7 @@
         if (result != CodeInstallResult.OK) {
             return null;
         }
-        return code;
+        return logOrDump(code, compResult);
     }
 
     public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) {
@@ -180,7 +191,6 @@
     }
 
     public InstalledCode addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult) {
-
         HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method;
         HotSpotInstalledCode icode = new HotSpotNmethod(javaMethod, compResult.getName(), false, true);
         HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, -1, compResult);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Tue Dec 03 16:53:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Tue Dec 03 17:11:06 2013 +0100
@@ -160,16 +160,12 @@
                     Stub stub = Stub.this;
                     HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub);
                     HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult);
+
                     CodeInstallResult result = runtime().getCompilerToVM().installCode(hsCompResult, installedCode, null);
                     if (result != CodeInstallResult.OK) {
                         throw new GraalInternalError("Error installing stub %s: %s", Stub.this, result);
                     }
-                    if (Debug.isDumpEnabled()) {
-                        Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
-                    }
-                    if (Debug.isLogEnabled()) {
-                        Debug.log("%s", providers.getDisassembler().disassemble(installedCode));
-                    }
+                    ((HotSpotCodeCacheProvider) codeCache).logOrDump(installedCode, compResult);
                     code = installedCode;
                 } catch (Throwable e) {
                     throw Debug.handle(e);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Tue Dec 03 16:53:21 2013 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Tue Dec 03 17:11:06 2013 +0100
@@ -167,10 +167,7 @@
         ResolvedJavaMethod resolvedCallMethod = metaAccess.lookupJavaMethod(getCallMethod());
         CompilationResult compResult = compileMethod(resolvedCallMethod);
         try (Scope s = Debug.scope("CodeInstall", codeCache, resolvedCallMethod)) {
-            InstalledCode installedCode = codeCache.setDefaultMethod(resolvedCallMethod, compResult);
-            if (Debug.isDumpEnabled()) {
-                Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
-            }
+            codeCache.setDefaultMethod(resolvedCallMethod, compResult);
         }
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Tue Dec 03 16:53:21 2013 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Tue Dec 03 17:11:06 2013 +0100
@@ -244,25 +244,21 @@
 
         result.setAssumptions(newAssumptions);
 
-        InstalledCode compiledMethod = null;
+        InstalledCode installedCode = null;
         try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache()); TimerCloseable a = CodeInstallationTime.start()) {
-            InstalledCode installedCode = providers.getCodeCache().addMethod(graph.method(), result);
-            if (installedCode != null) {
-                Debug.dump(new Object[]{result, installedCode}, "After code installation");
-            }
-            compiledMethod = installedCode;
+            installedCode = providers.getCodeCache().addMethod(graph.method(), result);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
 
         for (AssumptionValidAssumption a : validAssumptions) {
-            a.getAssumption().registerInstalledCode(compiledMethod);
+            a.getAssumption().registerInstalledCode(installedCode);
         }
 
         if (Debug.isLogEnabled()) {
-            Debug.log(providers.getCodeCache().disassemble(result, compiledMethod));
+            Debug.log(providers.getCodeCache().disassemble(result, installedCode));
         }
-        return compiledMethod;
+        return installedCode;
     }
 
     private PhasePlan createPhasePlan(final GraphBuilderConfiguration config) {