harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject svn commit: r613384 - in /harmony/enhanced/drlvm/trunk/vm/gc_gen: javasrc/org/apache/harmony/drlvm/gc_gen/ javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/ src/common/ src/gen/ src/los/ src/mark_compact/ src/mark_sweep/ src/semi_space/ src/thread/ src/t...
Date Sat, 19 Jan 2008 11:40:29 GMT
Author: xli
Date: Sat Jan 19 03:40:19 2008
New Revision: 613384

URL: http://svn.apache.org/viewvc?rev=613384&view=rev
Log:
HARMONY-5367 and HARMONY-5369, semispace GC updates and mark phase prefetch

Modified:
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/collection_scheduler.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/object_status.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_stats.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_utils.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_alloc.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_chunk.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_concurrent_gc_stats.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_mark_sweep.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_sweep_concurrent.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace_gen_ss_pool.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_gen_forward_pool.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_nongen_forward_pool.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/vector_block.h

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java Sat Jan 19 03:40:19 2008
@@ -71,12 +71,11 @@
             if(new_free.LE(end)) {
                // do prefetch from new_free to new_free + PREFETCH_DISTANCE + ZEROING_SIZE
                VMHelper.prefetch(new_free, PREFETCH_DISTANCE + ZEROING_SIZE, PREFETCH_STRIDE);
-
+    
                Address new_ceiling = new_free.plus(ZEROING_SIZE);
 	       // align ceiling to 64 bytes		
 	       int remainder = new_ceiling.toInt() & 63;
 	       new_ceiling = new_ceiling.minus(remainder);
-
                if( !new_ceiling.LE(end) ){
                    new_ceiling = end;
                }
@@ -137,7 +136,13 @@
             p_objSlot.store(p_target);
             return;
         }
-
+        Address p_obj_info = p_objBase.plus(4);
+        int obj_info = p_obj_info.loadInt();
+        if((obj_info & 0x80) != 0){
+            p_objSlot.store(p_target);
+            return;
+        }
+         
         VMHelper.writeBarrier(p_objBase, p_objSlot, p_target);
     }
 
@@ -155,6 +160,7 @@
     private static native long getNosBoundary();    
     private static native int TLSGCOffset();
 }
+
 
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc_uncomp/org/apache/harmony/drlvm/gc_gen/GCHelper.java Sat Jan 19 03:40:19 2008
@@ -136,7 +136,13 @@
             p_objSlot.store(p_target);
             return;
         }
-
+        Address p_obj_info = p_objBase.plus(4);
+        int obj_info = p_obj_info.loadInt();
+        if((obj_info & 0x80) != 0){
+            p_objSlot.store(p_target);
+            return;
+        }
+         
         VMHelper.writeBarrier(p_objBase, p_objSlot, p_target);
     }
 
@@ -154,6 +160,7 @@
     private static native long getNosBoundary();    
     private static native int TLSGCOffset();
 }
+
 
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/collection_scheduler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/collection_scheduler.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/collection_scheduler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/collection_scheduler.cpp Sat Jan 19 03:40:19 2008
@@ -157,7 +157,7 @@
       if(gc_concurrent_match_algorithm(OTF_REM_OBJ_SNAPSHOT_ALGO)||gc_concurrent_match_algorithm(OTF_REM_NEW_TARGET_ALGO)){
         collection_scheduler->time_delay_to_start_mark = (int64)((time_alloc_expected - time_trace_expected)*0.65);
       }else if(gc_concurrent_match_algorithm(MOSTLY_CONCURRENT_ALGO)){
-        collection_scheduler->time_delay_to_start_mark = (int64)(time_mutator* 0.6);
+        collection_scheduler->time_delay_to_start_mark = (int64)(time_mutator* 0.5);
       }
       
     }else{
@@ -190,18 +190,19 @@
 
     if(num_active_marker == 0) num_active_marker = 1;
 
-    if(c_time > m_time || (float)d_time > (m_time - c_time) * 0.75){      
+    if((c_time + d_time) > m_time || (float)d_time < (m_time * 0.25)){      
       INFO2("gc.con","[Concurrent GC] increase marker number.");
       num_active_marker ++;
       if(num_active_marker > gc->num_markers) num_active_marker = gc->num_markers;
-    }else if((float)d_time < (m_time - c_time) * 0.25){
+    }else if((float)d_time > (m_time * 0.6)){
       INFO2("gc.con","[Concurrent GC] decrease marker number.");
       num_active_marker --;
       if(num_active_marker == 0)  num_active_marker = 1;
     }
+    
+    INFO2("gc.con","[Concurrent GC] ctime  "<<(unsigned)(c_time>>10)<<"  mtime  "<<(unsigned)(m_time>>10)<<"  dtime  "<<(unsigned)(d_time>>10));
+    INFO2("gc.con","[Concurrent GC] marker num : "<<num_active_marker<<" ");
   }
-  
-  INFO2("gc.con","[Concurrent GC] marker num : "<<num_active_marker<<" ");
 
   
   collection_scheduler->last_marker_num = num_active_marker;
@@ -221,10 +222,12 @@
   }
   
   if(gc_need_start_concurrent_mark(gc)){
-    vm_gc_lock_enum();
-    INFO2("gc.con", "\nCon GC: concurrent mark start ...\n");
+    vm_gc_lock_enum();    
+    int64 pause_start = time_now();
+    INFO2("gc.con", "[Concurrent GC] concurrent mark start ...\n");
     gc_start_concurrent_mark(gc);
     vm_gc_unlock_enum();
+    INFO2("gc.con","[Concurrent GC] pause time of concurrent enumeration:  "<<((unsigned int)((time_now()-pause_start)>>10))<<"  ms \n");
     unlock(gc->collection_scheduler_lock);
     return TRUE;
   }
@@ -237,13 +240,15 @@
   }
 
   if(gc_need_reset_status(gc)){
+    int64 pause_start = time_now();
     vm_gc_lock_enum();
     int disable_count = hythread_reset_suspend_disable();    
     gc_prepare_rootset(gc);
     gc_reset_after_concurrent_collection(gc);
-    vm_resume_threads_after();    
+    vm_resume_threads_after();
     hythread_set_suspend_disable(disable_count);
     vm_gc_unlock_enum();
+    INFO2("gc.con","[Concurrent GC] pause time after concurrent GC:  "<<((unsigned int)((time_now()-pause_start)>>10))<<"  ms \n");
     unlock(gc->collection_scheduler_lock);
     return TRUE;
   }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_block.h Sat Jan 19 03:40:19 2008
@@ -214,6 +214,7 @@
     if( obj_is_marked_in_vt(cur_obj))
       return cur_obj;
     cur_obj = obj_end(cur_obj);
+    PREFETCH( ((POINTER_SIZE_INT) cur_obj) + 64);
   }
   
   return NULL;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp Sat Jan 19 03:40:19 2008
@@ -328,7 +328,7 @@
 
 #if defined(ALLOC_ZEROING) && defined(ALLOC_PREFETCH)
   if(is_property_set("gc.prefetch",VM_PROPERTIES) ==1) {
-    PREFETCH_ENABLED=get_boolean_property("gc.prefetch");
+    PREFETCH_ENABLED = get_boolean_property("gc.prefetch");
   }
 
   if(is_property_set("gc.prefetch_distance",VM_PROPERTIES)==1) {
@@ -347,12 +347,15 @@
   
   if(is_property_set("gc.zeroing_size",VM_PROPERTIES)==1) {
     ZEROING_SIZE = get_size_property("gc.zeroing_size");
-    if(!PREFETCH_ENABLED) {
-      WARN2("gc.zeroing_size","Warning: Zeroing size set with Prefetch disabled!");
-    }  
   }   
 #endif
 
+#ifdef PREFETCH_SUPPORTED
+  if(is_property_set("gc.mark_prefetch",VM_PROPERTIES) ==1) {
+    mark_prefetch = get_boolean_property("gc.mark_prefetch");
+  }  
+#endif
+
   return;
 }
 
@@ -397,13 +400,6 @@
 
 void gc_prepare_rootset(GC* gc)
 {
-  if(!USE_CONCURRENT_GC){
-    gc_metadata_verify(gc, TRUE);
-#ifndef BUILD_IN_REFERENT
-    gc_finref_metadata_verify((GC*)gc, TRUE);
-#endif
-  }
-
   /* Stop the threads and collect the roots. */
   lock(gc->enumerate_rootset_lock);
   INFO2("gc.process", "GC: stop the threads and enumerate rootset ...\n");
@@ -439,16 +435,9 @@
     gc_finref_metadata_verify((GC*)gc, TRUE);
 #endif
   }
-  /* Stop the threads and collect the roots. */
-  lock(gc->enumerate_rootset_lock);
-  INFO2("gc.process", "GC: stop the threads and enumerate rootset ...\n");
-  gc_clear_rootset(gc);
-  gc_reset_rootset(gc);
   int disable_count = hythread_reset_suspend_disable();
-  vm_enumerate_root_set_all_threads();
-  gc_copy_interior_pointer_table_to_rootset();
-  gc_set_rootset(gc);
-  unlock(gc->enumerate_rootset_lock);
+  /* Stop the threads and collect the roots. */
+  gc_prepare_rootset(gc);
   
   if(USE_CONCURRENT_GC && gc_sweep_is_concurrent()){
     if(gc_is_concurrent_sweep_phase())
@@ -535,6 +524,7 @@
   INFO2("gc.con","pause time:  "<<((unsigned int)(pause_time>>10))<<"  ms \n");
   return;
 }
+
 
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.h Sat Jan 19 03:40:19 2008
@@ -395,7 +395,7 @@
 
 inline Boolean obj_is_survivor(Partial_Reveal_Object* p_obj)
 {
-  return get_obj_info_raw(p_obj) & OBJ_AGE_BIT;
+  return (Boolean)(get_obj_info_raw(p_obj) & OBJ_AGE_BIT);
 }
 
 inline void obj_set_age_bit(Partial_Reveal_Object* p_obj)
@@ -411,6 +411,26 @@
 }
 
 /***************************************************************/
+
+inline Boolean obj_is_remembered(Partial_Reveal_Object* p_obj)
+{
+  return (Boolean)(get_obj_info_raw(p_obj) & OBJ_REM_BIT);
+}
+
+inline void obj_set_rem_bit(Partial_Reveal_Object* p_obj)
+{
+  Obj_Info_Type oi = get_obj_info_raw(p_obj);
+  return set_obj_info( p_obj, oi |OBJ_REM_BIT) ;
+}
+
+inline void obj_clear_rem_bit(Partial_Reveal_Object* p_obj)
+{
+  Obj_Info_Type oi = get_obj_info_raw(p_obj);
+  return set_obj_info( p_obj, oi & ~OBJ_REM_BIT) ;
+}
+
+/***************************************************************/
+
 /* all GCs inherit this GC structure */
 struct Marker;
 struct Mutator;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.cpp Sat Jan 19 03:40:19 2008
@@ -31,8 +31,74 @@
 
 volatile unsigned int write_barrier_function;
 
+void allocator_object_write_barrier(Partial_Reveal_Object* p_object, Collector* allocator) 
+{
+  if( addr_belongs_to_nos(p_object)) return;
+
+  REF* p_slot; 
+  /* scan array object */
+  if (object_is_array((Partial_Reveal_Object*)p_object)) {
+    Partial_Reveal_Object* array = p_object;
+    assert(!obj_is_primitive_array(array));
+
+    int32 array_length = vector_get_length((Vector_Handle) array);
+    for (int i = 0; i < array_length; i++) {
+      p_slot = (REF *)vector_get_element_address_ref((Vector_Handle)array, i);
+      if( read_slot(p_slot) != NULL && addr_belongs_to_nos(read_slot(p_slot))){
+        collector_remset_add_entry(allocator, (Partial_Reveal_Object**)p_slot);
+      }
+    }   
+    return;
+  }
+
+  /* scan non-array object */
+  Partial_Reveal_Object* p_obj =  (Partial_Reveal_Object*)p_object;   
+  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_slot = object_ref_iterator_get(ref_iterator+i, p_obj);        
+    if( addr_belongs_to_nos(read_slot(p_slot))){
+      collector_remset_add_entry(allocator, (Partial_Reveal_Object**)p_slot);
+    }
+  }
+
+  return;
+}
+
+static void mutator_rem_obj(Managed_Object_Handle p_obj_written)
+{
+  if( obj_is_remembered((Partial_Reveal_Object*)p_obj_written))
+    return;
+
+  Partial_Reveal_Object* p_obj = (Partial_Reveal_Object*)p_obj_written;
+  Obj_Info_Type info = get_obj_info_raw(p_obj);
+  Obj_Info_Type new_info = info | OBJ_REM_BIT;
+  while ( info != new_info) {
+    Obj_Info_Type temp =
+      atomic_casptrsz((volatile POINTER_SIZE_INT*)get_obj_info_addr(p_obj), new_info, info);
+    if (temp == info) break;
+    info = get_obj_info_raw(p_obj);
+    new_info = info | OBJ_REM_BIT;
+  }
+  if(info == new_info) return; /* remembered by other */
+    
+  Mutator *mutator = (Mutator *)gc_get_tls();            
+  mutator_remset_add_entry(mutator, (REF*)p_obj);
+  return;
+}
+
+static void gen_write_barrier_rem_obj(Managed_Object_Handle p_obj_holding_ref, 
+                      Managed_Object_Handle p_target) 
+{
+  if(p_target >= nos_boundary && p_obj_holding_ref < nos_boundary)
+    mutator_rem_obj(p_obj_holding_ref);
+
+  return;
+}
+
 /* The implementations are only temporary */
-static void write_barrier_rem_source_slot(Managed_Object_Handle *p_slot, 
+static void gen_write_barrier_rem_slot(Managed_Object_Handle *p_slot, 
                       Managed_Object_Handle p_target) 
 {
   if(p_target >= nos_boundary && p_slot < nos_boundary){
@@ -178,11 +244,18 @@
   }
   mutator_post_signal(mutator,MUTATOR_EXIT_BARRIER);
 
-  if( !gc_is_gen_mode() ) return;
-  if( object_has_ref_field((Partial_Reveal_Object*)p_obj_written)){
-    /* for array copy and object clone */
-    gc_object_write_barrier(p_obj_written); 
-  }
+  if( !gc_is_gen_mode() || !object_has_ref_field((Partial_Reveal_Object*)p_obj_written)) 
+    return;
+
+  /* for array copy and object clone */
+#ifdef USE_REM_SLOTS
+  gc_object_write_barrier(p_obj_written); 
+#else
+  if( p_obj_written >= nos_boundary ) return;
+
+  mutator_rem_obj( p_obj_written );  
+#endif 
+  return;
 }
 
 /* FIXME:: this is not the right interface for write barrier */
@@ -197,7 +270,11 @@
       break;
     case WRITE_BARRIER_REM_SOURCE_REF:
       *p_slot = p_target;
-      write_barrier_rem_source_slot(p_slot, p_target); 
+#ifdef USE_REM_SLOTS
+      gen_write_barrier_rem_slot(p_slot, p_target); 
+#else /* USE_REM_OBJS */
+      gen_write_barrier_rem_obj(p_obj_holding_ref, p_target);
+#endif
       break;      
     case WRITE_BARRIER_REM_SOURCE_OBJ:
       *p_slot = p_target;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_barrier.h Sat Jan 19 03:40:19 2008
@@ -39,5 +39,7 @@
 {
   write_barrier_function = wb_function;
 }
+
 #endif /* _GC_FOR_BARRIER_H_ */
+
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_class.h Sat Jan 19 03:40:19 2008
@@ -67,7 +67,11 @@
 
 #define OBJ_DIRTY_BIT 0x20
 
+/* used by semispace GC to indicate the object is a survivor in NOS */
 #define OBJ_AGE_BIT 0x40
+
+/* used by generational GC to indicate the object has been remembered */
+#define OBJ_REM_BIT 0x80
 
 #ifdef POINTER64 // Like in VM
   #define COMPRESS_VTABLE

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_metadata.cpp Sat Jan 19 03:40:19 2008
@@ -305,14 +305,34 @@
   assert(gc_match_either_kind(gc, MINOR_COLLECTION|NORMAL_MAJOR_COLLECTION));
   if( gc_match_kind(gc, NORMAL_MAJOR_COLLECTION )){
     /* all the remsets are useless now */
-    /* clean and put back mutator remsets */  
+    /* clean and put back mutator remsets */
+#ifdef USE_REM_SLOTS  
     root_set = pool_get_entry( mutator_remset_pool );
     while(root_set){
         vector_block_clear(root_set);
         pool_put_entry(free_set_pool, root_set);
         root_set = pool_get_entry( mutator_remset_pool );
     }
-  
+#else
+    Vector_Block* rem_set = pool_get_entry(mutator_remset_pool);
+    
+    while(rem_set){
+      POINTER_SIZE_INT* iter = vector_block_iterator_init(rem_set);
+      while(!vector_block_iterator_end(rem_set,iter)){
+        Partial_Reveal_Object* p_obj_holding_ref = (Partial_Reveal_Object*)*iter;
+        iter = vector_block_iterator_advance(rem_set,iter);
+        
+        assert( !obj_belongs_to_nos(p_obj_holding_ref));
+        assert( obj_is_remembered(p_obj_holding_ref));
+        obj_clear_rem_bit(p_obj_holding_ref);
+      } 
+      vector_block_clear(rem_set);
+      pool_put_entry(free_set_pool, rem_set);      
+      rem_set = pool_get_entry(metadata->mutator_remset_pool);
+    }
+    
+#endif /* ifdef USE_REM_SLOTS else */  
+
     /* clean and put back collector remsets */  
     root_set = pool_get_entry( collector_remset_pool );
     while(root_set){
@@ -322,12 +342,45 @@
     }
 
   }else{ /* generational MINOR_COLLECTION */
+
     /* all the remsets are put into the shared pool */
+#ifdef USE_REM_SLOTS
     root_set = pool_get_entry( mutator_remset_pool );
     while(root_set){
         pool_put_entry(gc_rootset_pool, root_set);
         root_set = pool_get_entry( mutator_remset_pool );
     }
+#else /* USE_REM_OBJS */
+    /* scan mutator remembered objects, and put the p_refs to collector_remset_pool if they
+       hold references to NOS. The pool will be moved to rootset_pool next. */
+    
+    void allocator_object_write_barrier(Partial_Reveal_Object* p_object, Collector* allocator); 
+    /* temporarily use collector[0]'s rem_set for the moving. Hope to be parallelized in future. */
+    Collector* collector = gc->collectors[0];
+    collector->rem_set = free_set_pool_get_entry(metadata);
+
+    Vector_Block* rem_set = pool_get_entry(mutator_remset_pool);
+    
+    while(rem_set){
+      POINTER_SIZE_INT* iter = vector_block_iterator_init(rem_set);
+      while(!vector_block_iterator_end(rem_set,iter)){
+        Partial_Reveal_Object* p_obj_holding_ref = (Partial_Reveal_Object*)*iter;
+        iter = vector_block_iterator_advance(rem_set,iter);
+        
+        assert( !obj_belongs_to_nos(p_obj_holding_ref));
+        assert( obj_is_remembered(p_obj_holding_ref));
+        obj_clear_rem_bit(p_obj_holding_ref);
+        allocator_object_write_barrier(p_obj_holding_ref, collector);  
+      } 
+      vector_block_clear(rem_set);
+      pool_put_entry(free_set_pool, rem_set);      
+      rem_set = pool_get_entry(metadata->mutator_remset_pool);
+    }
+    
+   pool_put_entry(collector_remset_pool, collector->rem_set);
+   collector->rem_set = NULL;
+    
+#endif /* ifdef USE_REM_SLOTS else */
   
     /* put back collector remsets */  
     root_set = pool_get_entry( collector_remset_pool );
@@ -379,9 +432,12 @@
 
 void gc_clear_remset(GC* gc)
 {
-  assert(gc->root_set != NULL);
+  /* this function clears all the remset before fallback */
+  assert(gc_match_kind(gc, FALLBACK_COLLECTION));
+  
   /* rootset pool has some entries that are actually remset, because all the remsets are put into rootset pool 
      before the collection. gc->root_set is a pointer pointing to the boundary between remset and rootset in the pool */
+  assert(gc->root_set != NULL);
   Pool* pool = gc_metadata.gc_rootset_pool;    
   Vector_Block* rem_set = pool_get_entry(pool);
   while(rem_set != gc->root_set){
@@ -396,16 +452,16 @@
   
   /* put back last remset block of each collector (saved in the minor collection before fallback) */  
   unsigned int num_active_collectors = gc->num_active_collectors;
+  pool = gc_metadata.collector_remset_pool;
   for(unsigned int i=0; i<num_active_collectors; i++)
   {
     Collector* collector = gc->collectors[i];
     assert(collector->rem_set != NULL);
-    pool_put_entry(gc_metadata.collector_remset_pool, collector->rem_set);
+    pool_put_entry(pool, collector->rem_set);
     collector->rem_set = NULL;
   }
   
   /* cleanup remset pool */  
-  pool = gc_metadata.collector_remset_pool;  
   rem_set = pool_get_entry(pool);
   while(rem_set){
     vector_block_clear(rem_set);
@@ -416,6 +472,8 @@
   return;
 } 
 
+//#include <hash_set>
+/* FIXME:: should better move to verifier dir */
 extern Boolean verify_live_heap;
 void gc_metadata_verify(GC* gc, Boolean is_before_gc)
 {
@@ -424,16 +482,84 @@
   assert(pool_is_empty(metadata->collector_repset_pool));
   assert(pool_is_empty(metadata->mark_task_pool));
   
-  if(!is_before_gc || !gc_is_gen_mode())
+  if(!is_before_gc || !gc_is_gen_mode()){
     assert(pool_is_empty(metadata->mutator_remset_pool));
-  
+  }else if(gc_is_gen_mode() && verify_live_heap ){
+    unsigned int remset_size = pool_size(metadata->mutator_remset_pool);
+    printf("Size of mutator remset pool %s: %d\n", is_before_gc?"before GC":"after GC", remset_size);   
+/*  
+      using namespace stdext;
+      hash_set<Partial_Reveal_Object**> pref_hash;
+      unsigned int num_rem_slots = 0;
+      unsigned int num_ref_to_nos = 0;
+
+      pool_iterator_init(metadata->mutator_remset_pool);
+      Vector_Block* rem_set = pool_iterator_next(metadata->mutator_remset_pool);
+      while(rem_set){
+        POINTER_SIZE_INT* iter = vector_block_iterator_init(rem_set);
+        while(!vector_block_iterator_end(rem_set,iter)){
+          Partial_Reveal_Object** p_ref = (Partial_Reveal_Object **)*iter;
+          iter = vector_block_iterator_advance(rem_set,iter);
+
+          pref_hash.insert(p_ref);
+          num_rem_slots ++; 
+#ifdef USE_REM_SLOTS
+          Partial_Reveal_Object *p_obj = *p_ref;
+          if( p_obj && addr_belongs_to_nos(p_obj))
+            num_ref_to_nos++;
+#endif
+          if(addr_belongs_to_nos(p_ref)){
+            printf("wrong remset value!!!\n");
+          }
+        } 
+        rem_set = pool_iterator_next(metadata->mutator_remset_pool);
+      }
+      printf("pref hashset size is %d\n", pref_hash.size());
+      printf("Num of rem slots: %d, refs to NOS: %d\n", num_rem_slots, num_ref_to_nos);
+*/
+  }
+
   if(!gc_is_gen_mode()){
-    /* FIXME:: even for gen gc, it should be empty if NOS is forwarding_all */  
     assert(pool_is_empty(metadata->collector_remset_pool));
-  }
+  }else if( verify_live_heap){
+    unsigned int remset_size = pool_size(metadata->collector_remset_pool);
+    printf("Size of collector remset pool %s: %d\n", is_before_gc?"before GC":"after GC", remset_size);
+/*    
+    if(!is_before_gc){ 
+ 
+      using namespace stdext;
+      hash_set<Partial_Reveal_Object**> pref_hash;
+      
+      unsigned int num_rem_slots = 0;
+      pool_iterator_init(metadata->collector_remset_pool);
+      Vector_Block* rem_set = pool_iterator_next(metadata->collector_remset_pool);
+      while(rem_set){
+        POINTER_SIZE_INT* iter = vector_block_iterator_init(rem_set);
+        while(!vector_block_iterator_end(rem_set,iter)){
+          Partial_Reveal_Object** p_ref = (Partial_Reveal_Object **)*iter;
+          iter = vector_block_iterator_advance(rem_set,iter);
+
+          pref_hash.insert(p_ref);
+          num_rem_slots ++; 
+          Partial_Reveal_Object *p_obj = *p_ref;
+          assert( obj_is_survivor(p_obj));
+          assert( addr_belongs_to_nos(p_obj) && !addr_belongs_to_nos(p_ref));
+          if( !obj_is_survivor(p_obj) || !addr_belongs_to_nos(p_obj) || addr_belongs_to_nos(p_ref)){
+            printf("wrong remset value!!!\n");
+          }
+        } 
+        rem_set = pool_iterator_next(metadata->collector_remset_pool);
+      }
+      printf("pref hashset size is %d\n", pref_hash.size());
+      printf("Num of rem slots: %d\n", num_rem_slots);
+  
+    }
+*/
+  }/* if verify_live_heap */
 
   if(verify_live_heap ){
     unsigned int free_pool_size = pool_size(metadata->free_set_pool);
+    printf("Size of free pool %s: %d\n\n\n", is_before_gc?"before GC":"after GC", free_pool_size); 
   }
   
   return;  
@@ -531,4 +657,5 @@
 
 void free_set_pool_put_entry(Vector_Block* block, GC_Metadata *metadata)
 { pool_put_entry(metadata->free_set_pool, block); }
+
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h Sat Jan 19 03:40:19 2008
@@ -53,13 +53,33 @@
 
 #endif //_DEBUG
 
+#ifndef _IPF_
+#define PREFETCH_SUPPORTED
+#endif
+
 #ifdef _WINDOWS_
 #define FORCE_INLINE __forceinline   
+
+#ifdef PREFETCH_SUPPORTED
+#include <xmmintrin.h>
+#define prefetchnta(pref_addr)	_mm_prefetch((char*)(pref_addr), _MM_HINT_NTA )
+#endif /*ALLOC_PREFETCH*/
+
 #elif defined (__linux__)
 #define FORCE_INLINE inline  __attribute__((always_inline))
+
+#ifdef PREFETCH_SUPPORTED
+#define prefetchnta(pref_addr)  __asm__ ("prefetchnta (%0)"::"r"(pref_addr))
+#endif /*PREFETCH_SUPPORTED*/
 #else 
 #define FORCE_INLINE inline
 #endif /* _WINDOWS_ */
+
+#ifdef PREFETCH_SUPPORTED
+#define PREFETCH prefetchnta
+#else
+#define PREFETCH(x) 
+#endif
 
 #define ABS_DIFF(x, y) (((x)>(y))?((x)-(y)):((y)-(x)))
 #define USEC_PER_SEC INT64_C(1000000)

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/object_status.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/object_status.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/object_status.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/object_status.h Sat Jan 19 03:40:19 2008
@@ -92,7 +92,6 @@
 
 inline Boolean fspace_obj_to_be_forwarded(Partial_Reveal_Object *p_obj)
 {
-  if(!obj_belongs_to_nos(p_obj)) return FALSE;
   return forward_first_half ? (p_obj < object_forwarding_boundary) : (p_obj>=object_forwarding_boundary);
 }
 inline Boolean obj_need_move(GC *gc, Partial_Reveal_Object *p_obj)
@@ -108,8 +107,13 @@
   Cspace *cspace = gc_mc_get_cspace((GC_MC*)gc);
   return cspace->move_object;
 #endif
-  if(gc_is_gen_mode() && gc_match_kind(gc, MINOR_COLLECTION))
-    return fspace_obj_to_be_forwarded(p_obj);
+  if(gc_match_kind(gc, MINOR_COLLECTION)){
+    if(!obj_belongs_to_nos(p_obj)) return FALSE;
+    if(MINOR_ALGO == MINOR_NONGEN_SEMISPACE_POOL || MINOR_ALGO == MINOR_GEN_SEMISPACE_POOL)
+      return TRUE;
+    else if(gc_is_gen_mode())
+      return fspace_obj_to_be_forwarded(p_obj);
+  }
   
   Space *space = space_of_addr(gc, p_obj);
   return space->move_object;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen.cpp Sat Jan 19 03:40:19 2008
@@ -255,24 +255,27 @@
 void gc_gen_destruct(GC_Gen *gc_gen)
 {
   TRACE2("gc.process", "GC: GC_Gen heap destruct ......");
+
+   /* We cannot use reserve_heap_size because perhaps only part of it is committed. */
+  int mos_size = space_committed_size((Space*)gc_gen->mos);
+  int nos_size = space_committed_size((Space*)gc_gen->nos);
+  int los_size = 0;
   
   gc_nos_destruct(gc_gen);
   gc_mos_destruct(gc_gen);
-  POINTER_SIZE_INT los_size = 0;
+
   if(MAJOR_ALGO != MAJOR_MARK_SWEEP){
-    los_size = space_committed_size((Space*)gc_gen->los);
+    los_size = (int)space_committed_size((Space*)gc_gen->los);
     gc_los_destruct(gc_gen);
   }
 
+
 #ifndef STATIC_NOS_MAPPING
-  /* without static mapping, the heap is release as a whole. 
-     We cannot use reserve_heap_size because perhaps only part of it is committed.  */
-  vm_unmap_mem(gc_gen->physical_start, gc_gen_total_memory_size(gc_gen));
+  /* without static mapping, the heap is release as a whole.  */
+  vm_unmap_mem(gc_gen->physical_start, mos_size + nos_size + los_size);
 
 #else  /* otherwise, release the spaces separately */
 
-  int mos_size = space_committed_size((Space*)gc_gen->mos);
-  int nos_size = space_committed_size((Space*)gc_gen->nos);
   vm_unmap_mem(gc_gen->physical_start, los_size + mos_size);  /* los+mos */
   vm_unmap_mem(nos_boundary, nos_size);  /* nos */
 
@@ -315,7 +318,12 @@
 }
 
 void gc_nos_destruct(GC_Gen *gc)
-{ fspace_destruct((Fspace*)gc->nos); }
+{ 
+  if(MINOR_ALGO == MINOR_NONGEN_SEMISPACE_POOL || MINOR_ALGO == MINOR_GEN_SEMISPACE_POOL)
+    sspace_destruct((Sspace*)gc->nos);
+  else
+    fspace_destruct((Fspace*)gc->nos); 
+}
 
 void gc_mos_initialize(GC_Gen *gc, void *start, POINTER_SIZE_INT mos_size, POINTER_SIZE_INT commit_size)
 {
@@ -422,7 +430,8 @@
 
     }else {
       WARN2("gc.base","\nWarning: GC algorithm setting incorrect. Will use default value.\n");
-    
+      MINOR_ALGO = MINOR_NONGEN_FORWARD_POOL;      
+      gc_disable_gen_mode();    
     }
   }
   
@@ -443,6 +452,7 @@
       is_collector_local_alloc = FALSE;
     }else{
      WARN2("gc.base","\nWarning: GC algorithm setting incorrect. Will use default value.\n");
+      MAJOR_ALGO = MAJOR_COMPACT_MOVE;
       
     }
   }
@@ -775,10 +785,7 @@
   if(gc->collect_result == FALSE && gc_match_kind((GC*)gc, MINOR_COLLECTION)){
     
     INFO2("gc.process", "GC: Minor collection failed, transform to fallback collection ...");
-    
-    if(gc_is_gen_mode()) 
-      gc_clear_remset((GC*)gc);
-    
+        
     /* runout mos in minor collection */
     if(MAJOR_ALGO != MAJOR_MARK_SWEEP){
       assert(((Blocked_Space*)mos)->free_block_idx == ((Blocked_Space*)mos)->ceiling_block_idx + 1);
@@ -794,6 +801,9 @@
     gc_gen_stats_reset_before_collection((GC_Gen*)gc);
     gc_gen_collector_stats_reset((GC_Gen*)gc);
 #endif
+
+    if(gc_is_gen_mode()) 
+      gc_clear_remset((GC*)gc);
 
     if(verify_live_heap && (MAJOR_ALGO != MAJOR_MARK_SWEEP))
       event_gc_collect_kind_changed((GC*)gc);

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_stats.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_stats.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_stats.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_stats.cpp Sat Jan 19 03:40:19 2008
@@ -29,7 +29,7 @@
   GC_Gen_Stats* stats = (GC_Gen_Stats*)STD_MALLOC(sizeof(GC_Gen_Stats));
 
   memset(stats, 0, sizeof(GC_Gen_Stats));
-  stats->is_los_collected = false;
+  stats->is_los_collected = FALSE;
 
   gc->stats = stats; 
 }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_utils.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_utils.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_utils.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_utils.cpp Sat Jan 19 03:40:19 2008
@@ -26,7 +26,7 @@
 {
   if(nos->collect_algorithm == MINOR_NONGEN_SEMISPACE_POOL || nos->collect_algorithm == MINOR_GEN_SEMISPACE_POOL)
     return sspace_heap_start_adjust((Sspace*)nos, new_nos_boundary, new_nos_size);
-  else if( nos->collect_algorithm == MINOR_NONGEN_FORWARD_POOL )
+  else if( nos->collect_algorithm == MINOR_NONGEN_FORWARD_POOL || nos->collect_algorithm == MINOR_GEN_FORWARD_POOL )
     return fspace_heap_start_adjust((Fspace*)nos, new_nos_boundary, new_nos_size);  
   
   assert(0);
@@ -49,7 +49,7 @@
   POINTER_SIZE_INT free_size = 0;
   if(nos->collect_algorithm == MINOR_NONGEN_SEMISPACE_POOL || nos->collect_algorithm == MINOR_GEN_SEMISPACE_POOL)
     return sspace_free_space_size((Sspace*)nos);
-  else if( nos->collect_algorithm == MINOR_NONGEN_FORWARD_POOL )
+  else if( nos->collect_algorithm == MINOR_NONGEN_FORWARD_POOL || nos->collect_algorithm == MINOR_GEN_FORWARD_POOL)
     return fspace_free_space_size((Fspace*)nos);
 
   assert(0);
@@ -72,7 +72,7 @@
   POINTER_SIZE_INT free_size = 0;
   if(nos->collect_algorithm == MINOR_NONGEN_SEMISPACE_POOL || nos->collect_algorithm == MINOR_GEN_SEMISPACE_POOL)
     return sspace_used_space_size((Sspace*)nos);
-  else if( nos->collect_algorithm == MINOR_NONGEN_FORWARD_POOL )
+  else if( nos->collect_algorithm == MINOR_NONGEN_FORWARD_POOL || nos->collect_algorithm == MINOR_GEN_FORWARD_POOL)
     return fspace_used_space_size((Fspace*)nos);
 
   assert(0);

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/los/lspace.cpp Sat Jan 19 03:40:19 2008
@@ -76,6 +76,7 @@
 
 void lspace_destruct(Lspace* lspace)
 {
+  /* we don't free the real space here, the heap will be freed altogether */
   STD_FREE(lspace);
   lspace = NULL;
   return;
@@ -128,4 +129,5 @@
 {
   return lspace->failure_size;
 }
+
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace.cpp Sat Jan 19 03:40:19 2008
@@ -89,7 +89,10 @@
 #ifdef USE_32BITS_HASHCODE
   space_desturct_blocks((Blocked_Space*)mspace);
 #endif
+
+  /* we don't free the real space here, the heap will be freed altogether */
   STD_FREE(mspace);  
+  mspace = NULL;
 }
 
 void mspace_reset_after_collection(Mspace* mspace)

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_slide_compact.cpp Sat Jan 19 03:40:19 2008
@@ -351,9 +351,7 @@
 static void mspace_sliding_compact(Collector* collector, Mspace* mspace)
 {
   void *start_pos;
-  Block_Header *nos_fw_start_block = (Block_Header *)&mspace->blocks[mspace_free_block_idx - mspace->first_block_idx];
-  Boolean is_fallback = gc_match_kind(collector->gc, FALLBACK_COLLECTION);
-  
+    
   while(Partial_Reveal_Object *p_obj = get_next_first_src_obj(mspace)){
     Block_Header *src_block = GC_BLOCK_HEADER(p_obj);
     assert(src_block->dest_counter);

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace.cpp Sat Jan 19 03:40:19 2008
@@ -80,7 +80,10 @@
 {
   //FIXME:: when map the to-half, the decommission start address should change
   wspace_destruct_chunks(wspace);
+
+  /* we don't free the real space here, the heap will be freed altogether */
   STD_FREE(wspace);
+  wspace = NULL;
 }
 
 void wspace_reset_after_collection(Wspace *wspace)

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_alloc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_alloc.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_alloc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_alloc.h Sat Jan 19 03:40:19 2008
@@ -138,10 +138,9 @@
 {
   //assert(!slot_is_alloc_in_table(table, slot_index));
   
-  unsigned int color_bits_index = slot_index * COLOR_BITS_PER_OBJ;
-  unsigned int word_index = color_bits_index / BITS_PER_WORD;
-  unsigned int index_in_word = color_bits_index % BITS_PER_WORD;
-    
+  unsigned int color_bits_index = slot_index << COLOR_BITS_PER_OBJ_SHIT;
+  unsigned int word_index = color_bits_index >> BIT_SHIFT_TO_BITS_PER_WORD;
+  unsigned int index_in_word = color_bits_index & (((unsigned int)(BITS_PER_WORD-1)));
   volatile POINTER_SIZE_INT *p_color_word = &table[word_index];
   assert(p_color_word);
   

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_chunk.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_chunk.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_chunk.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_chunk.h Sat Jan 19 03:40:19 2008
@@ -20,7 +20,7 @@
 
 #include "wspace.h"
 
-//#define SSPACE_USE_FASTDIV
+#define SSPACE_USE_FASTDIV
 #ifdef SSPACE_USE_FASTDIV
 #if 0
 #define massert(x) do { if(!(x)) { printf("%s:%s, , Assertion %s failed\n", __FILE__, __LINE__, #x); exit(1); }} while(0) 
@@ -109,8 +109,14 @@
 #define ABNORMAL_CHUNK_HEADER(addr) ((Chunk_Header*)((POINTER_SIZE_INT)addr & CHUNK_GRANULARITY_HIGH_MASK))
 
 #define MAX_SLOT_INDEX 0xFFffFFff
-#define COLOR_BITS_PER_OBJ 4   // should be powers of 2
-#define SLOT_NUM_PER_WORD_IN_TABLE  (BITS_PER_WORD /COLOR_BITS_PER_OBJ)
+//#define COLOR_BITS_PER_OBJ              4   // should be powers of 2
+#define COLOR_BITS_PER_OBJ_SHIT     2 // COLOR_BITS_PER_OBJ = 1 << COLOR_BITS_PER_OBJ_SHIT
+#define COLOR_BITS_PER_OBJ          (1<<COLOR_BITS_PER_OBJ_SHIT)
+
+//#define SLOT_NUM_PER_WORD_IN_TABLE  (BITS_PER_WORD /COLOR_BITS_PER_OBJ)
+#define SLOT_NUM_PER_WORD_SHIT      (BIT_SHIFT_TO_BITS_PER_WORD - COLOR_BITS_PER_OBJ_SHIT)
+#define SLOT_NUM_PER_WORD_IN_TABLE  (1<<SLOT_NUM_PER_WORD_SHIT)
+
 
 /* Two equations:
  * 1. CHUNK_HEADER_VARS_SIZE_BYTES + NORMAL_CHUNK_TABLE_SIZE_BYTES + slot_size*NORMAL_CHUNK_SLOT_NUM = NORMAL_CHUNK_SIZE_BYTES

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_concurrent_gc_stats.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_concurrent_gc_stats.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_concurrent_gc_stats.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_concurrent_gc_stats.cpp Sat Jan 19 03:40:19 2008
@@ -1,20 +1,3 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You 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.
- */
-
 #ifdef WSPACE_CONCURRENT_GC_STATS
 
 #include "wspace_alloc.h"
@@ -215,4 +198,5 @@
 
 }
 #endif
+
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_mark_sweep.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_mark_sweep.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_mark_sweep.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_mark_sweep.h Sat Jan 19 03:40:19 2008
@@ -80,13 +80,14 @@
     chunk = NORMAL_CHUNK_HEADER(obj);
     index = slot_addr_to_index(chunk, obj);
   }
-  unsigned int word_index = index / SLOT_NUM_PER_WORD_IN_TABLE;
-  index_in_word = COLOR_BITS_PER_OBJ * (index % SLOT_NUM_PER_WORD_IN_TABLE);
-  //unsigned int word_index = index >> 3;
-  //index_in_word = COLOR_BITS_PER_OBJ * (index & (((unsigned int)(SLOT_NUM_PER_WORD_IN_TABLE-1))));
+  //unsigned int word_index = index / SLOT_NUM_PER_WORD_IN_TABLE;
+  //index_in_word = COLOR_BITS_PER_OBJ * (index % SLOT_NUM_PER_WORD_IN_TABLE);
+  unsigned int word_index = index >> SLOT_NUM_PER_WORD_SHIT;
+  index_in_word = COLOR_BITS_PER_OBJ * (index & (((unsigned int)(SLOT_NUM_PER_WORD_IN_TABLE-1))));
   
   return &chunk->table[word_index];
 }
+
 FORCE_INLINE POINTER_SIZE_INT *get_color_word_in_table(Partial_Reveal_Object *obj, unsigned int &index_in_word, unsigned int size)
 {
   Chunk_Header *chunk;
@@ -99,7 +100,7 @@
     chunk = NORMAL_CHUNK_HEADER(obj);
     index = slot_addr_to_index(chunk, obj);
   }
-  unsigned int word_index = index >> 3;
+  unsigned int word_index = index >> SLOT_NUM_PER_WORD_SHIT;
   index_in_word = COLOR_BITS_PER_OBJ * (index & (((unsigned int)(SLOT_NUM_PER_WORD_IN_TABLE-1))));
   
   return &chunk->table[word_index];

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_sweep_concurrent.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_sweep_concurrent.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_sweep_concurrent.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_sweep/wspace_sweep_concurrent.cpp Sat Jan 19 03:40:19 2008
@@ -1,20 +1,3 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You 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.
- */
-
 #include "wspace.h"
 #include "wspace_chunk.h"
 #include "wspace_mark_sweep.h"

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.cpp Sat Jan 19 03:40:19 2008
@@ -131,7 +131,9 @@
 #ifdef USE_32BITS_HASHCODE
   space_desturct_blocks((Blocked_Space*)sspace);
 #endif
+  /* we don't free the real space here, the heap will be freed altogether */
   STD_FREE(sspace);   
+  sspace = NULL;
 }
 
 POINTER_SIZE_INT sspace_free_space_size(Sspace* nos)

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace.h Sat Jan 19 03:40:19 2008
@@ -99,10 +99,15 @@
                           p_obj < sspace->survivor_area_end);
 }
 
-FORCE_INLINE Boolean obj_to_be_forwarded(Sspace* sspace, Partial_Reveal_Object* p_obj)
+/* to be forwarded to MOS or was forwarded by other thread */
+FORCE_INLINE Boolean obj_be_forwarded(Sspace* sspace, Partial_Reveal_Object* p_obj)
 {
-  assert( obj_belongs_to_survivor_area(sspace, p_obj)?obj_is_survivor(p_obj):!obj_is_survivor(p_obj));
-  return obj_is_survivor(p_obj);
+  /* NOTE:: Tricky! When the thread checks, the oi could be set a forward address by another thread. */
+  Obj_Info_Type oi = get_obj_info_raw(p_obj);
+  Boolean be_forwarded = (Boolean)(oi & (FORWARD_BIT|OBJ_AGE_BIT));
+  assert( obj_belongs_to_survivor_area(sspace, p_obj)? be_forwarded:1);
+    
+  return be_forwarded;
 }
 
 /* treat semispace alloc as thread local alloc. If it fails or p_obj is old, forward it to MOS */
@@ -111,7 +116,9 @@
   void* p_targ_obj = NULL;
   Sspace* sspace = (Sspace*)allocator->alloc_space;
   
-  if( obj_to_be_forwarded(sspace, p_obj) ) 
+  /* this object should be forward to MOS, or is already forwarded by other thread (to either MOS or Tospace. 
+     In any case, we don't need to allocate it in tospace now. */
+  if( obj_be_forwarded(sspace, p_obj) ) 
     return NULL;
     
   p_targ_obj = thread_local_alloc(size, allocator);

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace_gen_ss_pool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace_gen_ss_pool.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace_gen_ss_pool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/semi_space/sspace_gen_ss_pool.cpp Sat Jan 19 03:40:19 2008
@@ -143,9 +143,11 @@
   }else{  /* otherwise, we successfully forwarded */
 
 #ifdef GC_GEN_STATS
+  if(gc_profile){
     GC_Gen_Collector_Stats* stats = (GC_Gen_Collector_Stats*)collector->stats;
     gc_gen_collector_update_marked_nos_obj_stats_minor(stats);
     gc_gen_collector_update_moved_nos_obj_stats_minor(stats, vm_object_size(p_obj));
+  }
 #endif
 
     scan_object(collector, p_target_obj);

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/thread/gc_thread.h Sat Jan 19 03:40:19 2008
@@ -33,14 +33,6 @@
 
 #ifdef ALLOC_ZEROING  /* ----------------- */
 #ifdef ALLOC_PREFETCH /* vvvvvvvvvvvvvvvv  */
-
-#ifdef _WINDOWS_
-#include <xmmintrin.h>
-#define prefetchnta(pref_addr)  _mm_prefetch((char*)(pref_addr), _MM_HINT_NTA )
-#else /* _WINDOWS_ */
-#define prefetchnta(pref_addr)  __asm__ ("prefetchnta (%0)"::"r"(pref_addr))
-#endif /* !_WINDOWS_ */
-
 extern POINTER_SIZE_INT PREFETCH_DISTANCE;
 extern POINTER_SIZE_INT ZEROING_SIZE;
 extern POINTER_SIZE_INT PREFETCH_STRIDE;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.cpp Sat Jan 19 03:40:19 2008
@@ -21,6 +21,10 @@
 
 #include "fspace.h"
 
+#ifdef PREFETCH_SUPPORTED
+Boolean mark_prefetch = FALSE;
+#endif
+
 Boolean NOS_PARTIAL_FORWARD = FALSE;
 
 Boolean forward_first_half;
@@ -92,8 +96,9 @@
 #ifdef USE_32BITS_HASHCODE
   space_desturct_blocks((Blocked_Space*)fspace);
 #endif
-
+  /* we don't free the real space here, the heap will be freed altogether */
   STD_FREE(fspace);   
+  fspace = NULL;
 }
 
 void fspace_reset_after_collection(Fspace* fspace)
@@ -174,9 +179,6 @@
 
 void collector_execute_task(GC* gc, TaskType task_func, Space* space);
 
-unsigned int mspace_free_block_idx;
-
-
 #ifdef GC_GEN_STATS
 #include "../gen/gen_stats.h"
 #endif
@@ -187,7 +189,6 @@
   fspace->num_collections++;  
 
   GC* gc = fspace->gc;
-  mspace_free_block_idx = ((Blocked_Space*)((GC_Gen*)gc)->mos)->free_block_idx;
 
   if(gc_is_gen_mode()){
     fspace->collect_algorithm = MINOR_GEN_FORWARD_POOL;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace.h Sat Jan 19 03:40:19 2008
@@ -29,6 +29,9 @@
  * In our Gen GC, not all live objects are copied to tspace space, the newer baby will
  * still be preserved in  fspace, that means to give them time to die. 
  */
+#ifdef PREFETCH_SUPPORTED
+extern Boolean mark_prefetch;
+#endif
 
 extern Boolean forward_first_half;
 /* boundary splitting fspace into forwarding part and remaining part */

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_gen_forward_pool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_gen_forward_pool.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_gen_forward_pool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_gen_forward_pool.cpp Sat Jan 19 03:40:19 2008
@@ -211,6 +211,15 @@
   Vector_Block* trace_stack = (Vector_Block*)collector->trace_stack;
   while( !vector_stack_is_empty(trace_stack)){
     p_ref = (REF *)vector_stack_pop(trace_stack); 
+#ifdef PREFETCH_SUPPORTED    
+    /* DO PREFETCH */
+   if(mark_prefetch) {
+     if(!vector_stack_is_empty(trace_stack)) {
+        REF *pref = (REF*)vector_stack_read(trace_stack, 0);
+        PREFETCH( read_slot(pref) );
+     }
+   }
+#endif   
     forward_object(collector, p_ref);
     trace_stack = (Vector_Block*)collector->trace_stack;
   }
@@ -278,6 +287,15 @@
     while(!vector_block_iterator_end(trace_task,iter)){
       REF *p_ref = (REF *)*iter;
       iter = vector_block_iterator_advance(trace_task,iter);
+#ifdef PREFETCH_SUPPORTED      
+      /* DO PREFETCH */  
+      if( mark_prefetch ) {    
+        if(!vector_block_iterator_end(trace_task, iter)) {
+      	  REF *pref= (REF*) *iter;
+      	  PREFETCH( read_slot(pref));
+        }	
+      }
+#endif           
       assert(*p_ref); /* a task can't be NULL, it was checked before put into the task stack */
       /* in sequential version, we only trace same object once, but we were using a local hashset for that,
          which couldn't catch the repetition between multiple collectors. This is subject to more study. */

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_nongen_forward_pool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_nongen_forward_pool.cpp?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_nongen_forward_pool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_nongen_forward_pool.cpp Sat Jan 19 03:40:19 2008
@@ -182,6 +182,15 @@
   Vector_Block* trace_stack = (Vector_Block*)collector->trace_stack;
   while( !vector_stack_is_empty(trace_stack)){
     p_ref = (REF *)vector_stack_pop(trace_stack); 
+#ifdef PREFETCH_SUPPORTED    
+    /* DO PREFETCH */
+   if(mark_prefetch) {
+     if(!vector_stack_is_empty(trace_stack)) {
+        REF *pref = (REF*)vector_stack_read(trace_stack, 0);
+        PREFETCH( read_slot(pref) );
+     }
+   }
+#endif    
     forward_object(collector, p_ref);
     trace_stack = (Vector_Block*)collector->trace_stack;
   }
@@ -245,6 +254,15 @@
     while(!vector_block_iterator_end(trace_task,iter)){
       REF *p_ref = (REF *)*iter;
       iter = vector_block_iterator_advance(trace_task, iter);
+#ifdef PREFETCH_SUPPORTED      
+      /* DO PREFETCH */  
+      if( mark_prefetch ) {    
+        if(!vector_block_iterator_end(trace_task, iter)) {
+      	  REF *pref= (REF*) *iter;
+      	  PREFETCH( read_slot(pref));
+        }	
+      }
+#endif            
       trace_object(collector, p_ref);
       
       if(collector->result == FALSE)  break; /* force return */

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/vector_block.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/vector_block.h?rev=613384&r1=613383&r2=613384&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/vector_block.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/utils/vector_block.h Sat Jan 19 03:40:19 2008
@@ -245,6 +245,11 @@
   return value;
 }
 
+inline POINTER_SIZE_INT vector_stack_read(Vector_Block* block, int idx)
+{
+	return block->head[idx];
+}
+
 inline void vector_block_integrity_check(Vector_Block* block)
 {
   POINTER_SIZE_INT* iter = vector_block_iterator_init(block);



Mime
View raw message