/[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.95.2.1 by rtoy, Wed May 14 16:12:06 2008 UTC revision 1.95.2.1.2.1 by rtoy, Sun Nov 2 13:30:03 2008 UTC
# Line 247  unsigned counters_verbose = 0; Line 247  unsigned counters_verbose = 0;
247   * To enable the use of page protection to help avoid the scavenging   * To enable the use of page protection to help avoid the scavenging
248   * of pages that don't have pointers to younger generations.   * of pages that don't have pointers to younger generations.
249   */   */
 #if defined(DARWIN) && defined(__i386__)  
 boolean enable_page_protection = FALSE;  
 #else  
250  boolean enable_page_protection = TRUE;  boolean enable_page_protection = TRUE;
 #endif  
251    
252  /*  /*
253   * Hunt for pointers to old-space, when GCing generations >= verify_gen.   * Hunt for pointers to old-space, when GCing generations >= verify_gen.
# Line 389  static char *heap_base = NULL; Line 385  static char *heap_base = NULL;
385  /*  /*
386   * Calculate the start address for the given page number.   * Calculate the start address for the given page number.
387   */   */
388  inline char *  static char *
389  page_address(int page_num)  page_address(int page_num)
390  {  {
391      return heap_base + PAGE_SIZE * page_num;      return heap_base + PAGE_SIZE * page_num;
# Line 399  page_address(int page_num) Line 395  page_address(int page_num)
395   * Find the page index within the page_table for the given address.   * Find the page index within the page_table for the given address.
396   * Returns -1 on failure.   * Returns -1 on failure.
397   */   */
398  inline int  int
399  find_page_index(void *addr)  find_page_index(void *addr)
400  {  {
401      int index = (char *) addr - heap_base;      int index = (char *) addr - heap_base;
# Line 413  find_page_index(void *addr) Line 409  find_page_index(void *addr)
409      return -1;      return -1;
410  }  }
411    
412    /*
413     * This routine implements a write barrier used to record stores into
414     * to boxed regions outside of generation 0.  When such a store occurs
415     * this routine will be automatically invoked by the page fault
416     * handler.  If passed an address outside of the dynamic space, this
417     * routine will return immediately with a value of 0.  Otherwise, the
418     * page belonging to the address is made writable, the protection
419     * change is recorded in the garbage collector page table, and a value
420     * of 1 is returned.
421     */
422    int
423    gc_write_barrier(void *addr)
424    {
425        int page_index = find_page_index(addr);
426    
427        /* Check if the fault is within the dynamic space. */
428        if (page_index == -1) {
429             return 0;
430        }
431    
432        /* The page should have been marked write protected */
433        if (!PAGE_WRITE_PROTECTED(page_index))
434             fprintf(stderr,
435                     "*** Page fault in page not marked as write protected\n");
436    
437        /* Un-protect the page */
438        os_protect(page_address(page_index), PAGE_SIZE, OS_VM_PROT_ALL);
439        page_table[page_index].flags &= ~PAGE_WRITE_PROTECTED_MASK;
440        page_table[page_index].flags |= PAGE_WRITE_PROTECT_CLEARED_MASK;
441    
442        return 1;
443    }
444    
445  /*  /*
446   * A structure to hold the state of a generation.   * A structure to hold the state of a generation.

Legend:
Removed from v.1.95.2.1  
changed lines
  Added in v.1.95.2.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.5