Changeset 8472


Ignore:
Timestamp:
Feb 12, 2008, 11:17:14 AM (12 years ago)
Author:
gb
Message:

purify() copies all ivectors to pure space. (Note that functions
aren't ivectors on x86-64 and not all ivectors are immutable, but
this (a) gets ivectors out of the GC's way and (b) a lot of ivectors
are in fact immutable and can therefore be kept in readonly pages
backed by the image rather than shared swap space.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/x86-gc.c

    r8369 r8472  
    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}
     1784void
     1785purify_headerless_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to)
    17961786{
    17971787  while (start < end) {
    1798     copy_ivector_reference(start, low, high, to, what);
     1788    copy_ivector_reference(start, low, high, to);
    17991789    start++;
    18001790  }
     
    18021792   
    18031793void
    1804 purify_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to, int what)
     1794purify_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to)
    18051795{
    18061796  LispObj header;
     
    18291819          nwords -= skip;
    18301820          while(skip--) {
    1831             copy_ivector_reference(start, low, high, to, what);
     1821            copy_ivector_reference(start, low, high, to);
    18321822            start++;
    18331823          }
     
    18381828          nwords >>= 1;
    18391829          while(nwords--) {
    1840             if (copy_ivector_reference(start, low, high, to, what) && hashp) {
     1830            if (copy_ivector_reference(start, low, high, to) && hashp) {
    18411831              hashp->flags |= nhash_key_moved_mask;
    18421832              hashp = NULL;
    18431833            }
    18441834            start++;
    1845             copy_ivector_reference(start, low, high, to, what);
     1835            copy_ivector_reference(start, low, high, to);
    18461836            start++;
    18471837          }
     
    18551845          start++;
    18561846          while(nwords--) {
    1857             copy_ivector_reference(start, low, high, to, what);
     1847            copy_ivector_reference(start, low, high, to);
    18581848            start++;
    18591849          }
     
    18611851      } else {
    18621852        /* Not a header, just a cons cell */
    1863         copy_ivector_reference(start, low, high, to, what);
     1853        copy_ivector_reference(start, low, high, to);
    18641854        start++;
    1865         copy_ivector_reference(start, low, high, to, what);
     1855        copy_ivector_reference(start, low, high, to);
    18661856        start++;
    18671857      }
     
    18721862/* Purify references from tstack areas */
    18731863void
    1874 purify_tstack_area(area *a, BytePtr low, BytePtr high, area *to, int what)
     1864purify_tstack_area(area *a, BytePtr low, BytePtr high, area *to)
    18751865{
    18761866  LispObj
     
    18861876    next = (LispObj *) ptr_from_lispobj(*current);
    18871877    end = ((next >= start) && (next < limit)) ? next : limit;
    1888     if (current[1] == 0) {
    1889       purify_range(current+2, end, low, high, to, what);
    1890     }
     1878    purify_range(current+2, end, low, high, to);
    18911879  }
    18921880}
     
    18941882/* Purify a vstack area */
    18951883void
    1896 purify_vstack_area(area *a, BytePtr low, BytePtr high, area *to, int what)
     1884purify_vstack_area(area *a, BytePtr low, BytePtr high, area *to)
    18971885{
    18981886  LispObj
     
    19001888    *q = (LispObj *) a->high;
    19011889 
    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)
     1890  purify_headerless_range(p, q, low, high, to);
     1891}
     1892
     1893
     1894void
     1895purify_xp(ExceptionInformation *xp, BytePtr low, BytePtr high, area *to)
    19081896{
    19091897  natural *regs = (natural *) xpGPRvector(xp);
     
    19111899
    19121900#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);
     1901  copy_ivector_reference(&(regs[Iarg_z]), low, high, to);
     1902  copy_ivector_reference(&(regs[Iarg_y]), low, high, to);
     1903  copy_ivector_reference(&(regs[Iarg_x]), low, high, to);
     1904  copy_ivector_reference(&(regs[Isave3]), low, high, to);
     1905  copy_ivector_reference(&(regs[Isave2]), low, high, to);
     1906  copy_ivector_reference(&(regs[Isave1]), low, high, to);
     1907  copy_ivector_reference(&(regs[Isave0]), low, high, to);
     1908  copy_ivector_reference(&(regs[Ifn]), low, high, to);
     1909  copy_ivector_reference(&(regs[Itemp0]), low, high, to);
     1910  copy_ivector_reference(&(regs[Itemp1]), low, high, to);
     1911  copy_ivector_reference(&(regs[Itemp2]), low, high, to);
    19241912#if 0
    1925   purify_locref(&(regs[Iip]), low, high, to, what);
     1913  purify_locref(&(regs[Iip]), low, high, to);
    19261914#endif
    19271915#else
     
    19301918
    19311919void
    1932 purify_tcr_tlb(TCR *tcr, BytePtr low, BytePtr high, area *to, int what)
     1920purify_tcr_tlb(TCR *tcr, BytePtr low, BytePtr high, area *to)
    19331921{
    19341922  natural n = tcr->tlb_limit;
    19351923  LispObj *start = tcr->tlb_pointer, *end = (LispObj *) ((BytePtr)start+n);
    19361924
    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)
     1925  purify_range(start, end, low, high, to);
     1926}
     1927
     1928void
     1929purify_tcr_xframes(TCR *tcr, BytePtr low, BytePtr high, area *to)
    19421930{
    19431931  xframe_list *xframes;
     
    19461934  xp = tcr->gc_context;
    19471935  if (xp) {
    1948     purify_xp(xp, low, high, to, what);
     1936    purify_xp(xp, low, high, to);
    19491937  }
    19501938
    19511939  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)
     1940    purify_xp(xframes->curr, low, high, to);
     1941  }
     1942}
     1943
     1944
     1945void
     1946purify_areas(BytePtr low, BytePtr high, area *target)
    19591947{
    19601948  area *next_area;
     
    19641952    switch (code) {
    19651953    case AREA_TSTACK:
    1966       purify_tstack_area(next_area, low, high, target, what);
     1954      purify_tstack_area(next_area, low, high, target);
    19671955      break;
    19681956     
    19691957    case AREA_VSTACK:
    1970       purify_vstack_area(next_area, low, high, target, what);
     1958      purify_vstack_area(next_area, low, high, target);
    19711959      break;
    19721960     
    19731961    case AREA_CSTACK:
    1974 #ifdef PPC
    1975       purify_cstack_area(next_area, low, high, target, what);
    1976 #endif
    19771962      break;
    19781963     
    19791964    case AREA_STATIC:
    19801965    case AREA_DYNAMIC:
    1981       purify_range((LispObj *) next_area->low, (LispObj *) next_area->active, low, high, target, what);
     1966      purify_range((LispObj *) next_area->low, (LispObj *) next_area->active, low, high, target);
    19821967      break;
    19831968     
     
    20111996
    20121997
    2013   max_pure_size = interned_pname_bytes_in_range((LispObj *)(a->low + (static_dnodes_for_area(a) << dnode_shift)),
     1998  max_pure_size = unboxed_bytes_in_range((LispObj *)(a->low + (static_dnodes_for_area(a) << dnode_shift)),
    20141999                                         (LispObj *) a->active);
    20152000  new_pure_area = extend_readonly_area(max_pure_size);
     
    20192004
    20202005    /*
    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.)
     2006
    20262007       
    20272008      Make the new_pure_area executable, just in case.
     
    20312012      */
    20322013
    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     }
     2014
    20662015   
    2067     purify_areas(a->low, a->active, new_pure_area, FORWARD_ONLY);
     2016    purify_areas(a->low, a->active, new_pure_area);
    20682017   
    20692018    other_tcr = tcr;
    20702019    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);
     2020      purify_tcr_xframes(other_tcr, a->low, a->active, new_pure_area);
     2021      purify_tcr_tlb(other_tcr, a->low, a->active, new_pure_area);
    20732022      other_tcr = other_tcr->next;
    20742023    } while (other_tcr != tcr);
    20752024
    2076 
     2025    purify_gcable_ptrs(a->low, a->active, new_pure_area);
    20772026    {
    20782027      natural puresize = (unsigned) (new_pure_area->active-new_pure_start);
Note: See TracChangeset for help on using the changeset viewer.