Changeset 8478


Ignore:
Timestamp:
Feb 13, 2008, 2:11:50 PM (12 years ago)
Author:
gz
Message:

update to trunk r8477

Location:
branches/gz-working/lisp-kernel
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/gz-working/lisp-kernel/gc-common.c

    r8420 r8478  
    815815forward_gcable_ptrs()
    816816{
    817   LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next;
     817  LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next, new;
    818818
    819819  while ((next = *prev) != (LispObj)NULL) {
    820     *prev = node_forwarding_address(next);
     820    new = node_forwarding_address(next);
     821    if (new != next) {
     822      *prev = new;
     823    }
    821824    prev = &(((xmacptr *)ptr_from_lispobj(untag(next)))->link);
    822825  }
  • branches/gz-working/lisp-kernel/gc.h

    r8408 r8478  
    214214void forward_cstack_area(area *);
    215215LispObj compact_dynamic_heap(void);
    216 LispObj * skip_over_ivector(natural, LispObj);
    217216int purify(TCR *, signed_natural);
    218217int impurify(TCR *, signed_natural);
  • branches/gz-working/lisp-kernel/lisp.h

    r8387 r8478  
    4747#define align_to_power_of_2(n,p) _align_to_power_of_2(((natural)(n)),p)
    4848
    49 static inline unsigned long
    50 _truncate_to_power_of_2(unsigned long n, unsigned power)
     49static inline natural
     50_truncate_to_power_of_2(natural n, unsigned power)
    5151{
    5252  return n & ~((1<<power) -1);
    5353}
    5454
    55 #define truncate_to_power_of_2(n,p) _truncate_to_power_of_2((unsigned long)(n),p)
     55#define truncate_to_power_of_2(n,p) _truncate_to_power_of_2((natural)(n),p)
    5656
    5757LispObj start_lisp(TCR*, LispObj);
  • branches/gz-working/lisp-kernel/memory.c

    r8408 r8478  
    616616}
    617617
     618void
     619release_readonly_area()
     620{
     621  area *a = readonly_area;
     622  munmap(a->low,align_to_power_of_2(a->active-a->low, log2_page_size));
     623  a->active = a->low;
     624  a->ndnodes = 0;
     625  pure_space_active = pure_space_start;
     626}
  • branches/gz-working/lisp-kernel/ppc-spentry.s

    r7624 r8478  
    947947/* because nargs < 32K.  */
    948948_spentry(gvector)
     949        __(subi nargs,nargs,node_size)
    949950        __(ldrx(arg_z,vsp,nargs))
    950951        __(unbox_fixnum(imm0,arg_z))
  • branches/gz-working/lisp-kernel/x86-exceptions.c

    r8465 r8478  
    157157  area *a = active_dynamic_area;
    158158  Boolean egc_was_enabled = (a->older != NULL);
     159 
    159160  natural gc_previously_deferred = gc_deferred;
    160161
     
    219220      full_gc_deferred = 0;
    220221    }
    221     if (selector & GC_TRAP_FUNCTION_PURIFY) {
    222       purify_from_xp(xp, 0L);
    223       gc_from_xp(xp, 0L);
    224     }
    225     if (selector & GC_TRAP_FUNCTION_SAVE_APPLICATION) {
    226       OSErr err;
    227       extern OSErr save_application(unsigned);
    228       area *vsarea = tcr->vs_area;
     222    if (selector > GC_TRAP_FUNCTION_GC) {
     223      if (selector & GC_TRAP_FUNCTION_IMPURIFY) {
     224        impurify_from_xp(xp, 0L);
     225        /*        nrs_GC_EVENT_STATUS_BITS.vcell |= gc_integrity_check_bit; */
     226        gc_from_xp(xp, 0L);
     227        release_readonly_area();
     228      }
     229      if (selector & GC_TRAP_FUNCTION_PURIFY) {
     230        purify_from_xp(xp, 0L);
     231        gc_from_xp(xp, 0L);
     232      }
     233      if (selector & GC_TRAP_FUNCTION_SAVE_APPLICATION) {
     234        OSErr err;
     235        extern OSErr save_application(unsigned);
     236        area *vsarea = tcr->vs_area;
    229237       
    230       nrs_TOPLFUNC.vcell = *((LispObj *)(vsarea->high)-1);
    231       err = save_application(arg);
    232       if (err == noErr) {
    233         _exit(0);
     238        nrs_TOPLFUNC.vcell = *((LispObj *)(vsarea->high)-1);
     239        err = save_application(arg);
     240        if (err == noErr) {
     241          _exit(0);
     242        }
     243        fatal_oserr(": save_application", err);
    234244      }
    235       fatal_oserr(": save_application", err);
    236     }
    237     switch (selector) {
    238     case GC_TRAP_FUNCTION_SET_HONS_AREA_SIZE:
    239       xpGPR(xp, Iimm0) = 0;
    240       break;
    241     case GC_TRAP_FUNCTION_FREEZE:
    242       a->active = (BytePtr) align_to_power_of_2(a->active, log2_page_size);
    243       tenured_area->static_dnodes = area_dnode(a->active, a->low);
    244       xpGPR(xp, Iimm0) = tenured_area->static_dnodes << dnode_shift;
    245       break;
    246     default:
    247       break;
     245      switch (selector) {
     246      case GC_TRAP_FUNCTION_SET_HONS_AREA_SIZE:
     247        xpGPR(xp, Iimm0) = 0;
     248        break;
     249      case GC_TRAP_FUNCTION_FREEZE:
     250        a->active = (BytePtr) align_to_power_of_2(a->active, log2_page_size);
     251        tenured_area->static_dnodes = area_dnode(a->active, a->low);
     252        xpGPR(xp, Iimm0) = tenured_area->static_dnodes << dnode_shift;
     253        break;
     254      default:
     255        break;
     256      }
    248257    }
    249258    if (egc_was_enabled) {
     
    638647      handler = protection_handlers[a->why];
    639648      return handler(xp, a, addr);
     649    } else {
     650      if ((addr >= readonly_area->low) &&
     651          (addr < readonly_area->active)) {
     652        UnProtectMemory((LogicalAddress)(truncate_to_power_of_2(addr,log2_page_size)),
     653                        page_size);
     654        return true;
     655      }
    640656    }
    641657  }
  • branches/gz-working/lisp-kernel/x86-gc.c

    r8369 r8478  
    16561656    new;
    16571657  natural
    1658     subtag = header_subtag(header),
    1659     element_count = header_element_count(header),
     1658    start = (natural)old,
    16601659    physbytes;
    16611660
    1662   switch(subtag) {
    1663   case subtag_simple_base_string:
    1664     physbytes = node_size + (element_count << 2);
    1665     break;
    1666 
    1667 #ifndef X86
    1668   case subtag_code_vector:
    1669     physbytes = node_size + (element_count << 2);
    1670     break;
    1671 #endif
    1672 
    1673   default:
    1674     Bug(NULL, "Can't purify object at 0x%08x", obj);
    1675     return obj;
    1676   }
    1677   physbytes = (physbytes+(dnode_size-1))&~(dnode_size-1);
     1661  physbytes = ((natural)(skip_over_ivector(start,header))) - start;
     1662
    16781663  dest->active += physbytes;
    16791664
     
    17061691
    17071692
    1708 #define FORWARD_ONLY 0
    1709 #define COPY_CODE (1<<0)
    1710 #define COPY_STRINGS (1<<1)
    17111693
    17121694
     
    17631745
    17641746Boolean
    1765 copy_ivector_reference(LispObj *ref, BytePtr low, BytePtr high, area *dest, int what_to_copy)
     1747copy_ivector_reference(LispObj *ref, BytePtr low, BytePtr high, area *dest)
    17661748{
    17671749  LispObj obj = *ref, header, new;
     
    17791761      header_tag = fulltag_of(header);
    17801762      if (immheader_tag_p(header_tag)) {
    1781         header_subtag = header_subtag(header);
    1782         if ((what_to_copy & COPY_STRINGS) &&
    1783             ((header_subtag == subtag_simple_base_string))) {
    1784           new = purify_object(obj, dest);
    1785           *ref = new;
    1786           changed = (new != obj);
    1787         }
     1763        new = purify_object(obj, dest);
     1764        *ref = new;
     1765        changed = (new != obj);
    17881766      }
    17891767    }
     
    17931771
    17941772
    1795 void purify_headerless_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to, int what)
     1773void
     1774purify_gcable_ptrs(BytePtr low, BytePtr high, area *to)
     1775{
     1776  LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next;
     1777
     1778  while ((*prev) != (LispObj)NULL) {
     1779    copy_ivector_reference(prev, low, high, to);
     1780    next = *prev;
     1781    prev = &(((xmacptr *)ptr_from_lispobj(untag(next)))->link);
     1782  }
     1783}
     1784
     1785void
     1786purify_headerless_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to)
    17961787{
    17971788  while (start < end) {
    1798     copy_ivector_reference(start, low, high, to, what);
     1789    copy_ivector_reference(start, low, high, to);
    17991790    start++;
    18001791  }
     
    18021793   
    18031794void
    1804 purify_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to, int what)
     1795purify_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to)
    18051796{
    18061797  LispObj header;
     
    18291820          nwords -= skip;
    18301821          while(skip--) {
    1831             copy_ivector_reference(start, low, high, to, what);
     1822            copy_ivector_reference(start, low, high, to);
    18321823            start++;
    18331824          }
     
    18381829          nwords >>= 1;
    18391830          while(nwords--) {
    1840             if (copy_ivector_reference(start, low, high, to, what) && hashp) {
     1831            if (copy_ivector_reference(start, low, high, to) && hashp) {
    18411832              hashp->flags |= nhash_key_moved_mask;
    18421833              hashp = NULL;
    18431834            }
    18441835            start++;
    1845             copy_ivector_reference(start, low, high, to, what);
     1836            copy_ivector_reference(start, low, high, to);
    18461837            start++;
    18471838          }
     
    18551846          start++;
    18561847          while(nwords--) {
    1857             copy_ivector_reference(start, low, high, to, what);
     1848            copy_ivector_reference(start, low, high, to);
    18581849            start++;
    18591850          }
     
    18611852      } else {
    18621853        /* Not a header, just a cons cell */
    1863         copy_ivector_reference(start, low, high, to, what);
     1854        copy_ivector_reference(start, low, high, to);
    18641855        start++;
    1865         copy_ivector_reference(start, low, high, to, what);
     1856        copy_ivector_reference(start, low, high, to);
    18661857        start++;
    18671858      }
     
    18721863/* Purify references from tstack areas */
    18731864void
    1874 purify_tstack_area(area *a, BytePtr low, BytePtr high, area *to, int what)
     1865purify_tstack_area(area *a, BytePtr low, BytePtr high, area *to)
    18751866{
    18761867  LispObj
     
    18861877    next = (LispObj *) ptr_from_lispobj(*current);
    18871878    end = ((next >= start) && (next < limit)) ? next : limit;
    1888     if (current[1] == 0) {
    1889       purify_range(current+2, end, low, high, to, what);
    1890     }
     1879    purify_range(current+2, end, low, high, to);
    18911880  }
    18921881}
     
    18941883/* Purify a vstack area */
    18951884void
    1896 purify_vstack_area(area *a, BytePtr low, BytePtr high, area *to, int what)
     1885purify_vstack_area(area *a, BytePtr low, BytePtr high, area *to)
    18971886{
    18981887  LispObj
     
    19001889    *q = (LispObj *) a->high;
    19011890 
    1902   purify_headerless_range(p, q, low, high, to, what);
    1903 }
    1904 
    1905 
    1906 void
    1907 purify_xp(ExceptionInformation *xp, BytePtr low, BytePtr high, area *to, int what)
     1891  purify_headerless_range(p, q, low, high, to);
     1892}
     1893
     1894
     1895void
     1896purify_xp(ExceptionInformation *xp, BytePtr low, BytePtr high, area *to)
    19081897{
    19091898  natural *regs = (natural *) xpGPRvector(xp);
     
    19111900
    19121901#ifdef X8664
    1913   copy_ivector_reference(&(regs[Iarg_z]), low, high, to, what);
    1914   copy_ivector_reference(&(regs[Iarg_y]), low, high, to, what);
    1915   copy_ivector_reference(&(regs[Iarg_x]), low, high, to, what);
    1916   copy_ivector_reference(&(regs[Isave3]), low, high, to, what);
    1917   copy_ivector_reference(&(regs[Isave2]), low, high, to, what);
    1918   copy_ivector_reference(&(regs[Isave1]), low, high, to, what);
    1919   copy_ivector_reference(&(regs[Isave0]), low, high, to, what);
    1920   copy_ivector_reference(&(regs[Ifn]), low, high, to, what);
    1921   copy_ivector_reference(&(regs[Itemp0]), low, high, to, what);
    1922   copy_ivector_reference(&(regs[Itemp1]), low, high, to, what);
    1923   copy_ivector_reference(&(regs[Itemp2]), low, high, to, what);
     1902  copy_ivector_reference(&(regs[Iarg_z]), low, high, to);
     1903  copy_ivector_reference(&(regs[Iarg_y]), low, high, to);
     1904  copy_ivector_reference(&(regs[Iarg_x]), low, high, to);
     1905  copy_ivector_reference(&(regs[Isave3]), low, high, to);
     1906  copy_ivector_reference(&(regs[Isave2]), low, high, to);
     1907  copy_ivector_reference(&(regs[Isave1]), low, high, to);
     1908  copy_ivector_reference(&(regs[Isave0]), low, high, to);
     1909  copy_ivector_reference(&(regs[Ifn]), low, high, to);
     1910  copy_ivector_reference(&(regs[Itemp0]), low, high, to);
     1911  copy_ivector_reference(&(regs[Itemp1]), low, high, to);
     1912  copy_ivector_reference(&(regs[Itemp2]), low, high, to);
    19241913#if 0
    1925   purify_locref(&(regs[Iip]), low, high, to, what);
     1914  purify_locref(&(regs[Iip]), low, high, to);
    19261915#endif
    19271916#else
     
    19301919
    19311920void
    1932 purify_tcr_tlb(TCR *tcr, BytePtr low, BytePtr high, area *to, int what)
     1921purify_tcr_tlb(TCR *tcr, BytePtr low, BytePtr high, area *to)
    19331922{
    19341923  natural n = tcr->tlb_limit;
    19351924  LispObj *start = tcr->tlb_pointer, *end = (LispObj *) ((BytePtr)start+n);
    19361925
    1937   purify_range(start, end, low, high, to, what);
    1938 }
    1939 
    1940 void
    1941 purify_tcr_xframes(TCR *tcr, BytePtr low, BytePtr high, area *to, int what)
     1926  purify_range(start, end, low, high, to);
     1927}
     1928
     1929void
     1930purify_tcr_xframes(TCR *tcr, BytePtr low, BytePtr high, area *to)
    19421931{
    19431932  xframe_list *xframes;
     
    19461935  xp = tcr->gc_context;
    19471936  if (xp) {
    1948     purify_xp(xp, low, high, to, what);
     1937    purify_xp(xp, low, high, to);
    19491938  }
    19501939
    19511940  for (xframes = tcr->xframe; xframes; xframes = xframes->prev) {
    1952     purify_xp(xframes->curr, low, high, to, what);
    1953   }
    1954 }
    1955 
    1956 
    1957 void
    1958 purify_areas(BytePtr low, BytePtr high, area *target, int what)
     1941    purify_xp(xframes->curr, low, high, to);
     1942  }
     1943}
     1944
     1945
     1946void
     1947purify_areas(BytePtr low, BytePtr high, area *target)
    19591948{
    19601949  area *next_area;
     
    19641953    switch (code) {
    19651954    case AREA_TSTACK:
    1966       purify_tstack_area(next_area, low, high, target, what);
     1955      purify_tstack_area(next_area, low, high, target);
    19671956      break;
    19681957     
    19691958    case AREA_VSTACK:
    1970       purify_vstack_area(next_area, low, high, target, what);
     1959      purify_vstack_area(next_area, low, high, target);
    19711960      break;
    19721961     
    19731962    case AREA_CSTACK:
    1974 #ifdef PPC
    1975       purify_cstack_area(next_area, low, high, target, what);
    1976 #endif
    19771963      break;
    19781964     
    19791965    case AREA_STATIC:
    19801966    case AREA_DYNAMIC:
    1981       purify_range((LispObj *) next_area->low, (LispObj *) next_area->active, low, high, target, what);
     1967      purify_range((LispObj *) next_area->low, (LispObj *) next_area->active, low, high, target);
    19821968      break;
    19831969     
     
    20111997
    20121998
    2013   max_pure_size = interned_pname_bytes_in_range((LispObj *)(a->low + (static_dnodes_for_area(a) << dnode_shift)),
     1999  max_pure_size = unboxed_bytes_in_range((LispObj *)(a->low + (static_dnodes_for_area(a) << dnode_shift)),
    20142000                                         (LispObj *) a->active);
    20152001  new_pure_area = extend_readonly_area(max_pure_size);
     
    20192005
    20202006    /*
    2021       First, loop thru *all-packages* and purify the pnames of all
    2022       interned symbols.  Then walk every place that could reference
    2023       a heap-allocated object (all_areas, the xframe_list) and
    2024       purify code_vectors (and update the odd case of a shared
    2025       reference to a pname.)
     2007
    20262008       
    20272009      Make the new_pure_area executable, just in case.
     
    20312013      */
    20322014
    2033     {
    2034       lispsymbol *rawsym = (lispsymbol *)(&(nrs_ALL_PACKAGES));
    2035       LispObj pkg_list = rawsym->vcell, htab, obj;
    2036       package *p;
    2037       cons *c;
    2038       natural elements, i;
    2039 
    2040       while (fulltag_of(pkg_list) == fulltag_cons) {
    2041         c = (cons *) ptr_from_lispobj(untag(pkg_list));
    2042         p = (package *) ptr_from_lispobj(untag(c->car));
    2043         pkg_list = c->cdr;
    2044         c = (cons *) ptr_from_lispobj(untag(p->itab));
    2045         htab = c->car;
    2046         elements = header_element_count(header_of(htab));
    2047         for (i = 1; i<= elements; i++) {
    2048           obj = deref(htab,i);
    2049           if (fulltag_of(obj) == fulltag_symbol) {
    2050             rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
    2051             copy_ivector_reference(&(rawsym->pname), a->low, a->active, new_pure_area, COPY_STRINGS);
    2052           }
    2053         }
    2054         c = (cons *) ptr_from_lispobj(untag(p->etab));
    2055         htab = c->car;
    2056         elements = header_element_count(header_of(htab));
    2057         for (i = 1; i<= elements; i++) {
    2058           obj = deref(htab,i);
    2059           if (fulltag_of(obj) == fulltag_symbol) {
    2060             rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
    2061             copy_ivector_reference(&(rawsym->pname), a->low, a->active, new_pure_area, COPY_STRINGS);
    2062           }
    2063         }
    2064       }
    2065     }
     2015
    20662016   
    2067     purify_areas(a->low, a->active, new_pure_area, FORWARD_ONLY);
     2017    purify_areas(a->low, a->active, new_pure_area);
    20682018   
    20692019    other_tcr = tcr;
    20702020    do {
    2071       purify_tcr_xframes(other_tcr, a->low, a->active, new_pure_area, FORWARD_ONLY);
    2072       purify_tcr_tlb(other_tcr, a->low, a->active, new_pure_area, FORWARD_ONLY);
     2021      purify_tcr_xframes(other_tcr, a->low, a->active, new_pure_area);
     2022      purify_tcr_tlb(other_tcr, a->low, a->active, new_pure_area);
    20732023      other_tcr = other_tcr->next;
    20742024    } while (other_tcr != tcr);
    20752025
    2076 
     2026    purify_gcable_ptrs(a->low, a->active, new_pure_area);
    20772027    {
    20782028      natural puresize = (unsigned) (new_pure_area->active-new_pure_start);
     
    21092059 
    21102060
    2111 
    2112 void
    2113 impurify_xp(ExceptionInformation *xp, LispObj low, LispObj high, int delta)
     2061void
     2062impurify_gcable_ptrs(LispObj low, LispObj high, signed_natural delta)
     2063{
     2064  LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next;
     2065
     2066  while ((*prev) != (LispObj)NULL) {
     2067    impurify_noderef(prev, low, high, delta);
     2068    next = *prev;
     2069    prev = &(((xmacptr *)ptr_from_lispobj(untag(next)))->link);
     2070  }
     2071}
     2072
     2073
     2074void
     2075impurify_xp(ExceptionInformation *xp, LispObj low, LispObj high, signed_natural delta)
    21142076{
    21152077  natural *regs = (natural *) xpGPRvector(xp);
     
    21362098
    21372099void
    2138 impurify_headerless_range(LispObj *start, LispObj *end, LispObj low, LispObj high, int delta)
     2100impurify_headerless_range(LispObj *start, LispObj *end, LispObj low, LispObj high, signed_natural delta)
    21392101{
    21402102  while (start < end) {
     
    21462108
    21472109void
    2148 impurify_range(LispObj *start, LispObj *end, LispObj low, LispObj high, int delta)
     2110impurify_range(LispObj *start, LispObj *end, LispObj low, LispObj high, signed_natural delta)
    21492111{
    21502112  LispObj header;
     
    22182180
    22192181void
    2220 impurify_tcr_tlb(TCR *tcr,  LispObj low, LispObj high, int delta)
     2182impurify_tcr_tlb(TCR *tcr,  LispObj low, LispObj high, signed_natural delta)
    22212183{
    22222184  unsigned n = tcr->tlb_limit;
     
    22272189
    22282190void
    2229 impurify_tcr_xframes(TCR *tcr, LispObj low, LispObj high, int delta)
     2191impurify_tcr_xframes(TCR *tcr, LispObj low, LispObj high, signed_natural delta)
    22302192{
    22312193  xframe_list *xframes;
     
    22432205
    22442206void
    2245 impurify_tstack_area(area *a, LispObj low, LispObj high, int delta)
     2207impurify_tstack_area(area *a, LispObj low, LispObj high, signed_natural delta)
    22462208{
    22472209  LispObj
     
    22632225}
    22642226void
    2265 impurify_vstack_area(area *a, LispObj low, LispObj high, int delta)
     2227impurify_vstack_area(area *a, LispObj low, LispObj high, signed_natural delta)
    22662228{
    22672229  LispObj
     
    22742236
    22752237void
    2276 impurify_areas(LispObj low, LispObj high, int delta)
     2238impurify_areas(LispObj low, LispObj high, signed_natural delta)
    22772239{
    22782240  area *next_area;
     
    22902252     
    22912253    case AREA_CSTACK:
    2292 #ifdef PPC
    2293       impurify_cstack_area(next_area, low, high, delta);
    2294 #endif
    22952254      break;
    22962255     
     
    23162275      oldhigh = a->high, newhigh;
    23172276    unsigned n = ro_limit - ro_base;
    2318     int delta = oldfree-ro_base;
     2277    signed_natural delta = oldfree-ro_base;
    23192278    TCR *other_tcr;
    23202279
     
    23412300        other_tcr = other_tcr->next;
    23422301      } while (other_tcr != tcr);
     2302
     2303      impurify_gcable_ptrs(ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    23432304      lisp_global(IN_GC) = 0;
    23442305    }
  • branches/gz-working/lisp-kernel/x86-spentry64.s

    r8341 r8478  
    15971597        __(push %rcontext:tcr.db_link)
    15981598        __(movq %rsp,%rcontext:tcr.db_link)
    1599         __(movq $nil_value,(%temp0,%temp1))
     1599        __(movq $nil_value,(%temp1,%temp0))
    16001600        __(jmp *%ra0)
    160116019:      __(movq $XSYMNOBIND,%arg_y)
     
    20762076/* objects.   */
    20772077_spentry(gvector)
     2078        __(subl $node_size,%nargs)
    20782079        __(movq (%rsp,%nargs_q),%imm0)  /* boxed subtype   */
    20792080        __(sarq $fixnumshift,%imm0)
Note: See TracChangeset for help on using the changeset viewer.