Changeset 13511


Ignore:
Timestamp:
Mar 11, 2010, 8:20:06 AM (9 years ago)
Author:
gb
Message:

Try to undo some of the damage done (mostly) by r13497.

image.c: handle relocation of weak vectors (hopefully) better.

lisp-debug.c: if we enter the kernel debugger with the batch flag

on, be more careful not to assume that we have exception context.
(We generally don't if 'Bug(NULL, "some message")' was used to
enter the debugger.)

ppc-gc.c, x86-gc.c: don't complain if the refbit for an intergenerational

reference from population.data of a weak list may have been cleared by
init_weakvll().

x86-gc.c: immutable_function_p() returns false on closures. Enter the

kernel debugger if purify_displaced_object() would try to copy a weak
vector out of dynamic space. (For now; need to take care to maintain
WEAKVLL if we do, and it's probably not something we'd want to do.)
Add purify_noderef(), which calls purify_locref() if ref points to
a tagged lisp pointer and does nothing otherwise.
Use purify_noderef() when recursively scanning in copy_reference(),
so we don't misinterpet immediate objects/headers as pointers to
dynamic space (as we've been doing since r13497.)
Make immutable_function_p() - which returns true if the function
can be copied to readonly memory - return false for closures, since
a closure's "constants" aren't as constant as a simple function's.

Location:
trunk/source/lisp-kernel
Files:
4 edited

Legend:

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

    r13330 r13511  
    5151    low = (LispObj)image_base - bias,
    5252    high = ptr_to_lispobj(active_dynamic_area->active) - bias,
    53     w0;
     53    w0, w1;
    5454  int fulltag;
     55  Boolean fixnum_after_header_is_link = false;
    5556
    5657  while (start < end) {
     
    8182#endif
    8283      if (header_subtag(w0) == subtag_weak) {
    83         LispObj link = start[1];
    84         if ((link >= low) && (link < high)) {
    85           start[1] = (link+bias);
     84        fixnum_after_header_is_link = true;
     85      }
     86      if (header_subtag(w0) == subtag_hash_vector) {
     87        hash_table_vector_header *hashp = (hash_table_vector_header *)start;
     88       
     89        if (hashp->flags & nhash_track_keys_mask) {
     90          hashp->flags |= nhash_key_moved_mask;
    8691        }
    87       }
     92        fixnum_after_header_is_link = true;
     93      }
     94
    8895      if ((w0 >= low) && (w0 < high) &&
    8996          ((1<<fulltag) & RELOCATABLE_FULLTAG_MASK)) {
    9097        *start = (w0+bias);
    9198      }
    92       w0 = *++start;
    93       fulltag = fulltag_of(w0);
    94       if ((w0 >= low) && (w0 < high) &&
    95           ((1<<fulltag) & RELOCATABLE_FULLTAG_MASK)) {
    96         *start = (w0+bias);
    97       }
     99      w1 = *++start;
     100      fulltag = fulltag_of(w1);
     101      if ((w1 >= low) && (w1 < high) &&
     102          (fixnum_after_header_is_link ||
     103           ((1<<fulltag) & RELOCATABLE_FULLTAG_MASK))) {
     104        *start = (w1+bias);
     105      }
     106      fixnum_after_header_is_link = false;
    98107      ++start;
    99108    }
     
    296305}
    297306
     307
    298308LispObj
    299309load_openmcl_image(int fd, openmcl_image_file_header *h)
     
    346356        set_nil(image_nil);
    347357        if (bias) {
     358          LispObj weakvll = lisp_global(WEAKVLL);
     359
     360          if ((weakvll >= ((LispObj)image_base-bias)) &&
     361              (weakvll < (ptr_to_lispobj(active_dynamic_area->active)-bias))) {
     362            lisp_global(WEAKVLL) = weakvll+bias;
     363          }
    348364          relocate_area_contents(a, bias);
    349365        }
     
    390406 
    391407void
    392 prepare_to_write_dynamic_space()
    393 {
    394   area *a = active_dynamic_area;
     408prepare_to_write_dynamic_space(area *a)
     409{
    395410  LispObj
    396411    *start = (LispObj *)(a->low),
     
    485500 
    486501  prepare_to_write_dynamic_space(active_dynamic_area);
     502  prepare_to_write_dynamic_space(managed_static_area);
    487503
    488504  /*
  • trunk/source/lisp-kernel/lisp-debug.c

    r13095 r13511  
    692692    fprintf(dbgout, "Value (lisp) stack area: low = 0x" LISP ", high = 0x" LISP "\n",
    693693            (u64_t)(natural)(vs_area->low), (u64_t)(natural)vs_area->high);
    694     fprintf(dbgout, "Exception stack pointer = 0x" LISP "\n",
     694    if (xp) {
     695      fprintf(dbgout, "Exception stack pointer = 0x" LISP "\n",
    695696#ifdef PPC
    696             (u64_t) (natural)(xpGPR(xp,1))
     697              (u64_t) (natural)(xpGPR(xp,1))
    697698#endif
    698699#ifdef X86
    699             (u64_t) (natural)(xpGPR(xp,Isp))
    700 #endif
    701             );
     700              (u64_t) (natural)(xpGPR(xp,Isp))
     701#endif           
     702              );
     703    }
    702704  }
    703705  return debug_continue;
     
    968970  if (xp) {
    969971    plbt(xp);
     972#ifndef X86
    970973  } else {
    971974    plbt_sp(current_stack_pointer());
     975#endif
    972976  }
    973977  return debug_continue;
     
    11921196    }
    11931197    debug_backtrace(xp, info, 0);
     1198
    11941199    abort();
    11951200  }
  • trunk/source/lisp-kernel/ppc-gc.c

    r13330 r13511  
    856856  int tag;
    857857  natural ref_dnode, node_dnode;
    858   Boolean intergen_ref;
     858  Boolean intergen_ref, lenient_next_dnode = false, lenient_this_dnode = false;
    859859
    860860  while (start < end) {
     
    865865    } else {
    866866      intergen_ref = false;
     867      if (header_subtag(x1) == subtag_weak)
     868        lenient_next_dnode == true;
     869      }
    867870      if ((tag == fulltag_misc) || (tag == fulltag_cons)) {       
    868871        node_dnode = gc_area_dnode(x1);
     
    871874        }
    872875      }
    873       if (intergen_ref == false) {       
    874         x1 = start[1];
    875         tag = fulltag_of(x1);
    876         if ((tag == fulltag_misc) || (tag == fulltag_cons)) {
    877           node_dnode = gc_area_dnode(x1);
    878           if (node_dnode < GCndnodes_in_area) {
    879             intergen_ref = true;
     876      if (lenient_this_dnode) {
     877        lenient_this_dnode = false;
     878      } else {
     879        if (intergen_ref == false) {       
     880          x1 = start[1];
     881          tag = fulltag_of(x1);
     882          if ((tag == fulltag_misc) || (tag == fulltag_cons)) {
     883            node_dnode = gc_area_dnode(x1);
     884            if (node_dnode < GCndnodes_in_area) {
     885              intergen_ref = true;
     886            }
    880887          }
    881888        }
     
    883890      if (intergen_ref) {
    884891        ref_dnode = area_dnode(start, base);
    885         if (!ref_bit(refbits, ref_dnode)) {
     892        if (!lenient_after_weak_header && !ref_bit(refbits, ref_dnode)) {
    886893          Bug(NULL, "Missing memoization in doublenode at 0x" LISP "\n", start);
    887894          set_bit(refbits, ref_dnode);
     
    889896      }
    890897      start += 2;
     898      if (lenient_next_dnode) {
     899        lenient_this_dnode = true;
     900      }
     901      lenient_next_dnode = false;
    891902    }
    892903  }
  • trunk/source/lisp-kernel/x86-gc.c

    r13497 r13511  
    11631163  int tag;
    11641164  natural ref_dnode, node_dnode;
    1165   Boolean intergen_ref;
     1165  Boolean intergen_ref, lenient_next_dnode = false, lenient_this_dnode = false;
    11661166
    11671167  while (start < end) {
     
    11741174      if (header_subtag(x1) == subtag_function) {
    11751175#ifdef X8632
    1176         int skip = (unsigned short)deref(start,1);
    1177         /* XXX bootstrapping */
    1178         if (skip & 0x8000)
    1179           skip = header_element_count(x1) - (skip & 0x7fff);
     1176        int skip = (unsigned short)deref(start,1);
     1177        /* XXX bootstrapping */
     1178        if (skip & 0x8000)
     1179          skip = header_element_count(x1) - (skip & 0x7fff);
    11801180#else
    11811181        int skip = (int) deref(start,1);
     
    11841184        x1 = *start;
    11851185        tag = fulltag_of(x1);
     1186      } else {
     1187        if (header_subtag(x1) == subtag_weak) {
     1188          lenient_next_dnode = true;
     1189        }
    11861190      }
    11871191      intergen_ref = false;
     
    11921196        }
    11931197      }
    1194       if (intergen_ref == false) {       
    1195         x1 = start[1];
    1196         tag = fulltag_of(x1);
    1197         if (is_node_fulltag(tag)) {       
    1198           node_dnode = gc_area_dnode(x1);
    1199           if (node_dnode < GCndnodes_in_area) {
    1200             intergen_ref = true;
     1198      if (lenient_this_dnode) {
     1199        lenient_this_dnode = false;
     1200      } else {
     1201        if ((intergen_ref == false)) {       
     1202          x1 = start[1];
     1203          tag = fulltag_of(x1);
     1204          if (is_node_fulltag(tag)) {       
     1205            node_dnode = gc_area_dnode(x1);
     1206            if (node_dnode < GCndnodes_in_area) {
     1207              intergen_ref = true;
     1208            }
    12011209          }
    12021210        }
     
    12101218      }
    12111219      start += 2;
     1220      if (lenient_next_dnode) {
     1221        lenient_this_dnode = true;
     1222      }
     1223      lenient_next_dnode = false;
    12121224    }
    12131225  }
     
    21872199         lfbits_cm_mask) &&
    21882200        ((lfbits & (lfbits_gfn_mask | lfbits_method_mask)) !=
    2189          lfbits_gfn_mask)) {
     2201         lfbits_gfn_mask) &&
     2202        ((lfbits & lfbits_trampoline_mask) == 0)) {
    21902203      return true;
    21912204    }
     
    22952308#endif
    22962309
     2310  if (1) {
     2311    if ((header_subtag(header) == subtag_weak) ||
     2312        (header_subtag(header) == subtag_hash_vector)) {
     2313      Bug(NULL, "purifying weak vector "LISP "\n", obj);
     2314    }
     2315  }
     2316
    22972317  if (immheader_tag_p(header_tag)) {
    22982318    physbytes = ((natural)(skip_over_ivector(start,header))) - start;
     
    23632383
    23642384Boolean
     2385purify_noderef(LispObj *ref,  BytePtr low, BytePtr high, area *dest, int what)
     2386{
     2387  LispObj obj = *ref;
     2388  natural tag = fulltag_of(obj);
     2389
     2390  if (is_node_fulltag(tag)) {
     2391    return purify_locref(ref,low,high,dest,what);
     2392  }
     2393  return false;
     2394}
     2395
     2396
     2397Boolean
    23652398copy_reference(LispObj *ref, BytePtr low, BytePtr high, area *dest, int what, Boolean recursive)
    23662399{
     
    23962429          } else if (nodeheader_tag_p(tag)) {
    23972430            if ((header_subtag(header) == subtag_simple_vector) ||
    2398                 (header_subtag(header) == subtag_struct)) {
     2431#if 0
     2432                false
     2433#else
     2434                (header_subtag(header) == subtag_struct)
     2435#endif
     2436                ) {
    23992437              scan++;
    2400               purify_locref(scan,low,high,dest,what);
     2438              purify_noderef(scan,low,high,dest,what);
    24012439              scan++;
    24022440            } else {
     
    24052443            }
    24062444          } else {
    2407             purify_locref(scan,low,high,dest,what);
     2445            purify_noderef(scan,low,high,dest,what);
    24082446            scan++;
    2409             purify_locref(scan,low,high,dest,what);
     2447            purify_noderef(scan,low,high,dest,what);
    24102448            scan++;
    24112449          }
Note: See TracChangeset for help on using the changeset viewer.