harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r450698 - in /incubator/harmony/enhanced/drlvm/trunk: src/test/harmony-1588/ src/test/harmony-1588/Test.java vm/gc/src/gc_for_vm.cpp
Date Thu, 28 Sep 2006 05:14:46 GMT
Author: geirm
Date: Wed Sep 27 22:14:45 2006
New Revision: 450698

URL: http://svn.apache.org/viewvc?view=rev&rev=450698
Log:
HARMONY-1588

fix to incorrect handling of finalizable objects by
GC.

Test included.

Test now passes w/ patch.  Ubuntu 6, smoke and c-unit


Added:
    incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/
    incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/Test.java   (with props)
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/gc/src/gc_for_vm.cpp

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/Test.java?view=auto&rev=450698
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/Test.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/Test.java Wed Sep 27 22:14:45
2006
@@ -0,0 +1,34 @@
+import java.util.Vector;
+
+class Fin {
+    public void finalize() {}
+}
+
+public class Test {
+    public static void main(String[] args) {
+        try {
+            Vector v = new Vector();
+            while (true) {
+                int fin = 0, obj = 0;
+                Object[] array = new Object[4096];
+                for(int i = 0; i < 512; i++) {
+                    array[i * 8] = new Object();
+                    for(int j = 1; j < 8; j++) {
+                        array[i * 8 + j] = new Fin();
+                    }
+                }
+                for(int i = 0; i < 4096; i++) {
+                    if (array[i] instanceof Fin) {
+                        fin++;
+                    } else {
+                        obj++;
+                    }
+                }
+                System.err.print(".");
+                v.add(array);
+            }
+        } catch (OutOfMemoryError e) {
+            System.out.println("PASSED");
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1588/Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=450698&r1=450697&r2=450698
==============================================================================
--- 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 Wed Sep 27 22:14:45 2006
@@ -250,27 +250,33 @@
     if (gcvt->is_finalizible()) {
         unsigned char *obj;
         unsigned char *endpos;
-        bool res = place_into_old_objects(obj, endpos, size);
-        if (res) {
+        bool allocated = place_into_old_objects(obj, endpos, size);
+        if (allocated) {
             memset(obj, 0, size);
             finalizible_objects.push_back((Partial_Reveal_Object*) obj);
             vm_gc_unlock_enum();
             *(int*)obj = ah;
             return (Managed_Object_Handle)obj;
         }
-    }
 
-    if (info->tls_current_free + size <= info->tls_current_ceiling) {
-        res = (unsigned char*) info->tls_current_free;
-        info->tls_current_free += size;
-        assert(!((POINTER_SIZE_INT)res & 3));
+        // reload cached values after possible GC
+        res = info->tls_current_free;
+        cleaned = info->tls_current_cleaned;
 
-        if (gcvt->is_finalizible()) {
+        if (res + size <= info->tls_current_ceiling) {
+            unsigned char *next;
+            info->tls_current_free = next = info->tls_current_free + in_size;
+            assert(!((POINTER_SIZE_INT)res & 3));
             finalizible_objects.push_back((Partial_Reveal_Object*) res);
+
+            if (cleaned < next) {
+                memset(cleaned, 0, next - cleaned);
+                info->tls_current_cleaned = next;
+            }
+            vm_gc_unlock_enum();
+            *(int*)res = ah;
+            return (Managed_Object_Handle)res;
         }
-        vm_gc_unlock_enum();
-        *(int*)res = ah;
-        return (Managed_Object_Handle)res;
     }
 
     res = heap.pos;



Mime
View raw message