/[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.96 by rtoy, Thu Sep 11 00:15:28 2008 UTC revision 1.97 by cshapiro, Tue Sep 16 08:52:31 2008 UTC
# Line 385  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 395  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 409  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.96  
changed lines
  Added in v.1.97

  ViewVC Help
Powered by ViewVC 1.1.5