/[cmucl]/src/lisp/gencgc.c
ViewVC logotype

Diff of /src/lisp/gencgc.c

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

revision 1.46 by toy, Fri Oct 24 02:57:00 2003 UTC revision 1.47 by toy, Fri Jan 9 05:07:39 2004 UTC
# Line 47  Line 47 
47  #define clr_pseudo_atomic_interrupted() \  #define clr_pseudo_atomic_interrupted() \
48    SetSymbolValue (PSEUDO_ATOMIC_INTERRUPTED, make_fixnum (0))    SetSymbolValue (PSEUDO_ATOMIC_INTERRUPTED, make_fixnum (0))
49    
50    #define set_current_region_free(value) \
51      SetSymbolValue(CURRENT_REGION_FREE_POINTER, (value))
52    #define set_current_region_end(value) \
53      SetSymbolValue(CURRENT_REGION_END_ADDR, (value))
54    #define get_current_region_free() \
55      SymbolValue(CURRENT_REGION_FREE_POINTER)
56    
57    #define set_current_region_end(value) \
58      SetSymbolValue(CURRENT_REGION_END_ADDR, (value))
59    
60  #elif defined(sparc)  #elif defined(sparc)
61    
62  /*  /*
# Line 54  Line 64 
64   * stuff, so we need to preserve those bits when we give it a value.   * stuff, so we need to preserve those bits when we give it a value.
65   * This value better not have any bits set there either!   * This value better not have any bits set there either!
66   */   */
67    #if 0
68  #define set_alloc_pointer(value) \  #define set_alloc_pointer(value) \
69    (current_dynamic_space_free_pointer = (lispobj*) ((value) \    (current_dynamic_space_free_pointer = (lispobj*) ((value) \
70           | ((unsigned long) current_dynamic_space_free_pointer & lowtag_Mask)))           | ((unsigned long) current_dynamic_space_free_pointer & lowtag_Mask)))
71    #else
72    #define set_alloc_pointer(value)
73    #endif
74  #define get_alloc_pointer() \  #define get_alloc_pointer() \
75    ((unsigned long) current_dynamic_space_free_pointer & ~lowtag_Mask)    ((unsigned long) current_dynamic_space_free_pointer & ~lowtag_Mask)
76  #define get_binding_stack_pointer() \  #define get_binding_stack_pointer() \
# Line 75  Line 89 
89    (current_dynamic_space_free_pointer \    (current_dynamic_space_free_pointer \
90     = (lispobj*) ((unsigned long) current_dynamic_space_free_pointer & ~pseudo_atomic_InterruptedValue))     = (lispobj*) ((unsigned long) current_dynamic_space_free_pointer & ~pseudo_atomic_InterruptedValue))
91    
92    #if 0
93    #define set_current_region_free(value) \
94      SetSymbolValue(CURRENT_REGION_FREE_POINTER, (value))
95    
96    #define get_current_region_free() \
97      SymbolValue(CURRENT_REGION_FREE_POINTER)
98    
99    #else
100    #define set_current_region_free(value) \
101      current_dynamic_space_free_pointer = (lispobj*)((value) | ((long)current_dynamic_space_free_pointer & lowtag_Mask))
102    
103    #define get_current_region_free() \
104      ((long)current_dynamic_space_free_pointer & (~(lowtag_Mask)))
105    #endif
106    
107    #define set_current_region_end(value) \
108      SetSymbolValue(CURRENT_REGION_END_ADDR, (value))
109    
110  #else  #else
111  #error gencgc is not supported on this platform  #error gencgc is not supported on this platform
112  #endif  #endif
# Line 835  static void gc_alloc_new_region(int nbyt Line 867  static void gc_alloc_new_region(int nbyt
867    
868      /* Check for a failure */      /* Check for a failure */
869      if (first_page >= dynamic_space_pages - reserved_heap_pages) {      if (first_page >= dynamic_space_pages - reserved_heap_pages) {
870    #if 0
871        handle_heap_overflow("*A2 gc_alloc_new_region failed, nbytes=%d.\n", nbytes);        handle_heap_overflow("*A2 gc_alloc_new_region failed, nbytes=%d.\n", nbytes);
872    #else
873          break;
874    #endif
875      }      }
876    
877      gc_assert(!PAGE_WRITE_PROTECTED(first_page));      gc_assert(!PAGE_WRITE_PROTECTED(first_page));
# Line 877  static void gc_alloc_new_region(int nbyt Line 913  static void gc_alloc_new_region(int nbyt
913    }    }
914    while (restart_page < dynamic_space_pages && bytes_found < nbytes);    while (restart_page < dynamic_space_pages && bytes_found < nbytes);
915    
916      if (first_page >= dynamic_space_pages - reserved_heap_pages) {
917        handle_heap_overflow("*A2 gc_alloc_new_region failed, nbytes=%d.\n", nbytes);
918      }
919    
920    /* Check for a failure */    /* Check for a failure */
921    if (restart_page >= (dynamic_space_pages - reserved_heap_pages) && bytes_found < nbytes) {    if (restart_page >= (dynamic_space_pages - reserved_heap_pages) && bytes_found < nbytes) {
922      handle_heap_overflow("*A1 gc_alloc_new_region failed, nbytes=%d.\n", nbytes);      handle_heap_overflow("*A1 gc_alloc_new_region failed, nbytes=%d.\n", nbytes);
# Line 1275  static void *gc_alloc_large(int  nbytes, Line 1315  static void *gc_alloc_large(int  nbytes,
1315    
1316      /* Check for a failure */      /* Check for a failure */
1317      if (first_page >= dynamic_space_pages - reserved_heap_pages) {      if (first_page >= dynamic_space_pages - reserved_heap_pages) {
1318    #if 0
1319        handle_heap_overflow("*A2 gc_alloc_large failed, nbytes=%d.\n", nbytes);        handle_heap_overflow("*A2 gc_alloc_large failed, nbytes=%d.\n", nbytes);
1320    #else
1321          break;
1322    #endif
1323      }      }
   
1324      gc_assert(!PAGE_WRITE_PROTECTED(first_page));      gc_assert(!PAGE_WRITE_PROTECTED(first_page));
1325    
1326  #if 0  #if 0
# Line 1311  static void *gc_alloc_large(int  nbytes, Line 1354  static void *gc_alloc_large(int  nbytes,
1354    }    }
1355    while ((restart_page < dynamic_space_pages) && (bytes_found < nbytes));    while ((restart_page < dynamic_space_pages) && (bytes_found < nbytes));
1356    
1357      if (first_page >= dynamic_space_pages - reserved_heap_pages) {
1358        handle_heap_overflow("*A2 gc_alloc_large failed, nbytes=%d.\n", nbytes);
1359      }
1360    
1361    /* Check for a failure */    /* Check for a failure */
1362    if (restart_page >= (dynamic_space_pages - reserved_heap_pages) && bytes_found < nbytes) {    if (restart_page >= (dynamic_space_pages - reserved_heap_pages) && bytes_found < nbytes) {
1363      handle_heap_overflow("*A1 gc_alloc_large failed, nbytes=%d.\n", nbytes);      handle_heap_overflow("*A1 gc_alloc_large failed, nbytes=%d.\n", nbytes);
# Line 6157  void gencgc_verify_zero_fill(void) Line 6204  void gencgc_verify_zero_fill(void)
6204  {  {
6205    /* Flush the alloc regions updating the tables. */    /* Flush the alloc regions updating the tables. */
6206    
6207    boxed_region.free_pointer = (void *) SymbolValue(CURRENT_REGION_FREE_POINTER);    boxed_region.free_pointer = (void *) get_current_region_free();
6208    gc_alloc_update_page_tables(0, &boxed_region);    gc_alloc_update_page_tables(0, &boxed_region);
6209    gc_alloc_update_page_tables(1, &unboxed_region);    gc_alloc_update_page_tables(1, &unboxed_region);
6210    fprintf(stderr, "* Verifying zero fill\n");    fprintf(stderr, "* Verifying zero fill\n");
6211    verify_zero_fill();    verify_zero_fill();
6212    SetSymbolValue(CURRENT_REGION_FREE_POINTER,    set_current_region_free((lispobj)boxed_region.free_pointer);
6213                   (lispobj)boxed_region.free_pointer);    set_current_region_end((lispobj)boxed_region.end_addr);
   SetSymbolValue(CURRENT_REGION_END_ADDR, (lispobj)boxed_region.end_addr);  
6214  }  }
6215    
6216  static void verify_dynamic_space(void)  static void verify_dynamic_space(void)
# Line 6533  void   collect_garbage(unsigned last_gen) Line 6579  void   collect_garbage(unsigned last_gen)
6579    int gen_to_wp;    int gen_to_wp;
6580    int i;    int i;
6581    
6582    boxed_region.free_pointer = (void *) SymbolValue(CURRENT_REGION_FREE_POINTER);    boxed_region.free_pointer = (void *) get_current_region_free();
6583    
6584    /* Check last_gen */    /* Check last_gen */
6585    if (last_gen > NUM_GENERATIONS) {    if (last_gen > NUM_GENERATIONS) {
# Line 6641  void   collect_garbage(unsigned last_gen) Line 6687  void   collect_garbage(unsigned last_gen)
6687    gc_assert(boxed_region.free_pointer - boxed_region.start_addr == 0);    gc_assert(boxed_region.free_pointer - boxed_region.start_addr == 0);
6688    gc_alloc_generation = 0;    gc_alloc_generation = 0;
6689    
6690      /* Sparc doesn't need this because the dynamic space free pointer is
6691         the same as the current region free pointer, which is updated by
6692         the allocation routines appropriately. */
6693    #if !defined(sparc)
6694    update_dynamic_space_free_pointer();    update_dynamic_space_free_pointer();
6695    #endif
6696    SetSymbolValue(CURRENT_REGION_FREE_POINTER, (lispobj) boxed_region.free_pointer);  
6697    SetSymbolValue(CURRENT_REGION_END_ADDR, (lispobj) boxed_region.end_addr);    set_current_region_free((lispobj) boxed_region.free_pointer);
6698      set_current_region_end((lispobj) boxed_region.end_addr);
6699    
6700    /* Call the scavenger hook functions */    /* Call the scavenger hook functions */
6701    {    {
# Line 6757  void   gc_free_heap(void) Line 6808  void   gc_free_heap(void)
6808    
6809    set_alloc_pointer((lispobj) heap_base);    set_alloc_pointer((lispobj) heap_base);
6810    
6811    SetSymbolValue(CURRENT_REGION_FREE_POINTER, (lispobj) boxed_region.free_pointer);    set_current_region_free((lispobj) boxed_region.free_pointer);
6812    SetSymbolValue(CURRENT_REGION_END_ADDR, (lispobj) boxed_region.end_addr);    set_current_region_end((lispobj) boxed_region.end_addr);
6813    
6814    if (verify_after_free_heap) {    if (verify_after_free_heap) {
6815      /* Check if purify has left any bad pointers. */      /* Check if purify has left any bad pointers. */
# Line 6833  void gc_init(void) Line 6884  void gc_init(void)
6884    
6885    last_free_page = 0;    last_free_page = 0;
6886    
6887    SetSymbolValue(CURRENT_REGION_FREE_POINTER, (lispobj) boxed_region.free_pointer);    set_current_region_free((lispobj) boxed_region.free_pointer);
6888    SetSymbolValue(CURRENT_REGION_END_ADDR, (lispobj) boxed_region.end_addr);    set_current_region_end((lispobj) boxed_region.end_addr);
6889  }  }
6890    
6891  /*  /*
# Line 6867  void   gencgc_pickup_dynamic(void) Line 6918  void   gencgc_pickup_dynamic(void)
6918    generations[0].bytes_allocated = PAGE_SIZE * page;    generations[0].bytes_allocated = PAGE_SIZE * page;
6919    bytes_allocated = PAGE_SIZE * page;    bytes_allocated = PAGE_SIZE * page;
6920    
6921    SetSymbolValue(CURRENT_REGION_FREE_POINTER, (lispobj) boxed_region.free_pointer);    set_current_region_free((lispobj) boxed_region.free_pointer);
6922    SetSymbolValue(CURRENT_REGION_END_ADDR, (lispobj) boxed_region.end_addr);    set_current_region_end((lispobj) boxed_region.end_addr);
6923  }  }
6924    
6925    
# Line 6897  void do_pending_interrupt (void); Line 6948  void do_pending_interrupt (void);
6948  char *  char *
6949  alloc (int nbytes)  alloc (int nbytes)
6950  {  {
6951    gc_assert (((unsigned) SymbolValue (CURRENT_REGION_FREE_POINTER) & lowtag_Mask) == 0);  #ifndef sparc
6952      gc_assert (((unsigned) get_current_region_free() & lowtag_Mask) == 0);
6953    #endif
6954    gc_assert ((nbytes & lowtag_Mask) == 0);    gc_assert ((nbytes & lowtag_Mask) == 0);
6955    gc_assert (get_pseudo_atomic_atomic ());    gc_assert (get_pseudo_atomic_atomic ());
6956    
# Line 6907  alloc (int nbytes) Line 6960  alloc (int nbytes)
6960      {      {
6961        void *new_obj;        void *new_obj;
6962        char *new_free_pointer        char *new_free_pointer
6963          = (void *) (SymbolValue (CURRENT_REGION_FREE_POINTER) + nbytes);          = (void *) (get_current_region_free() + nbytes);
6964    
6965        if (new_free_pointer <= boxed_region.end_addr)        if (new_free_pointer <= boxed_region.end_addr)
6966          {          {
6967            /* Allocate from the current region. */            /* Allocate from the current region. */
6968            new_obj = (void *) SymbolValue (CURRENT_REGION_FREE_POINTER);            new_obj = (void *) get_current_region_free();
6969            SetSymbolValue (CURRENT_REGION_FREE_POINTER,            set_current_region_free((lispobj) new_free_pointer);
                           (lispobj) new_free_pointer);  
6970            return new_obj;            return new_obj;
6971          }          }
6972        else if (bytes_allocated <= auto_gc_trigger)        else if (bytes_allocated <= auto_gc_trigger)
6973          {          {
6974            /* Call gc_alloc.  */            /* Call gc_alloc.  */
6975            boxed_region.free_pointer            boxed_region.free_pointer = (void *) get_current_region_free();
6976              = (void *) SymbolValue (CURRENT_REGION_FREE_POINTER);            boxed_region.end_addr = (void *) SymbolValue(CURRENT_REGION_END_ADDR);
6977    
6978            new_obj = gc_alloc (nbytes);            new_obj = gc_alloc (nbytes);
6979            SetSymbolValue (CURRENT_REGION_FREE_POINTER,            set_current_region_free((lispobj) boxed_region.free_pointer);
6980                            (lispobj) boxed_region.free_pointer);            set_current_region_end((lispobj) boxed_region.end_addr);
           SetSymbolValue (CURRENT_REGION_END_ADDR,  
                           (lispobj) boxed_region.end_addr);  
6981            return new_obj;            return new_obj;
6982          }          }
6983        else        else
# Line 7013  int get_bytes_consed_upper(void) Line 7064  int get_bytes_consed_upper(void)
7064    return ((int)bytes_allocated_sum / 0x10000000) & 0xFFFFFFF;    return ((int)bytes_allocated_sum / 0x10000000) & 0xFFFFFFF;
7065  }  }
7066    
7067    #if 0
7068  #define current_region_free_pointer SymbolValue(CURRENT_REGION_FREE_POINTER)  #define current_region_free_pointer SymbolValue(CURRENT_REGION_FREE_POINTER)
7069  #define current_region_end_addr     ((void *) SymbolValue(CURRENT_REGION_END_ADDR))  #define current_region_end_addr     ((void *) SymbolValue(CURRENT_REGION_END_ADDR))
7070    #else
7071    #define current_region_free_pointer get_current_region_free()
7072    #define current_region_end_addr     ((void *) SymbolValue(CURRENT_REGION_END_ADDR))
7073    #endif
7074  int get_bytes_allocated_lower(void)  int get_bytes_allocated_lower(void)
7075  {  {
7076    int size = bytes_allocated;    int size = bytes_allocated;

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.5