Changeset 13270


Ignore:
Timestamp:
Dec 9, 2009, 12:38:07 AM (10 years ago)
Author:
gb
Message:

Get purify/impurify working on x86 (including x8632.)

File:
1 edited

Legend:

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

    r13260 r13270  
    24562456
    24572457void
    2458 purify_xp(ExceptionInformation *xp, BytePtr low, BytePtr high, area *to, int what)
     2458purify_xp(ExceptionInformation *xp, BytePtr low, BytePtr high, area *to, int what
     2459#ifdef X8632
     2460          ,natural node_regs_mask
     2461#endif
     2462)
    24592463{
    24602464  natural *regs = (natural *) xpGPRvector(xp);
     
    24772481
    24782482#else
     2483  if (node_regs_mask & (1<<0)) {
     2484    copy_reference(&(regs[REG_EAX]), low, high, to, what);
     2485  }
     2486  if (node_regs_mask & (1<<1)) {
     2487    copy_reference(&(regs[REG_ECX]), low, high, to, what);
     2488  }
     2489  if (! (regs[REG_EFL] & EFL_DF)) {
     2490    if (node_regs_mask & (1<<2)) {
     2491      copy_reference(&(regs[REG_EDX]), low, high, to, what);
     2492    }
     2493  }
     2494  if (node_regs_mask & (1<<3)) {
     2495    copy_reference(&(regs[REG_EBX]), low, high, to, what);
     2496  }
     2497  if (node_regs_mask & (1<<4)) {
     2498    copy_reference(&(regs[REG_ESP]), low, high, to, what);
     2499  }
     2500  if (node_regs_mask & (1<<5)) {
     2501    copy_reference(&(regs[REG_EBP]), low, high, to, what);
     2502  }
     2503  if (node_regs_mask & (1<<6)) {
     2504    copy_reference(&(regs[REG_ESI]), low, high, to, what);
     2505  }
     2506  if (node_regs_mask & (1<<7)) {
     2507    copy_reference(&(regs[REG_EDI]), low, high, to, what);
     2508  }
     2509  purify_locref(&regs[REG_EIP], low, high, to, what);
    24792510#endif
    24802511}
     
    24972528  xp = tcr->gc_context;
    24982529  if (xp) {
     2530#ifdef X8632
     2531    purify_xp(xp, low, high, to, what, tcr->node_regs_mask);
     2532#else
    24992533    purify_xp(xp, low, high, to, what);
    2500   }
     2534#endif
     2535  }
     2536#ifdef X8632
     2537  copy_reference(&tcr->save0, low, high, to, what);
     2538  copy_reference(&tcr->save1, low, high, to, what);
     2539  copy_reference(&tcr->save2, low, high, to, what);
     2540  copy_reference(&tcr->save3, low, high, to, what);
     2541  copy_reference(&tcr->next_method_context, low, high, to, what);
     2542#endif
    25012543
    25022544  for (xframes = tcr->xframe; xframes; xframes = xframes->prev) {
    2503     purify_xp(xframes->curr, low, high, to, what);
     2545    purify_xp(xframes->curr, low, high, to, what
     2546#ifdef X8632
     2547              , xframes->node_regs_mask
     2548#endif
     2549              );
    25042550  }
    25052551}
     
    27062752}
    27072753
    2708 
     2754Boolean
     2755impurify_locref(LispObj *p, LispObj low, LispObj high, signed_natural delta)
     2756{
     2757  LispObj q = *p;
     2758
     2759  if ((q >= low) &&
     2760      (q < high)) {
     2761    *p = (q+delta);
     2762    return true;
     2763  }
     2764  return false;
     2765}
    27092766 
    27102767Boolean
    2711 impurify_noderef(LispObj *p, LispObj low, LispObj high, int delta)
     2768impurify_noderef(LispObj *p, LispObj low, LispObj high, signed_natural delta)
    27122769{
    27132770  LispObj q = *p;
     
    27372794
    27382795void
    2739 impurify_xp(ExceptionInformation *xp, LispObj low, LispObj high, signed_natural delta)
     2796impurify_xp(ExceptionInformation *xp, LispObj low, LispObj high, signed_natural delta
     2797#ifdef X8632
     2798            ,natural node_regs_mask
     2799#endif
     2800)
    27402801{
    27412802  natural *regs = (natural *) xpGPRvector(xp);
     
    27462807  impurify_noderef(&(regs[Iarg_y]), low, high, delta);
    27472808  impurify_noderef(&(regs[Iarg_x]), low, high, delta);
    2748 #ifndef WINDOWS
     2809#ifndef TCR_IN_GPR
    27492810  impurify_noderef(&(regs[Isave3]), low, high, delta);
    27502811#endif
     
    27552816  impurify_noderef(&(regs[Itemp0]), low, high, delta);
    27562817  impurify_noderef(&(regs[Itemp1]), low, high, delta);
    2757 #if 0
     2818
    27582819  impurify_locref(&(regs[Iip]), low, high, delta);
    2759 #endif
    27602820#else
     2821  if (node_regs_mask & (1<<0)) {
     2822    impurify_noderef(&(regs[REG_EAX]), low, high, delta);
     2823  }
     2824  if (node_regs_mask & (1<<1)) {
     2825    impurify_noderef(&(regs[REG_ECX]), low, high, delta);
     2826  }
     2827  if (! (regs[REG_EFL] & EFL_DF)) {
     2828    if (node_regs_mask & (1<<2)) {
     2829      impurify_noderef(&(regs[REG_EDX]), low, high, delta);
     2830    }
     2831  }
     2832  if (node_regs_mask & (1<<3)) {
     2833    impurify_noderef(&(regs[REG_EBX]), low, high, delta);
     2834  }
     2835  if (node_regs_mask & (1<<4)) {
     2836    impurify_noderef(&(regs[REG_ESP]), low, high, delta);
     2837  }
     2838  if (node_regs_mask & (1<<5)) {
     2839    impurify_noderef(&(regs[REG_EBP]), low, high, delta);
     2840  }
     2841  if (node_regs_mask & (1<<6)) {
     2842    impurify_noderef(&(regs[REG_ESI]), low, high, delta);
     2843  }
     2844  if (node_regs_mask & (1<<7)) {
     2845    impurify_noderef(&(regs[REG_EDI]), low, high, delta);
     2846  }
     2847  impurify_locref(&(regs[REG_EIP]), low, high, delta);
     2848
    27612849#endif
    27622850
     
    28662954  xp = tcr->gc_context;
    28672955  if (xp) {
     2956#ifdef X8632
     2957    impurify_xp(xp, low, high, delta, tcr->node_regs_mask);
     2958#else
    28682959    impurify_xp(xp, low, high, delta);
    2869   }
     2960#endif
     2961  }
     2962
     2963#ifdef X8632
     2964  impurify_noderef(&tcr->save0, low, high, delta);
     2965  impurify_noderef(&tcr->save1, low, high, delta);
     2966  impurify_noderef(&tcr->save2, low, high, delta);
     2967  impurify_noderef(&tcr->save3, low, high, delta);
     2968  impurify_noderef(&tcr->next_method_context, low, high, delta);
     2969#endif
    28702970
    28712971  for (xframes = tcr->xframe; xframes; xframes = xframes->prev) {
    2872     impurify_xp(xframes->curr, low, high, delta);
     2972    impurify_xp(xframes->curr, low, high, delta
     2973#ifdef X8632
     2974                ,xframes->node_regs_mask
     2975#endif
     2976);
    28732977  }
    28742978}
     
    28892993    next = (LispObj *) ptr_from_lispobj(*current);
    28902994    end = ((next >= start) && (next < limit)) ? next : limit;
    2891     if (current[1] == 0) {
    2892       impurify_range(current+2, end, low, high, delta);
    2893     }
     2995    impurify_range(current+2, end, low, high, delta);
    28942996  }
    28952997}
     
    29263028    case AREA_STATIC:
    29273029    case AREA_DYNAMIC:
     3030    case AREA_MANAGED_STATIC:
    29283031      impurify_range((LispObj *) next_area->low, (LispObj *) next_area->active, low, high, delta);
    29293032      break;
     
    29353038}
    29363039
     3040void
     3041impurify_from_area(TCR *tcr, area *src)
     3042{
     3043  area *a = active_dynamic_area;
     3044  BytePtr base = src->low, limit = src->active, oldfree = a->active,
     3045    oldhigh = a->high, newhigh;
     3046  natural n = limit-base;
     3047  signed_natural delta = oldfree-base;
     3048  TCR *other_tcr;
     3049
     3050  newhigh = (BytePtr) (align_to_power_of_2(oldfree+n,
     3051                                           log2_heap_segment_size));
     3052  if (newhigh > oldhigh) {
     3053    grow_dynamic_area(newhigh-oldhigh);
     3054  }
     3055  a->active += n;
     3056  memmove(oldfree, base, n);
     3057  UnCommitMemory((void *)base, n);
     3058  a->ndnodes = area_dnode(a, a->active);
     3059  src->active = src->low;
     3060  if (src == readonly_area) {
     3061    pure_space_active = src->low;
     3062  }
     3063  src->ndnodes = 0;
     3064 
     3065  impurify_areas(ptr_to_lispobj(base), ptr_to_lispobj(limit), delta);
     3066 
     3067  other_tcr = tcr;
     3068  do {
     3069    impurify_tcr_xframes(other_tcr, ptr_to_lispobj(base), ptr_to_lispobj(limit), delta);
     3070    impurify_tcr_tlb(other_tcr, ptr_to_lispobj(base), ptr_to_lispobj(limit), delta);
     3071    other_tcr = other_tcr->next;
     3072  } while (other_tcr != tcr);
     3073 
     3074  impurify_gcable_ptrs(ptr_to_lispobj(base), ptr_to_lispobj(limit), delta);
     3075}
     3076
    29373077signed_natural
    29383078impurify(TCR *tcr, signed_natural param)
    29393079{
    2940   area *r = find_readonly_area();
    2941 
    2942   if (r) {
    2943     area *a = active_dynamic_area;
    2944     BytePtr ro_base = r->low, ro_limit = r->active, oldfree = a->active,
    2945       oldhigh = a->high, newhigh;
    2946     unsigned n = ro_limit - ro_base;
    2947     signed_natural delta = oldfree-ro_base;
    2948     TCR *other_tcr;
    2949 
    2950     if (n) {
    2951       lisp_global(IN_GC) = 1;
    2952       newhigh = (BytePtr) (align_to_power_of_2(oldfree+n,
    2953                                                log2_heap_segment_size));
    2954       if (newhigh > oldhigh) {
    2955         grow_dynamic_area(newhigh-oldhigh);
    2956       }
    2957       a->active += n;
    2958       memmove(oldfree, ro_base, n);
    2959       UnMapMemory((void *)ro_base, n);
    2960       a->ndnodes = area_dnode(a, a->active);
    2961       pure_space_active = r->active = r->low;
    2962       r->ndnodes = 0;
    2963 
    2964       impurify_areas(ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    2965 
    2966       other_tcr = tcr;
    2967       do {
    2968         impurify_tcr_xframes(other_tcr, ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    2969         impurify_tcr_tlb(other_tcr, ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    2970         other_tcr = other_tcr->next;
    2971       } while (other_tcr != tcr);
    2972 
    2973       impurify_gcable_ptrs(ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    2974       lisp_global(IN_GC) = 0;
    2975     }
    2976     return 0;
    2977   }
    2978   return -1;
     3080  lisp_global(IN_GC)=1;
     3081  impurify_from_area(tcr, readonly_area);
     3082  impurify_from_area(tcr, managed_static_area);
     3083  lisp_global(IN_GC)=0;
     3084  return 0;
    29793085}
    29803086
Note: See TracChangeset for help on using the changeset viewer.