/[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.110.6.5 by rtoy, Mon Dec 20 23:32:55 2010 UTC revision 1.112 by rtoy, Sun Jan 9 00:12:36 2011 UTC
# Line 324  boolean gencgc_zero_check_during_free_he Line 324  boolean gencgc_zero_check_during_free_he
324  /*  /*
325   * The minimum size for a large object.   * The minimum size for a large object.
326   */   */
327  unsigned large_object_size = 4 * PAGE_SIZE;  unsigned large_object_size = 4 * GC_PAGE_SIZE;
328    
329  /*  /*
330   * Enable the filtering of stack/register pointers. This could reduce   * Enable the filtering of stack/register pointers. This could reduce
# Line 394  static char *heap_base = NULL; Line 394  static char *heap_base = NULL;
394  static char *  static char *
395  page_address(int page_num)  page_address(int page_num)
396  {  {
397      return heap_base + PAGE_SIZE * page_num;      return heap_base + GC_PAGE_SIZE * page_num;
398  }  }
399    
400  /*  /*
# Line 407  find_page_index(void *addr) Line 407  find_page_index(void *addr)
407      int index = (char *) addr - heap_base;      int index = (char *) addr - heap_base;
408    
409      if (index >= 0) {      if (index >= 0) {
410          index = (unsigned int) index / PAGE_SIZE;          index = (unsigned int) index / GC_PAGE_SIZE;
411          if (index < dynamic_space_pages)          if (index < dynamic_space_pages)
412              return index;              return index;
413      }      }
# Line 441  gc_write_barrier(void *addr) Line 441  gc_write_barrier(void *addr)
441                   "*** Page fault in page not marked as write protected\n");                   "*** Page fault in page not marked as write protected\n");
442    
443      /* Un-protect the page */      /* Un-protect the page */
444      os_protect((os_vm_address_t) page_address(page_index), PAGE_SIZE, OS_VM_PROT_ALL);      os_protect((os_vm_address_t) page_address(page_index), GC_PAGE_SIZE, OS_VM_PROT_ALL);
445      page_table[page_index].flags &= ~PAGE_WRITE_PROTECTED_MASK;      page_table[page_index].flags &= ~PAGE_WRITE_PROTECTED_MASK;
446      page_table[page_index].flags |= PAGE_WRITE_PROTECT_CLEARED_MASK;      page_table[page_index].flags |= PAGE_WRITE_PROTECT_CLEARED_MASK;
447    
# Line 712  print_generation_stats(int verbose) Line 712  print_generation_stats(int verbose)
712          gens = NUM_GENERATIONS;          gens = NUM_GENERATIONS;
713    
714      /* Print the heap stats */      /* Print the heap stats */
715      fprintf(stderr, "          Page count (%d KB)\n", PAGE_SIZE / 1024);      fprintf(stderr, "          Page count (%d KB)\n", GC_PAGE_SIZE / 1024);
716      fprintf(stderr,      fprintf(stderr,
717              "   Gen  Boxed Unboxed  LB   LUB    Alloc    Waste    Trigger   WP  GCs Mem-age\n");              "   Gen  Boxed Unboxed  LB   LUB    Alloc    Waste    Trigger   WP  GCs Mem-age\n");
718    
# Line 750  print_generation_stats(int verbose) Line 750  print_generation_stats(int verbose)
750          fprintf(stderr, " %5d: %5d %5d %5d %5d %10d %6d %10d %4d %3d %7.4f\n",          fprintf(stderr, " %5d: %5d %5d %5d %5d %10d %6d %10d %4d %3d %7.4f\n",
751                  i, boxed_cnt, unboxed_cnt, large_boxed_cnt, large_unboxed_cnt,                  i, boxed_cnt, unboxed_cnt, large_boxed_cnt, large_unboxed_cnt,
752                  generations[i].bytes_allocated,                  generations[i].bytes_allocated,
753                  PAGE_SIZE * count_generation_pages(i) -                  GC_PAGE_SIZE * count_generation_pages(i) -
754                  generations[i].bytes_allocated, generations[i].gc_trigger,                  generations[i].bytes_allocated, generations[i].gc_trigger,
755                  count_write_protect_generation_pages(i), generations[i].num_gc,                  count_write_protect_generation_pages(i), generations[i].num_gc,
756                  gen_av_mem_age(i));                  gen_av_mem_age(i));
# Line 993  gc_alloc_new_region(int nbytes, int unbo Line 993  gc_alloc_new_region(int nbytes, int unbo
993    
994              if (!(flags & PAGE_ALLOCATED_MASK)              if (!(flags & PAGE_ALLOCATED_MASK)
995                  || ((flags & mmask) == mflags &&                  || ((flags & mmask) == mflags &&
996                      page_table[first_page].bytes_used < PAGE_SIZE - 32))                      page_table[first_page].bytes_used < GC_PAGE_SIZE - 32))
997                  break;                  break;
998              first_page++;              first_page++;
999          }          }
# Line 1022  gc_alloc_new_region(int nbytes, int unbo Line 1022  gc_alloc_new_region(int nbytes, int unbo
1022           * number of pages in a region.           * number of pages in a region.
1023           */           */
1024          last_page = first_page;          last_page = first_page;
1025          bytes_found = PAGE_SIZE - page_table[first_page].bytes_used;          bytes_found = GC_PAGE_SIZE - page_table[first_page].bytes_used;
1026          num_pages = 1;          num_pages = 1;
1027          while ((bytes_found < nbytes || num_pages < 2)          while ((bytes_found < nbytes || num_pages < 2)
1028                 && last_page < dynamic_space_pages - 1                 && last_page < dynamic_space_pages - 1
1029                 && !PAGE_ALLOCATED(last_page + 1)) {                 && !PAGE_ALLOCATED(last_page + 1)) {
1030              last_page++;              last_page++;
1031              num_pages++;              num_pages++;
1032              bytes_found += PAGE_SIZE;              bytes_found += GC_PAGE_SIZE;
1033              gc_assert(!PAGE_WRITE_PROTECTED(last_page));              gc_assert(!PAGE_WRITE_PROTECTED(last_page));
1034          }          }
1035    
1036          region_size = (PAGE_SIZE - page_table[first_page].bytes_used)          region_size = (GC_PAGE_SIZE - page_table[first_page].bytes_used)
1037              + PAGE_SIZE * (last_page - first_page);              + GC_PAGE_SIZE * (last_page - first_page);
1038    
1039          gc_assert(bytes_found == region_size);          gc_assert(bytes_found == region_size);
1040    
# Line 1113  gc_alloc_new_region(int nbytes, int unbo Line 1113  gc_alloc_new_region(int nbytes, int unbo
1113      if (last_page + 1 > last_free_page) {      if (last_page + 1 > last_free_page) {
1114          last_free_page = last_page + 1;          last_free_page = last_page + 1;
1115          set_alloc_pointer((lispobj) ((char *) heap_base +          set_alloc_pointer((lispobj) ((char *) heap_base +
1116                                       PAGE_SIZE * last_free_page));                                       GC_PAGE_SIZE * last_free_page));
1117    
1118      }      }
1119  }  }
# Line 1174  add_new_area(int first_page, int offset, Line 1174  add_new_area(int first_page, int offset,
1174            gc_abort();            gc_abort();
1175      }      }
1176    
1177      new_area_start = PAGE_SIZE * first_page + offset;      new_area_start = GC_PAGE_SIZE * first_page + offset;
1178    
1179      /*      /*
1180       * Search backwards for a prior area that this follows from.  If       * Search backwards for a prior area that this follows from.  If
1181       * found this will save adding a new area.       * found this will save adding a new area.
1182       */       */
1183      for (i = new_areas_index - 1, c = 0; i >= 0 && c < 8; i--, c++) {      for (i = new_areas_index - 1, c = 0; i >= 0 && c < 8; i--, c++) {
1184          unsigned area_end = PAGE_SIZE * (*new_areas)[i].page          unsigned area_end = GC_PAGE_SIZE * (*new_areas)[i].page
1185              + (*new_areas)[i].offset + (*new_areas)[i].size;              + (*new_areas)[i].offset + (*new_areas)[i].size;
1186    
1187  #if 0  #if 0
# Line 1281  gc_alloc_update_page_tables(int unboxed, Line 1281  gc_alloc_update_page_tables(int unboxed,
1281           */           */
1282          more = 0;          more = 0;
1283          bytes_used = alloc_region->free_pointer - page_address(first_page);          bytes_used = alloc_region->free_pointer - page_address(first_page);
1284          if (bytes_used > PAGE_SIZE) {          if (bytes_used > GC_PAGE_SIZE) {
1285              bytes_used = PAGE_SIZE;              bytes_used = GC_PAGE_SIZE;
1286              more = 1;              more = 1;
1287          }          }
1288          page_table[first_page].bytes_used = bytes_used;          page_table[first_page].bytes_used = bytes_used;
# Line 1309  gc_alloc_update_page_tables(int unboxed, Line 1309  gc_alloc_update_page_tables(int unboxed,
1309              /* Calc. the number of bytes used in this page. */              /* Calc. the number of bytes used in this page. */
1310              more = 0;              more = 0;
1311              bytes_used = alloc_region->free_pointer - page_address(next_page);              bytes_used = alloc_region->free_pointer - page_address(next_page);
1312              if (bytes_used > PAGE_SIZE) {              if (bytes_used > GC_PAGE_SIZE) {
1313                  bytes_used = PAGE_SIZE;                  bytes_used = GC_PAGE_SIZE;
1314                  more = 1;                  more = 1;
1315              }              }
1316              page_table[next_page].bytes_used = bytes_used;              page_table[next_page].bytes_used = bytes_used;
# Line 1456  gc_alloc_large(int nbytes, int unboxed, Line 1456  gc_alloc_large(int nbytes, int unboxed,
1456    
1457                  if (!(flags & PAGE_ALLOCATED_MASK)                  if (!(flags & PAGE_ALLOCATED_MASK)
1458                      || ((flags & mmask) == mflags &&                      || ((flags & mmask) == mflags &&
1459                          page_table[first_page].bytes_used < PAGE_SIZE - 32))                          page_table[first_page].bytes_used < GC_PAGE_SIZE - 32))
1460                      break;                      break;
1461                  first_page++;                  first_page++;
1462              }              }
# Line 1478  gc_alloc_large(int nbytes, int unboxed, Line 1478  gc_alloc_large(int nbytes, int unboxed,
1478  #endif  #endif
1479    
1480          last_page = first_page;          last_page = first_page;
1481          bytes_found = PAGE_SIZE - page_table[first_page].bytes_used;          bytes_found = GC_PAGE_SIZE - page_table[first_page].bytes_used;
1482          num_pages = 1;          num_pages = 1;
1483          while (bytes_found < nbytes          while (bytes_found < nbytes
1484                 && last_page < dynamic_space_pages - 1                 && last_page < dynamic_space_pages - 1
1485                 && !PAGE_ALLOCATED(last_page + 1)) {                 && !PAGE_ALLOCATED(last_page + 1)) {
1486              last_page++;              last_page++;
1487              num_pages++;              num_pages++;
1488              bytes_found += PAGE_SIZE;              bytes_found += GC_PAGE_SIZE;
1489              gc_assert(!PAGE_WRITE_PROTECTED(last_page));              gc_assert(!PAGE_WRITE_PROTECTED(last_page));
1490          }          }
1491    
1492          region_size = (PAGE_SIZE - page_table[first_page].bytes_used)          region_size = (GC_PAGE_SIZE - page_table[first_page].bytes_used)
1493              + PAGE_SIZE * (last_page - first_page);              + GC_PAGE_SIZE * (last_page - first_page);
1494    
1495          gc_assert(bytes_found == region_size);          gc_assert(bytes_found == region_size);
1496    
# Line 1555  gc_alloc_large(int nbytes, int unboxed, Line 1555  gc_alloc_large(int nbytes, int unboxed,
1555       */       */
1556      more = 0;      more = 0;
1557      bytes_used = nbytes + orig_first_page_bytes_used;      bytes_used = nbytes + orig_first_page_bytes_used;
1558      if (bytes_used > PAGE_SIZE) {      if (bytes_used > GC_PAGE_SIZE) {
1559          bytes_used = PAGE_SIZE;          bytes_used = GC_PAGE_SIZE;
1560          more = 1;          more = 1;
1561      }      }
1562      page_table[first_page].bytes_used = bytes_used;      page_table[first_page].bytes_used = bytes_used;
# Line 1579  gc_alloc_large(int nbytes, int unboxed, Line 1579  gc_alloc_large(int nbytes, int unboxed,
1579          PAGE_FLAGS_UPDATE(next_page, mmask, mflags);          PAGE_FLAGS_UPDATE(next_page, mmask, mflags);
1580    
1581          page_table[next_page].first_object_offset =          page_table[next_page].first_object_offset =
1582              orig_first_page_bytes_used - PAGE_SIZE * (next_page - first_page);              orig_first_page_bytes_used - GC_PAGE_SIZE * (next_page - first_page);
1583    
1584          /* Calc. the number of bytes used in this page. */          /* Calc. the number of bytes used in this page. */
1585          more = 0;          more = 0;
1586          bytes_used = nbytes + orig_first_page_bytes_used - byte_cnt;          bytes_used = nbytes + orig_first_page_bytes_used - byte_cnt;
1587          if (bytes_used > PAGE_SIZE) {          if (bytes_used > GC_PAGE_SIZE) {
1588              bytes_used = PAGE_SIZE;              bytes_used = GC_PAGE_SIZE;
1589              more = 1;              more = 1;
1590          }          }
1591          page_table[next_page].bytes_used = bytes_used;          page_table[next_page].bytes_used = bytes_used;
# Line 1607  gc_alloc_large(int nbytes, int unboxed, Line 1607  gc_alloc_large(int nbytes, int unboxed,
1607      if (last_page + 1 > last_free_page) {      if (last_page + 1 > last_free_page) {
1608          last_free_page = last_page + 1;          last_free_page = last_page + 1;
1609          set_alloc_pointer((lispobj) ((char *) heap_base +          set_alloc_pointer((lispobj) ((char *) heap_base +
1610                                       PAGE_SIZE * last_free_page));                                       GC_PAGE_SIZE * last_free_page));
1611      }      }
1612    
1613      return (void *) (page_address(first_page) + orig_first_page_bytes_used);      return (void *) (page_address(first_page) + orig_first_page_bytes_used);
# Line 1961  from_space_p(lispobj obj) Line 1961  from_space_p(lispobj obj)
1961    
1962      return page_index >= 0      return page_index >= 0
1963          && (page_index =          && (page_index =
1964              (unsigned int) page_index / PAGE_SIZE) < dynamic_space_pages              (unsigned int) page_index / GC_PAGE_SIZE) < dynamic_space_pages
1965          && PAGE_GENERATION(page_index) == from_space;          && PAGE_GENERATION(page_index) == from_space;
1966  }  }
1967    
# Line 1972  new_space_p(lispobj obj) Line 1972  new_space_p(lispobj obj)
1972    
1973      return page_index >= 0      return page_index >= 0
1974          && (page_index =          && (page_index =
1975              (unsigned int) page_index / PAGE_SIZE) < dynamic_space_pages              (unsigned int) page_index / GC_PAGE_SIZE) < dynamic_space_pages
1976          && PAGE_GENERATION(page_index) == new_space;          && PAGE_GENERATION(page_index) == new_space;
1977  }  }
1978    
# Line 2170  copy_large_object(lispobj object, int nw Line 2170  copy_large_object(lispobj object, int nw
2170    
2171          next_page = first_page;          next_page = first_page;
2172          remaining_bytes = nwords * sizeof(lispobj);          remaining_bytes = nwords * sizeof(lispobj);
2173          while (remaining_bytes > PAGE_SIZE) {          while (remaining_bytes > GC_PAGE_SIZE) {
2174              gc_assert(PAGE_GENERATION(next_page) == from_space);              gc_assert(PAGE_GENERATION(next_page) == from_space);
2175              gc_assert(PAGE_ALLOCATED(next_page));              gc_assert(PAGE_ALLOCATED(next_page));
2176              gc_assert(!PAGE_UNBOXED(next_page));              gc_assert(!PAGE_UNBOXED(next_page));
2177              gc_assert(PAGE_LARGE_OBJECT(next_page));              gc_assert(PAGE_LARGE_OBJECT(next_page));
2178              gc_assert(page_table[next_page].first_object_offset ==              gc_assert(page_table[next_page].first_object_offset ==
2179                        PAGE_SIZE * (first_page - next_page));                        GC_PAGE_SIZE * (first_page - next_page));
2180              gc_assert(page_table[next_page].bytes_used == PAGE_SIZE);              gc_assert(page_table[next_page].bytes_used == GC_PAGE_SIZE);
2181    
2182              PAGE_FLAGS_UPDATE(next_page, PAGE_GENERATION_MASK, new_space);              PAGE_FLAGS_UPDATE(next_page, PAGE_GENERATION_MASK, new_space);
2183    
# Line 2186  copy_large_object(lispobj object, int nw Line 2186  copy_large_object(lispobj object, int nw
2186               * WP flag to avoid redundant calls.               * WP flag to avoid redundant calls.
2187               */               */
2188              if (PAGE_WRITE_PROTECTED(next_page)) {              if (PAGE_WRITE_PROTECTED(next_page)) {
2189                  os_protect((os_vm_address_t) page_address(next_page), PAGE_SIZE,                  os_protect((os_vm_address_t) page_address(next_page), GC_PAGE_SIZE,
2190                             OS_VM_PROT_ALL);                             OS_VM_PROT_ALL);
2191                  page_table[next_page].flags &= ~PAGE_WRITE_PROTECTED_MASK;                  page_table[next_page].flags &= ~PAGE_WRITE_PROTECTED_MASK;
2192              }              }
2193              remaining_bytes -= PAGE_SIZE;              remaining_bytes -= GC_PAGE_SIZE;
2194              next_page++;              next_page++;
2195          }          }
2196    
# Line 2218  copy_large_object(lispobj object, int nw Line 2218  copy_large_object(lispobj object, int nw
2218    
2219          /* Free any remaining pages; needs care. */          /* Free any remaining pages; needs care. */
2220          next_page++;          next_page++;
2221          while (old_bytes_used == PAGE_SIZE &&          while (old_bytes_used == GC_PAGE_SIZE &&
2222                 PAGE_FLAGS(next_page, mmask) == mflags &&                 PAGE_FLAGS(next_page, mmask) == mflags &&
2223                 page_table[next_page].first_object_offset ==                 page_table[next_page].first_object_offset ==
2224                 PAGE_SIZE * (first_page - next_page)) {                 GC_PAGE_SIZE * (first_page - next_page)) {
2225              /*              /*
2226               * Checks out OK, free the page. Don't need to both zeroing               * Checks out OK, free the page. Don't need to both zeroing
2227               * pages as this should have been done before shrinking the               * pages as this should have been done before shrinking the
# Line 2352  copy_large_unboxed_object(lispobj object Line 2352  copy_large_unboxed_object(lispobj object
2352    
2353          next_page = first_page;          next_page = first_page;
2354          remaining_bytes = nwords * sizeof(lispobj);          remaining_bytes = nwords * sizeof(lispobj);
2355          while (remaining_bytes > PAGE_SIZE) {          while (remaining_bytes > GC_PAGE_SIZE) {
2356              gc_assert(PAGE_GENERATION(next_page) == from_space);              gc_assert(PAGE_GENERATION(next_page) == from_space);
2357              gc_assert(PAGE_ALLOCATED(next_page));              gc_assert(PAGE_ALLOCATED(next_page));
2358              gc_assert(PAGE_LARGE_OBJECT(next_page));              gc_assert(PAGE_LARGE_OBJECT(next_page));
2359              gc_assert(page_table[next_page].first_object_offset ==              gc_assert(page_table[next_page].first_object_offset ==
2360                        PAGE_SIZE * (first_page - next_page));                        GC_PAGE_SIZE * (first_page - next_page));
2361              gc_assert(page_table[next_page].bytes_used == PAGE_SIZE);              gc_assert(page_table[next_page].bytes_used == GC_PAGE_SIZE);
2362    
2363              PAGE_FLAGS_UPDATE(next_page,              PAGE_FLAGS_UPDATE(next_page,
2364                                PAGE_UNBOXED_MASK | PAGE_GENERATION_MASK,                                PAGE_UNBOXED_MASK | PAGE_GENERATION_MASK,
2365                                PAGE_UNBOXED_MASK | new_space);                                PAGE_UNBOXED_MASK | new_space);
2366              remaining_bytes -= PAGE_SIZE;              remaining_bytes -= GC_PAGE_SIZE;
2367              next_page++;              next_page++;
2368          }          }
2369    
# Line 2391  copy_large_unboxed_object(lispobj object Line 2391  copy_large_unboxed_object(lispobj object
2391    
2392          /* Free any remaining pages; needs care. */          /* Free any remaining pages; needs care. */
2393          next_page++;          next_page++;
2394          while (old_bytes_used == PAGE_SIZE &&          while (old_bytes_used == GC_PAGE_SIZE &&
2395                 PAGE_FLAGS(next_page, mmask) == mflags &&                 PAGE_FLAGS(next_page, mmask) == mflags &&
2396                 page_table[next_page].first_object_offset ==                 page_table[next_page].first_object_offset ==
2397                 PAGE_SIZE * (first_page - next_page)) {                 GC_PAGE_SIZE * (first_page - next_page)) {
2398              /*              /*
2399               * Checks out OK, free the page. Don't need to both zeroing               * Checks out OK, free the page. Don't need to both zeroing
2400               * pages as this should have been done before shrinking the               * pages as this should have been done before shrinking the
# Line 5880  maybe_adjust_large_object(lispobj * wher Line 5880  maybe_adjust_large_object(lispobj * wher
5880    
5881      next_page = first_page;      next_page = first_page;
5882      remaining_bytes = nwords * sizeof(lispobj);      remaining_bytes = nwords * sizeof(lispobj);
5883      while (remaining_bytes > PAGE_SIZE) {      while (remaining_bytes > GC_PAGE_SIZE) {
5884          gc_assert(PAGE_GENERATION(next_page) == from_space);          gc_assert(PAGE_GENERATION(next_page) == from_space);
5885          gc_assert(PAGE_ALLOCATED(next_page));          gc_assert(PAGE_ALLOCATED(next_page));
5886          gc_assert(PAGE_LARGE_OBJECT(next_page));          gc_assert(PAGE_LARGE_OBJECT(next_page));
5887          gc_assert(page_table[next_page].first_object_offset ==          gc_assert(page_table[next_page].first_object_offset ==
5888                    PAGE_SIZE * (first_page - next_page));                    GC_PAGE_SIZE * (first_page - next_page));
5889          gc_assert(page_table[next_page].bytes_used == PAGE_SIZE);          gc_assert(page_table[next_page].bytes_used == GC_PAGE_SIZE);
5890    
5891          PAGE_FLAGS_UPDATE(next_page, PAGE_UNBOXED_MASK,          PAGE_FLAGS_UPDATE(next_page, PAGE_UNBOXED_MASK,
5892                            unboxed << PAGE_UNBOXED_SHIFT);                            unboxed << PAGE_UNBOXED_SHIFT);
# Line 5896  maybe_adjust_large_object(lispobj * wher Line 5896  maybe_adjust_large_object(lispobj * wher
5896           * pages aren't.           * pages aren't.
5897           */           */
5898          gc_assert(!PAGE_WRITE_PROTECTED(next_page));          gc_assert(!PAGE_WRITE_PROTECTED(next_page));
5899          remaining_bytes -= PAGE_SIZE;          remaining_bytes -= GC_PAGE_SIZE;
5900          next_page++;          next_page++;
5901      }      }
5902    
# Line 5924  maybe_adjust_large_object(lispobj * wher Line 5924  maybe_adjust_large_object(lispobj * wher
5924    
5925      /* Free any remaining pages; needs care. */      /* Free any remaining pages; needs care. */
5926      next_page++;      next_page++;
5927      while (old_bytes_used == PAGE_SIZE &&      while (old_bytes_used == GC_PAGE_SIZE &&
5928             PAGE_FLAGS(next_page, mmask) == mflags &&             PAGE_FLAGS(next_page, mmask) == mflags &&
5929             page_table[next_page].first_object_offset == PAGE_SIZE * (first_page             page_table[next_page].first_object_offset == GC_PAGE_SIZE * (first_page
5930                                                                       -                                                                       -
5931                                                                       next_page))                                                                       next_page))
5932      {      {
# Line 6010  preserve_pointer(void *addr) Line 6010  preserve_pointer(void *addr)
6010      while (page_table[first_page].first_object_offset != 0) {      while (page_table[first_page].first_object_offset != 0) {
6011          first_page--;          first_page--;
6012          /* Do some checks */          /* Do some checks */
6013          gc_assert(page_table[first_page].bytes_used == PAGE_SIZE);          gc_assert(page_table[first_page].bytes_used == GC_PAGE_SIZE);
6014          gc_assert(PAGE_GENERATION(first_page) == from_space);          gc_assert(PAGE_GENERATION(first_page) == from_space);
6015          gc_assert(PAGE_ALLOCATED(first_page));          gc_assert(PAGE_ALLOCATED(first_page));
6016          gc_assert(PAGE_UNBOXED(first_page) == region_unboxed);          gc_assert(PAGE_UNBOXED(first_page) == region_unboxed);
# Line 6072  preserve_pointer(void *addr) Line 6072  preserve_pointer(void *addr)
6072          gc_assert(!PAGE_WRITE_PROTECTED(i));          gc_assert(!PAGE_WRITE_PROTECTED(i));
6073    
6074          /* Check if this is the last page in this contiguous block */          /* Check if this is the last page in this contiguous block */
6075          if (page_table[i].bytes_used < PAGE_SIZE          if (page_table[i].bytes_used < GC_PAGE_SIZE
6076              /* Or it is PAGE_SIZE and is the last in the block */              /* Or it is GC_PAGE_SIZE and is the last in the block */
6077              || !PAGE_ALLOCATED(i + 1)              || !PAGE_ALLOCATED(i + 1)
6078              || page_table[i + 1].bytes_used == 0        /* Next page free */              || page_table[i + 1].bytes_used == 0        /* Next page free */
6079              || PAGE_GENERATION(i + 1) != from_space     /* Diff. gen */              || PAGE_GENERATION(i + 1) != from_space     /* Diff. gen */
# Line 6214  update_page_write_prot(unsigned page) Line 6214  update_page_write_prot(unsigned page)
6214          fprintf(stderr, "* WP page %d of gen %d\n", page, gen);          fprintf(stderr, "* WP page %d of gen %d\n", page, gen);
6215  #endif  #endif
6216    
6217          os_protect((os_vm_address_t) page_addr, PAGE_SIZE,          os_protect((os_vm_address_t) page_addr, GC_PAGE_SIZE,
6218                     OS_VM_PROT_READ | OS_VM_PROT_EXECUTE);                     OS_VM_PROT_READ | OS_VM_PROT_EXECUTE);
6219    
6220          /* Note the page as protected in the page tables */          /* Note the page as protected in the page tables */
# Line 6292  scavenge_generation(int generation) Line 6292  scavenge_generation(int generation)
6292               */               */
6293              for (last_page = i;; last_page++)              for (last_page = i;; last_page++)
6294                  /* Check if this is the last page in this contiguous block */                  /* Check if this is the last page in this contiguous block */
6295                  if (page_table[last_page].bytes_used < PAGE_SIZE                  if (page_table[last_page].bytes_used < GC_PAGE_SIZE
6296                      /* Or it is PAGE_SIZE and is the last in the block */                      /* Or it is GC_PAGE_SIZE and is the last in the block */
6297                      || !PAGE_ALLOCATED(last_page + 1)                      || !PAGE_ALLOCATED(last_page + 1)
6298                      || PAGE_UNBOXED(last_page + 1)                      || PAGE_UNBOXED(last_page + 1)
6299                      || page_table[last_page + 1].bytes_used == 0                      || page_table[last_page + 1].bytes_used == 0
# Line 6318  scavenge_generation(int generation) Line 6318  scavenge_generation(int generation)
6318  #endif  #endif
6319                  {                  {
6320                      scavenge(page_address(i), (page_table[last_page].bytes_used                      scavenge(page_address(i), (page_table[last_page].bytes_used
6321                                                 + PAGE_SIZE * (last_page -                                                 + GC_PAGE_SIZE * (last_page -
6322                                                                i)) /                                                                i)) /
6323                               sizeof(lispobj));                               sizeof(lispobj));
6324    
# Line 6425  scavenge_newspace_generation_one_scan(in Line 6425  scavenge_newspace_generation_one_scan(in
6425               */               */
6426              for (last_page = i;; last_page++)              for (last_page = i;; last_page++)
6427                  /* Check if this is the last page in this contiguous block */                  /* Check if this is the last page in this contiguous block */
6428                  if (page_table[last_page].bytes_used < PAGE_SIZE                  if (page_table[last_page].bytes_used < GC_PAGE_SIZE
6429                      /* Or it is PAGE_SIZE and is the last in the block */                      /* Or it is GC_PAGE_SIZE and is the last in the block */
6430                      || !PAGE_ALLOCATED(last_page + 1)                      || !PAGE_ALLOCATED(last_page + 1)
6431                      || PAGE_UNBOXED(last_page + 1)                      || PAGE_UNBOXED(last_page + 1)
6432                      || page_table[last_page + 1].bytes_used == 0                      || page_table[last_page + 1].bytes_used == 0
# Line 6462  scavenge_newspace_generation_one_scan(in Line 6462  scavenge_newspace_generation_one_scan(in
6462                      else                      else
6463                          size =                          size =
6464                              (page_table[last_page].bytes_used +                              (page_table[last_page].bytes_used +
6465                               PAGE_SIZE * (last_page - i) -                               GC_PAGE_SIZE * (last_page - i) -
6466                               page_table[i].first_object_offset) /                               page_table[i].first_object_offset) /
6467                              sizeof(lispobj);                              sizeof(lispobj);
6468    
# Line 6750  unprotect_oldspace(void) Line 6750  unprotect_oldspace(void)
6750               * WP flag to avoid redundant calls.               * WP flag to avoid redundant calls.
6751               */               */
6752              if (PAGE_WRITE_PROTECTED(i)) {              if (PAGE_WRITE_PROTECTED(i)) {
6753                  os_protect((os_vm_address_t) page_start, PAGE_SIZE,                  os_protect((os_vm_address_t) page_start, GC_PAGE_SIZE,
6754                             OS_VM_PROT_ALL);                             OS_VM_PROT_ALL);
6755                  page_table[i].flags &= ~PAGE_WRITE_PROTECTED_MASK;                  page_table[i].flags &= ~PAGE_WRITE_PROTECTED_MASK;
6756              }              }
# Line 6802  free_oldspace(void) Line 6802  free_oldspace(void)
6802                  void *page_start = (void *) page_address(last_page);                  void *page_start = (void *) page_address(last_page);
6803    
6804                  if (PAGE_WRITE_PROTECTED(last_page)) {                  if (PAGE_WRITE_PROTECTED(last_page)) {
6805                      os_protect((os_vm_address_t) page_start, PAGE_SIZE,                      os_protect((os_vm_address_t) page_start, GC_PAGE_SIZE,
6806                                 OS_VM_PROT_ALL);                                 OS_VM_PROT_ALL);
6807                      page_table[last_page].flags &= ~PAGE_WRITE_PROTECTED_MASK;                      page_table[last_page].flags &= ~PAGE_WRITE_PROTECTED_MASK;
6808                  }                  }
# Line 6820  free_oldspace(void) Line 6820  free_oldspace(void)
6820              page_start = page_address(first_page);              page_start = page_address(first_page);
6821    
6822              os_invalidate((os_vm_address_t) page_start,              os_invalidate((os_vm_address_t) page_start,
6823                            PAGE_SIZE * (last_page - first_page));                            GC_PAGE_SIZE * (last_page - first_page));
6824              addr =              addr =
6825                  (char *) os_validate((os_vm_address_t) page_start,                  (char *) os_validate((os_vm_address_t) page_start,
6826                                       PAGE_SIZE * (last_page - first_page));                                       GC_PAGE_SIZE * (last_page - first_page));
6827              if (addr == NULL || addr != page_start)              if (addr == NULL || addr != page_start)
6828                  fprintf(stderr, "gc_zero: page moved, 0x%08lx ==> 0x%08lx!\n",                  fprintf(stderr, "gc_zero: page moved, 0x%08lx ==> 0x%08lx!\n",
6829                          (unsigned long) page_start, (unsigned long) addr);                          (unsigned long) page_start, (unsigned long) addr);
# Line 6831  free_oldspace(void) Line 6831  free_oldspace(void)
6831              int *page_start;              int *page_start;
6832    
6833              page_start = (int *) page_address(first_page);              page_start = (int *) page_address(first_page);
6834              memset(page_start, 0, PAGE_SIZE * (last_page - first_page));              memset(page_start, 0, GC_PAGE_SIZE * (last_page - first_page));
6835          }          }
6836    
6837          first_page = last_page;          first_page = last_page;
# Line 7150  verify_generation(int generation) Line 7150  verify_generation(int generation)
7150               */               */
7151              for (last_page = i;; last_page++)              for (last_page = i;; last_page++)
7152                  /* Check if this is the last page in this contiguous block */                  /* Check if this is the last page in this contiguous block */
7153                  if (page_table[last_page].bytes_used < PAGE_SIZE                  if (page_table[last_page].bytes_used < GC_PAGE_SIZE
7154                      /* Or it is PAGE_SIZE and is the last in the block */                      /* Or it is GC_PAGE_SIZE and is the last in the block */
7155                      || !PAGE_ALLOCATED(last_page + 1)                      || !PAGE_ALLOCATED(last_page + 1)
7156                      || PAGE_UNBOXED(last_page + 1) != region_unboxed                      || PAGE_UNBOXED(last_page + 1) != region_unboxed
7157                      || page_table[last_page + 1].bytes_used == 0                      || page_table[last_page + 1].bytes_used == 0
# Line 7161  verify_generation(int generation) Line 7161  verify_generation(int generation)
7161    
7162              verify_space((lispobj *) page_address(i),              verify_space((lispobj *) page_address(i),
7163                           (page_table[last_page].bytes_used +                           (page_table[last_page].bytes_used +
7164                            PAGE_SIZE * (last_page - i)) / sizeof(lispobj));                            GC_PAGE_SIZE * (last_page - i)) / sizeof(lispobj));
7165              i = last_page;              i = last_page;
7166          }          }
7167      }      }
# Line 7185  verify_zero_fill(void) Line 7185  verify_zero_fill(void)
7185                      fprintf(stderr, "** free page not zero @ %lx\n",                      fprintf(stderr, "** free page not zero @ %lx\n",
7186                              (unsigned long) (start_addr + i));                              (unsigned long) (start_addr + i));
7187          } else {          } else {
7188              int free_bytes = PAGE_SIZE - page_table[page].bytes_used;              int free_bytes = GC_PAGE_SIZE - page_table[page].bytes_used;
7189    
7190              if (free_bytes > 0) {              if (free_bytes > 0) {
7191                  unsigned long *start_addr =                  unsigned long *start_addr =
# Line 7251  write_protect_generation_pages(int gener Line 7251  write_protect_generation_pages(int gener
7251    
7252              page_start = (void *) page_address(i);              page_start = (void *) page_address(i);
7253    
7254              os_protect((os_vm_address_t) page_start, PAGE_SIZE,              os_protect((os_vm_address_t) page_start, GC_PAGE_SIZE,
7255                         OS_VM_PROT_READ | OS_VM_PROT_EXECUTE);                         OS_VM_PROT_READ | OS_VM_PROT_EXECUTE);
7256    
7257              /* Note the page as protected in the page tables */              /* Note the page as protected in the page tables */
# Line 7396  garbage_collect_generation(int generatio Line 7396  garbage_collect_generation(int generatio
7396    
7397          fprintf(stderr,          fprintf(stderr,
7398                  "Non-movable pages due to conservative pointers = %d, %d bytes\n",                  "Non-movable pages due to conservative pointers = %d, %d bytes\n",
7399                  num_dont_move_pages, PAGE_SIZE * num_dont_move_pages);                  num_dont_move_pages, GC_PAGE_SIZE * num_dont_move_pages);
7400  #if !(defined(i386) || defined(__x86_64))  #if !(defined(i386) || defined(__x86_64))
7401          /*          /*
7402           * There shouldn't be any non-movable pages because we don't have           * There shouldn't be any non-movable pages because we don't have
# Line 7576  update_dynamic_space_free_pointer(void) Line 7576  update_dynamic_space_free_pointer(void)
7576      last_free_page = last_page + 1;      last_free_page = last_page + 1;
7577    
7578      set_alloc_pointer((lispobj)      set_alloc_pointer((lispobj)
7579                        ((char *) heap_base + PAGE_SIZE * last_free_page));                        ((char *) heap_base + GC_PAGE_SIZE * last_free_page));
7580  }  }
7581    
7582    
# Line 7770  gc_free_heap(void) Line 7770  gc_free_heap(void)
7770              page_start = (void *) page_address(page);              page_start = (void *) page_address(page);
7771    
7772              /* First remove any write protection */              /* First remove any write protection */
7773              os_protect((os_vm_address_t) page_start, PAGE_SIZE, OS_VM_PROT_ALL);              os_protect((os_vm_address_t) page_start, GC_PAGE_SIZE, OS_VM_PROT_ALL);
7774              page_table[page].flags &= ~PAGE_WRITE_PROTECTED_MASK;              page_table[page].flags &= ~PAGE_WRITE_PROTECTED_MASK;
7775    
7776              os_invalidate((os_vm_address_t) page_start, PAGE_SIZE);              os_invalidate((os_vm_address_t) page_start, GC_PAGE_SIZE);
7777              addr =              addr =
7778                  (char *) os_validate((os_vm_address_t) page_start, PAGE_SIZE);                  (char *) os_validate((os_vm_address_t) page_start, GC_PAGE_SIZE);
7779              if (addr == NULL || addr != page_start)              if (addr == NULL || addr != page_start)
7780                  fprintf(stderr, "gc_zero: page moved, 0x%08lx ==> 0x%08lx!\n",                  fprintf(stderr, "gc_zero: page moved, 0x%08lx ==> 0x%08lx!\n",
7781                          (unsigned long) page_start, (unsigned long) addr);                          (unsigned long) page_start, (unsigned long) addr);
# Line 7853  gc_init(void) Line 7853  gc_init(void)
7853      heap_base = (void *) DYNAMIC_0_SPACE_START;      heap_base = (void *) DYNAMIC_0_SPACE_START;
7854    
7855      /* The number of pages needed for the dynamic space - rounding up. */      /* The number of pages needed for the dynamic space - rounding up. */
7856      dynamic_space_pages = (dynamic_space_size + (PAGE_SIZE - 1)) / PAGE_SIZE;      dynamic_space_pages = (dynamic_space_size + (GC_PAGE_SIZE - 1)) / GC_PAGE_SIZE;
7857    
7858      page_table =      page_table =
7859          (struct page *) malloc(dynamic_space_pages * sizeof(struct page));          (struct page *) malloc(dynamic_space_pages * sizeof(struct page));
# Line 7932  gencgc_pickup_dynamic(void) Line 7932  gencgc_pickup_dynamic(void)
7932          page_table[page].flags |= PAGE_ALLOCATED_MASK;          page_table[page].flags |= PAGE_ALLOCATED_MASK;
7933          page_table[page].flags &= ~(PAGE_UNBOXED_MASK | PAGE_GENERATION_MASK          page_table[page].flags &= ~(PAGE_UNBOXED_MASK | PAGE_GENERATION_MASK
7934                                      | PAGE_LARGE_OBJECT_MASK);                                      | PAGE_LARGE_OBJECT_MASK);
7935          page_table[page].bytes_used = PAGE_SIZE;          page_table[page].bytes_used = GC_PAGE_SIZE;
7936          page_table[page].first_object_offset =          page_table[page].first_object_offset =
7937              (char *) DYNAMIC_0_SPACE_START - page_address(page);              (char *) DYNAMIC_0_SPACE_START - page_address(page);
7938          addr += PAGE_SIZE;          addr += GC_PAGE_SIZE;
7939          page++;          page++;
7940      }      }
7941      while (addr < alloc_ptr);      while (addr < alloc_ptr);
7942    
7943      generations[0].bytes_allocated = PAGE_SIZE * page;      generations[0].bytes_allocated = GC_PAGE_SIZE * page;
7944      bytes_allocated = PAGE_SIZE * page;      bytes_allocated = GC_PAGE_SIZE * page;
7945    
7946      set_current_region_free((lispobj) boxed_region.free_pointer);      set_current_region_free((lispobj) boxed_region.free_pointer);
7947      set_current_region_end((lispobj) boxed_region.end_addr);      set_current_region_end((lispobj) boxed_region.end_addr);

Legend:
Removed from v.1.110.6.5  
changed lines
  Added in v.1.112

  ViewVC Help
Powered by ViewVC 1.1.5