You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/09/28 07:14:46 UTC
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
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;