changeset 3566:b0d192f86f34

more work on ci removal
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 01 Sep 2011 09:43:10 +0200
parents b3f0f8a01ca2
children dbf8d6a4201f
files src/share/vm/graal/graalCompiler.cpp src/share/vm/graal/graalVMEntries.cpp
diffstat 2 files changed, 31 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompiler.cpp	Wed Aug 31 09:58:35 2011 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Thu Sep 01 09:43:10 2011 +0200
@@ -128,7 +128,13 @@
 }
 
 oop GraalCompiler::get_RiType(KlassHandle klass, KlassHandle accessor, TRAPS) {
-  assert(instanceKlass::cast(klass())->is_initialized(), "unexpected unresolved klass");
+  if (klass->oop_is_instance_slow()) {
+    assert(instanceKlass::cast(klass())->is_initialized(), "unexpected unresolved klass");
+  } else if (klass->oop_is_javaArray_slow()){
+  } else {
+    klass()->print();
+    assert(false, "unexpected klass");
+  }
   Handle name = VmIds::toString<Handle>(klass->name(), THREAD);
   return createHotSpotTypeResolved(klass, name, CHECK_NULL);
 }
--- a/src/share/vm/graal/graalVMEntries.cpp	Wed Aug 31 09:58:35 2011 +0200
+++ b/src/share/vm/graal/graalVMEntries.cpp	Thu Sep 01 09:43:10 2011 +0200
@@ -243,12 +243,17 @@
 // invocation counts in methods.
 int scale_count(methodDataOop method_data, int count) {
   if (count > 0) {
-    int method_life = method_data->method()->invocation_count();
-    int counter_life = method_life - method_data->creation_mileage();
+    int counter_life;
+    int method_life = method_data->method()->interpreter_invocation_count();
+    int current_mileage = methodDataOopDesc::mileage_of(method_data->method());
+    int creation_mileage = method_data->creation_mileage();
+    counter_life = current_mileage - creation_mileage;
 
-    if (method_life > 0 && counter_life > 0 && method_life > counter_life) {
-      double factor = method_life / (double) counter_life;
-      count = (int)(count * factor);
+    // counter_life due to backedge_counter could be > method_life
+    if (counter_life > method_life)
+      counter_life = method_life;
+    if (0 < counter_life && counter_life <= method_life) {
+      count = (int)((double)count * method_life / counter_life + 0.5);
       count = (count > 0) ? count : 1;
     }
   }
@@ -260,9 +265,14 @@
   TRACE_graal_3("VMEntries::RiMethod_typeProfile");
   Handle obj;
   {
-    /*
     VM_ENTRY_MARK;
     methodHandle method = getMethodFromHotSpotMethod(hotspot_method);
+    if (strstr(method->name_and_sig_as_C_string(), "factor") != NULL) {
+//      tty->print_cr("here");
+    }
+    if (bci == 123) {
+//      tty->print_cr("here2");
+    }
     methodDataHandle method_data = method->method_data();
     if (method_data == NULL || !method_data->is_mature()) {
       return NULL;
@@ -272,7 +282,7 @@
       ReceiverTypeData* recv = data->as_ReceiverTypeData();
       // determine morphism
       int morphism = 0;
-      int total_count = 0;
+      uint total_count = 0;
       for (uint i = 0; i < recv->row_limit(); i++) {
         klassOop receiver = recv->receiver(i);
         if (receiver == NULL)  continue;
@@ -280,14 +290,15 @@
         total_count += recv->receiver_count(i);
       }
 
-      if (morphism > 0) {
         instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL);
         obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL);
         assert(obj() != NULL, "must succeed in allocating instance");
 
-        RiTypeProfile::set_count(obj, scale_count(method_data(), recv->count()));
+        int count = MAX2(total_count, recv->count());
+        RiTypeProfile::set_count(obj, scale_count(method_data(), count));
         RiTypeProfile::set_morphism(obj, morphism);
 
+      if (morphism > 0) {
         typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, morphism, CHECK_NULL);
         objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), morphism, CHECK_NULL);
         int pos = 0;
@@ -306,8 +317,11 @@
 
         RiTypeProfile::set_probabilities(obj, probabilities());
         RiTypeProfile::set_types(obj, types());
+      } else {
+        RiTypeProfile::set_probabilities(obj, NULL);
+        RiTypeProfile::set_types(obj, NULL);
       }
-    }*/
+    }
   }
 
   return JNIHandles::make_local(obj());