harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r470923 - in /incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src: collect.cpp collect.h collect_copy.cpp collect_slide_compact.cpp gc_for_vm.cpp gc_types.h init.cpp
Date Fri, 03 Nov 2006 17:40:33 GMT
Author: geirm
Date: Fri Nov  3 09:40:32 2006
New Revision: 470923

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

[DRLVM][GC] jvmti heap iteration support in gcv41

Ubuntu 6 - smoke, c-unit, ~kernel


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.h
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_copy.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_slide_compact.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_types.h
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.cpp?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.cpp Fri Nov  3 09:40:32 2006
@@ -33,6 +33,9 @@
 reference_vector phantom_references;
 reference_vector to_finalize;
 
+slots_vector weak_roots;
+slots_vector phantom_roots;
+
 std::vector<unsigned char*> pinned_areas;
 fast_list<unsigned char*, 1024> pinned_areas_unsorted;
 unsigned pinned_areas_pos = 0;
@@ -192,6 +195,35 @@
     to_finalize.clear();
 }
 
+void process_special_roots(slots_vector& array) {
+    for(slots_vector::iterator i = array.begin();
+            i != array.end(); ++i) {
+        Partial_Reveal_Object **ref = *i;
+
+        Partial_Reveal_Object* obj = *ref;
+
+        if (obj == 0) {
+            // reference already cleared
+            continue;
+        }
+
+        int info = obj->obj_info();
+        if (info & heap_mark_phase) {
+            // object marked, is it moved?
+            int vt = obj->vt();
+            if (!(vt & FORWARDING_BIT)) continue;
+            // moved, updating referent field
+            *ref = fw_to_pointer(vt & ~FORWARDING_BIT);
+            assert((((POINTER_SIZE_INT)*ref) & 3) == 0);
+            continue;
+        }
+
+        // object not marked, clear ref
+        *ref = 0;
+    }
+    array.clear();
+}
+
 void process_special_references(reference_vector& array) {
     for(reference_vector::iterator i = array.begin();
             i != array.end(); ++i) {
@@ -279,11 +311,13 @@
     if (stage == 0) {
         gc_slide_process_special_references(soft_references);
         gc_slide_process_special_references(weak_references);
+        gc_slide_process_special_roots(weak_roots);
         process_finalizable_objects();
     }
     gc_slide_process_special_references(soft_references);
     gc_slide_process_special_references(weak_references);
     gc_slide_process_special_references(phantom_references);
+    gc_slide_process_special_roots(phantom_roots);
 
     TIME(gc_slide_move_all,());
     roots_update();
@@ -344,6 +378,7 @@
     }
     process_special_references(soft_references);
     process_special_references(weak_references);
+    process_special_roots(weak_roots);
     process_finalizable_objects();
     if (gc_type == GC_SLIDE_COMPACT) {
         unsigned char *res = finish_slide_gc(size, 1);
@@ -353,6 +388,7 @@
     process_special_references(soft_references);
     process_special_references(weak_references);
     process_special_references(phantom_references);
+    process_special_roots(phantom_roots);
     roots_update();
     finalize_objects();
 
@@ -380,14 +416,16 @@
     TIME(enumerate_universe,());
     TIME(process_special_references,(soft_references));
     TIME(process_special_references,(weak_references));
+    TIME(process_special_roots,(weak_roots));
     TIME(process_finalizable_objects,());
     TIME(process_special_references,(soft_references));
     TIME(process_special_references,(weak_references));
     TIME(process_special_references,(phantom_references));
+    TIME(process_special_roots,(phantom_roots));
     roots_update();
     TIME(finalize_objects,());
 
-    heap_mark_phase ^= 3;
+    heap_mark_phase ^= MARK_BITS; // toggle mark bits
     // reset thread-local allocation areas
     //clear_thread_local_buffers();
 
@@ -395,3 +433,14 @@
     notify_gc_end();
 }
 
+void gc_add_weak_root_set_entry(Managed_Object_Handle *_slot, 
+    Boolean is_pinned, Boolean is_short_weak) {
+    Partial_Reveal_Object **slot = (Partial_Reveal_Object**) _slot;
+    (*slot)->vt();
+    assert(!is_pinned);
+    if (is_short_weak) {
+        weak_roots.push_back(slot);
+    } else {
+        phantom_roots.push_back(slot);
+    }
+}

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.h?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect.h Fri Nov  3 09:40:32 2006
@@ -28,6 +28,7 @@
 
 extern fast_list<Slot,65536> slots;
 typedef fast_list<Partial_Reveal_Object*,1024> reference_vector;
+typedef fast_list<Partial_Reveal_Object**,1024> slots_vector;
 extern reference_vector finalizible_objects;
 extern reference_vector soft_references;
 extern reference_vector weak_references;
@@ -77,6 +78,7 @@
 void gc_slide_add_root_set_entry(Slot slot);
 void gc_slide_move_all();
 void gc_slide_process_special_references(reference_vector& array);
+void gc_slide_process_special_roots(slots_vector& array);
 void gc_slide_postprocess_special_references();
 
 void transition_copy_to_sliding_compaction(fast_list<Slot,65536>& slots);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_copy.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_copy.cpp?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_copy.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_copy.cpp Fri Nov  3 09:40:32
2006
@@ -99,6 +99,7 @@
     TRACE2("gc.pin.gc", "old area: reached heap.old_objects.pos_limit =" << heap.old_objects.pos_limit);
 
 
+    clear_mem_for_heap_iteration(newpos, heap.old_objects.pos_limit - newpos);
 
     // object doesn't feet in old objects region, skip possibly
     // pinned objects in old objects region
@@ -134,6 +135,7 @@
             assert(((POINTER_SIZE_INT) endpos & (GC_OBJECT_ALIGNMENT - 1)) == 0);
             return true;
         }
+        clear_mem_for_heap_iteration(newpos, heap.old_objects.pos_limit - newpos);
     }
     return false;
 }
@@ -160,10 +162,6 @@
         return true;
     }
     obj->valid();
-
-    VMEXPORT Class_Handle vtable_get_class(VTable_Handle vh);
-    assert(class_get_vtable(vtable_get_class((VTable_Handle)obj->vtable())) == (VTable_Handle)obj->vtable());
-    TRACE2("gc.debug", "0x" << obj << " is " << class_get_name(vtable_get_class((VTable_Handle)obj->vtable())));
 
     obj->obj_info() = (info & ~MARK_BITS) | phase;
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_slide_compact.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_slide_compact.cpp?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_slide_compact.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/collect_slide_compact.cpp Fri Nov
 3 09:40:32 2006
@@ -298,6 +298,14 @@
 
                     // 4/8 bytes reserved for hash
                     while (compact_pos + size > compact_pos_limit) {
+
+                        if (compact_pos == pos) {
+                            break;
+                        }
+
+                        assert(compact_pos_limit <= pos);
+                        clear_mem_for_heap_iteration(compact_pos, compact_pos_limit - compact_pos);
+
                         assert(pinned_areas_pos < pinned_areas.size());
                         compact_pos = pinned_areas[pinned_areas_pos];
                         compact_pos_limit = pinned_areas[pinned_areas_pos+1];
@@ -306,16 +314,15 @@
                     
                     Partial_Reveal_Object *newobj;
 
-                    if (compact_pos >= pos) {
+                    assert(compact_pos <= pos);
+
+                    if (compact_pos == pos) {
                         newobj = obj;
                         process_reference_queue(obj, obj);
+
                         unsigned info = obj->obj_info();
-                        if (compact_pos == pos) {
-                            compact_pos += size +
-                                (((info & HASHCODE_IS_ALLOCATED_BIT) != 0) ? GC_OBJECT_ALIGNMENT
: 0);
-                        } else {
-                            assert(compact_pos >= pos + size);
-                        }
+                        compact_pos += size +
+                            (((info & HASHCODE_IS_ALLOCATED_BIT) != 0) ? GC_OBJECT_ALIGNMENT
: 0);
                     } else {
                         unsigned char *newpos = compact_pos;
                         compact_pos += size;
@@ -611,6 +618,34 @@
             update_forwarded_reference(obj, root);
         } else if (is_compaction_object(obj)) {
             enqueue_reference(obj, root);
+        }
+    }
+    array.clear();
+}
+
+void gc_slide_process_special_roots(slots_vector& array) {
+    for(slots_vector::iterator i = array.begin();
+            i != array.end(); ++i) {
+        Partial_Reveal_Object **ref = *i;
+        Partial_Reveal_Object* refobj = *ref;
+
+        if (refobj == 0) {
+            // reference already cleared, no post processing needed
+            continue;
+        }
+
+        if (is_object_marked(refobj)) {
+            //assert(mark_bit_is_set(refobj) || !is_compaction_object(refobj) || is_forwarded_object(refobj));
+
+            Slot root = make_direct_root(ref);
+
+            if (is_forwarded_object(refobj)) {
+                update_forwarded_reference(refobj, root);
+            } else if (is_compaction_object(refobj)) {
+                enqueue_reference(refobj, root);
+            }
+        } else {
+            *ref = NULL;
         }
     }
     array.clear();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp Fri Nov  3 09:40:32
2006
@@ -81,16 +81,6 @@
     return false;
 }
 
-void gc_vm_initialized() {
-    static int UNUSED count = 0;
-    TRACE2("gc.init2", "gc_vm_initialized called (" << count++ << ")");
-}
-
-void gc_add_weak_root_set_entry(Managed_Object_Handle *slot, 
-    Boolean is_pinned, Boolean is_short_weak) {
-    TRACE2("gc.enum", "gc_add_weak_root_set_entry - EMPTY");
-    abort();
-}
 //GCExport void gc_add_root_set_entry_managed_pointer(void **slot,
 //                                                    Boolean is_pinned); //  optional
 
@@ -498,4 +488,68 @@
 void gc_finalize_on_exit() {
     process_finalizible_objects_on_exit();
 }
+
+/**
+ * Iterates all objects in the heap.
+ * This function calls vm_iterate_object() for each
+ * iterated object.
+ * Used for JVMTI Heap Iteration.
+ * Should be called only in stop-the-world setting
+ *
+ * @see vm_gc.h#vm_iterate_object()
+ */
+
+#ifdef GC_YUK_JVMTI_HEAP_ITERATION
+
+static bool gc_iterate_region(Ptr pos, Ptr limit) {
+    while (pos < limit) {
+        int32 vt = *(int32*)pos;
+        if (vt == 0) {
+            pos += sizeof(int32);
+            continue;
+        }
+        Partial_Reveal_Object *obj = (Partial_Reveal_Object*) pos;
+        obj->valid();
+        bool cont = vm_iterate_object((Managed_Object_Handle) obj);
+        if (!cont) return false;
+
+        pos += get_object_size(obj, obj->vtable()->get_gcvt());
+
+        if (obj->obj_info() & HASHCODE_IS_ALLOCATED_BIT) {
+            pos += sizeof(int32);
+        }
+    }
+    return true;
+}
+
+void gc_iterate_heap() {
+    // data structures in not consistent for heap iteration
+    if (!jvmti_heap_iteration) return;
+    bool cont;
+
+    // iterate over old objects
+    cont = gc_iterate_region(heap.base, heap.old_objects.pos);
+    if (!cont) return;
+
+    // iterate over new objects
+    cont = gc_iterate_region(heap.old_objects.end, heap.pos);
+    if (!cont) return;
+
+    // iterate over pinned objects in evacuation area
+    for(unsigned opos = old_pinned_areas_pos; opos < old_pinned_areas.size(); opos +=
2) {
+        Partial_Reveal_Object *obj = (Partial_Reveal_Object*) old_pinned_areas[opos];
+        obj->valid();
+        cont = vm_iterate_object((Managed_Object_Handle) obj);
+        if (!cont) return;
+    }
+
+    // iterate over pinned objects in new objects area
+    for (unsigned pos = pinned_areas_pos; pos < pinned_areas.size(); pos += 2) {
+        Partial_Reveal_Object *obj = (Partial_Reveal_Object*) pinned_areas[pos];
+        obj->valid();
+        cont = vm_iterate_object((Managed_Object_Handle) obj);
+        if (!cont) return;
+    }
+}
+#endif
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_types.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_types.h?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_types.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_types.h Fri Nov  3 09:40:32 2006
@@ -109,6 +109,7 @@
 extern const char *lp_hint; // Use large pages
 extern bool ignore_finalizers;
 extern bool remember_root_set;
+extern bool jvmti_heap_iteration;
 
 #define field_offset(type,field) ((POINTER_SIZE_INT)&((type*)0)->field)
 
@@ -359,6 +360,16 @@
 inline int gen_hashcode(void *addr) { return (int)(POINTER_SIZE_INT)addr; }
 inline void check_hashcode(int hash) {}
 #endif /* DEBUG_HASHCODE */
+
+#define GC_YUK_JVMTI_HEAP_ITERATION
+#ifdef GC_YUK_JVMTI_HEAP_ITERATION
+static inline void clear_mem_for_heap_iteration(void *pos, size_t size) {
+    if (!jvmti_heap_iteration) return;
+    memset(pos, 0, size);
+}
+#else
+static inline void clear_mem_for_heap_iteration(void *pos, size_t size) {}
+#endif
 
 #endif /* __GC_TYPES_H__ */
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp?view=diff&rev=470923&r1=470922&r2=470923
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp Fri Nov  3 09:40:32 2006
@@ -63,6 +63,7 @@
 bool ignore_finalizers = false;
 bool remember_root_set = false;
 const char *lp_hint = NULL;
+bool jvmti_heap_iteration = false;
 
 static size_t parse_size_string(const char* size_string) {
     size_t len = strlen(size_string);
@@ -177,6 +178,20 @@
     if (get_property_value_boolean("gc.remember_root_set", false)) {
         remember_root_set = true;
         INFO("GC will retrieve root set before any modification in heap");
+    }
+
+    if (get_property_value_boolean("gc.heap_iteration", false)) {
+        jvmti_heap_iteration = true;
+        INFO("GC jvmti heap iteration enabled");
+    }
+}
+
+void gc_vm_initialized() {
+    TRACE2("gc.init", "gc_vm_initialized");
+
+    if (get_property_value_boolean("gc.heap_iteration", false)) {
+        jvmti_heap_iteration = true;
+        INFO("GC jvmti heap iteration enabled");
     }
 }
 



Mime
View raw message