Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/runtime/gc/ml-objects.c
ViewVC logotype

Diff of /sml/trunk/src/runtime/gc/ml-objects.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1219, Wed May 22 14:41:38 2002 UTC revision 1247, Mon Jun 17 20:32:12 2002 UTC
# Line 35  Line 35 
35  #define COUNT_ALLOC(msp, nbytes)        /* null */  #define COUNT_ALLOC(msp, nbytes)        /* null */
36  #endif  #endif
37    
 PVT bool_t ShrinkCheck (arena_t *ap, Word_t reqSzB);  
   
38    
39  /* ML_CString:  /* ML_CString:
40   *   *
# Line 138  Line 136 
136                  ap->reqSizeB += szb;                  ap->reqSizeB += szb;
137                  RELEASE_LOCK(MP_GCGenLock);                  RELEASE_LOCK(MP_GCGenLock);
138                      InvokeGC (msp, 1);                      InvokeGC (msp, 1);
                     if (ShrinkCheck (ap, szb))  
                         InvokeGC (msp, 1);  
139                  ACQUIRE_LOCK(MP_GCGenLock);                  ACQUIRE_LOCK(MP_GCGenLock);
140                    ap->reqSizeB = 0;
141              }              }
142              *(ap->nextw++) = desc;              *(ap->nextw++) = desc;
143              res = PTR_CtoML(ap->nextw);              res = PTR_CtoML(ap->nextw);
144              ap->nextw += nwords;              ap->nextw += nwords;
145          END_CRITICAL_SECT(MP_GCGenLock)          END_CRITICAL_SECT(MP_GCGenLock)
146          COUNT_ALLOC(msp, WORD_SZB*(nwords + 1));          COUNT_ALLOC(msp, szb);
147      }      }
148      else {      else {
149          ML_AllocWrite (msp, 0, desc);          ML_AllocWrite (msp, 0, desc);
# Line 206  Line 203 
203                  ap->reqSizeB += szb;                  ap->reqSizeB += szb;
204                  RELEASE_LOCK(MP_GCGenLock);                  RELEASE_LOCK(MP_GCGenLock);
205                      InvokeGC (msp, 1);                      InvokeGC (msp, 1);
                     if (ShrinkCheck (ap, szb))  
                         InvokeGC (msp, 1);  
206                  ACQUIRE_LOCK(MP_GCGenLock);                  ACQUIRE_LOCK(MP_GCGenLock);
207                    ap->reqSizeB = 0;
208              }              }
209  #ifdef ALIGN_REALDS  #ifdef ALIGN_REALDS
210            /* Force REALD_SZB alignment (descriptor is off by one word) */            /* Force REALD_SZB alignment (descriptor is off by one word) */
# Line 225  Line 221 
221              res = PTR_CtoML(ap->nextw);              res = PTR_CtoML(ap->nextw);
222              ap->nextw += nwords;              ap->nextw += nwords;
223          END_CRITICAL_SECT(MP_GCGenLock)          END_CRITICAL_SECT(MP_GCGenLock)
224          COUNT_ALLOC(msp, WORD_SZB*(nwords + 1));          COUNT_ALLOC(msp, szb-WORD_SZB);
225      }      }
226      else {      else {
227  #ifdef ALIGN_REALDS  #ifdef ALIGN_REALDS
# Line 334  Line 330 
330                  ap->reqSizeB += szb;                  ap->reqSizeB += szb;
331                  RELEASE_LOCK(MP_GCGenLock);                  RELEASE_LOCK(MP_GCGenLock);
332                      InvokeGCWithRoots (msp, gcLevel, &root, NIL(ml_val_t *));                      InvokeGCWithRoots (msp, gcLevel, &root, NIL(ml_val_t *));
                     if (ShrinkCheck(ap, szb))  
                         InvokeGCWithRoots (msp, 1, &root, NIL(ml_val_t *));  
333                      initVal = root;                      initVal = root;
334                  ACQUIRE_LOCK(MP_GCGenLock);                  ACQUIRE_LOCK(MP_GCGenLock);
335                    ap->reqSizeB = 0;
336  #ifdef MP_SUPPORT  #ifdef MP_SUPPORT
337                /* check again to insure that we have sufficient space */                /* check again to insure that we have sufficient space */
338                  gcLevel = -1;                  gcLevel = -1;
# Line 350  Line 345 
345              ap->nextw += len;              ap->nextw += len;
346              ap->sweep_nextw = ap->nextw;              ap->sweep_nextw = ap->nextw;
347          END_CRITICAL_SECT(MP_GCGenLock)          END_CRITICAL_SECT(MP_GCGenLock)
348          COUNT_ALLOC(msp, WORD_SZB*(len + 1));          COUNT_ALLOC(msp, szb);
349      }      }
350      else {      else {
351          ML_AllocWrite (msp, 0, desc);          ML_AllocWrite (msp, 0, desc);
# Line 396  Line 391 
391              ap->reqSizeB += szb;              ap->reqSizeB += szb;
392              RELEASE_LOCK(MP_GCGenLock);              RELEASE_LOCK(MP_GCGenLock);
393                  InvokeGCWithRoots (msp, gcLevel, &root, NIL(ml_val_t *));                  InvokeGCWithRoots (msp, gcLevel, &root, NIL(ml_val_t *));
                 if (ShrinkCheck(ap, szb))  
                     InvokeGCWithRoots (msp, 1, &root, NIL(ml_val_t *));  
394                  initVal = root;                  initVal = root;
395              ACQUIRE_LOCK(MP_GCGenLock);              ACQUIRE_LOCK(MP_GCGenLock);
396                ap->reqSizeB = 0;
397  #ifdef MP_SUPPORT  #ifdef MP_SUPPORT
398            /* check again to insure that we have sufficient space */            /* check again to insure that we have sufficient space */
399              if (AVAIL_SPACE(ap) <= szb+msp->ml_heap->allocSzB)              if (AVAIL_SPACE(ap) <= szb+msp->ml_heap->allocSzB)
# Line 411  Line 405 
405              ap->nextw += len;              ap->nextw += len;
406              ap->sweep_nextw = ap->nextw;              ap->sweep_nextw = ap->nextw;
407          END_CRITICAL_SECT(MP_GCGenLock)          END_CRITICAL_SECT(MP_GCGenLock)
408          COUNT_ALLOC(msp, WORD_SZB*(len + 1));          COUNT_ALLOC(msp, szb);
409      }      }
410      else {      else {
411          ML_AllocWrite (msp, 0, desc);          ML_AllocWrite (msp, 0, desc);
# Line 512  Line 506 
506      }      }
507    
508  } /* end of ML_CData */  } /* end of ML_CData */
   
   
 /********** Local routines **********/  
   
 /* ShrinkCheck:  
  *  
  * This function checks to see if we need to do another GC to shrink the  
  * heap.  It is a hack to work around a flaw in the sizing policy that can  
  * lead to unbounded heap growth even when the live data is constant.  
  */  
 PVT bool_t ShrinkCheck (arena_t *ap, Word_t reqSzB)  
 {  
     if ((ap->tospSizeB > ap->maxSizeB)  
     && (USED_SPACE(ap) + 2*reqSzB < ap->tospSizeB)) {  
       /* here the arena has grown beyond the soft max, while it would be  
        * possible to fit the twice request within the arena, so we force  
        * another GC.  
        */  
         ap->reqSizeB = reqSzB;  
         return TRUE;  
     }  
     else  
         return FALSE;  
   
 } /* end of ShrinkCheck */  

Legend:
Removed from v.1219  
changed lines
  Added in v.1247

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0