Changeset 5176


Ignore:
Timestamp:
Sep 8, 2006, 5:51:18 PM (18 years ago)
Author:
Gary Byers
Message:

Start to get purify working on x86-64; for now, just purify strings.

File:
1 edited

Legend:

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

    r4951 r5176  
    424424 
    425425
    426 #ifdef X86
     426
    427427#ifdef X8664
    428428#define RMARK_PREV_ROOT fulltag_imm_1 /* fulltag of 'undefined' value */
    429429#define RMARK_PREV_CAR fulltag_nil /* fulltag_nil + node_size. Coincidence ? I think not. */
    430430#else
    431 #endif
    432431#endif
    433432
     
    27532752  switch(subtag) {
    27542753  case subtag_simple_base_string:
    2755     physbytes = node_size + element_count;
     2754    physbytes = node_size + (element_count << 2);
    27562755    break;
    27572756
     
    28012800#define COPY_STRINGS (1<<1)
    28022801
     2802
     2803/*
     2804  This may overestimate a bit, if the same symbol is accessible from multiple
     2805  packages.
     2806*/
     2807natural
     2808interned_pname_bytes_in_range(LispObj *start, LispObj *end)
     2809{
     2810  lispsymbol *rawsym = (lispsymbol *)(&(nrs_ALL_PACKAGES));
     2811  LispObj pkg_list = rawsym->vcell, htab, obj, pname, pname_header;
     2812  package *p;
     2813  cons *c;
     2814  natural elements, i, nbytes = 0;
     2815
     2816  while (fulltag_of(pkg_list) == fulltag_cons) {
     2817    c = (cons *) ptr_from_lispobj(untag(pkg_list));
     2818    p = (package *) ptr_from_lispobj(untag(c->car));
     2819    pkg_list = c->cdr;
     2820    c = (cons *) ptr_from_lispobj(untag(p->itab));
     2821    htab = c->car;
     2822    elements = header_element_count(header_of(htab));
     2823    for (i = 1; i<= elements; i++) {
     2824      obj = deref(htab,i);
     2825      if (fulltag_of(obj) == fulltag_symbol) {
     2826        rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
     2827        pname = rawsym->pname;
     2828
     2829        if ((pname >= (LispObj)start) && (pname < (LispObj)end)) {
     2830          pname_header = header_of(pname);
     2831          nbytes += ((8 + (header_element_count(pname_header)<<2) + 15) &~15);
     2832        }
     2833      }
     2834    }
     2835    c = (cons *) ptr_from_lispobj(untag(p->etab));
     2836    htab = c->car;
     2837    elements = header_element_count(header_of(htab));
     2838    for (i = 1; i<= elements; i++) {
     2839      obj = deref(htab,i);
     2840      if (fulltag_of(obj) == fulltag_symbol) {
     2841        rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
     2842        pname = rawsym->pname;
     2843
     2844        if ((pname >= (LispObj)start) && (pname < (LispObj)end)) {
     2845          pname_header = header_of(pname);
     2846          nbytes += ((8 + (header_element_count(pname_header)<<2) + 15) &~15);
     2847        }
     2848      }
     2849    }
     2850  }
     2851  return nbytes;
     2852}
     2853
    28032854void
    28042855copy_ivector_reference(LispObj *ref, BytePtr low, BytePtr high, area *dest, int what_to_copy)
    28052856{
    2806 #ifndef X86
    28072857  LispObj obj = *ref, header;
    28082858  natural tag = fulltag_of(obj), header_tag, header_subtag;
     
    28182868      if (immheader_tag_p(header_tag)) {
    28192869        header_subtag = header_subtag(header);
    2820         if (((header_subtag == subtag_code_vector) && (what_to_copy & COPY_CODE)) ||
    2821             ((what_to_copy & COPY_STRINGS) &&
    2822              ((header_subtag == subtag_simple_base_string)))) {
     2870        if ((what_to_copy & COPY_STRINGS) &&
     2871            ((header_subtag == subtag_simple_base_string))) {
    28232872          *ref = purify_object(obj, dest);
    28242873        }
     
    28262875    }
    28272876  }
    2828 #endif
    2829 }
    2830 
    2831 void
    2832 purify_locref(LispObj *locaddr, BytePtr low, BytePtr high, area *to, int what)
    2833 {
    2834 #ifdef PPC
    2835   LispObj
    2836     loc = *locaddr,
    2837     *headerP;
    2838   opcode
    2839     *p,
    2840     insn;
    2841   natural
    2842     tag = fulltag_of(loc);
    2843 
    2844   if (((BytePtr)ptr_from_lispobj(loc) > low) &&
    2845 
    2846       ((BytePtr)ptr_from_lispobj(loc) < high)) {
    2847 
    2848     headerP = (LispObj *)ptr_from_lispobj(untag(loc));
    2849     switch (tag) {
    2850     case fulltag_even_fixnum:
    2851     case fulltag_odd_fixnum:
    2852 #ifdef PPC64
    2853     case fulltag_cons:
    2854     case fulltag_misc:
    2855 #endif
    2856       if (*headerP == forward_marker) {
    2857         *locaddr = (headerP[1]+tag);
    2858       } else {
    2859         /* Grovel backwards until the header's found; copy
    2860            the code vector to to space, then treat it as if it
    2861            hasn't already been copied. */
    2862         p = (opcode *)headerP;
    2863         do {
    2864           p -= 2;
    2865           tag += 8;
    2866           insn = *p;
    2867 #ifdef PPC64
    2868         } while (insn != PPC64_CODE_VECTOR_PREFIX);
    2869         headerP = ((LispObj*)p)-1;
    2870         *locaddr = purify_displaced_object(((LispObj)headerP), to, tag);
    2871 #else
    2872         } while ((insn & code_header_mask) != subtag_code_vector);
    2873         *locaddr = purify_displaced_object(ptr_to_lispobj(p), to, tag);
    2874 #endif
    2875       }
    2876       break;
    2877 
    2878 #ifndef PPC64
    2879     case fulltag_misc:
    2880       copy_ivector_reference(locaddr, low, high, to, what);
    2881       break;
    2882 #endif
    2883     }
    2884   }
    2885 #endif
    2886 #ifdef X86
    2887 #ifdef X8664
    2888 #warning Figure out what purify_locref needs to do, if anything, on X8664
    2889 #else
    2890 #endif
    2891 #endif
    2892 }
     2877}
     2878
    28932879
    28942880void
     
    29552941}
    29562942
    2957 #ifdef PPC
    2958 void
    2959 purify_cstack_area(area *a, BytePtr low, BytePtr high, area *to, int what)
    2960 {
    2961   BytePtr
    2962     current,
    2963     next,
    2964     limit = a->high;
    2965 
    2966   for (current = a->active; current != limit; current = next) {
    2967     next = *((BytePtr *)current);
    2968     if (next == NULL) break;
    2969     if (((next - current) == sizeof(lisp_frame)) &&
    2970         (((((lisp_frame *)current)->savefn) == 0) ||
    2971          (fulltag_of(((lisp_frame *)current)->savefn) == fulltag_misc))) {
    2972       purify_locref(&((lisp_frame *) current)->savelr, low, high, to, what);
    2973     } else {
    2974       /* Clear low bits of "next", just in case */
    2975       next = (BytePtr) (((natural)next) & ~(sizeof(natural)-1));
    2976     }
    2977   }
    2978 }
    2979 #endif
    29802943
    29812944void
     
    29852948
    29862949
    2987 #ifdef X86
    29882950#ifdef X8664
    29892951  copy_ivector_reference(&(regs[Iarg_z]), low, high, to, what);
     
    29992961  copy_ivector_reference(&(regs[Itemp1]), low, high, to, what);
    30002962  copy_ivector_reference(&(regs[Itemp2]), low, high, to, what);
     2963#if 0
    30012964  purify_locref(&(regs[Iip]), low, high, to, what);
     2965#endif
    30022966#else
    3003 #endif
    30042967#endif
    30052968}
     
    30753038purify(TCR *tcr, signed_natural param)
    30763039{
    3077 #if 1
    3078   return 0;
    3079 #else
    30803040  extern area *extend_readonly_area(unsigned);
    30813041  area
     
    30893049
    30903050
    3091   max_pure_size = unboxed_bytes_in_range((LispObj *)(a->low + (static_dnodes_for_area(a) << dnode_shift)),
     3051  max_pure_size = interned_pname_bytes_in_range((LispObj *)(a->low + (static_dnodes_for_area(a) << dnode_shift)),
    30923052                                         (LispObj *) a->active);
    30933053  new_pure_area = extend_readonly_area(max_pure_size);
     
    31253085        for (i = 1; i<= elements; i++) {
    31263086          obj = deref(htab,i);
    3127           if (fulltag_of(obj) == fulltag_misc) {
     3087          if (fulltag_of(obj) == fulltag_symbol) {
    31283088            rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
    31293089            copy_ivector_reference(&(rawsym->pname), a->low, a->active, new_pure_area, COPY_STRINGS);
     
    31353095        for (i = 1; i<= elements; i++) {
    31363096          obj = deref(htab,i);
    3137           if (fulltag_of(obj) == fulltag_misc) {
     3097          if (fulltag_of(obj) == fulltag_symbol) {
    31383098            rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
    31393099            copy_ivector_reference(&(rawsym->pname), a->low, a->active, new_pure_area, COPY_STRINGS);
     
    31433103    }
    31443104   
    3145     purify_areas(a->low, a->active, new_pure_area, COPY_CODE);
     3105    purify_areas(a->low, a->active, new_pure_area, FORWARD_ONLY);
    31463106   
    31473107    other_tcr = tcr;
    31483108    do {
    3149       purify_tcr_xframes(other_tcr, a->low, a->active, new_pure_area, COPY_CODE);
    3150       purify_tcr_tlb(other_tcr, a->low, a->active, new_pure_area, COPY_CODE);
     3109      purify_tcr_xframes(other_tcr, a->low, a->active, new_pure_area, FORWARD_ONLY);
     3110      purify_tcr_tlb(other_tcr, a->low, a->active, new_pure_area, FORWARD_ONLY);
    31513111      other_tcr = other_tcr->next;
    31523112    } while (other_tcr != tcr);
     
    31683128  }
    31693129  return -1;
    3170 #endif
    3171 }
    3172 
    3173 void
    3174 impurify_locref(LispObj *p, LispObj low, LispObj high, int delta)
    3175 {
    3176   LispObj q = *p;
    3177  
    3178   switch (fulltag_of(q)) {
    3179 #ifdef PPC64
    3180   case fulltag_cons:
    3181 #endif
    3182   case fulltag_misc:
    3183   case fulltag_even_fixnum:
    3184   case fulltag_odd_fixnum:
    3185     if ((q >= low) && (q < high)) {
    3186       *p = (q+delta);
    3187     }
    3188   }
    3189 }
     3130}
     3131
    31903132
    31913133 
     
    32033145 
    32043146
    3205 #ifdef PPC
    3206 void
    3207 impurify_cstack_area(area *a, LispObj low, LispObj high, int delta)
    3208 {
    3209   BytePtr
    3210     current,
    3211     next,
    3212     limit = a->high;
    3213 
    3214   for (current = a->active; current != limit; current = next) {
    3215     next = *((BytePtr *)current);
    3216     if (next == NULL) break;
    3217     if (((next - current) == sizeof(lisp_frame)) &&
    3218         (((((lisp_frame *)current)->savefn) == 0) ||
    3219          (fulltag_of(((lisp_frame *)current)->savefn) == fulltag_misc))) {
    3220       impurify_locref(&((lisp_frame *) current)->savelr, low, high, delta);
    3221     } else {
    3222       /* Clear low bits of "next", just in case */
    3223       next = (BytePtr) (((natural)next) & ~(sizeof(natural)-1));
    3224     }
    3225   }
    3226 }
    3227 #endif
    32283147
    32293148void
     
    32323151  natural *regs = (natural *) xpGPRvector(xp);
    32333152
    3234 #ifdef PPC
    3235   int r;
    3236   /* registers >= fn should be treated as roots.
    3237      The PC, LR, loc_pc, and CTR should be treated as "locatives".
    3238    */
    3239 
    3240   for (r = fn; r < 32; r++) {
    3241     impurify_noderef((LispObj*) (&(regs[r])), low, high, delta);
    3242   };
    3243 
    3244   impurify_locref((LispObj*) (&(regs[loc_pc])), low, high, delta);
    3245 
    3246   impurify_locref((LispObj*) (&(xpPC(xp))), low, high, delta);
    3247   impurify_locref((LispObj*) (&(xpLR(xp))), low, high, delta);
    3248   impurify_locref((LispObj*) (&(xpCTR(xp))), low, high, delta);
    3249 #endif
    3250 
    3251 #ifdef X86
     3153
    32523154#ifdef X8664
    32533155  impurify_noderef(&(regs[Iarg_z]), low, high, delta);
     
    32623164  impurify_noderef(&(regs[Itemp0]), low, high, delta);
    32633165  impurify_noderef(&(regs[Itemp1]), low, high, delta);
     3166#if 0
    32643167  impurify_locref(&(regs[Iip]), low, high, delta);
     3168#endif
    32653169#else
    32663170#endif
    3267 #endif
     3171
    32683172}
    32693173
Note: See TracChangeset for help on using the changeset viewer.