You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by xl...@apache.org on 2007/04/18 17:20:58 UTC

svn commit: r530055 - in /harmony/enhanced/drlvm/trunk/vm/gc_gen/src: common/space_tuner.cpp gen/gen_adapt.cpp mark_compact/mspace_collect_compact.cpp trace_forward/fspace_alloc.cpp

Author: xli
Date: Wed Apr 18 08:20:57 2007
New Revision: 530055

URL: http://svn.apache.org/viewvc?view=rev&rev=530055
Log:
HARMONY-3700 : fix a bug in LOS(large object space) adaptation

Modified:
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_adapt.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp?view=diff&rev=530055&r1=530054&r2=530055
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/space_tuner.cpp Wed Apr 18 08:20:57 2007
@@ -173,7 +173,7 @@
     if(tuning_size > max_tuning_size) tuning_size = max_tuning_size;
     tuner->tuning_size = round_down_to_size(tuning_size, GC_BLOCK_SIZE_BYTES);
   }
-  if(tuner->tuning_size == 0){
+  if( (tuner->tuning_size == 0) && (!tuner->force_tune) ){
     tuner->kind = TRANS_NOTHING;
     lspace->move_object = 0;
     return;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_adapt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_adapt.cpp?view=diff&rev=530055&r1=530054&r2=530055
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_adapt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/gen/gen_adapt.cpp Wed Apr 18 08:20:57 2007
@@ -225,7 +225,11 @@
   #ifdef NOS_SURVIVE_RATIO_SENSITIVE
       /*If this major is caused by fall back compaction, 
          we must give fspace->survive_ratio a conservative and reasonable number to avoid next fall back.*/
-      fspace->survive_ratio = mspace->survive_ratio;
+      //fspace->survive_ratio = mspace->survive_ratio;
+      /*In fallback compaction, the survive_ratio of mspace must be 1.*/
+      if(gc_match_kind((GC*)gc, FALLBACK_COLLECTION))
+      	fspace->survive_ratio = 1;
+      	
   #endif
     }else{
       /*Give a hint to mini_free_ratio. */
@@ -305,14 +309,27 @@
   /* predict NOS + NOS*ratio = total_free_size */
   POINTER_SIZE_INT nos_reserve_size;
   nos_reserve_size = (POINTER_SIZE_INT)(((float)total_free)/(1.0f + fspace->survive_ratio));
-  /*Nos should not be too small*/
+  /*NOS should not be zero, if there is only one block in non-los, i.e. in the former if sentence,
+    if total_free = GC_BLOCK_SIZE_BYTES, then the computed nos_reserve_size is between zero
+    and GC_BLOCK_SIZE_BYTES. In this case, we assign this block to NOS*/
   if(nos_reserve_size <= GC_BLOCK_SIZE_BYTES)  nos_reserve_size = GC_BLOCK_SIZE_BYTES;
-  new_nos_size = round_down_to_size((POINTER_SIZE_INT)nos_reserve_size, GC_BLOCK_SIZE_BYTES);
 
 #ifdef STATIC_NOS_MAPPING
-  if(new_nos_size > fspace->reserved_heap_size) new_nos_size = fspace->reserved_heap_size;
+  if(nos_reserve_size > fspace->reserved_heap_size) nos_reserve_size = fspace->reserved_heap_size;
 #endif  
-  if(new_nos_size > GC_MOS_MIN_EXTRA_REMAIN_SIZE) new_nos_size -= GC_MOS_MIN_EXTRA_REMAIN_SIZE ;
+  //To reserve some MOS space to avoid fallback situation. 
+  //But we need ensure nos has at least one block 
+  //if(new_nos_size > GC_MOS_MIN_EXTRA_REMAIN_SIZE) new_nos_size -= GC_MOS_MIN_EXTRA_REMAIN_SIZE ;
+  POINTER_SIZE_INT reserve_in_mos = GC_MOS_MIN_EXTRA_REMAIN_SIZE;
+  while (reserve_in_mos >= GC_BLOCK_SIZE_BYTES){
+    if(nos_reserve_size >= reserve_in_mos + GC_BLOCK_SIZE_BYTES){
+      nos_reserve_size -= reserve_in_mos;    
+      break;
+    }
+    reserve_in_mos >>= 1;
+  }
+
+  new_nos_size = round_down_to_size((POINTER_SIZE_INT)nos_reserve_size, GC_BLOCK_SIZE_BYTES); 
 
   if(gc->force_gen_mode){
     new_nos_size = min_nos_size_bytes;//round_down_to_size((unsigned int)(gc->gen_minor_adaptor->adapt_nos_size), SPACE_ALLOC_UNIT);
@@ -400,7 +417,7 @@
   
   POINTER_SIZE_INT curr_nos_size = space_committed_size((Space*)fspace);
 
-  if( abs((POINTER_SIZE_SINT)new_nos_size - (POINTER_SIZE_SINT)curr_nos_size) < NOS_COPY_RESERVE_DELTA )
+  if( ABS_DIFF(new_nos_size, curr_nos_size) < NOS_COPY_RESERVE_DELTA )
     return;
       
   POINTER_SIZE_INT used_mos_size = space_used_memory_size((Blocked_Space*)mspace);  

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp?view=diff&rev=530055&r1=530054&r2=530055
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/mark_compact/mspace_collect_compact.cpp Wed Apr 18 08:20:57 2007
@@ -149,6 +149,7 @@
   unsigned int i;
   Block_Header* block;
   Space_Tuner* tuner = gc->tuner;
+  Block_Header* nos_last_block;
   /*Needn't change LOS size.*/
   if(tuner->kind == TRANS_NOTHING){
     for(i=0; i<gc->num_active_collectors; i++){
@@ -168,7 +169,11 @@
   else if(tuner->kind == TRANS_FROM_MOS_TO_LOS)
   {
     Blocked_Space* nos = (Blocked_Space*)gc_get_nos((GC_Gen*)gc);
-    Block_Header* nos_last_block = (Block_Header*)&nos->blocks[nos->num_managed_blocks-1];
+    if(nos->num_managed_blocks)
+      nos_last_block = (Block_Header*)&nos->blocks[nos->num_managed_blocks-1];
+    else
+      /*If nos->num_managed_blocks is zero, we take mos_last_block as nos_last_block instead.*/
+      nos_last_block = (Block_Header*)&mspace->blocks[mspace->num_managed_blocks - 1];
     Block_Header* mos_first_block = (Block_Header*)&mspace->blocks[0];
     unsigned int trans_blocks = (unsigned int)(tuner->tuning_size >> GC_BLOCK_SHIFT_COUNT);
     nos_last_block->next = mos_first_block;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp?view=diff&rev=530055&r1=530054&r2=530055
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/trace_forward/fspace_alloc.cpp Wed Apr 18 08:20:57 2007
@@ -82,9 +82,9 @@
     vm_gc_lock_enum();
     /* after holding lock, try if other thread collected already */
     if ( !space_has_free_block((Blocked_Space*)fspace) ) {  
-        if(attempts == 0) {
+        if(attempts < 2) {
           gc_reclaim_heap(allocator->gc, GC_CAUSE_NOS_IS_FULL); 
-          attempts = 1;
+          attempts++;
         }else{
           vm_gc_unlock_enum();  
           return NULL;