Changeset 15831


Ignore:
Timestamp:
Jun 4, 2013, 11:00:42 AM (7 years ago)
Author:
gb
Message:

Zero dnodes when allocating segments, not in GC.

Location:
branches/gb-egc/lisp-kernel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/gb-egc/lisp-kernel/arm-exceptions.c

    r15822 r15831  
    225225     without extending the heap.
    226226  */
    227   if (new_heap_segment(xp, bytes_needed, false, tcr)) {
     227  if (new_heap_segment(xp, bytes_needed, false, tcr, NULL)) {
    228228    xpGPR(xp, allocptr) += disp_from_allocptr;
    229229    return true;
     
    240240 
    241241  /* Try again, growing the heap if necessary */
    242   if (new_heap_segment(xp, bytes_needed, true, tcr)) {
     242  if (new_heap_segment(xp, bytes_needed, true, tcr, NULL)) {
    243243    xpGPR(xp, allocptr) += disp_from_allocptr;
    244244    return true;
     
    622622}
    623623
    624 /*
    625   This doesn't GC; it returns true if it made enough room, false
    626   otherwise.
    627   If "extend" is true, it can try to extend the dynamic area to
    628   satisfy the request.
    629 */
    630 
    631 Boolean
    632 new_heap_segment(ExceptionInformation *xp, natural need, Boolean extend, TCR *tcr)
    633 {
    634   area *a;
    635   natural newlimit, oldlimit;
    636   natural log2_allocation_quantum = tcr->log2_allocation_quantum;
    637 
    638   a  = active_dynamic_area;
    639   oldlimit = (natural) a->active;
    640   newlimit = (align_to_power_of_2(oldlimit, log2_allocation_quantum) +
    641               align_to_power_of_2(need, log2_allocation_quantum));
    642   if (newlimit > (natural) (a->high)) {
    643     if (extend) {
    644       signed_natural inhibit = (signed_natural)(lisp_global(GC_INHIBIT_COUNT));
    645       natural extend_by = inhibit ? 0 : lisp_heap_gc_threshold;
    646       do {
    647         if (resize_dynamic_heap(a->active, (newlimit-oldlimit)+extend_by)) {
    648           break;
    649         }
    650         extend_by = align_to_power_of_2(extend_by>>1, log2_allocation_quantum);
    651         if (extend_by < 4<<20) {
    652           return false;
    653         }
    654       } while (1);
    655     } else {
    656       return false;
    657     }
    658   }
    659   a->active = (BytePtr) newlimit;
     624
     625
     626void
     627platform_new_heap_segment(ExceptionInformation *xp, TCR *tcr, BytePtr low, BytePtr high)
     628{
    660629  tcr->last_allocptr = (void *)newlimit;
    661630  xpGPR(xp,allocptr) = (LispObj) newlimit;
    662631  tcr->save_allocbase = (void*) oldlimit;
    663 
    664   return true;
    665 }
    666 
     632}
    667633 
    668634void
  • branches/gb-egc/lisp-kernel/gc-common.c

    r15827 r15831  
    15551555}
    15561556
    1557 extern void zero_dnodes(void *,natural);
    15581557
    15591558void
     
    15671566    pkg = 0,
    15681567    itabvec = 0;
    1569   BytePtr oldfree = a->active, last_zeroed_addr;
     1568  BytePtr oldfree = a->active;
    15701569  TCR *other_tcr;
    15711570  natural static_dnodes;
     
    19051904                        (GCephemeral_low == 0) ? lisp_heap_gc_threshold : 0);
    19061905
    1907     if (oldfree < a->high) {
    1908       last_zeroed_addr = oldfree;
    1909     } else {
    1910       last_zeroed_addr = a->high;
    1911     }
    1912     zero_dnodes(a->active, area_dnode(last_zeroed_addr,a->active));
    19131906
    19141907    /*
     
    20061999  }
    20072000}
     2001
     2002/*
     2003  This doesn't GC; it returns true if it made enough room, false
     2004  otherwise.
     2005  If "extend" is true, it can try to extend the dynamic area to
     2006  satisfy the request.
     2007*/
     2008
     2009Boolean
     2010new_heap_segment(ExceptionInformation *xp, natural need, Boolean extend, TCR *tcr, Boolean *crossed_threshold)
     2011{
     2012  area *a;
     2013  natural newlimit, oldlimit;
     2014  natural log2_allocation_quantum = TCR_AUX(tcr)->log2_allocation_quantum;
     2015
     2016  if (crossed_threshold) {
     2017    *crossed_threshold = false;
     2018  }
     2019
     2020  a  = active_dynamic_area;
     2021  oldlimit = (natural) a->active;
     2022  newlimit = (align_to_power_of_2(oldlimit, log2_allocation_quantum) +
     2023              align_to_power_of_2(need, log2_allocation_quantum));
     2024  if (newlimit > (natural) (a->high)) {
     2025    if (extend) {
     2026      signed_natural inhibit = (signed_natural)(lisp_global(GC_INHIBIT_COUNT));
     2027      natural extend_by = inhibit ? 0 : lisp_heap_gc_threshold;
     2028      do {
     2029        if (resize_dynamic_heap(a->active, (newlimit-oldlimit)+extend_by)) {
     2030          break;
     2031        }
     2032        extend_by = align_to_power_of_2(extend_by>>1,log2_allocation_quantum);
     2033        if (extend_by < 4<<20) {
     2034          return false;
     2035        }
     2036      } while (1);
     2037    } else {
     2038      return false;
     2039    }
     2040  }
     2041  a->active = (BytePtr) newlimit;
     2042  platform_new_heap_segment(xp, tcr, (BytePtr)oldlimit, (BytePtr)newlimit);
     2043  if ((BytePtr)oldlimit < heap_dirty_limit) {
     2044    if ((BytePtr)newlimit < heap_dirty_limit) {
     2045      zero_dnodes((void *)oldlimit,area_dnode(newlimit,oldlimit));
     2046    } else {
     2047      zero_dnodes((void *)oldlimit,area_dnode(heap_dirty_limit,oldlimit));
     2048    }
     2049  }
     2050  if ((BytePtr)newlimit > heap_dirty_limit) {
     2051    heap_dirty_limit = (BytePtr)newlimit;       
     2052  }
     2053
     2054  if (crossed_threshold && (!extend)) {
     2055    if (((a->high - (BytePtr)newlimit) < lisp_heap_notify_threshold)&&
     2056        ((a->high - (BytePtr)oldlimit) >= lisp_heap_notify_threshold)) {
     2057      *crossed_threshold = true;
     2058    }
     2059  }
     2060   
     2061
     2062  return true;
     2063}
  • branches/gb-egc/lisp-kernel/gc.h

    r15823 r15831  
    8787Boolean egc_control(Boolean, BytePtr);
    8888Boolean free_segments_zero_filled_by_OS;
    89 
     89Boolean new_heap_segment(ExceptionInformation *, natural, Boolean , TCR *, Boolean *);
     90void platform_new_heap_segment(ExceptionInformation *, TCR*, BytePtr, BytePtr);
    9091/* an type representing 1/4 of a natural word */
    9192#if WORD_SIZE == 64
     
    254255did_gc_notification_since_last_full_gc;
    255256
     257extern BytePtr heap_dirty_limit;
     258extern void zero_dnodes(void *,natural);
    256259
    257260
  • branches/gb-egc/lisp-kernel/memory.c

    r15823 r15831  
    468468      return true;
    469469    }
    470   }
     470  } 
    471471  return false;
    472472}
  • branches/gb-egc/lisp-kernel/pmcl-kernel.c

    r15823 r15831  
    151151extern LispObj import_ptrs_base;
    152152
     153/* The highest heap address that's (probably) been written to. */
     154BytePtr heap_dirty_limit = NULL;
    153155
    154156
     
    20872089    lisp_global(OLDSPACE_DNODE_COUNT) = 0;
    20882090  }
     2091  heap_dirty_limit = active_dynamic_area->active;
    20892092  lisp_global(MANAGED_STATIC_REFBITS) = (LispObj)managed_static_refbits;
    20902093  lisp_global(MANAGED_STATIC_REFIDX) = (LispObj)managed_static_refidx;
  • branches/gb-egc/lisp-kernel/ppc-exceptions.c

    r15816 r15831  
    250250     without extending the heap.
    251251  */
    252   if (new_heap_segment(xp, bytes_needed, false, tcr)) {
     252  if (new_heap_segment(xp, bytes_needed, false, tcr, NULL)) {
    253253    xpGPR(xp, allocptr) += disp_from_allocptr;
    254254#ifdef DEBUG
     
    269269 
    270270  /* Try again, growing the heap if necessary */
    271   if (new_heap_segment(xp, bytes_needed, true, tcr)) {
     271  if (new_heap_segment(xp, bytes_needed, true, tcr, NULL)) {
    272272    xpGPR(xp, allocptr) += disp_from_allocptr;
    273273#ifdef DEBUG
     
    668668  }
    669669  a->active = (BytePtr) newlimit;
    670   tcr->last_allocptr = (void *)newlimit;
    671   xpGPR(xp,allocptr) = (LispObj) newlimit;
    672   xpGPR(xp,allocbase) = (LispObj) oldlimit;
    673670
    674671  return true;
     672}
     673
     674void
     675platform_new_heap_segment(ExceptionInformation *xp, TCR *tcr, BytePtr low, BytePtr high)
     676{
     677  tcr->last_allocptr = (void *)high;
     678  xpGPR(xp,allocptr) = (LispObj) high;
     679  xpGPR(xp,allocbase) = (LispObj) low;
    675680}
    676681
  • branches/gb-egc/lisp-kernel/x86-exceptions.c

    r15823 r15831  
    141141
    142142
    143 Boolean
    144 new_heap_segment(ExceptionInformation *xp, natural need, Boolean extend, TCR *tcr, Boolean *crossed_threshold)
    145 {
    146   area *a;
    147   natural newlimit, oldlimit;
    148   natural log2_allocation_quantum = TCR_AUX(tcr)->log2_allocation_quantum;
    149 
    150   if (crossed_threshold) {
    151     *crossed_threshold = false;
    152   }
    153 
    154   a  = active_dynamic_area;
    155   oldlimit = (natural) a->active;
    156   newlimit = (align_to_power_of_2(oldlimit, log2_allocation_quantum) +
    157               align_to_power_of_2(need, log2_allocation_quantum));
    158   if (newlimit > (natural) (a->high)) {
    159     if (extend) {
    160       signed_natural inhibit = (signed_natural)(lisp_global(GC_INHIBIT_COUNT));
    161       natural extend_by = inhibit ? 0 : lisp_heap_gc_threshold;
    162       do {
    163         if (resize_dynamic_heap(a->active, (newlimit-oldlimit)+extend_by)) {
    164           break;
    165         }
    166         extend_by = align_to_power_of_2(extend_by>>1,log2_allocation_quantum);
    167         if (extend_by < 4<<20) {
    168           return false;
    169         }
    170       } while (1);
    171     } else {
    172       return false;
    173     }
    174   }
    175   a->active = (BytePtr) newlimit;
    176   tcr->last_allocptr = (void *)newlimit;
    177   tcr->save_allocptr = (void *)newlimit;
    178   xpGPR(xp,Iallocptr) = (LispObj) newlimit;
    179   tcr->save_allocbase = (void *) oldlimit;
    180 
    181   if (crossed_threshold && (!extend)) {
    182     if (((a->high - (BytePtr)newlimit) < lisp_heap_notify_threshold)&&
    183         ((a->high - (BytePtr)oldlimit) >= lisp_heap_notify_threshold)) {
    184       *crossed_threshold = true;
    185     }
    186   }
    187    
    188 
    189   return true;
     143
     144void
     145platform_new_heap_segment(ExceptionInformation *xp, TCR *tcr, BytePtr low, BytePtr high)
     146{
     147  tcr->last_allocptr = (void *)high;
     148  tcr->save_allocptr = (void *)high;
     149  xpGPR(xp,Iallocptr) = (LispObj) high;
     150  tcr->save_allocbase = (void *) low;
    190151}
    191152
Note: See TracChangeset for help on using the changeset viewer.