changeset 4670:41034914e2ee

add MethodContents assumption to fix debbugging issue
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 22 Feb 2012 17:04:27 +0100
parents a6d18567b2ff
children 70b7b7071e68
files graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiAssumptions.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java src/share/vm/classfile/systemDictionary.hpp src/share/vm/classfile/vmSymbols.hpp src/share/vm/graal/graalCodeInstaller.cpp src/share/vm/graal/graalCodeInstaller.hpp src/share/vm/graal/graalJavaAccess.hpp
diffstat 8 files changed, 69 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiAssumptions.java	Tue Feb 21 16:23:44 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiAssumptions.java	Wed Feb 22 17:04:27 2012 +0100
@@ -34,16 +34,10 @@
  */
 public final class CiAssumptions implements Serializable, Iterable<CiAssumptions.Assumption> {
 
-    /**
-     *
-     */
     private static final long serialVersionUID = 5152062717588239131L;
 
     public abstract static class Assumption implements Serializable {
 
-        /**
-         *
-         */
         private static final long serialVersionUID = -1936652569665112915L;
     }
 
@@ -51,9 +45,7 @@
      * An assumption about a unique subtype of a given type.
      */
     public static final class ConcreteSubtype extends Assumption {
-        /**
-         *
-         */
+
         private static final long serialVersionUID = -1457173265437676252L;
 
         /**
@@ -95,9 +87,6 @@
      */
     public static final class ConcreteMethod extends Assumption {
 
-        /**
-         *
-         */
         private static final long serialVersionUID = -7636746737947390059L;
 
         /**
@@ -143,6 +132,37 @@
     }
 
     /**
+     * An assumption that specified that a method was used during the compilation.
+     */
+    public static final class MethodContents extends Assumption {
+
+        private static final long serialVersionUID = -4821594103928571659L;
+
+        public final RiResolvedMethod method;
+
+        public MethodContents(RiResolvedMethod method) {
+            this.method = method;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + method.hashCode();
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof ConcreteMethod) {
+                ConcreteMethod other = (ConcreteMethod) obj;
+                return other.method == method;
+            }
+            return false;
+        }
+    }
+
+    /**
      * Array with the assumptions. This field is directly accessed from C++ code in the Graal/HotSpot implementation.
      */
     private Assumption[] list;
@@ -209,6 +229,15 @@
         record(new ConcreteMethod(method, context, impl));
     }
 
+    /**
+     * Records that {@code method} was used during the compilation.
+     *
+     * @param method a method whose contents were used
+     */
+    public void recordMethodContents(RiResolvedMethod method) {
+        record(new MethodContents(method));
+    }
+
     private void record(Assumption assumption) {
         if (list == null) {
             list = new Assumption[4];
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Tue Feb 21 16:23:44 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Wed Feb 22 17:04:27 2012 +0100
@@ -197,6 +197,11 @@
         assumptions.recordConcreteMethod(method, context, impl);
     }
 
+    @Override
+    public void recordMethodContentsAssumption(RiResolvedMethod method) {
+        assumptions.recordMethodContents(method);
+    }
+
     private static int computeInliningLevel(Invoke invoke) {
         int count = 0;
         FrameState curState = invoke.stateAfter();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Tue Feb 21 16:23:44 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Wed Feb 22 17:04:27 2012 +0100
@@ -48,6 +48,7 @@
     public interface InliningCallback {
         StructuredGraph buildGraph(RiResolvedMethod method);
         double inliningWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke);
+        void recordMethodContentsAssumption(RiResolvedMethod method);
         void recordConcreteMethodAssumption(RiResolvedMethod method, RiResolvedType context, RiResolvedMethod impl);
     }
 
@@ -129,6 +130,7 @@
         public void inline(StructuredGraph compilerGraph, GraalRuntime runtime, final InliningCallback callback) {
             StructuredGraph graph = getGraph(concrete, callback);
             assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime);
+            callback.recordMethodContentsAssumption(concrete);
             InliningUtil.inline(invoke, graph, true);
         }
 
@@ -189,6 +191,7 @@
 
             StructuredGraph calleeGraph = getGraph(concrete, callback);
             assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime);
+            callback.recordMethodContentsAssumption(concrete);
             InliningUtil.inline(invoke, calleeGraph, false);
         }
 
@@ -333,6 +336,7 @@
 
                 RiResolvedMethod concrete = concretes.get(i);
                 StructuredGraph calleeGraph = getGraph(concrete, callback);
+                callback.recordMethodContentsAssumption(concrete);
                 assert !IntrinsificationPhase.canIntrinsify(invokeForInlining, concrete, runtime);
                 InliningUtil.inline(invokeForInlining, calleeGraph, false);
             }
@@ -371,6 +375,7 @@
             RiResolvedMethod concrete = concretes.get(0);
             StructuredGraph calleeGraph = getGraph(concrete, callback);
             assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime);
+            callback.recordMethodContentsAssumption(concrete);
             InliningUtil.inline(invoke, calleeGraph, false);
         }
 
--- a/src/share/vm/classfile/systemDictionary.hpp	Tue Feb 21 16:23:44 2012 -0800
+++ b/src/share/vm/classfile/systemDictionary.hpp	Wed Feb 22 17:04:27 2012 +0100
@@ -198,6 +198,7 @@
   template(HotSpotExceptionHandler_klass,         com_oracle_max_graal_hotspot_HotSpotExceptionHandler,             Opt) \
   template(HotSpotProxy_klass,                    com_oracle_max_graal_hotspot_HotSpotProxy,                        Opt) \
   template(CiAssumptions_klass,                   com_oracle_max_cri_ci_CiAssumptions,                              Opt) \
+  template(CiAssumptions_MethodContents_klass,    com_oracle_max_cri_ci_CiAssumptions_MethodContents,               Opt) \
   template(CiAssumptions_ConcreteSubtype_klass,   com_oracle_max_cri_ci_CiAssumptions_ConcreteSubtype,              Opt) \
   template(CiAssumptions_ConcreteMethod_klass,    com_oracle_max_cri_ci_CiAssumptions_ConcreteMethod,               Opt) \
   template(CiTargetMethod_klass,                  com_oracle_max_cri_ci_CiTargetMethod,                             Opt) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Tue Feb 21 16:23:44 2012 -0800
+++ b/src/share/vm/classfile/vmSymbols.hpp	Wed Feb 22 17:04:27 2012 +0100
@@ -288,6 +288,7 @@
   template(com_oracle_max_cri_ri_RiConstantPool,                      "com/oracle/max/cri/ri/RiConstantPool")                             \
   template(com_oracle_max_cri_ri_RiExceptionHandler,                  "com/oracle/max/cri/ri/RiExceptionHandler")                         \
   template(com_oracle_max_cri_ci_CiAssumptions,                       "com/oracle/max/cri/ci/CiAssumptions")                              \
+  template(com_oracle_max_cri_ci_CiAssumptions_MethodContents,        "com/oracle/max/cri/ci/CiAssumptions$MethodContents")               \
   template(com_oracle_max_cri_ci_CiAssumptions_ConcreteSubtype,       "com/oracle/max/cri/ci/CiAssumptions$ConcreteSubtype")              \
   template(com_oracle_max_cri_ci_CiAssumptions_ConcreteMethod,        "com/oracle/max/cri/ci/CiAssumptions$ConcreteMethod")               \
   template(com_oracle_max_cri_ci_CiGenericCallback,                   "com/oracle/max/cri/ci/CiGenericCallback")                          \
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Tue Feb 21 16:23:44 2012 -0800
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Wed Feb 22 17:04:27 2012 +0100
@@ -245,7 +245,9 @@
     for (int i = 0; i < length; ++i) {
       Handle assumption = assumptions->obj_at(i);
       if (!assumption.is_null()) {
-        if (assumption->klass() == CiAssumptions_ConcreteSubtype::klass()) {
+        if (assumption->klass() == CiAssumptions_MethodContents::klass()) {
+          assumption_MethodContents(assumption);
+        } else if (assumption->klass() == CiAssumptions_ConcreteSubtype::klass()) {
           assumption_ConcreteSubtype(assumption);
         } else if (assumption->klass() == CiAssumptions_ConcreteMethod::klass()) {
           assumption_ConcreteMethod(assumption);
@@ -371,6 +373,14 @@
   }
 }
 
+void CodeInstaller::assumption_MethodContents(Handle assumption) {
+  Handle method_handle = CiAssumptions_MethodContents::method(assumption());
+  methodHandle method = getMethodFromHotSpotMethod(method_handle());
+  ciMethod* m = (ciMethod*) CURRENT_ENV->get_object(method());
+
+  _dependencies->assert_evol_method(m);
+}
+
 void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) {
   Handle context_handle = CiAssumptions_ConcreteSubtype::context(assumption());
   ciKlass* context = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(context_handle)));
--- a/src/share/vm/graal/graalCodeInstaller.hpp	Tue Feb 21 16:23:44 2012 -0800
+++ b/src/share/vm/graal/graalCodeInstaller.hpp	Wed Feb 22 17:04:27 2012 +0100
@@ -97,6 +97,7 @@
   // perform data and call relocation on the CodeBuffer
   void initialize_buffer(CodeBuffer& buffer);
 
+  void assumption_MethodContents(Handle assumption);
   void assumption_ConcreteSubtype(Handle assumption);
   void assumption_ConcreteMethod(Handle assumption);
 
--- a/src/share/vm/graal/graalJavaAccess.hpp	Tue Feb 21 16:23:44 2012 -0800
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Wed Feb 22 17:04:27 2012 +0100
@@ -115,12 +115,15 @@
   start_class(CiAssumptions)                                                            \
     oop_field(CiAssumptions, list, "[Lcom/oracle/max/cri/ci/CiAssumptions$Assumption;") \
   end_class                                                                             \
+  start_class(CiAssumptions_MethodContents)                                             \
+    oop_field(CiAssumptions_MethodContents, method, "Lcom/oracle/max/cri/ri/RiResolvedMethod;") \
+  end_class                                                                             \
   start_class(CiAssumptions_ConcreteSubtype)                                            \
     oop_field(CiAssumptions_ConcreteSubtype, context, "Lcom/oracle/max/cri/ri/RiResolvedType;") \
     oop_field(CiAssumptions_ConcreteSubtype, subtype, "Lcom/oracle/max/cri/ri/RiResolvedType;") \
   end_class                                                                             \
   start_class(CiAssumptions_ConcreteMethod)                                             \
-  oop_field(CiAssumptions_ConcreteMethod, method, "Lcom/oracle/max/cri/ri/RiResolvedMethod;") \
+    oop_field(CiAssumptions_ConcreteMethod, method, "Lcom/oracle/max/cri/ri/RiResolvedMethod;") \
     oop_field(CiAssumptions_ConcreteMethod, context, "Lcom/oracle/max/cri/ri/RiResolvedType;") \
     oop_field(CiAssumptions_ConcreteMethod, impl, "Lcom/oracle/max/cri/ri/RiResolvedMethod;") \
   end_class                                                                             \