harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r449252 - in /incubator/harmony/enhanced/drlvm/trunk/vm/gc/src: collect.cpp gc_for_vm.cpp gc_types.h selector.cpp
Date Sat, 23 Sep 2006 14:43:49 GMT
Author: geirm
Date: Sat Sep 23 07:43:49 2006
New Revision: 449252

URL: http://svn.apache.org/viewvc?view=rev&rev=449252
Log:
HARMONY-1371
Allocation path optimization: reduced cleaned in advance memory.
Fixed dead finalizible objects detection algorithm.
Disabled force_gc() algorithm: triggers finalization problem on dacapo benchmark.

Ubuntu 6 - Applied both patches - smoke, c-unit
 

Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/collect.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_for_vm.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_types.h
    incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/selector.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/collect.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/collect.cpp?view=diff&rev=449252&r1=449251&r2=449252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/collect.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/collect.cpp Sat Sep 23 07:43:49 2006
@@ -113,6 +113,7 @@
     while(info) {
         info->tls_current_free = 0;
         info->tls_current_ceiling = 0;
+        info->tls_current_cleaned = 0;
         info = info->next;
     }
 }
@@ -159,7 +160,6 @@
             // not marked
             TRACE2("gc.debug", "0x" << obj << " referenced from finalizible objects
(unmarked)");
             to_finalize.push_back(obj);
-            gc_add_root_set_entry((Managed_Object_Handle*)&to_finalize.back(), false);
 
             // removing this object from vector, replacing it with last one.
             *i = finalizible_objects.pop_back();
@@ -167,7 +167,13 @@
         }
         ++i;
     }
+
     if (!to_finalize.empty()) {
+        for(reference_vector::iterator i = to_finalize.begin();
+                i != to_finalize.end(); ++i) {
+            gc_add_root_set_entry((Managed_Object_Handle*)&*i, false);
+        }
+
         pending_finalizers = true;
         TRACE2("gc.finalize", to_finalize.count() << " objects to be finalized");
     }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_for_vm.cpp?view=diff&rev=449252&r1=449251&r2=449252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_for_vm.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_for_vm.cpp Sat Sep 23 07:43:49 2006
@@ -70,7 +70,7 @@
 Boolean gc_supports_frontier_allocation(unsigned *offset_of_current, unsigned *offset_of_limit)
{
     // Need additional support for object offset in native stubs.
     *offset_of_current = field_offset(GC_Thread_Info, tls_current_free);
-    *offset_of_limit = field_offset(GC_Thread_Info, tls_current_ceiling);
+    *offset_of_limit = field_offset(GC_Thread_Info, tls_current_cleaned);
     return true;
 }
 
@@ -155,19 +155,42 @@
     //TRACE2("gc.alloc", "gc_alloc_fast");
     assert((in_size % GC_OBJECT_ALIGNMENT) == 0);
     assert (ah);
-    unsigned char *res;
+    unsigned char *next;
 
     GC_Thread_Info *info = (GC_Thread_Info *) thread_pointer;
     Partial_Reveal_VTable *vtable = (Partial_Reveal_VTable*) ah;
     GC_VTable_Info *gcvt = vtable->get_gcvt();
+    unsigned char *cleaned = info->tls_current_cleaned;
+    unsigned char *res = info->tls_current_free;
 
-    // TODO: finalizible objects can be added atomicly and can be handled here
-    if (info->tls_current_free + in_size <= info->tls_current_ceiling &&
!gcvt->is_finalizible()) {
-        res = (unsigned char*) info->tls_current_free;
-        info->tls_current_free += in_size;
+    if (res + in_size <= cleaned) {
+        if (gcvt->is_finalizible()) return 0;
+
+        info->tls_current_free =  res + in_size;
         *(int*)res = ah;
-        return (Managed_Object_Handle)res;
+
+        return res;
+    }
+
+    if (gcvt->is_finalizible()) return 0;
+
+    unsigned char *ceiling = info->tls_current_ceiling;
+
+
+    if (res + in_size <= ceiling) {
+
+        info->tls_current_free = next = info->tls_current_free + in_size;
+
+        // cleaning required
+        unsigned char *cleaned_new = next + THREAD_LOCAL_CLEANED_AREA_SIZE;
+        if (cleaned_new > ceiling) cleaned_new = ceiling;
+        info->tls_current_cleaned = cleaned_new;
+        memset(cleaned, 0, cleaned_new - cleaned);
+        *(int*)res = ah;
+
+        return res;
     }
+
     return 0;
 }
 
@@ -177,17 +200,38 @@
     TRACE2("gc.alloc", "gc_alloc: " << in_size);
     assert((in_size % GC_OBJECT_ALIGNMENT) == 0);
     assert (ah);
-    unsigned char *res;
 
     GC_Thread_Info *info = (GC_Thread_Info *) thread_pointer;
     Partial_Reveal_VTable *vtable = (Partial_Reveal_VTable*) ah;
     GC_VTable_Info *gcvt = vtable->get_gcvt();
+    unsigned char *res = info->tls_current_free;
+    unsigned char *cleaned = info->tls_current_cleaned;
 
-    if (!gcvt->is_finalizible() && info->tls_current_free + in_size <= info->tls_current_ceiling)
{
-        res = (unsigned char*) info->tls_current_free;
-        info->tls_current_free += in_size;
-        *(int*)res = ah;
-        return (Managed_Object_Handle)res;
+    if (!gcvt->is_finalizible()) {
+
+        if (res + in_size <= cleaned) {
+            info->tls_current_free =  res + in_size;
+            *(int*)res = ah;
+
+            return res;
+        }
+
+        unsigned char *ceiling = info->tls_current_ceiling;
+
+        if (res + in_size <= ceiling) {
+            unsigned char *next;
+
+            info->tls_current_free = next = info->tls_current_free + in_size;
+
+            // cleaning required
+            unsigned char *cleaned_new = next + THREAD_LOCAL_CLEANED_AREA_SIZE;
+            if (cleaned_new > ceiling) cleaned_new = ceiling;
+            info->tls_current_cleaned = cleaned_new;
+            memset(cleaned, 0, cleaned_new - cleaned);
+
+            *(int*)res = ah;
+            return (Managed_Object_Handle)res;
+        }
     }
 
     // TODO: can reproduce problems of synchronization of finalizer threads
@@ -275,9 +319,12 @@
     if (info->tls_current_ceiling > heap.pos_limit)
         info->tls_current_ceiling = heap.pos_limit;
     heap.pos = info->tls_current_ceiling;
+    if (cleaning_needed) info->tls_current_cleaned = info->tls_current_free;
+    else info->tls_current_cleaned = info->tls_current_ceiling;
 
     vm_gc_unlock_enum();
-    if (cleaning_needed) memset(res, 0, info->tls_current_ceiling - info->tls_current_free
+ size);
+    if (cleaning_needed) memset(res, 0, size);
+
     *(int*)res = ah;
     return (Managed_Object_Handle)res;
 }
@@ -305,6 +352,7 @@
     GC_Thread_Info *info = (GC_Thread_Info *) gc_information;
     info->tls_current_free = 0;
     info->tls_current_ceiling = 0;
+    info->tls_current_cleaned = 0;
     //info->saved_object = 0;
     spin_lock(&thread_list_lock);
     info->next = thread_list;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_types.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_types.h?view=diff&rev=449252&r1=449251&r2=449252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_types.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_types.h Sat Sep 23 07:43:49 2006
@@ -67,8 +67,11 @@
 extern GC_TYPE gc_type;
 class Partial_Reveal_Object;
 
+#define THREAD_LOCAL_CLEANED_AREA_SIZE 2048
+
 typedef struct GC_Thread_Info {
     unsigned char *tls_current_free;
+    unsigned char *tls_current_cleaned;
     unsigned char *tls_current_ceiling;
 
     GC_Thread_Info *next;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/selector.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/selector.cpp?view=diff&rev=449252&r1=449251&r2=449252
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/selector.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/selector.cpp Sat Sep 23 07:43:49 2006
@@ -292,6 +292,11 @@
         full_gc(0);
         vm_gc_unlock_enum();
         vm_hint_finalize();
+    } else if ((gc_algorithm / 10) == 3) {
+        vm_gc_lock_enum();
+        copy_gc(0);
+        vm_gc_unlock_enum();
+        vm_hint_finalize();
     }
 }
 



Mime
View raw message