changeset 12555:2d11b9128e01

renamed TruffleIRJavaMethod to TruffleDebugJavaMethod and made Truffle debug scopes more consistent in its usage
author Doug Simon <doug.simon@oracle.com>
date Thu, 24 Oct 2013 12:23:52 +0200
parents c41342332b7f
children b247ddd2fa0f 1c8d5a0891b5
files graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleIRJavaMethod.java
diffstat 5 files changed, 143 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java	Wed Oct 23 17:12:30 2013 -0700
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java	Thu Oct 24 12:23:52 2013 +0200
@@ -102,7 +102,7 @@
             compilable.call(null, arguments);
         } while (compilable.inline());
 
-        StructuredGraph graph = Debug.scope("TruffleCompilation", new DebugDumpScope("TruffleCompilation: " + compilable), new Callable<StructuredGraph>() {
+        StructuredGraph graph = Debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable), new Callable<StructuredGraph>() {
 
             @Override
             public StructuredGraph call() {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Oct 23 17:12:30 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Thu Oct 24 12:23:52 2013 +0200
@@ -104,7 +104,7 @@
 
         final StructuredGraph graph = new StructuredGraph(executeHelperMethod);
 
-        Debug.scope("createGraph", graph, new Runnable() {
+        Debug.scope("createGraph", new Runnable() {
 
             @Override
             public void run() {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Wed Oct 23 17:12:30 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Thu Oct 24 12:23:52 2013 +0200
@@ -95,7 +95,7 @@
     }
 
     public InstalledCode compile(final OptimizedCallTarget compilable) {
-        Object[] debug = new Object[]{new DebugDumpScope("Truffle: " + compilable)};
+        Object[] debug = new Object[]{new TruffleDebugJavaMethod(compilable)};
         return Debug.scope("Truffle", debug, new Callable<InstalledCode>() {
 
             @Override
@@ -132,14 +132,17 @@
     }
 
     public InstalledCode compileMethodHelper(final StructuredGraph graph, final GraphBuilderConfiguration config, final Assumptions assumptions) {
-        return compileMethodHelper(graph, config, null, assumptions);
+        return Debug.scope("Truffle", graph, new Callable<InstalledCode>() {
+            public InstalledCode call() throws Exception {
+                return compileMethodHelper(graph, config, null, assumptions);
+            }
+        });
     }
 
     public InstalledCode compileMethodHelper(final StructuredGraph graph, final GraphBuilderConfiguration config, final OptimizedCallTarget compilable, final Assumptions assumptions) {
         final PhasePlan plan = createPhasePlan(config);
-        final TruffleIRJavaMethod truffleJavaMethod = new TruffleIRJavaMethod(providers.getMetaAccess(), compilable);
 
-        Debug.scope("TruffleFinal", graph, new Runnable() {
+        Debug.scope("TruffleFinal", new Runnable() {
 
             @Override
             public void run() {
@@ -152,7 +155,7 @@
             @Override
             public CompilationResult call() {
                 try (TimerCloseable a = CompilationTime.start()) {
-                    return Debug.scope("GraalCompiler", new Object[]{truffleJavaMethod, providers.getCodeCache()}, new Callable<CompilationResult>() {
+                    return Debug.scope("GraalCompiler", new Object[]{providers.getCodeCache()}, new Callable<CompilationResult>() {
                         public CompilationResult call() {
                             CodeCacheProvider codeCache = providers.getCodeCache();
                             CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false);
@@ -181,7 +184,7 @@
 
         result.setAssumptions(newAssumptions);
 
-        InstalledCode compiledMethod = Debug.scope("CodeInstall", new Object[]{truffleJavaMethod, providers.getCodeCache()}, new Callable<InstalledCode>() {
+        InstalledCode compiledMethod = Debug.scope("CodeInstall", new Object[]{providers.getCodeCache()}, new Callable<InstalledCode>() {
 
             @Override
             public InstalledCode call() throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java	Thu Oct 24 12:23:52 2013 +0200
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.truffle;
+
+import static com.oracle.graal.api.meta.MetaUtil.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.debug.*;
+import com.oracle.truffle.api.impl.*;
+
+/**
+ * Enables a Truffle compilable to masquerade as a {@link JavaMethod} for use as a context value in
+ * {@linkplain Debug#scope(String, Object[], Runnable) debug scopes}.
+ */
+public class TruffleDebugJavaMethod implements JavaMethod {
+    private final DefaultCallTarget compilable;
+
+    private static final JavaType declaringClass = new JavaType() {
+
+        public String getName() {
+            return "LTruffle;";
+        }
+
+        public JavaType getComponentType() {
+            return null;
+        }
+
+        public JavaType getArrayClass() {
+            throw new UnsupportedOperationException();
+        }
+
+        public Kind getKind() {
+            return Kind.Object;
+        }
+
+        public ResolvedJavaType resolve(ResolvedJavaType accessingClass) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return obj.getClass() == getClass();
+        }
+
+        @Override
+        public int hashCode() {
+            return getName().hashCode();
+        }
+    };
+
+    private static final Signature signature = new Signature() {
+
+        public JavaType getReturnType(ResolvedJavaType accessingClass) {
+            return declaringClass;
+        }
+
+        public Kind getReturnKind() {
+            return declaringClass.getKind();
+        }
+
+        public JavaType getParameterType(int index, ResolvedJavaType accessingClass) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        public int getParameterSlots(boolean withReceiver) {
+            return 0;
+        }
+
+        public Kind getParameterKind(int index) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        public int getParameterCount(boolean receiver) {
+            return 0;
+        }
+    };
+
+    public TruffleDebugJavaMethod(DefaultCallTarget compilable) {
+        this.compilable = compilable;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof TruffleDebugJavaMethod) {
+            TruffleDebugJavaMethod other = (TruffleDebugJavaMethod) obj;
+            return other.compilable.equals(compilable);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return compilable.hashCode();
+    }
+
+    public Signature getSignature() {
+        return signature;
+    }
+
+    public String getName() {
+        return compilable.toString().replace('.', '_').replace(' ', '_');
+    }
+
+    public JavaType getDeclaringClass() {
+        return declaringClass;
+    }
+
+    @Override
+    public String toString() {
+        return format("Truffle<%n(%p)>", this);
+    }
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleIRJavaMethod.java	Wed Oct 23 17:12:30 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.truffle;
-
-import static com.oracle.graal.api.meta.MetaUtil.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.debug.*;
-import com.oracle.truffle.api.impl.*;
-
-/**
- * Enables a Truffle compilable to masquerade as a {@link JavaMethod} for use as a context value in
- * {@linkplain Debug#scope(String, Object[], Runnable) debug scopes}.
- */
-class TruffleIRJavaMethod implements JavaMethod {
-    private final MetaAccessProvider metaAccess;
-    private final DefaultCallTarget compilable;
-
-    public TruffleIRJavaMethod(MetaAccessProvider metaAccess, DefaultCallTarget compilable) {
-        this.metaAccess = metaAccess;
-        this.compilable = compilable;
-    }
-
-    public Signature getSignature() {
-        return metaAccess.parseMethodDescriptor("()V");
-    }
-
-    public String getName() {
-        return compilable.toString().replace('.', '_').replace(' ', '_');
-    }
-
-    public JavaType getDeclaringClass() {
-        return metaAccess.lookupJavaType(getClass());
-    }
-
-    @Override
-    public String toString() {
-        return format(getClass().getSimpleName() + "<%n(%p)>", this);
-    }
-}