Changeset 8478
- Timestamp:
- Feb 13, 2008, 6:11:50 AM (17 years ago)
- Location:
- branches/gz-working/lisp-kernel
- Files:
-
- 8 edited
-
gc-common.c (modified) (1 diff)
-
gc.h (modified) (1 diff)
-
lisp.h (modified) (1 diff)
-
memory.c (modified) (1 diff)
-
ppc-spentry.s (modified) (1 diff)
-
x86-exceptions.c (modified) (3 diffs)
-
x86-gc.c (modified) (32 diffs)
-
x86-spentry64.s (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gz-working/lisp-kernel/gc-common.c
r8420 r8478 815 815 forward_gcable_ptrs() 816 816 { 817 LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next ;817 LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next, new; 818 818 819 819 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 } 821 824 prev = &(((xmacptr *)ptr_from_lispobj(untag(next)))->link); 822 825 } -
branches/gz-working/lisp-kernel/gc.h
r8408 r8478 214 214 void forward_cstack_area(area *); 215 215 LispObj compact_dynamic_heap(void); 216 LispObj * skip_over_ivector(natural, LispObj);217 216 int purify(TCR *, signed_natural); 218 217 int impurify(TCR *, signed_natural); -
branches/gz-working/lisp-kernel/lisp.h
r8387 r8478 47 47 #define align_to_power_of_2(n,p) _align_to_power_of_2(((natural)(n)),p) 48 48 49 static inline unsigned long50 _truncate_to_power_of_2( unsigned longn, unsigned power)49 static inline natural 50 _truncate_to_power_of_2(natural n, unsigned power) 51 51 { 52 52 return n & ~((1<<power) -1); 53 53 } 54 54 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) 56 56 57 57 LispObj start_lisp(TCR*, LispObj); -
branches/gz-working/lisp-kernel/memory.c
r8408 r8478 616 616 } 617 617 618 void 619 release_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 947 947 /* because nargs < 32K. */ 948 948 _spentry(gvector) 949 __(subi nargs,nargs,node_size) 949 950 __(ldrx(arg_z,vsp,nargs)) 950 951 __(unbox_fixnum(imm0,arg_z)) -
branches/gz-working/lisp-kernel/x86-exceptions.c
r8465 r8478 157 157 area *a = active_dynamic_area; 158 158 Boolean egc_was_enabled = (a->older != NULL); 159 159 160 natural gc_previously_deferred = gc_deferred; 160 161 … … 219 220 full_gc_deferred = 0; 220 221 } 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; 229 237 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); 234 244 } 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 } 248 257 } 249 258 if (egc_was_enabled) { … … 638 647 handler = protection_handlers[a->why]; 639 648 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 } 640 656 } 641 657 } -
branches/gz-working/lisp-kernel/x86-gc.c
r8369 r8478 1656 1656 new; 1657 1657 natural 1658 subtag = header_subtag(header), 1659 element_count = header_element_count(header), 1658 start = (natural)old, 1660 1659 physbytes; 1661 1660 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 1678 1663 dest->active += physbytes; 1679 1664 … … 1706 1691 1707 1692 1708 #define FORWARD_ONLY 01709 #define COPY_CODE (1<<0)1710 #define COPY_STRINGS (1<<1)1711 1693 1712 1694 … … 1763 1745 1764 1746 Boolean 1765 copy_ivector_reference(LispObj *ref, BytePtr low, BytePtr high, area *dest , int what_to_copy)1747 copy_ivector_reference(LispObj *ref, BytePtr low, BytePtr high, area *dest) 1766 1748 { 1767 1749 LispObj obj = *ref, header, new; … … 1779 1761 header_tag = fulltag_of(header); 1780 1762 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); 1788 1766 } 1789 1767 } … … 1793 1771 1794 1772 1795 void purify_headerless_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to, int what) 1773 void 1774 purify_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 1785 void 1786 purify_headerless_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to) 1796 1787 { 1797 1788 while (start < end) { 1798 copy_ivector_reference(start, low, high, to , what);1789 copy_ivector_reference(start, low, high, to); 1799 1790 start++; 1800 1791 } … … 1802 1793 1803 1794 void 1804 purify_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to , int what)1795 purify_range(LispObj *start, LispObj *end, BytePtr low, BytePtr high, area *to) 1805 1796 { 1806 1797 LispObj header; … … 1829 1820 nwords -= skip; 1830 1821 while(skip--) { 1831 copy_ivector_reference(start, low, high, to , what);1822 copy_ivector_reference(start, low, high, to); 1832 1823 start++; 1833 1824 } … … 1838 1829 nwords >>= 1; 1839 1830 while(nwords--) { 1840 if (copy_ivector_reference(start, low, high, to , what) && hashp) {1831 if (copy_ivector_reference(start, low, high, to) && hashp) { 1841 1832 hashp->flags |= nhash_key_moved_mask; 1842 1833 hashp = NULL; 1843 1834 } 1844 1835 start++; 1845 copy_ivector_reference(start, low, high, to , what);1836 copy_ivector_reference(start, low, high, to); 1846 1837 start++; 1847 1838 } … … 1855 1846 start++; 1856 1847 while(nwords--) { 1857 copy_ivector_reference(start, low, high, to , what);1848 copy_ivector_reference(start, low, high, to); 1858 1849 start++; 1859 1850 } … … 1861 1852 } else { 1862 1853 /* Not a header, just a cons cell */ 1863 copy_ivector_reference(start, low, high, to , what);1854 copy_ivector_reference(start, low, high, to); 1864 1855 start++; 1865 copy_ivector_reference(start, low, high, to , what);1856 copy_ivector_reference(start, low, high, to); 1866 1857 start++; 1867 1858 } … … 1872 1863 /* Purify references from tstack areas */ 1873 1864 void 1874 purify_tstack_area(area *a, BytePtr low, BytePtr high, area *to , int what)1865 purify_tstack_area(area *a, BytePtr low, BytePtr high, area *to) 1875 1866 { 1876 1867 LispObj … … 1886 1877 next = (LispObj *) ptr_from_lispobj(*current); 1887 1878 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); 1891 1880 } 1892 1881 } … … 1894 1883 /* Purify a vstack area */ 1895 1884 void 1896 purify_vstack_area(area *a, BytePtr low, BytePtr high, area *to , int what)1885 purify_vstack_area(area *a, BytePtr low, BytePtr high, area *to) 1897 1886 { 1898 1887 LispObj … … 1900 1889 *q = (LispObj *) a->high; 1901 1890 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 1895 void 1896 purify_xp(ExceptionInformation *xp, BytePtr low, BytePtr high, area *to) 1908 1897 { 1909 1898 natural *regs = (natural *) xpGPRvector(xp); … … 1911 1900 1912 1901 #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); 1924 1913 #if 0 1925 purify_locref(&(regs[Iip]), low, high, to , what);1914 purify_locref(&(regs[Iip]), low, high, to); 1926 1915 #endif 1927 1916 #else … … 1930 1919 1931 1920 void 1932 purify_tcr_tlb(TCR *tcr, BytePtr low, BytePtr high, area *to , int what)1921 purify_tcr_tlb(TCR *tcr, BytePtr low, BytePtr high, area *to) 1933 1922 { 1934 1923 natural n = tcr->tlb_limit; 1935 1924 LispObj *start = tcr->tlb_pointer, *end = (LispObj *) ((BytePtr)start+n); 1936 1925 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 1929 void 1930 purify_tcr_xframes(TCR *tcr, BytePtr low, BytePtr high, area *to) 1942 1931 { 1943 1932 xframe_list *xframes; … … 1946 1935 xp = tcr->gc_context; 1947 1936 if (xp) { 1948 purify_xp(xp, low, high, to , what);1937 purify_xp(xp, low, high, to); 1949 1938 } 1950 1939 1951 1940 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 1946 void 1947 purify_areas(BytePtr low, BytePtr high, area *target) 1959 1948 { 1960 1949 area *next_area; … … 1964 1953 switch (code) { 1965 1954 case AREA_TSTACK: 1966 purify_tstack_area(next_area, low, high, target , what);1955 purify_tstack_area(next_area, low, high, target); 1967 1956 break; 1968 1957 1969 1958 case AREA_VSTACK: 1970 purify_vstack_area(next_area, low, high, target , what);1959 purify_vstack_area(next_area, low, high, target); 1971 1960 break; 1972 1961 1973 1962 case AREA_CSTACK: 1974 #ifdef PPC1975 purify_cstack_area(next_area, low, high, target, what);1976 #endif1977 1963 break; 1978 1964 1979 1965 case AREA_STATIC: 1980 1966 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); 1982 1968 break; 1983 1969 … … 2011 1997 2012 1998 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)), 2014 2000 (LispObj *) a->active); 2015 2001 new_pure_area = extend_readonly_area(max_pure_size); … … 2019 2005 2020 2006 /* 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 2026 2008 2027 2009 Make the new_pure_area executable, just in case. … … 2031 2013 */ 2032 2014 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 2066 2016 2067 purify_areas(a->low, a->active, new_pure_area , FORWARD_ONLY);2017 purify_areas(a->low, a->active, new_pure_area); 2068 2018 2069 2019 other_tcr = tcr; 2070 2020 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); 2073 2023 other_tcr = other_tcr->next; 2074 2024 } while (other_tcr != tcr); 2075 2025 2076 2026 purify_gcable_ptrs(a->low, a->active, new_pure_area); 2077 2027 { 2078 2028 natural puresize = (unsigned) (new_pure_area->active-new_pure_start); … … 2109 2059 2110 2060 2111 2112 void 2113 impurify_xp(ExceptionInformation *xp, LispObj low, LispObj high, int delta) 2061 void 2062 impurify_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 2074 void 2075 impurify_xp(ExceptionInformation *xp, LispObj low, LispObj high, signed_natural delta) 2114 2076 { 2115 2077 natural *regs = (natural *) xpGPRvector(xp); … … 2136 2098 2137 2099 void 2138 impurify_headerless_range(LispObj *start, LispObj *end, LispObj low, LispObj high, intdelta)2100 impurify_headerless_range(LispObj *start, LispObj *end, LispObj low, LispObj high, signed_natural delta) 2139 2101 { 2140 2102 while (start < end) { … … 2146 2108 2147 2109 void 2148 impurify_range(LispObj *start, LispObj *end, LispObj low, LispObj high, intdelta)2110 impurify_range(LispObj *start, LispObj *end, LispObj low, LispObj high, signed_natural delta) 2149 2111 { 2150 2112 LispObj header; … … 2218 2180 2219 2181 void 2220 impurify_tcr_tlb(TCR *tcr, LispObj low, LispObj high, intdelta)2182 impurify_tcr_tlb(TCR *tcr, LispObj low, LispObj high, signed_natural delta) 2221 2183 { 2222 2184 unsigned n = tcr->tlb_limit; … … 2227 2189 2228 2190 void 2229 impurify_tcr_xframes(TCR *tcr, LispObj low, LispObj high, intdelta)2191 impurify_tcr_xframes(TCR *tcr, LispObj low, LispObj high, signed_natural delta) 2230 2192 { 2231 2193 xframe_list *xframes; … … 2243 2205 2244 2206 void 2245 impurify_tstack_area(area *a, LispObj low, LispObj high, intdelta)2207 impurify_tstack_area(area *a, LispObj low, LispObj high, signed_natural delta) 2246 2208 { 2247 2209 LispObj … … 2263 2225 } 2264 2226 void 2265 impurify_vstack_area(area *a, LispObj low, LispObj high, intdelta)2227 impurify_vstack_area(area *a, LispObj low, LispObj high, signed_natural delta) 2266 2228 { 2267 2229 LispObj … … 2274 2236 2275 2237 void 2276 impurify_areas(LispObj low, LispObj high, intdelta)2238 impurify_areas(LispObj low, LispObj high, signed_natural delta) 2277 2239 { 2278 2240 area *next_area; … … 2290 2252 2291 2253 case AREA_CSTACK: 2292 #ifdef PPC2293 impurify_cstack_area(next_area, low, high, delta);2294 #endif2295 2254 break; 2296 2255 … … 2316 2275 oldhigh = a->high, newhigh; 2317 2276 unsigned n = ro_limit - ro_base; 2318 intdelta = oldfree-ro_base;2277 signed_natural delta = oldfree-ro_base; 2319 2278 TCR *other_tcr; 2320 2279 … … 2341 2300 other_tcr = other_tcr->next; 2342 2301 } while (other_tcr != tcr); 2302 2303 impurify_gcable_ptrs(ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta); 2343 2304 lisp_global(IN_GC) = 0; 2344 2305 } -
branches/gz-working/lisp-kernel/x86-spentry64.s
r8341 r8478 1597 1597 __(push %rcontext:tcr.db_link) 1598 1598 __(movq %rsp,%rcontext:tcr.db_link) 1599 __(movq $nil_value,(%temp 0,%temp1))1599 __(movq $nil_value,(%temp1,%temp0)) 1600 1600 __(jmp *%ra0) 1601 1601 9: __(movq $XSYMNOBIND,%arg_y) … … 2076 2076 /* objects. */ 2077 2077 _spentry(gvector) 2078 __(subl $node_size,%nargs) 2078 2079 __(movq (%rsp,%nargs_q),%imm0) /* boxed subtype */ 2079 2080 __(sarq $fixnumshift,%imm0)
Note:
See TracChangeset
for help on using the changeset viewer.
