[BACK]Return to allchblk.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / gc

Diff for /OpenXM_contrib2/asir2000/gc/allchblk.c between version 1.2 and 1.3

version 1.2, 2000/04/10 08:31:30 version 1.3, 2000/12/01 09:26:10
Line 19 
Line 19 
 #include <stdio.h>  #include <stdio.h>
 #include "gc_priv.h"  #include "gc_priv.h"
   
   GC_bool GC_use_entire_heap = 0;
   
 /*  /*
  * Free heap blocks are kept on one of several free lists,   * Free heap blocks are kept on one of several free lists,
Line 229  int n;
Line 230  int n;
         GC_ASSERT(HDR(GC_hblkfreelist[index]) == hhdr);          GC_ASSERT(HDR(GC_hblkfreelist[index]) == hhdr);
         GC_hblkfreelist[index] = hhdr -> hb_next;          GC_hblkfreelist[index] = hhdr -> hb_next;
     } else {      } else {
         PHDR(hhdr) -> hb_next = hhdr -> hb_next;          hdr *phdr;
           GET_HDR(hhdr -> hb_prev, phdr);
           phdr -> hb_next = hhdr -> hb_next;
     }      }
     if (0 != hhdr -> hb_next) {      if (0 != hhdr -> hb_next) {
           hdr * nhdr;
         GC_ASSERT(!IS_FORWARDING_ADDR_OR_NIL(NHDR(hhdr)));          GC_ASSERT(!IS_FORWARDING_ADDR_OR_NIL(NHDR(hhdr)));
         NHDR(hhdr) -> hb_prev = hhdr -> hb_prev;          GET_HDR(hhdr -> hb_next, nhdr);
           nhdr -> hb_prev = hhdr -> hb_prev;
     }      }
 }  }
   
Line 244  struct hblk * GC_free_block_ending_at(h)
Line 249  struct hblk * GC_free_block_ending_at(h)
 struct hblk *h;  struct hblk *h;
 {  {
     struct hblk * p = h - 1;      struct hblk * p = h - 1;
     hdr * phdr = HDR(p);      hdr * phdr;
   
       GET_HDR(p, phdr);
     while (0 != phdr && IS_FORWARDING_ADDR_OR_NIL(phdr)) {      while (0 != phdr && IS_FORWARDING_ADDR_OR_NIL(phdr)) {
         p = FORWARDED_ADDR(p,phdr);          p = FORWARDED_ADDR(p,phdr);
         phdr = HDR(p);          phdr = HDR(p);
     }      }
     if (0 != phdr && HBLK_IS_FREE(phdr)) return p;      if (0 != phdr) {
           if(HBLK_IS_FREE(phdr)) {
               return p;
           } else {
               return 0;
           }
       }
     p = GC_prev_block(h - 1);      p = GC_prev_block(h - 1);
     if (0 != p) {      if (0 != p) {
       phdr = HDR(p);        phdr = HDR(p);
Line 271  hdr * hhdr;
Line 283  hdr * hhdr;
 {  {
     int index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));      int index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));
     struct hblk *second = GC_hblkfreelist[index];      struct hblk *second = GC_hblkfreelist[index];
       hdr * second_hdr;
 #   ifdef GC_ASSERTIONS  #   ifdef GC_ASSERTIONS
       struct hblk *next = (struct hblk *)((word)h + hhdr -> hb_sz);        struct hblk *next = (struct hblk *)((word)h + hhdr -> hb_sz);
       hdr * nexthdr = HDR(next);        hdr * nexthdr = HDR(next);
Line 283  hdr * hhdr;
Line 296  hdr * hhdr;
     GC_hblkfreelist[index] = h;      GC_hblkfreelist[index] = h;
     hhdr -> hb_next = second;      hhdr -> hb_next = second;
     hhdr -> hb_prev = 0;      hhdr -> hb_prev = 0;
     if (0 != second) HDR(second) -> hb_prev = h;      if (0 != second) {
         GET_HDR(second, second_hdr);
         second_hdr -> hb_prev = h;
       }
     GC_invalidate_map(hhdr);      GC_invalidate_map(hhdr);
 }  }
   
Line 330  void GC_merge_unmapped(void)
Line 346  void GC_merge_unmapped(void)
     for (i = 0; i <= N_HBLK_FLS; ++i) {      for (i = 0; i <= N_HBLK_FLS; ++i) {
       h = GC_hblkfreelist[i];        h = GC_hblkfreelist[i];
       while (h != 0) {        while (h != 0) {
         hhdr = HDR(h);          GET_HDR(h, hhdr);
         size = hhdr->hb_sz;          size = hhdr->hb_sz;
         next = (struct hblk *)((word)h + size);          next = (struct hblk *)((word)h + size);
         nexthdr = HDR(next);          GET_HDR(next, nexthdr);
         /* Coalesce with successor, if possible */          /* Coalesce with successor, if possible */
           if (0 != nexthdr && HBLK_IS_FREE(nexthdr)) {            if (0 != nexthdr && HBLK_IS_FREE(nexthdr)) {
             nextsize = nexthdr -> hb_sz;              nextsize = nexthdr -> hb_sz;
Line 398  int index;
Line 414  int index;
     GC_remove_from_fl(hhdr, index);      GC_remove_from_fl(hhdr, index);
     if (total_size == bytes) return h;      if (total_size == bytes) return h;
     rest = (struct hblk *)((word)h + bytes);      rest = (struct hblk *)((word)h + bytes);
     if (!GC_install_header(rest)) return(0);      rest_hdr = GC_install_header(rest);
     rest_hdr = HDR(rest);      if (0 == rest_hdr) return(0);
     rest_hdr -> hb_sz = total_size - bytes;      rest_hdr -> hb_sz = total_size - bytes;
     rest_hdr -> hb_flags = 0;      rest_hdr -> hb_flags = 0;
 #   ifdef GC_ASSERTIONS  #   ifdef GC_ASSERTIONS
Line 506  int n;
Line 522  int n;
   
     /* search for a big enough block in free list */      /* search for a big enough block in free list */
         hbp = GC_hblkfreelist[n];          hbp = GC_hblkfreelist[n];
         hhdr = HDR(hbp);          for(; 0 != hbp; hbp = hhdr -> hb_next) {
         for(; 0 != hbp; hbp = hhdr -> hb_next, hhdr = HDR(hbp)) {              GET_HDR(hbp, hhdr);
             size_avail = hhdr->hb_sz;              size_avail = hhdr->hb_sz;
             if (size_avail < size_needed) continue;              if (size_avail < size_needed) continue;
 #           ifdef PRESERVE_LAST              if (!GC_use_entire_heap) {
                 if (size_avail != size_needed                  if (size_avail != size_needed
                       && USED_HEAP_SIZE >= GC_requested_heapsize
                     && !GC_incremental && GC_should_collect()) {                      && !GC_incremental && GC_should_collect()) {
                     continue;                      continue;
                 }                  }
 #           endif              }
             /* If the next heap block is obviously better, go on.       */              /* If the next heap block is obviously better, go on.       */
             /* This prevents us from disassembling a single large block */              /* This prevents us from disassembling a single large block */
             /* to get tiny blocks.                                      */              /* to get tiny blocks.                                      */
Line 524  int n;
Line 541  int n;
   
               thishbp = hhdr -> hb_next;                thishbp = hhdr -> hb_next;
               if (thishbp != 0) {                if (thishbp != 0) {
                 thishdr = HDR(thishbp);                  GET_HDR(thishbp, thishdr);
                 next_size = (signed_word)(thishdr -> hb_sz);                  next_size = (signed_word)(thishdr -> hb_sz);
                 if (next_size < size_avail                  if (next_size < size_avail
                   && next_size >= size_needed                    && next_size >= size_needed
Line 551  int n;
Line 568  int n;
               size_avail -= (ptr_t)lasthbp - (ptr_t)hbp;                size_avail -= (ptr_t)lasthbp - (ptr_t)hbp;
               thishbp = lasthbp;                thishbp = lasthbp;
               if (size_avail >= size_needed) {                if (size_avail >= size_needed) {
                 if (thishbp != hbp && GC_install_header(thishbp)) {                  if (thishbp != hbp &&
                       0 != (thishdr = GC_install_header(thishbp))) {
                   /* Make sure it's mapped before we mangle it. */                    /* Make sure it's mapped before we mangle it. */
 #                   ifdef USE_MUNMAP  #                   ifdef USE_MUNMAP
                       if (!IS_MAPPED(hhdr)) {                        if (!IS_MAPPED(hhdr)) {
                         GC_remap((ptr_t)hbp, size_avail);                          GC_remap((ptr_t)hbp, hhdr -> hb_sz);
                         hhdr -> hb_flags &= ~WAS_UNMAPPED;                          hhdr -> hb_flags &= ~WAS_UNMAPPED;
                       }                        }
 #                   endif  #                   endif
                   /* Split the block at thishbp */                    /* Split the block at thishbp */
                       thishdr = HDR(thishbp);  
                       GC_split_block(hbp, hhdr, thishbp, thishdr, n);                        GC_split_block(hbp, hhdr, thishbp, thishdr, n);
                   /* Advance to thishbp */                    /* Advance to thishbp */
                       hbp = thishbp;                        hbp = thishbp;
Line 598  int n;
Line 615  int n;
                       GC_large_free_bytes -= total_size;                        GC_large_free_bytes -= total_size;
                       GC_remove_from_fl(hhdr, n);                        GC_remove_from_fl(hhdr, n);
                       for (h = hbp; h < limit; h++) {                        for (h = hbp; h < limit; h++) {
                         if (h == hbp || GC_install_header(h)) {                          if (h == hbp || 0 != (hhdr = GC_install_header(h))) {
                           hhdr = HDR(h);  
                           (void) setup_header(                            (void) setup_header(
                                   hhdr,                                    hhdr,
                                   BYTES_TO_WORDS(HBLKSIZE - HDR_BYTES),                                    BYTES_TO_WORDS(HBLKSIZE - HDR_BYTES),
Line 622  int n;
Line 638  int n;
             if( size_avail >= size_needed ) {              if( size_avail >= size_needed ) {
 #               ifdef USE_MUNMAP  #               ifdef USE_MUNMAP
                   if (!IS_MAPPED(hhdr)) {                    if (!IS_MAPPED(hhdr)) {
                     GC_remap((ptr_t)hbp, size_avail);                      GC_remap((ptr_t)hbp, hhdr -> hb_sz);
                     hhdr -> hb_flags &= ~WAS_UNMAPPED;                      hhdr -> hb_flags &= ~WAS_UNMAPPED;
                   }                    }
 #               endif  #               endif
Line 686  hdr *hhdr, *prevhdr, *nexthdr;
Line 702  hdr *hhdr, *prevhdr, *nexthdr;
 signed_word size;  signed_word size;
   
   
     hhdr = HDR(hbp);      GET_HDR(hbp, hhdr);
     size = hhdr->hb_sz;      size = hhdr->hb_sz;
     size = HBLKSIZE * OBJ_SZ_TO_BLOCKS(size);      size = HBLKSIZE * OBJ_SZ_TO_BLOCKS(size);
     GC_remove_counts(hbp, (word)size);      GC_remove_counts(hbp, (word)size);
Line 701  signed_word size;
Line 717  signed_word size;
     GC_ASSERT(IS_MAPPED(hhdr));      GC_ASSERT(IS_MAPPED(hhdr));
     GC_invalidate_map(hhdr);      GC_invalidate_map(hhdr);
     next = (struct hblk *)((word)hbp + size);      next = (struct hblk *)((word)hbp + size);
     nexthdr = HDR(next);      GET_HDR(next, nexthdr);
     prev = GC_free_block_ending_at(hbp);      prev = GC_free_block_ending_at(hbp);
     /* Coalesce with successor, if possible */      /* Coalesce with successor, if possible */
       if(0 != nexthdr && HBLK_IS_FREE(nexthdr) && IS_MAPPED(nexthdr)) {        if(0 != nexthdr && HBLK_IS_FREE(nexthdr) && IS_MAPPED(nexthdr)) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>