harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject svn commit: r522715 [2/2] - in /harmony/enhanced/drlvm/trunk/vm/gc_gen/src: common/ gen/ mark_compact/ mark_sweep/ thread/ trace_forward/ verify/
Date Tue, 27 Mar 2007 02:54:00 GMT
Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_scanner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_scanner.cpp?view=auto&rev=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_scanner.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_scanner.cpp Mon Mar 26 19:53:57 2007
@@ -0,0 +1,384 @@
+#include "verify_live_heap.h"
+#include "verifier_common.h"
+#include "verify_gc_effect.h"
+#include "verify_mutator_effect.h"
+#include "../finalizer_weakref/finalizer_weakref.h"
+
+ /*<--------live objects scanner begin-------->*/
+static FORCE_INLINE void scan_slot(Heap_Verifier* heap_verifier, REF*p_ref) 
+{
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  Partial_Reveal_Object *p_obj = read_slot(p_ref);
+  if(p_obj == NULL) return;  
+   
+  verify_live_object_slot(p_ref, heap_verifier);  
+  verifier_tracestack_push(p_obj, gc_verifier->trace_stack); 
+  return;
+}
+ 
+static FORCE_INLINE void scan_object(Heap_Verifier* heap_verifier, Partial_Reveal_Object *p_obj) 
+{
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  if(gc_verifier->is_before_fallback_collection) {
+    if(obj_belongs_to_nos(p_obj) && obj_is_fw_in_oi(p_obj)){
+      assert(obj_get_vt(p_obj) == obj_get_vt(obj_get_fw_in_oi(p_obj)));
+      p_obj = obj_get_fw_in_oi(p_obj);
+      assert(p_obj);
+    }
+  }
+  if(!obj_mark_in_vt(p_obj)) return;
+ 
+  verify_object_header(p_obj, heap_verifier); 
+  verifier_update_verify_info(p_obj, heap_verifier);
+
+   /*FIXME: */
+  if (!object_has_ref_field(p_obj)) return;
+    
+  REF* p_ref;
+
+  if (object_is_array(p_obj)) {  
+  
+    Partial_Reveal_Array* array = (Partial_Reveal_Array*)p_obj;
+    unsigned int array_length = array->array_len; 
+    p_ref = (REF*)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array));
+
+    for (unsigned int i = 0; i < array_length; i++) {
+      scan_slot(heap_verifier, p_ref+i);
+    }   
+
+  }else{ 
+    
+    unsigned int num_refs = object_ref_field_num(p_obj);
+    int* ref_iterator = object_ref_iterator_init(p_obj);
+ 
+    for(unsigned int i=0; i<num_refs; i++){  
+      p_ref = object_ref_iterator_get(ref_iterator+i, p_obj);  
+      scan_slot(heap_verifier, p_ref);
+    }
+
+#ifndef BUILD_IN_REFERENT
+     WeakReferenceType type = special_reference_type(p_obj);
+    if(type == SOFT_REFERENCE && verifier_get_gc_collect_kind(heap_verifier->gc_verifier) == MINOR_COLLECTION){
+      p_ref = obj_get_referent_field(p_obj);
+      scan_slot(heap_verifier, p_ref);
+    } 
+#endif  
+  }
+  return;
+}
+
+ 
+static void trace_object(Heap_Verifier* heap_verifier, Partial_Reveal_Object* p_obj)
+{ 
+  scan_object(heap_verifier, p_obj);
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  Vector_Block* trace_stack = (Vector_Block*)gc_verifier->trace_stack;
+  while( !vector_stack_is_empty(trace_stack)){
+    p_obj = (Partial_Reveal_Object *)vector_stack_pop(trace_stack); 
+    scan_object(heap_verifier, p_obj);
+    trace_stack = (Vector_Block*)gc_verifier->trace_stack;
+  }
+  return; 
+}
+ 
+void verifier_trace_rootsets(Heap_Verifier* heap_verifier, Pool* root_set_pool)
+{
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  gc_verifier->objects_set = verifier_free_task_pool_get_entry(verifier_metadata->free_objects_pool);
+  gc_verifier->trace_stack = verifier_free_task_pool_get_entry(verifier_metadata->free_task_pool);
+  pool_iterator_init(root_set_pool);
+  Vector_Block* root_set = pool_iterator_next(root_set_pool);
+  
+  /* first step: copy all root objects to trace tasks. */ 
+  while(root_set){
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(root_set);
+    while(!vector_block_iterator_end(root_set,iter)){
+      REF* p_ref = (REF* )*iter;
+      iter = vector_block_iterator_advance(root_set,iter);
+
+      if(!heap_verifier->need_verify_rootset || !heap_verifier->is_before_gc){
+        if(!verify_rootset_slot(p_ref, heap_verifier)){
+          gc_verifier->is_verification_passed = FALSE;
+          assert(0);
+          continue;
+        }
+      }
+
+      Partial_Reveal_Object* p_obj = read_slot(p_ref);
+      assert(p_obj != NULL);  
+
+      verifier_tracestack_push(p_obj, gc_verifier->trace_stack);
+    } 
+    root_set = pool_iterator_next(root_set_pool);
+  }
+  /* put back the last trace_stack task */    
+  pool_put_entry(verifier_metadata->mark_task_pool, gc_verifier->trace_stack);
+  
+  /* second step: iterate over the trace tasks and forward objects */
+  gc_verifier->trace_stack = verifier_free_task_pool_get_entry(verifier_metadata->free_task_pool);
+
+  Vector_Block* trace_task = pool_get_entry(verifier_metadata->mark_task_pool);
+
+  while(trace_task){    
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(trace_task);
+    while(!vector_block_iterator_end(trace_task,iter)){
+      Partial_Reveal_Object* p_obj = (Partial_Reveal_Object* )*iter;
+      iter = vector_block_iterator_advance(trace_task,iter);
+      trace_object(heap_verifier, p_obj); 
+    }
+    vector_stack_clear(trace_task);
+    pool_put_entry(verifier_metadata->free_task_pool, trace_task);
+    trace_task = pool_get_entry(verifier_metadata->mark_task_pool);
+  }
+  vector_stack_clear(gc_verifier->trace_stack);
+  pool_put_entry(verifier_metadata->free_task_pool, gc_verifier->trace_stack);
+  gc_verifier->trace_stack = NULL;
+
+}
+
+
+void verifier_trace_objsets(Heap_Verifier* heap_verifier, Pool* obj_set_pool)
+{
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  gc_verifier->trace_stack = verifier_free_task_pool_get_entry(verifier_metadata->free_task_pool);
+  pool_iterator_init(obj_set_pool);
+  Vector_Block* obj_set = pool_iterator_next(obj_set_pool);
+  
+  /* first step: copy all root objects to trace tasks. */ 
+  while(obj_set){
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(obj_set);
+    while(!vector_block_iterator_end(obj_set,iter)){
+      Partial_Reveal_Object* p_obj = (Partial_Reveal_Object* )*iter;
+      iter = vector_block_iterator_advance(obj_set,iter);
+      /*p_obj can be NULL , When GC happened, the obj in Finalize objs list will be clear.*/
+      //assert(p_obj != NULL);  
+      if(p_obj == NULL) continue;
+      verifier_tracestack_push(p_obj, gc_verifier->trace_stack);
+    } 
+    obj_set = pool_iterator_next(obj_set_pool);
+  }
+  /* put back the last trace_stack task */    
+  pool_put_entry(verifier_metadata->mark_task_pool, gc_verifier->trace_stack);
+  
+  /* second step: iterate over the trace tasks and forward objects */
+  gc_verifier->trace_stack = verifier_free_task_pool_get_entry(verifier_metadata->free_task_pool);
+
+  Vector_Block* trace_task = pool_get_entry(verifier_metadata->mark_task_pool);
+
+  while(trace_task){    
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(trace_task);
+    while(!vector_block_iterator_end(trace_task,iter)){
+      Partial_Reveal_Object* p_obj = (Partial_Reveal_Object* )*iter;
+      iter = vector_block_iterator_advance(trace_task,iter);
+      trace_object(heap_verifier, p_obj); 
+    }
+    vector_stack_clear(trace_task);
+    pool_put_entry(verifier_metadata->free_task_pool, trace_task);
+    trace_task = pool_get_entry(verifier_metadata->mark_task_pool);
+  }
+  vector_stack_clear(gc_verifier->trace_stack);
+  pool_put_entry(verifier_metadata->free_task_pool, gc_verifier->trace_stack);
+  gc_verifier->trace_stack = NULL;
+
+}
+
+void verifier_scan_resurrect_objects(Heap_Verifier* heap_verifier)
+{
+  GC_Gen* gc    =  (GC_Gen*)heap_verifier->gc;
+  verifier_update_info_before_resurrect(heap_verifier);
+#ifndef BUILD_IN_REFERENT
+  heap_verifier->gc_verifier->is_tracing_resurrect_obj = TRUE;
+  if(heap_verifier->is_before_gc){
+    verifier_trace_objsets(heap_verifier, gc->finref_metadata->obj_with_fin_pool);
+  }else{
+    verify_live_finalizable_obj(heap_verifier, gc->finref_metadata->obj_with_fin_pool);
+    verifier_trace_objsets(heap_verifier, gc->finref_metadata->finalizable_obj_pool);
+  }
+  heap_verifier->gc_verifier->is_tracing_resurrect_obj = FALSE;
+  verifier_update_info_after_resurrect(heap_verifier);
+#endif
+}
+
+void verifier_scan_unreachable_objects(Heap_Verifier* heap_verifier);
+
+void verifier_scan_live_objects(Heap_Verifier* heap_verifier)
+{
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  verifier_trace_rootsets(heap_verifier, verifier_metadata->root_set_pool);
+  verifier_scan_resurrect_objects(heap_verifier);
+  verifier_scan_unreachable_objects(heap_verifier);
+  verifier_clear_objs_mark_bit(heap_verifier);
+}
+/*<--------live objects scanner end--------->*/
+
+/*<--------all (live and dead) objects scanner begin-------->*/
+static FORCE_INLINE void verifier_scan_object_slots(Partial_Reveal_Object *p_obj, Heap_Verifier* heap_verifier) 
+{
+  verifier_allocation_update_info(p_obj, heap_verifier);
+  verify_object_header(p_obj, heap_verifier); 
+  if (!object_has_ref_field(p_obj)) return; 
+  REF* p_ref;
+
+  if (object_is_array(p_obj)){    
+    Partial_Reveal_Array* array = (Partial_Reveal_Array*)p_obj;
+    unsigned int array_length = array->array_len; 
+    p_ref = (REF*)((POINTER_SIZE_INT)array + (int)array_first_element_offset(array));
+
+    for (unsigned int i = 0; i < array_length; i++) {
+      if(!is_unreachable_obj(p_obj)){ 
+        verify_write_barrier(p_ref+i, heap_verifier);
+        if(*(p_ref+i) != COMPRESSED_NULL) verify_live_object_slot(p_ref+i, heap_verifier);
+      }else{
+        if(*(p_ref+i) != COMPRESSED_NULL) verify_all_object_slot(p_ref+i, heap_verifier);
+      }
+    }   
+  }else{   
+    unsigned int num_refs = object_ref_field_num(p_obj);
+    int* ref_iterator = object_ref_iterator_init(p_obj);
+ 
+    for(unsigned int i=0; i<num_refs; i++){
+      p_ref = object_ref_iterator_get(ref_iterator+i, p_obj);  
+      if(!is_unreachable_obj(p_obj)){
+        verify_write_barrier(p_ref, heap_verifier);
+        if(*p_ref  != COMPRESSED_NULL) verify_live_object_slot(p_ref, heap_verifier);
+      }else{
+        if(*p_ref  != COMPRESSED_NULL) verify_all_object_slot(p_ref, heap_verifier);
+      }
+    }
+    
+#ifndef BUILD_IN_REFERENT
+    WeakReferenceType type = special_reference_type(p_obj);
+    if(type == NOT_REFERENCE) return;
+    
+    //if(type != SOFT_REFERENCE && verifier_get_gc_collect_kind(heap_verifier) == MINOR_COLLECTION){
+    {
+      p_ref = obj_get_referent_field(p_obj);
+      if(!is_unreachable_obj(p_obj)){ 
+        verify_write_barrier(p_ref, heap_verifier);
+        if(*p_ref  != NULL)   verify_live_object_slot(p_ref, heap_verifier);
+      }else{
+        if(*p_ref  != NULL)   verify_all_object_slot(p_ref, heap_verifier);
+      }
+    } 
+#endif
+  
+  }
+  return;
+}
+
+void verifier_scan_nos_mos_objects(Space* space, Heap_Verifier* heap_verifier)
+{
+  Block* blocks = (Block*)space->heap_start; 
+  unsigned int start_idx = ((Blocked_Space*)space)->first_block_idx; 
+  unsigned int i;
+  unsigned int num_block = ((Blocked_Space*)space)->free_block_idx - ((Blocked_Space*)space)->first_block_idx;
+  for( i=0; i < num_block; i++ ){
+    Block_Header* block = (Block_Header*)&(blocks[i]);
+    Partial_Reveal_Object* cur_obj = (Partial_Reveal_Object*) block->base;
+    while( cur_obj < block->free ){
+      verify_object_header(cur_obj, heap_verifier);
+      verifier_scan_object_slots(cur_obj, heap_verifier);
+      cur_obj = obj_end(cur_obj);
+    }
+  }
+}
+
+inline Partial_Reveal_Object* lspace_get_next_object( Space* lspace, POINTER_SIZE_INT* & next_area_start){
+  POINTER_SIZE_INT* ret_obj = NULL;
+  
+  while(!*next_area_start && (POINTER_SIZE_INT)next_area_start < (POINTER_SIZE_INT)lspace->heap_end){
+    next_area_start =(POINTER_SIZE_INT*)((POINTER_SIZE_INT)next_area_start + ((Free_Area*)next_area_start)->size);
+  }
+  if((POINTER_SIZE_INT)next_area_start < (POINTER_SIZE_INT)lspace->heap_end){
+    ret_obj = next_area_start;
+    unsigned int obj_size = ALIGN_UP_TO_KILO(vm_object_size((Partial_Reveal_Object*)next_area_start));
+    assert(obj_size);
+    next_area_start = (POINTER_SIZE_INT*)((POINTER_SIZE_INT)next_area_start + obj_size);
+    return (Partial_Reveal_Object*)ret_obj;
+  }else{
+    return NULL;
+  } 
+}
+
+inline Partial_Reveal_Object* lspace_get_first_object( Space* lspace, POINTER_SIZE_INT* & next_area_start){
+  return lspace_get_next_object(lspace, next_area_start);
+}
+
+void verifier_scan_los_objects(Space* lspace, Heap_Verifier* heap_verifier)
+{
+  POINTER_SIZE_INT* interator = (POINTER_SIZE_INT*)lspace->heap_start;
+  Partial_Reveal_Object* p_los_obj = lspace_get_first_object(lspace, interator);
+
+  while(p_los_obj){
+    verify_object_header(p_los_obj, heap_verifier);
+    verifier_scan_object_slots(p_los_obj, heap_verifier);
+    p_los_obj = lspace_get_next_object(lspace, interator);
+  }
+}
+
+void verifier_scan_all_objects(Heap_Verifier* heap_verifier)
+{
+  GC_Gen* gc       = (GC_Gen*)heap_verifier->gc;
+  Space* fspace     = gc_get_nos(gc);
+  Space* mspace   = gc_get_mos(gc);
+  Space* lspace     = gc_get_los(gc);
+  
+  verifier_scan_nos_mos_objects(fspace, heap_verifier);
+  verifier_scan_nos_mos_objects(mspace, heap_verifier);
+  verifier_scan_los_objects(lspace, heap_verifier);
+}
+/*<--------all objects scanner end--------->*/
+
+/*<--------unreachable objects scanner begin------>*/
+
+void verifier_scan_mos_unreachable_objects(Space* space, Heap_Verifier* heap_verifier)
+{
+  Block* blocks = (Block*)space->heap_start; 
+  unsigned int start_idx = ((Blocked_Space*)space)->first_block_idx; 
+  unsigned int i;
+  unsigned int num_block = ((Blocked_Space*)space)->free_block_idx - ((Blocked_Space*)space)->first_block_idx;
+  for( i=0; i < num_block; i++ ){
+    Block_Header* block = (Block_Header*)&(blocks[i]);
+    Partial_Reveal_Object* cur_obj = (Partial_Reveal_Object*) block->base;
+    while( cur_obj < block->free ){
+      verify_object_header(cur_obj, heap_verifier);
+      if(!obj_is_marked_in_vt(cur_obj)) tag_unreachable_obj(cur_obj);
+      cur_obj = obj_end(cur_obj);
+    }
+  }
+}
+
+void verifier_scan_los_unreachable_objects(Space* lspace, Heap_Verifier* heap_verifier)
+{
+  POINTER_SIZE_INT* interator = (POINTER_SIZE_INT*)lspace->heap_start;
+  Partial_Reveal_Object* p_los_obj = lspace_get_first_object(lspace, interator);
+
+  while(p_los_obj){
+    verify_object_header(p_los_obj, heap_verifier);
+    if(!obj_is_marked_in_vt(p_los_obj)) tag_unreachable_obj(p_los_obj);
+    p_los_obj = lspace_get_next_object(lspace, interator);
+  }
+}
+
+void verifier_scan_unreachable_objects(Heap_Verifier* heap_verifier)
+{
+  if(heap_verifier->is_before_gc) return;
+  GC_Gen* gc       = (GC_Gen*)heap_verifier->gc;  
+  Space* mspace   = gc_get_mos(gc);
+  Space* lspace     = gc_get_los(gc);
+  
+  verifier_scan_mos_unreachable_objects(mspace, heap_verifier);
+  verifier_scan_los_unreachable_objects(lspace, heap_verifier);
+
+}
+/*<--------unreachable objects scanner end------>*/
+
+void verifier_init_object_scanner(Heap_Verifier* heap_verifier)
+{
+  heap_verifier->live_obj_scanner = verifier_scan_live_objects;
+  heap_verifier->all_obj_scanner   = verifier_scan_all_objects;
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verifier_scanner.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.cpp?view=auto&rev=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.cpp Mon Mar 26 19:53:57 2007
@@ -0,0 +1,311 @@
+#include "verifier_common.h"
+#include "verify_gc_effect.h"
+
+void verifier_init_GC_verifier(Heap_Verifier* heap_verifier)
+{
+  GC_Verifier* gc_verifier = (GC_Verifier*)STD_MALLOC(sizeof(GC_Verifier));
+  assert(gc_verifier);
+  memset(gc_verifier, 0, sizeof(GC_Verifier));
+  
+  gc_verifier->trace_stack = gc_verifier->objects_set = gc_verifier->root_set = NULL;
+  gc_verifier->is_tracing_resurrect_obj = FALSE;
+  gc_verifier->num_live_objects_after_gc = gc_verifier->num_live_objects_before_gc = 0;
+  gc_verifier->size_live_objects_after_gc = gc_verifier->size_live_objects_before_gc = 0;
+  gc_verifier->num_resurrect_objects_after_gc = gc_verifier->num_resurrect_objects_before_gc = 0;
+  gc_verifier->size_resurrect_objects_after_gc = gc_verifier->size_resurrect_objects_before_gc = 0;
+  heap_verifier->gc_verifier = gc_verifier;
+}
+void verifier_destruct_GC_verifier(Heap_Verifier* heap_verifier)
+{
+  assert(!heap_verifier->gc_verifier ->trace_stack);
+  assert(!heap_verifier->gc_verifier ->objects_set );
+  assert(!heap_verifier->gc_verifier ->root_set);
+  STD_FREE(heap_verifier->gc_verifier );
+  heap_verifier->gc_verifier  = NULL;
+}
+
+
+void verifier_clear_objsets(Heap_Verifier* heap_verifier)
+{
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  verifier_clear_pool(verifier_metadata->objects_pool_before_gc, verifier_metadata->free_objects_pool, FALSE);
+  verifier_clear_pool(verifier_metadata->objects_pool_after_gc, verifier_metadata->free_objects_pool, FALSE);
+#ifndef BUILD_IN_REFERENT
+  verifier_clear_pool(verifier_metadata->resurrect_objects_pool_before_gc, verifier_metadata->free_objects_pool, FALSE);
+  verifier_clear_pool(verifier_metadata->resurrect_objects_pool_after_gc, verifier_metadata->free_objects_pool, FALSE);
+#endif
+}
+
+void verify_gc_reset(Heap_Verifier* heap_verifier)
+{
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  
+  gc_verifier->trace_stack = gc_verifier->objects_set = gc_verifier->root_set = NULL;
+  gc_verifier->is_tracing_resurrect_obj = FALSE;
+  gc_verifier->num_live_objects_after_gc = gc_verifier->num_live_objects_before_gc = 0;
+  gc_verifier->size_live_objects_after_gc = gc_verifier->size_live_objects_before_gc = 0;
+#ifndef BUILD_IN_REFERENT
+  gc_verifier->num_resurrect_objects_after_gc = gc_verifier->num_resurrect_objects_before_gc = 0;
+  gc_verifier->size_resurrect_objects_after_gc = gc_verifier->size_resurrect_objects_before_gc = 0;
+#endif
+
+  verifier_clear_rootsets(heap_verifier);
+  verifier_clear_objsets(heap_verifier);
+}
+
+void verify_live_finalizable_obj(Heap_Verifier* heap_verifier, Pool* live_finalizable_objs_pool)
+{
+  pool_iterator_init(live_finalizable_objs_pool);
+  Vector_Block* live_fin_objs = pool_iterator_next(live_finalizable_objs_pool);
+  while(live_fin_objs){
+    POINTER_SIZE_INT * iter = vector_block_iterator_init(live_fin_objs);
+    while(!vector_block_iterator_end(live_fin_objs, iter)){
+      Partial_Reveal_Object* p_fin_obj = (Partial_Reveal_Object*) *iter;
+      iter = vector_block_iterator_advance(live_fin_objs, iter);
+      if(p_fin_obj==NULL) continue;
+      assert(obj_is_marked_in_vt(p_fin_obj));
+      if(!obj_is_marked_in_vt(p_fin_obj)){
+        printf("ERROR\n");
+      }
+    }
+    live_fin_objs = pool_iterator_next(live_finalizable_objs_pool);
+  }
+}
+
+void* verifier_copy_obj_information(Partial_Reveal_Object* p_obj)
+{
+  Live_Object_Inform* p_obj_information = (Live_Object_Inform* )STD_MALLOC(sizeof(Live_Object_Inform));
+  assert(p_obj_information);
+  p_obj_information->vt_raw = obj_get_vt_raw(p_obj);
+  p_obj_information->address = p_obj;
+  return (void*) p_obj_information;
+}
+
+static Boolean fspace_object_was_forwarded(Partial_Reveal_Object *p_obj, Fspace *fspace, Heap_Verifier* heap_verifier)
+{
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  assert(obj_belongs_to_space(p_obj, (Space*)fspace));
+  unsigned int forwarded_first_part;
+  if(!gc_verifier->gc_collect_kind == MINOR_COLLECTION  || !NOS_PARTIAL_FORWARD || heap_verifier->gc_is_gen_mode)
+    forwarded_first_part = true;
+  else
+    forwarded_first_part = forward_first_half^1;
+  /* forward_first_half is flipped after the collection, so the condition is reversed as well */
+  return forwarded_first_part? (p_obj < object_forwarding_boundary):(p_obj >= object_forwarding_boundary);
+}
+
+void verifier_update_info_before_resurrect(Heap_Verifier* heap_verifier)
+{
+  if(!heap_verifier->need_verify_gc) return;
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+
+  if(heap_verifier->is_before_gc){
+    pool_put_entry(verifier_metadata->objects_pool_before_gc, gc_verifier->objects_set);
+    gc_verifier->objects_set = verifier_free_set_pool_get_entry(verifier_metadata->free_objects_pool);
+    assert(gc_verifier->objects_set);
+    return;
+  }else{
+    pool_put_entry(verifier_metadata->objects_pool_after_gc, gc_verifier->objects_set);
+    gc_verifier->objects_set = verifier_free_set_pool_get_entry(verifier_metadata->free_objects_pool);
+    assert(gc_verifier->objects_set);
+    return;
+  }
+
+}
+
+void verifier_update_info_after_resurrect(Heap_Verifier* heap_verifier)
+{
+  if(!heap_verifier->need_verify_gc) return;
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+
+  if(heap_verifier->is_before_gc){
+    pool_put_entry(verifier_metadata->resurrect_objects_pool_before_gc, gc_verifier->objects_set);
+    gc_verifier->objects_set = NULL;
+    assert(!gc_verifier->objects_set);
+    return;
+  }else{
+    pool_put_entry(verifier_metadata->resurrect_objects_pool_after_gc, gc_verifier->objects_set);
+    gc_verifier->objects_set = NULL;
+    assert(!gc_verifier->objects_set);
+    return;
+  }
+
+}
+
+
+void verifier_update_verify_info(Partial_Reveal_Object* p_obj, Heap_Verifier* heap_verifier)
+{
+  if(!heap_verifier->need_verify_gc) return;
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+
+  GC_Gen* gc = (GC_Gen*)heap_verifier->gc;
+  Space* mspace = gc_get_mos(gc);
+  Space* nspace = gc_get_nos(gc);
+  Space* lspace  = gc_get_los(gc);
+
+  if(!gc_verifier->is_before_fallback_collection && gc_verifier->gc_collect_kind == MINOR_COLLECTION){
+    if(!heap_verifier->is_before_gc){
+      assert(!obj_belongs_to_space(p_obj, nspace) ||!fspace_object_was_forwarded(p_obj, (Fspace*)nspace, heap_verifier));
+      if(obj_belongs_to_space(p_obj, nspace) && fspace_object_was_forwarded(p_obj, (Fspace*)nspace, heap_verifier)){
+        gc_verifier->is_verification_passed = FALSE;
+      }
+    }
+  }else if(!gc_verifier->is_before_fallback_collection){
+    if(!heap_verifier->is_before_gc){
+      assert(!obj_belongs_to_space(p_obj, nspace));
+      if(obj_belongs_to_space(p_obj, nspace)){
+        gc_verifier->is_verification_passed = FALSE;
+      }
+    }
+  }
+   /*store the object information*/
+  void* p_obj_information =  verifier_copy_obj_information(p_obj);
+   
+#ifndef BUILD_IN_REFERENT
+  if(!gc_verifier->is_tracing_resurrect_obj){
+#endif    
+    /*size and number*/
+    if(heap_verifier->is_before_gc){
+      verifier_set_push(p_obj_information, gc_verifier->objects_set, verifier_metadata->objects_pool_before_gc);
+      gc_verifier->num_live_objects_before_gc ++;
+      gc_verifier->size_live_objects_before_gc += vm_object_size(p_obj);
+    }else{
+      verifier_set_push(p_obj_information, gc_verifier->objects_set, verifier_metadata->objects_pool_after_gc);
+      gc_verifier->num_live_objects_after_gc ++;
+      gc_verifier->size_live_objects_after_gc += vm_object_size(p_obj);
+    }
+    return;
+    
+#ifndef BUILD_IN_REFERENT    
+  }else{
+    
+    if(heap_verifier->is_before_gc){
+      verifier_set_push(p_obj_information, gc_verifier->objects_set, verifier_metadata->resurrect_objects_pool_before_gc);
+      gc_verifier->num_resurrect_objects_before_gc ++;
+      gc_verifier->size_resurrect_objects_before_gc += vm_object_size(p_obj);
+    }else{
+      verifier_set_push(p_obj_information, gc_verifier->objects_set, verifier_metadata->resurrect_objects_pool_after_gc);
+      gc_verifier->num_resurrect_objects_after_gc ++;
+      gc_verifier->size_resurrect_objects_after_gc += vm_object_size(p_obj);
+    }
+    return;
+    
+  }
+#endif
+
+}
+
+Boolean compare_live_obj_inform(POINTER_SIZE_INT* obj_container1,POINTER_SIZE_INT* obj_container2)
+{
+  Live_Object_Inform* obj_inform_1 = (Live_Object_Inform*)*obj_container1;
+  Live_Object_Inform* obj_inform_2 = (Live_Object_Inform*)*obj_container2;
+  if(((POINTER_SIZE_INT)obj_inform_1->vt_raw) == ((POINTER_SIZE_INT)obj_inform_2->vt_raw)){
+    /*FIXME: erase live object information in compare_function. */
+    STD_FREE(obj_inform_1);
+    STD_FREE(obj_inform_2);
+    return TRUE;
+  }else{ 
+    STD_FREE(obj_inform_1);
+    STD_FREE(obj_inform_2);
+    return FALSE;
+  }
+}
+
+
+void verify_gc_effect(Heap_Verifier* heap_verifier)
+{
+  GC_Verifier* gc_verifier = heap_verifier->gc_verifier;
+  
+  if(gc_verifier->num_live_objects_before_gc != gc_verifier->num_live_objects_after_gc){
+    gc_verifier->is_verification_passed = FALSE;
+    printf("ERROR");
+  }
+  
+  if(gc_verifier->size_live_objects_before_gc != gc_verifier->size_live_objects_after_gc){
+    printf("ERROR");    
+    gc_verifier->is_verification_passed = FALSE;
+  }
+  
+#ifndef BUILD_IN_REFERENT  
+  if(gc_verifier->num_resurrect_objects_before_gc != gc_verifier->num_resurrect_objects_after_gc){
+    printf("ERROR");
+    gc_verifier->is_verification_passed = FALSE;
+  }
+  
+  if(gc_verifier->size_resurrect_objects_before_gc != gc_verifier->size_resurrect_objects_after_gc){
+    printf("ERROR");    
+    gc_verifier->is_verification_passed = FALSE;
+  }
+#endif
+  
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  Pool* free_pool = verifier_metadata->free_objects_pool;
+
+  Object_Comparator object_comparator = compare_live_obj_inform;
+  Boolean passed = verifier_compare_objs_pools(verifier_metadata->objects_pool_before_gc, 
+                    verifier_metadata->objects_pool_after_gc , free_pool, object_comparator);
+  if(!passed)     gc_verifier->is_verification_passed = FALSE;
+#ifndef BUILD_IN_REFERENT
+  passed = verifier_compare_objs_pools(verifier_metadata->resurrect_objects_pool_before_gc, 
+                    verifier_metadata->resurrect_objects_pool_after_gc , free_pool, object_comparator);
+  if(!passed)     gc_verifier->is_verification_passed = FALSE;
+#endif
+}
+
+
+void verifier_pool_clear_objs_mark_bit(Pool* marked_objs_pool)
+{
+  pool_iterator_init(marked_objs_pool);
+  Vector_Block* objs_set = pool_iterator_next(marked_objs_pool);
+  
+  while(objs_set){
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(objs_set);
+    while(!vector_block_iterator_end(objs_set,iter)){
+      Live_Object_Inform* p_verify_obj = (Live_Object_Inform* )*iter;
+      iter = vector_block_iterator_advance(objs_set,iter);
+
+      Partial_Reveal_Object* p_obj = p_verify_obj->address;
+      assert(p_obj != NULL); 
+      assert(obj_is_marked_in_vt(p_obj));
+      obj_unmark_in_vt(p_obj);
+    } 
+    objs_set = pool_iterator_next(marked_objs_pool);
+  }
+}
+
+void verifier_clear_objs_mark_bit(Heap_Verifier* heap_verifier)
+{
+  Pool* marked_objs_pool = NULL;
+  
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  if(heap_verifier->is_before_gc) {
+    verifier_pool_clear_objs_mark_bit(verifier_metadata->objects_pool_before_gc);
+  #ifndef BUILD_IN_REFERENT
+    verifier_pool_clear_objs_mark_bit(verifier_metadata->resurrect_objects_pool_before_gc);
+  #endif
+  }else{
+    verifier_pool_clear_objs_mark_bit(verifier_metadata->objects_pool_after_gc);
+  #ifndef BUILD_IN_REFERENT
+    verifier_pool_clear_objs_mark_bit(verifier_metadata->resurrect_objects_pool_after_gc);
+  #endif
+  }
+  return;
+}
+
+
+void verifier_reset_gc_verification(Heap_Verifier* heap_verifier)
+{
+  if(!heap_verifier->need_verify_gc) return;
+  heap_verifier->gc_verifier->is_verification_passed = TRUE;
+  verifier_copy_rootsets(heap_verifier->gc, heap_verifier);
+}
+void verifier_clear_gc_verification(Heap_Verifier* heap_verifier)
+{
+  verify_gc_reset(heap_verifier);  
+  verifier_set_fallback_collection(heap_verifier->gc_verifier, FALSE);  
+}
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.h?view=auto&rev=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.h Mon Mar 26 19:53:57 2007
@@ -0,0 +1,59 @@
+#ifndef _VERIFY_GC_EFFECT_H_
+#define _VERIFY_GC_EFFECT_H_
+
+#include "verifier_common.h"
+
+typedef struct GC_Verifier{
+  Vector_Block* trace_stack;
+  Vector_Block* root_set;
+  Vector_Block* objects_set;
+
+  Boolean is_tracing_resurrect_obj;
+  unsigned int gc_collect_kind;
+  Boolean is_before_fallback_collection;
+  
+  POINTER_SIZE_INT num_live_objects_before_gc;
+  POINTER_SIZE_INT num_live_objects_after_gc;
+  POINTER_SIZE_INT size_live_objects_before_gc;
+  POINTER_SIZE_INT size_live_objects_after_gc;
+  
+  POINTER_SIZE_INT num_resurrect_objects_before_gc;
+  POINTER_SIZE_INT num_resurrect_objects_after_gc;
+  POINTER_SIZE_INT size_resurrect_objects_before_gc;
+  POINTER_SIZE_INT size_resurrect_objects_after_gc;
+  
+  Boolean is_verification_passed;
+}GC_Verifier;
+
+typedef struct Live_Object_Inform_struct{
+  VT vt_raw;
+  Partial_Reveal_Object* address;
+} Live_Object_Inform;
+
+void verifier_init_GC_verifier(Heap_Verifier* heap_verifier);
+void verifier_destruct_GC_verifier(Heap_Verifier* heap_verifier);
+void verifier_reset_gc_verification(Heap_Verifier* heap_verifier);
+void verifier_clear_gc_verification(Heap_Verifier* heap_verifier);
+
+void verifier_update_verify_info(Partial_Reveal_Object* p_obj, Heap_Verifier* heap_verifier);
+void verify_live_finalizable_obj(Heap_Verifier* heap_verifier, Pool* live_finalizable_objs_pool);
+void verifier_clear_objs_mark_bit(Heap_Verifier* heap_verifier);
+
+
+void verifier_update_info_before_resurrect(Heap_Verifier* heap_verifier);
+void verifier_update_info_after_resurrect(Heap_Verifier* heap_verifier);
+
+void verify_gc_effect(Heap_Verifier* heap_verifier);
+
+
+
+inline unsigned int verifier_get_gc_collect_kind(GC_Verifier* gc_verifier)
+{  return gc_verifier->gc_collect_kind;  }
+inline void verifier_set_gc_collect_kind(GC_Verifier* gc_verifier, unsigned int collect_kind)
+{  gc_verifier->gc_collect_kind = collect_kind;  }
+
+inline void verifier_set_fallback_collection(GC_Verifier* gc_verifier, Boolean is_before_fallback)
+{  gc_verifier->is_before_fallback_collection = is_before_fallback;  }
+
+#endif
+

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_gc_effect.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.cpp?view=diff&rev=522715&r1=522714&r2=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.cpp Mon Mar 26 19:53:57 2007
@@ -1,40 +1,136 @@
-/*
- *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * @author Xiao-Feng Li, 2006/10/05
- */
-
 #include "verify_live_heap.h"
+#include "verifier_common.h"
+#include "verify_gc_effect.h"
+#include "verify_mutator_effect.h"
 
-Boolean GC_VERIFY = FALSE;
+char* GC_VERIFY = NULL;
 Boolean verify_live_heap;
 
-void gc_verify_heap(GC* gc, Boolean is_before_gc)
-{ return; }
+Heap_Verifier* heap_verifier;
+
 
 void gc_init_heap_verification(GC* gc)
-{ return; }
+{
+  if(GC_VERIFY == NULL){
+    verify_live_heap = FALSE;
+    return;
+  }
+  heap_verifier = (Heap_Verifier*) STD_MALLOC(sizeof(Heap_Verifier));
+  assert(heap_verifier);
+  memset(heap_verifier, 0, sizeof(Heap_Verifier));
+
+  heap_verifier->gc = gc;
+
+  verifier_metadata_initialize(heap_verifier);
+  verifier_init_mutator_verifiers(heap_verifier);
+  verifier_init_GC_verifier(heap_verifier);
+  verifier_init_object_scanner(heap_verifier);
+
+  heap_verifier->is_before_gc = heap_verifier->gc_is_gen_mode = FALSE;
+  heap_verifier->need_verify_gc =  heap_verifier->need_verify_rootset
+    = heap_verifier->need_verify_allocation =  heap_verifier->need_verify_writebarrier = FALSE;
+  
+  if(!verifier_parse_options(heap_verifier, GC_VERIFY)){
+    printf("GC Verify options error, verifier will not start.\n");
+    gc_terminate_heap_verification(gc);
+    return;
+  }
+  
+  verify_live_heap = TRUE;
+  return;
+}
 
 void gc_terminate_heap_verification(GC* gc)
-{ return; }
+{
+  gc_verifier_metadata_destruct(heap_verifier);
+  verifier_destruct_mutator_verifiers(heap_verifier);
+  verifier_destruct_GC_verifier(heap_verifier);
+  STD_FREE(heap_verifier);
+  heap_verifier = NULL;
+  return; 
+}
+
+void verify_heap_before_gc(GC* gc)
+{
+  verifier_log_start();
+  verifier_set_gc_collect_kind(heap_verifier->gc_verifier, gc->collect_kind);  
+  verifier_set_gen_mode(heap_verifier);
+  verifier_reset_mutator_verification(heap_verifier);
+  verifier_reset_gc_verification(heap_verifier);
+
+  if(need_scan_all_objs(heap_verifier))
+    (*heap_verifier->all_obj_scanner)(heap_verifier);  
+
+  /*verify mutator side effect before gc after scanning all objs.*/
+  if(need_verify_mutator_effect(heap_verifier))
+    verify_mutator_effect(heap_verifier);
+
+  if(need_scan_live_objs(heap_verifier))
+    (*heap_verifier->live_obj_scanner)(heap_verifier);
+  
+  verifier_log_before_gc(heap_verifier);
+
+}
+
+void verify_heap_after_gc(GC* gc)
+{
+  verifier_log_start();
+  if(need_scan_live_objs(heap_verifier))
+    (*heap_verifier->live_obj_scanner)(heap_verifier);
+  if(need_verify_gc_effect(heap_verifier))
+    verify_gc_effect(heap_verifier);
+
+  verifier_log_after_gc(heap_verifier);
+  
+  verifier_clear_mutator_verification(heap_verifier);
+  verifier_clear_gc_verification(heap_verifier);
+}
+
+void gc_verify_heap(GC* gc, Boolean is_before_gc)
+{
+  heap_verifier->is_before_gc = is_before_gc;
+
+  if(is_before_gc){
+    verify_heap_before_gc(gc);
+  }else{
+    verify_heap_after_gc(gc);
+  }
+}
+
+void event_gc_collect_kind_changed(GC* gc)
+{
+  /*GC collection kind were changed from normal MINOR or MAJOR  to FALLBACK MAJOR*/
+  assert(gc->collect_kind == FALLBACK_COLLECTION);
+  if(!heap_verifier->need_verify_gc) return;
+  
+  verifier_log_start();
+  /*finish the fallbacked gc verify*/
+  heap_verifier->is_before_gc = FALSE;
+  verifier_set_fallback_collection(heap_verifier->gc_verifier, TRUE);  
+  (*heap_verifier->live_obj_scanner)(heap_verifier);  
+  verify_gc_effect(heap_verifier);
+  printf("GC Fall Back, GC end.\n");
+  verifier_log_after_gc(heap_verifier);
+  verifier_clear_gc_verification(heap_verifier);
+
+  /*start fallback major gc verify */
+  heap_verifier->is_before_gc = TRUE;
+  verifier_set_fallback_collection(heap_verifier->gc_verifier, TRUE);  
+  verifier_set_gc_collect_kind(heap_verifier->gc_verifier, gc->collect_kind);
+  verifier_set_gen_mode(heap_verifier);
+  verifier_reset_gc_verification(heap_verifier);
+
+  (*heap_verifier->live_obj_scanner)(heap_verifier);
+  
+}
+
+void event_mutator_allocate_newobj(Partial_Reveal_Object* p_newobj, POINTER_SIZE_INT size, VT vt_raw)
+{
+  verifier_event_mutator_allocate_newobj(p_newobj, size, vt_raw);
+}
+
+Heap_Verifier* get_heap_verifier()
+{ return heap_verifier; }
 
-void event_collector_move_obj(Partial_Reveal_Object *p_old, Partial_Reveal_Object *p_new, Collector* collector)
-{ return; }
 
-void event_collector_doublemove_obj(Partial_Reveal_Object *p_old, Partial_Reveal_Object *p_new, Collector* collector)
-{ return; }
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.h?view=diff&rev=522715&r1=522714&r2=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_live_heap.h Mon Mar 26 19:53:57 2007
@@ -1,35 +1,15 @@
-/*
- *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * @author Xiao-Feng Li, 2006/10/05
- */
-
 #ifndef _VERIFY_LIVE_HEAP_H_
 #define _VERIFY_LIVE_HEAP_H_
 
 #include "../common/gc_common.h"
 
 extern Boolean verify_live_heap;
+
 void gc_init_heap_verification(GC* gc);
 void gc_terminate_heap_verification(GC* gc);
-void event_collector_move_obj(Partial_Reveal_Object *p_old, Partial_Reveal_Object *p_new, Collector* collector);
 void gc_verify_heap(GC* gc, Boolean is_before_gc);
 
-/* functions used in fall back compaction and the out-of-space cases*/
-void event_collector_doublemove_obj(Partial_Reveal_Object *p_old, Partial_Reveal_Object *p_new, Collector* collector);
 
+void event_mutator_allocate_newobj(Partial_Reveal_Object* p_newobj, POINTER_SIZE_INT size, VT vt_raw);
+void event_gc_collect_kind_changed(GC* gc);
 #endif

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.cpp?view=auto&rev=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.cpp Mon Mar 26 19:53:57 2007
@@ -0,0 +1,397 @@
+#include "verifier_common.h"
+#include "verify_mutator_effect.h"
+
+/*<-----------verify allocation----------------->*/
+void verifier_init_allocation_verifier( Heap_Verifier* heap_verifier)
+{
+  Allocation_Verifier* allocation_verifier = (Allocation_Verifier*)STD_MALLOC(sizeof(Allocation_Verifier));
+  assert(allocation_verifier);
+  memset(allocation_verifier, 0, sizeof(Allocation_Verifier));
+  allocation_verifier->size_nos_newobjs = allocation_verifier->num_nos_newobjs = 0;
+  allocation_verifier->size_los_newobjs = allocation_verifier->size_los_newobjs = 0;
+  allocation_verifier->size_nos_objs = allocation_verifier->num_nos_objs = 0;
+  allocation_verifier->size_los_objs = allocation_verifier->num_los_objs = 0;
+  allocation_verifier->last_size_los_objs = allocation_verifier->last_num_los_objs = 0;
+  allocation_verifier->new_objects_set = NULL;
+  allocation_verifier->new_objects_set 
+      = verifier_free_set_pool_get_entry(heap_verifier->heap_verifier_metadata->free_objects_pool);
+  heap_verifier->allocation_verifier = allocation_verifier;
+}
+
+void verifier_destruct_allocation_verifier(Heap_Verifier* heap_verifier)
+{
+  //assert(heap_verifier->allocation_verifier->new_objects_set == NULL);
+  STD_FREE(heap_verifier->allocation_verifier);
+  heap_verifier->allocation_verifier = NULL;
+}
+
+void verify_allocation_reset(Heap_Verifier* heap_verifier)
+{
+  Allocation_Verifier* alloc_verifier = heap_verifier->allocation_verifier;
+  GC_Gen* gc    = (GC_Gen*)heap_verifier->gc;
+  Space* lspace  = gc_get_los(gc);
+
+  alloc_verifier->size_los_objs = alloc_verifier->num_los_objs = 0;
+
+  verifier_scan_los_objects(lspace, heap_verifier);
+  
+  alloc_verifier->last_size_los_objs = alloc_verifier->size_los_objs;
+  alloc_verifier->last_num_los_objs = alloc_verifier->num_los_objs;
+  
+  alloc_verifier->size_nos_newobjs = alloc_verifier->num_nos_newobjs = 0;
+  alloc_verifier->size_los_newobjs = alloc_verifier->num_los_newobjs = 0;
+  alloc_verifier->size_nos_objs = alloc_verifier->num_nos_objs = 0;
+  alloc_verifier->size_los_objs = alloc_verifier->num_los_objs = 0;
+  
+  assert(alloc_verifier->new_objects_set == NULL);
+  alloc_verifier->new_objects_set = verifier_free_set_pool_get_entry(verifier_metadata->free_objects_pool);
+  assert(alloc_verifier->new_objects_set);
+
+}
+
+Boolean verify_new_object(New_Object* new_obj, Heap_Verifier* heap_verifier)
+{
+  if(!heap_verifier->need_verify_allocation) return TRUE;
+  
+  GC_Gen* gc    =(GC_Gen*) heap_verifier->gc;
+  Space* mspace = gc_get_mos(gc);
+  assert(mspace);
+  
+  if(obj_belongs_to_space(new_obj->address, mspace)){
+    assert(0);
+    printf("GC Verify ==> Verify Allocation: new Objects in MOS...\n ");
+    return FALSE;
+  }
+  
+  Partial_Reveal_Object* p_newobj = new_obj->address;
+  if(obj_get_vt_raw(p_newobj) != new_obj->vt_raw){
+    assert(0);
+    printf("GC Verify ==> Verify Allocation: new Objects Vtable Error...\n ");
+    return FALSE;
+  }
+  
+  if(vm_object_size(p_newobj) != new_obj->size){
+    assert(0);
+    printf("GC Verify ==> Verify Allocation: new Objects size Error...\n ");
+    return FALSE;
+  }
+  
+  return TRUE;
+}
+
+void verify_allocation(Heap_Verifier* heap_verifier)
+{
+  Allocation_Verifier* alloc_verifier = heap_verifier->allocation_verifier;
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  pool_put_entry(verifier_metadata->new_objects_pool, alloc_verifier->new_objects_set);
+  alloc_verifier->new_objects_set = NULL;
+  
+  GC_Gen* gc    = (GC_Gen*)heap_verifier->gc;
+  Space* nspace = gc_get_nos(gc);
+  Space* lspace  = gc_get_los(gc);
+  assert(nspace);
+  assert(lspace);
+  
+  POINTER_SIZE_INT size_los_newobjs 
+                        = alloc_verifier->size_los_objs - alloc_verifier->last_size_los_objs;
+  POINTER_SIZE_INT num_los_newobjs 
+                        = alloc_verifier->num_los_objs - alloc_verifier->last_num_los_objs;
+
+  assert(alloc_verifier->size_nos_objs == alloc_verifier->size_nos_newobjs);
+  assert(alloc_verifier->num_nos_objs == alloc_verifier->num_nos_newobjs);
+  if(alloc_verifier->size_nos_objs != alloc_verifier->size_nos_newobjs){
+    printf("GC Verify ==> Verify Allocation: NOS new objects size error.\n"); 
+    alloc_verifier->is_verification_passed = FALSE;
+  }
+  if(alloc_verifier->num_nos_objs != alloc_verifier->num_nos_newobjs){
+    printf("GC Verify ==> Verify Allocation: NOS new objects number error.\n"); 
+    alloc_verifier->is_verification_passed = FALSE;
+  }
+  
+  assert(size_los_newobjs == alloc_verifier->size_los_newobjs);
+  assert(num_los_newobjs == alloc_verifier->num_los_newobjs);
+  if(size_los_newobjs != alloc_verifier->size_los_newobjs){
+    printf("GC Verify ==> Verify Allocation: LOS new objects size error.\n"); 
+    alloc_verifier->is_verification_passed = FALSE;
+  }
+  if(num_los_newobjs != alloc_verifier->num_los_newobjs){
+    printf("GC Verify ==> Verify Allocation: LOS new objects number error.\n"); 
+    alloc_verifier->is_verification_passed = FALSE;
+  }
+
+  
+  assert(alloc_verifier->new_objects_set == NULL);
+  Vector_Block* new_objects = pool_get_entry(verifier_metadata->new_objects_pool);
+  while(new_objects){
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(new_objects);
+    while(!vector_block_iterator_end(new_objects, iter)){
+      New_Object* p_newobj = (New_Object*) *iter;
+      iter = vector_block_iterator_advance(new_objects, iter);
+      if(!verify_new_object(p_newobj, heap_verifier)){
+        assert(0);
+        printf("GC Verify ==> Verify Allocation: new objects verify error.\n");
+        alloc_verifier->is_verification_passed = FALSE;
+      }
+      STD_FREE(p_newobj);
+    }
+    vector_block_clear(new_objects);
+    pool_put_entry(verifier_metadata->free_objects_pool, new_objects);
+    new_objects = pool_get_entry(verifier_metadata->new_objects_pool);
+  }
+}
+
+
+
+void verifier_allocation_update_info(Partial_Reveal_Object *p_obj, Heap_Verifier* heap_verifier)
+{
+  if(!heap_verifier->need_verify_allocation) return;
+  
+  Allocation_Verifier* alloc_verifier = heap_verifier->allocation_verifier;
+  GC_Gen* gc  =  (GC_Gen*)heap_verifier->gc;
+  Space* nspace   = gc_get_nos(gc);
+  Space* mspace  = gc_get_mos(gc); 
+  Space* lspace    = gc_get_los(gc);
+  assert(nspace);
+  assert(lspace);
+  
+  if(obj_belongs_to_space(p_obj, nspace)){
+    alloc_verifier->size_nos_objs += vm_object_size(p_obj); 
+    alloc_verifier->num_nos_objs ++;
+    return;
+  }else if(obj_belongs_to_space(p_obj, lspace)){
+    alloc_verifier->size_los_objs += vm_object_size(p_obj); 
+    alloc_verifier->num_los_objs ++;
+    return;
+  }else if(obj_belongs_to_space(p_obj, mspace)){
+    return;
+  }
+  assert(0);
+}
+
+void verifier_event_mutator_allocate_newobj(Partial_Reveal_Object* p_newobj, POINTER_SIZE_INT size, VT vt_raw)
+{
+  Heap_Verifier* heap_verifier = get_heap_verifier();
+  if(!heap_verifier->need_verify_allocation) return;
+
+  assert(p_newobj);
+  assert(obj_get_vt(p_newobj));
+  assert(obj_get_vt(p_newobj) == vt_raw);
+  
+  New_Object* new_obj = (New_Object*) STD_MALLOC(sizeof(New_Object));
+  assert(new_obj);
+  new_obj->address  = p_newobj;
+  new_obj->size         = size;
+  new_obj->vt_raw     = (VT) vt_raw;
+  
+  Heap_Verifier_Metadata* verifier_metadata = heap_verifier->heap_verifier_metadata;
+  Allocation_Verifier* alloc_verifier = heap_verifier->allocation_verifier;
+  
+  /*FIXME: Replace lock */
+  lock(alloc_verifier->alloc_lock);
+  
+  verifier_set_push((void*)new_obj, alloc_verifier->new_objects_set, verifier_metadata->new_objects_pool);
+  
+  GC_Gen* gc    =(GC_Gen*) heap_verifier->gc;
+  Space* nspace = gc_get_nos(gc);
+  Space* lspace  = gc_get_los(gc);
+
+  //FIXME: 
+  //assert(size == vm_object_size(p_newobj));
+  if(obj_belongs_to_space(p_newobj, nspace)){
+    alloc_verifier->size_nos_newobjs += size;
+    alloc_verifier->num_nos_newobjs ++;
+  }else if (obj_belongs_to_space(p_newobj, lspace)){
+    alloc_verifier->size_los_newobjs += size;
+    alloc_verifier->num_los_newobjs ++;
+  }else{
+    assert(0);
+    alloc_verifier->is_verification_passed = FALSE;
+
+  }
+  unlock(alloc_verifier->alloc_lock);
+}
+
+/*<-----------verify root sets----------------->*/
+/*FIXME: where should root set verifier be placed*/
+/*The rootset set verifier is placed here, so the rootset verifier
+    verifys the rootset that vm enumerated before GC. The rootset 
+    verifying processes before and after gc will be integrated in  gc verifying pass,
+    the rootset verifying is considered as slot verifying while verifying gc. */
+void verifier_init_rootset_verifier( Heap_Verifier* heap_verifier)
+{
+  RootSet_Verifier* rs_verifier = (RootSet_Verifier*)STD_MALLOC(sizeof(RootSet_Verifier));
+  assert(rs_verifier);
+  memset(rs_verifier, 0, sizeof(RootSet_Verifier));
+  rs_verifier->num_slots_in_rootset = 0;
+  rs_verifier->num_error_slots = 0;
+  rs_verifier->is_verification_passed = FALSE;
+  heap_verifier->rootset_verifier = rs_verifier;
+}
+ 
+
+void verifier_destruct_rootset_verifier( Heap_Verifier* heap_verifier)
+{
+  assert(heap_verifier != NULL);
+  assert(heap_verifier->rootset_verifier != NULL);
+  STD_FREE(heap_verifier->rootset_verifier);
+  heap_verifier->rootset_verifier = NULL;
+}
+
+
+void verify_root_set(Heap_Verifier* heap_verifier)
+{
+  assert(heap_verifier);
+  GC_Gen* gc    = (GC_Gen*)heap_verifier->gc;
+  GC_Metadata* gc_metadata = gc->metadata;
+
+  assert(gc);
+  assert(gc_metadata);
+  assert(gc_metadata->gc_rootset_pool);
+
+  RootSet_Verifier* rootset_verifier = heap_verifier->rootset_verifier;
+  
+  pool_iterator_init(gc_metadata->gc_rootset_pool);
+  Vector_Block* root_set = pool_iterator_next(gc_metadata->gc_rootset_pool);
+  
+  /* first step: copy all root objects to trace tasks. */ 
+  while(root_set){
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(root_set);
+    while(!vector_block_iterator_end(root_set,iter)){
+      REF* p_ref = (REF* )*iter;
+      iter = vector_block_iterator_advance(root_set,iter);
+      rootset_verifier->num_slots_in_rootset ++;
+      if(!verify_rootset_slot(p_ref, heap_verifier)){
+        rootset_verifier->is_verification_passed = FALSE;
+        rootset_verifier->num_error_slots ++;
+        assert(0);
+        continue;
+      }
+    } 
+    root_set = pool_iterator_next(gc_metadata->gc_rootset_pool);
+  }
+}
+
+
+
+/*<-----------verify write barrier----------------->*/
+
+void verifier_init_wb_verifier( Heap_Verifier* heap_verifier)
+{
+  WriteBarrier_Verifier* wb_verifier = (WriteBarrier_Verifier*) STD_MALLOC(sizeof(WriteBarrier_Verifier));
+  assert(wb_verifier);
+  memset(wb_verifier, 0, sizeof(WriteBarrier_Verifier));
+  wb_verifier->num_ref_wb_after_scanning = 0;
+  wb_verifier->num_ref_wb_in_remset = 0;
+  wb_verifier->num_slots_in_remset = 0;
+  wb_verifier->is_verification_passed = FALSE;
+  heap_verifier->writebarrier_verifier = wb_verifier;
+}
+ 
+
+void verifier_destruct_wb_verifier( Heap_Verifier* heap_verifier)
+{
+  assert(heap_verifier != NULL);
+  assert(heap_verifier->writebarrier_verifier != NULL);
+  STD_FREE(heap_verifier->writebarrier_verifier);
+  heap_verifier->writebarrier_verifier = NULL;
+}
+
+
+void verifier_mark_wb_slots(Heap_Verifier* heap_verifier)
+{
+  GC_Gen* gc = (GC_Gen*)(heap_verifier->gc);
+  if(gc->collect_kind != MINOR_COLLECTION ||!gc_is_gen_mode()) return;
+
+  GC_Metadata*gc_metadata = gc->metadata;
+  Space* nspace  = gc_get_nos(gc);
+
+  WriteBarrier_Verifier* wb_verifier = heap_verifier->writebarrier_verifier;
+  assert(wb_verifier);
+  
+  pool_iterator_init(gc_metadata->gc_rootset_pool);
+  Vector_Block* rem_set = pool_iterator_next(gc_metadata->gc_rootset_pool);
+
+    
+  while(rem_set){
+    if(rem_set == gc->root_set) break;
+    POINTER_SIZE_INT* iter = vector_block_iterator_init(rem_set);
+    while(!vector_block_iterator_end(rem_set, iter)){
+      REF* p_ref = (REF* )*iter;
+      wb_verifier->num_slots_in_remset ++;
+      if(!address_belongs_to_space((void*)p_ref, nspace) && address_belongs_to_space((void*)*p_ref, nspace)){
+        if(!wb_is_marked_in_slot(p_ref)){
+          wb_mark_in_slot(p_ref);
+          wb_verifier->num_ref_wb_in_remset ++;
+        }
+      }
+      iter = vector_block_iterator_advance(rem_set, iter);
+    }
+    rem_set = pool_iterator_next(gc_metadata->gc_rootset_pool);
+  }  
+}
+
+void verify_write_barrier(REF* p_ref, Heap_Verifier* heap_verifier)
+{
+  GC_Gen* gc    = (GC_Gen*)heap_verifier->gc;
+  if(gc->collect_kind != MINOR_COLLECTION ||!gc_is_gen_mode()) return;
+  
+  Space* nspace  = gc_get_nos(gc);
+  assert(address_belongs_to_gc_heap((void*)p_ref, (GC *) gc));
+  
+  WriteBarrier_Verifier* wb_verifier = heap_verifier->writebarrier_verifier;
+  assert(wb_verifier);
+
+  if(!address_belongs_to_space((void*)p_ref, nspace) && address_belongs_to_space((void*)*p_ref, nspace)){
+    if(!wb_is_marked_in_slot(p_ref)){
+      assert(0);
+      printf("GC Verify ==> Verify Write Barrier: error!!!\n");
+      wb_verifier->is_verification_passed = FALSE;
+    }else{
+      wb_unmark_in_slot(p_ref);
+      wb_verifier->num_ref_wb_after_scanning ++;
+    }
+  }
+}
+
+/*<------------verify mutator effect common--------------->*/
+
+void verifier_init_mutator_verifiers( Heap_Verifier* heap_verifier)
+{
+  verifier_init_allocation_verifier(heap_verifier);
+  verifier_init_wb_verifier(heap_verifier);
+  verifier_init_rootset_verifier(heap_verifier);
+}
+ 
+
+void verifier_destruct_mutator_verifiers( Heap_Verifier* heap_verifier)
+{
+  verifier_destruct_allocation_verifier(heap_verifier);
+  verifier_destruct_wb_verifier(heap_verifier);
+  verifier_destruct_rootset_verifier(heap_verifier);
+}
+
+void verifier_reset_mutator_verification(Heap_Verifier* heap_verifier)
+{
+  heap_verifier->allocation_verifier->is_verification_passed = TRUE;
+  heap_verifier->writebarrier_verifier->is_verification_passed = TRUE;
+  heap_verifier->rootset_verifier->is_verification_passed = TRUE;
+  
+  if(heap_verifier->need_verify_writebarrier && heap_verifier->gc_is_gen_mode)
+    verifier_mark_wb_slots(heap_verifier);
+
+}
+
+
+void verifier_clear_mutator_verification(Heap_Verifier* heap_verifier)
+{
+  if(heap_verifier->need_verify_allocation) verify_allocation_reset(heap_verifier);  
+}
+
+
+void verify_mutator_effect(Heap_Verifier* heap_verifier)
+{
+  if(heap_verifier->need_verify_rootset)  verify_root_set(heap_verifier);
+  if(heap_verifier->need_verify_allocation)  verify_allocation(heap_verifier);
+}
+ 
+

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.h?view=auto&rev=522715
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.h Mon Mar 26 19:53:57 2007
@@ -0,0 +1,65 @@
+#ifndef _VERIFY_MUTATOR_EFFECT_H_
+#define _VERIFY_MUTATOR_EFFECT_H_
+
+#include "verifier_common.h"
+
+typedef struct Allocation_Verifier{
+  SpinLock alloc_lock;
+    
+  /*calculated in GC allocation phase.*/
+  POINTER_SIZE_INT size_nos_newobjs;
+  POINTER_SIZE_INT num_nos_newobjs;
+  POINTER_SIZE_INT size_los_newobjs;
+  POINTER_SIZE_INT num_los_newobjs;
+  
+  /*size and number of objects in LOS after last GC*/
+  POINTER_SIZE_INT last_size_los_objs;
+  POINTER_SIZE_INT last_num_los_objs;
+  
+  /*calculated in whole heap scanning phase.*/
+  POINTER_SIZE_INT size_nos_objs;
+  POINTER_SIZE_INT num_nos_objs;
+  POINTER_SIZE_INT size_los_objs;
+  POINTER_SIZE_INT num_los_objs;
+  
+  Vector_Block* new_objects_set;
+  
+  Boolean is_verification_passed;  
+}Allocation_Verifier;
+
+typedef struct WriteBarrier_Verifier{
+  POINTER_SIZE_INT num_slots_in_remset;
+  POINTER_SIZE_INT num_ref_wb_in_remset;
+  POINTER_SIZE_INT num_ref_wb_after_scanning;
+  Boolean is_verification_passed;
+}WriteBarrier_Verifier;
+
+typedef struct RootSet_Verifier{
+  POINTER_SIZE_INT num_slots_in_rootset;
+  POINTER_SIZE_INT num_error_slots;
+  Boolean is_verification_passed;
+}RootSet_Verifier;
+
+
+typedef struct New_Object_struct{
+  Partial_Reveal_Object* address;
+  POINTER_SIZE_INT size;
+  VT vt_raw;
+} New_Object;
+
+void verify_write_barrier(REF* p_ref, Heap_Verifier* heap_verifier);
+void verify_allocation(Heap_Verifier* heap_verifier);
+void verify_root_set(Heap_Verifier* heap_verifier);
+
+void verifier_init_mutator_verifiers(Heap_Verifier* heap_verifier);
+void verifier_event_mutator_allocate_newobj(Partial_Reveal_Object* p_newobj, POINTER_SIZE_INT size, VT vt_raw);
+void verifier_destruct_mutator_verifiers(Heap_Verifier* heap_verifier);
+void verifier_allocation_update_info(Partial_Reveal_Object *p_obj, Heap_Verifier* heap_verifier);
+
+void verifier_reset_mutator_verification(Heap_Verifier* heap_verifier);
+void verifier_clear_mutator_verification(Heap_Verifier* heap_verifier);
+
+void verify_mutator_effect(Heap_Verifier* heap_verifier);
+
+
+#endif //_VERIFY_MUTATOR_EFFECT_H_

Propchange: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/verify/verify_mutator_effect.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message