changeset 18346:ddd7829c45b1

made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
author Doug Simon <doug.simon@oracle.com>
date Wed, 12 Nov 2014 12:55:21 +0100
parents 343ca85103f2
children 4571c14bb4ef
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java mx/mx_graal.py
diffstat 2 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Wed Nov 12 10:56:21 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Wed Nov 12 12:55:21 2014 +0100
@@ -145,7 +145,38 @@
                 hcf.addComment(mark.pcOffset, MarkId.getEnum((int) mark.id).toString());
             }
         }
-        return hcf.toEmbeddedString();
+        String hcfEmbeddedString = hcf.toEmbeddedString();
+        return HexCodeFileDisTool.tryDisassemble(hcfEmbeddedString);
+    }
+
+    /**
+     * Interface to the tool for disassembling an {@link HexCodeFile#toEmbeddedString() embedded}
+     * {@link HexCodeFile}.
+     */
+    static class HexCodeFileDisTool {
+        static final Method processMethod;
+        static {
+            Method toolMethod = null;
+            try {
+                Class<?> toolClass = Class.forName("com.oracle.max.hcfdis.HexCodeFileDis", true, ClassLoader.getSystemClassLoader());
+                toolMethod = toolClass.getDeclaredMethod("processEmbeddedString", String.class);
+            } catch (Exception e) {
+                // Tool not available on the class path
+            }
+            processMethod = toolMethod;
+        }
+
+        public static String tryDisassemble(String hcfEmbeddedString) {
+            if (processMethod != null) {
+                try {
+                    return (String) processMethod.invoke(null, hcfEmbeddedString);
+                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+                    // If the tool is available, for now let's be noisy when it fails
+                    throw new GraalInternalError(e);
+                }
+            }
+            return hcfEmbeddedString;
+        }
     }
 
     /**
--- a/mx/mx_graal.py	Wed Nov 12 10:56:21 2014 +0100
+++ b/mx/mx_graal.py	Wed Nov 12 12:55:21 2014 +0100
@@ -1146,7 +1146,8 @@
     if testfile is None:
         (_, testfile) = tempfile.mkstemp(".testclasses", "graal")
         os.close(_)
-    coreCp = mx.classpath(['com.oracle.graal.test'])
+        
+    coreCp = mx.classpath(['com.oracle.graal.test', 'HCFDIS'])
 
     coreArgs = []
     if verbose: