Changeset 557


Ignore:
Timestamp:
Feb 22, 2004, 1:27:13 AM (15 years ago)
Author:
gb
Message:

PPC64 changes (some of them rather suspect ...). 32-bit kernel may be a
little funky ...

Location:
trunk/ccl/lisp-kernel
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/area.h

    r6 r557  
    3939
    4040typedef struct area {
    41   struct area *pred;            /* linked list predecessor */
    42   struct area *succ;            /* linked list successor */
    43   BytePtr low;                  /* arithmetic lower limit on addresses (inclusive) */
    44   BytePtr high;                 /* arithmetic upper limit on addresses (exclusive) */
    45   BytePtr active;               /* low bound (stack) or high bound (heap) */
    46   BytePtr softlimit;            /* only makes sense for dynamic heaps & stacks */
    47   BytePtr hardlimit;            /* only makes sense for dynamic heaps & stacks */
    48   area_code code;
    49   bitvector markbits;           /* markbits for active area */
    50   unsigned ndwords;             /* "active" size of dynamic area or stack */
    51   struct area *older;           /* if ephemeral, the next older ephemeral area
     41  NATURAL_POINTER_FIELD(struct area,pred);  /* linked list predecessor */
     42  NATURAL_POINTER_FIELD(struct area,succ);  /* linked list successor */
     43  NATURAL_POINTER_FIELD(char,low);        /* arithmetic lower limit on addresses (inclusive) */
     44  NATURAL_POINTER_FIELD(char,high);        /* arithmetic upper limit on addresses (exclusive) */
     45  NATURAL_POINTER_FIELD(char,active);       /* low bound (stack) or high bound (heap) */
     46  NATURAL_POINTER_FIELD(char,softlimit);                /* only makes sense for dynamic heaps & stacks */
     47  NATURAL_POINTER_FIELD(char,hardlimit);                /* only makes sense for dynamic heaps & stacks */
     48  natural code;
     49  NATURAL_POINTER_FIELD(natural, markbits);           /* markbits for active area */
     50  natural ndnodes;              /* "active" size of dynamic area or stack */
     51  NATURAL_POINTER_FIELD(struct area,older);             /* if ephemeral, the next older ephemeral area
    5252                                 or the dynamic area */
    53   struct area *younger;         /* if ephemeral, the next "younger" ephemeral area
    54                                 if there is one.  If dynamic, the oldest ephemeral
     53  NATURAL_POINTER_FIELD(struct area,younger); /* if ephemeral, the next "younger" ephemeral area
     54                                  if there is one.  If dynamic, the oldest ephemeral
    5555                                 area. */
    56   Ptr h;                        /* The pointer allocated to contain this area, or NULL
     56  NATURAL_POINTER_FIELD(char, h);                       /* The pointer allocated to contain this area, or NULL
    5757                                 if the operating system allocated it for us. */
    58   protected_area_ptr softprot;  /* "soft" protected_area */
    59   protected_area_ptr hardprot;  /* "hard" protected_area */
    60   unsigned owner;               /* position in external_containers linked list */
    61   bitvector refbits;            /* intergenerational references.
    62                                    May or may not be the same as markbits */
    63   unsigned threshold;          /* egc threshold (boxed "fullword count") or 0 */
     58  NATURAL_POINTER_FIELD(protected_area,softprot);  /* "soft" protected_area */
     59  NATURAL_POINTER_FIELD(protected_area,hardprot);  /* "hard" protected_area */
     60  natural owner;               /* position in external_containers linked list */
     61  NATURAL_POINTER_FIELD(natural, refbits); /* intergenerational references.
     62                                               May or may not be the same as markbits */
     63  natural threshold; /* egc threshold (boxed "fullword count") or 0 */
    6464  LispObj gccount;              /* boxed generation GC count. */
    6565} area;
  • trunk/ccl/lisp-kernel/bits.c

    r6 r557  
    1616
    1717
     18#include "lisp.h"
    1819#include "bits.h"
    19 #include "lisp.h"
    2020
    2121
  • trunk/ccl/lisp-kernel/bits.h

    r6 r557  
    2525#include <string.h>
    2626
    27 typedef unsigned *bitvector;
     27typedef natural *bitvector;
    2828
    2929
  • trunk/ccl/lisp-kernel/constants.h

    r469 r557  
    1717#ifndef __constants__
    1818#define __constants__ 1
    19 
    20 
    21 #define nbits_in_word 32
    22 #define nbits_in_byte 8
    23 #define ntagbits 3      /* But only 2 are significant to lisp */
    24 #define nlisptagbits 2
    25 #define nfixnumtagbits 2
    26 #define num_subtag_bits 8
    27 #define fixnumshift 2
    28 #define fixnum_shift 2
    29 #define fulltagmask 7
    30 #define tagmask  3
    31 #define fixnummask 3
    32 #define subtagmask ((1<<num_subtag_bits)-1)
    33 #define ncharcodebits 16
    34 #define charcode_shift (nbits_in_word-ncharcodebits)
    35 
    36 /*  Tags. */
    37 /*  There are two-bit tags and three-bit tags. */
    38 /*  A FULLTAG is the value of the low three bits of a tagged object. */
    39 /*  A TAG is the value of the low two bits of a tagged object. */
    40 /*  A TYPECODE is either a TAG or the value of a "tag-misc" object's header-byte. */
    41 
    42 /*  There are 4 primary TAG values.  Any object which lisp can "see" can be classified  */
    43 /*  by its TAG.  (Some headers have FULLTAGS that are congruent modulo 4 with the */
    44 /*  TAGS of other objects, but lisp can't "see" headers.) */
    45 
    46 
    47 #define tag_fixnum 0    /*  All fixnums, whether odd or even */
    48 #define tag_list 1      /*  Conses and NIL */
    49 #define tag_misc 2      /*  Heap-consed objects other than lists: vectors, symbols, functions, floats ... */
    50 #define tag_imm  3      /*  Immediate-objects: characters, UNBOUND, other markers. */
    51 
    52 /*  And there are 8 FULLTAG values.  Note that NIL has its own FULLTAG (congruent mod 4 to tag-list), */
    53 /*  that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low */
    54 /*  two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags */
    55 /*  that share the same TAG. */
    56 /*  Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each */
    57 /*  object that they see. */
    58 
    59 #define fulltag_even_fixnum 0   /*  I suppose EVENP/ODDP might care; nothing else does. */
    60 #define fulltag_cons     1      /*  a real (non_null) cons.  Shares TAG with fulltag_nil. */
    61 #define fulltag_nodeheader 2    /*  Header of heap_allocated object that contains lisp_object pointers */
    62 #define fulltag_imm      3      /*  a "real" immediate object.  Shares TAG with fulltag_immheader. */
    63 #define fulltag_odd_fixnum 4    /*   */
    64 #define fulltag_nil      5      /*  NIL and nothing but.  (Note that there's still a hidden NILSYM.) */
    65 #define fulltag_misc     6      /*  Pointer "real" tag_misc object.  Shares TAG with fulltag_nodeheader. */
    66 #define fulltag_immheader 7     /*  Header of heap-allocated object that contains unboxed data. */
    6719
    6820/*  Register usage: */
     
    10658#define closure_data temp0
    10759
    108 
    109 /*  Order of CAR and CDR doesn't seem to matter much - there aren't */
    110 /*  too many tricks to be played with predecrement/preincrement addressing. */
    111 /*  Keep them in the confusing MCL 3.0 order, to avoid confusion. */
    112 
    113 typedef struct cons {
    114   LispObj cdr;
    115   LispObj car;
    116 } cons;
    117 
    118 
    119 #define misc_header_offset -fulltag_misc
    120 #define misc_subtag_offset misc_header_offset+3         /*  low byte of header */
    121 #define misc_data_offset misc_header_offset+4           /*  first word of data */
    122 #define misc_dfloat_offset misc_header_offset+8         /*  double-floats are doubleword-aligned */
    123 
    124 #define max_64_bit_constant_index ((0x7fff + misc_dfloat_offset)>>3)
    125 #define max_32_bit_constant_index ((0x7fff + misc_data_offset)>>2)
    126 #define max_16_bit_constant_index ((0x7fff + misc_data_offset)>>1)
    127 #define max_8_bit_constant_index (0x7fff + misc_data_offset)
    128 #define max_1_bit_constant_index ((0x7fff + misc_data_offset)<<5)
    129 
    130 /*  T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans */
    131 /*  two doublewords.  The arithmetic difference between T and NIL is */
    132 /*  such that the least-significant bit and exactly one other bit is */
    133 /*  set in the result. */
    134 
    135 #define t_offset (8+(8-fulltag_nil)+fulltag_misc)
    136 
    137 /*  The order in which various header values are defined is significant in several ways: */
    138 /*  1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. */
    139 /*  2) All subtags which denote CL arrays are preceded by those that don't, */
    140 /*     with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) */
    141 /*  3) The element-size of ivectors is determined by the ordering of ivector subtags. */
    142 /*  4) All subtags are >= fulltag-immheader . */
    143 
    144 #define SUBTAG(tag,subtag) ((tag) | ((subtag) << ntagbits))
    145 #define IMM_SUBTAG(subtag) SUBTAG(fulltag_immheader,(subtag))
    146 #define NODE_SUBTAG(subtag) SUBTAG(fulltag_nodeheader,(subtag))
    147 
    148        
    149 /* Numeric subtags. */
    150 
    151 #define subtag_bignum IMM_SUBTAG(0)
    152 #define min_numeric_subtag subtag_bignum
    153 
    154 #define subtag_ratio NODE_SUBTAG(1)
    155 #define max_rational_subtag subtag_ratio
    156 
    157 #define subtag_single_float IMM_SUBTAG(1)
    158 #define subtag_double_float IMM_SUBTAG(2)
    159 #define min_float_subtag subtag_single_float
    160 #define max_float_subtag subtag_double_float
    161 #define max_real_subtag subtag_double_float
    162 
    163 #define subtag_complex NODE_SUBTAG(3)
    164 #define max_numeric_subtag subtag_complex
    165 
    166 
    167 /*  CL array types.  There are more immediate types than node types; all CL array subtags must be > than */
    168 /*  all non-CL-array subtags.  So we start by defining the immediate subtags in decreasing order, starting */
    169 /*  with that subtag whose element size isn't an integral number of bits and ending with those whose */
    170 /*  element size - like all non-CL-array fulltag-immheader types - is 32 bits. */
    171 
    172 #define subtag_bit_vector IMM_SUBTAG(31)
    173 #define subtag_double_float_vector IMM_SUBTAG(30)
    174 #define subtag_s16_vector IMM_SUBTAG(29)
    175 #define subtag_u16_vector IMM_SUBTAG(28)
    176 #define subtag_simple_general_string IMM_SUBTAG(27)
    177 #define min_16_bit_ivector_subtag subtag_simple_general_string
    178 #define max_16_bit_ivector_subtag subtag_s16_vector
    179 #define max_string_subtag subtag_simple_general_string
    180 
    181 #define subtag_simple_base_string IMM_SUBTAG(26)
    182 #define subtag_s8_vector IMM_SUBTAG(25)
    183 #define subtag_u8_vector IMM_SUBTAG(24)
    184 #define min_8_bit_ivector_subtag subtag_u8_vector
    185 #define max_8_bit_ivector_subtag subtag_simple_base_string
    186 #define min_string_subtag subtag_simple_base_string
    187 
    188 #define subtag_s32_vector IMM_SUBTAG(23)
    189 #define subtag_u32_vector IMM_SUBTAG(22)
    190 #define subtag_single_float_vector IMM_SUBTAG(21)
    191 #define max_32_bit_ivector_subtag subtag_s32_vector
    192 #define min_cl_ivector_subtag subtag_single_float_vector
    193 
    194 
    195 #define subtag_vectorH NODE_SUBTAG(21)
    196 #define subtag_arrayH NODE_SUBTAG(20)
    197 #define subtag_simple_vector NODE_SUBTAG(22)    /*  Only one such subtag) */
    198 #define min_vector_subtag subtag_vectorH
    199 #define min_array_subtag subtag_arrayH
    200 
    201 /*  So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag)) */
    202 /*  for various immediate/node object types. */
    203 
    204 #define subtag_macptr IMM_SUBTAG(3)
    205 #define min_non_numeric_imm_subtag subtag_macptr
    206 
    207 #define subtag_dead_macptr IMM_SUBTAG(4)
    208 #define subtag_code_vector IMM_SUBTAG(5)
    209 #define subtag_creole IMM_SUBTAG(6)
    210 
    211 #define max_non_array_imm_subtag ((19<<ntagbits)|fulltag_immheader)
    212 
    213 #define subtag_catch_frame NODE_SUBTAG(4)
    214 #define subtag_function NODE_SUBTAG(5)
    215 #define subtag_sgbuf NODE_SUBTAG(6)
    216 #define subtag_symbol NODE_SUBTAG(7)
    217 #define subtag_lock NODE_SUBTAG(8)
    218 #define subtag_hash_vector NODE_SUBTAG(9)
    219 #define subtag_pool NODE_SUBTAG(10)
    220 #define subtag_weak NODE_SUBTAG(11)
    221 #define subtag_package NODE_SUBTAG(12)
    222 #define subtag_mark NODE_SUBTAG(13)
    223 #define subtag_instance NODE_SUBTAG(14)
    224 #define subtag_struct NODE_SUBTAG(15)
    225 #define subtag_istruct NODE_SUBTAG(16)
    226 #define max_non_array_node_subtag ((19<<ntagbits)|fulltag_immheader)
    227        
    228 /*  The objects themselves look something like this: */
    229 
    230 typedef struct lispsymbol {
    231   LispObj header;
    232   LispObj pname;
    233   LispObj vcell;
    234   LispObj fcell;
    235   LispObj package_plist;
    236   LispObj flags;
    237 } lispsymbol;
    238 
    239 typedef struct ratio {
    240   LispObj header;
    241   LispObj numer;
    242   LispObj denom;
    243 } ratio;
    244 
    245 typedef struct double_float {
    246   LispObj header;
    247   LispObj pad;
    248   LispObj value_high;
    249   LispObj value_low;
    250 } double_float;
    251 
    252 typedef struct single_float {
    253   LispObj header;
    254   LispObj value;
    255 } single_float;
    256 
    257 typedef struct macptr {
    258   LispObj header;
    259   LispObj address;
    260   LispObj class;
    261   LispObj type;
    262 } macptr;
    263 
    264 typedef struct xmacptr {
    265   LispObj header;
    266   LispObj address;
    267   LispObj class;
    268   LispObj type;
    269   LispObj flags;
    270   LispObj link;
    271 } xmacptr;
    272  
    273 
    274 typedef struct eabi_c_frame {
    275   struct eabi_c_frame *backlink;
    276   unsigned savelr;
    277   unsigned params[8];
    278 } eabi_c_frame;
    279 
    280 /* PowerOpen ABI C frame */
    281 
    282 typedef struct c_frame {
    283   struct c_frame *backlink;
    284   unsigned crsave;
    285   unsigned savelr;
    286   unsigned unused[2];
    287   unsigned savetoc;             /* Used with CFM */
    288   unsigned params[8];           /* Space for callee to save r3-r10 */
    289 } c_frame;
    290 
    291 typedef struct lisp_frame {
    292   struct lisp_frame *backlink;
    293   LispObj savefn;
    294   LispObj savelr;
    295   LispObj savevsp;
    296 } lisp_frame;
    297 
    298 typedef struct special_binding {
    299   struct special_binding *link;
    300   struct lispsymbol *sym;
    301   LispObj value;
    302 } special_binding;
    303 
    304 /* The GC (at least) needs to know what a
    305    package looks like, so that it can do GCTWA. */
    306 typedef struct package {
    307   LispObj header;
    308   LispObj itab;                 /* itab and etab look like (vector (fixnum . fixnum) */
    309   LispObj etab;
    310   LispObj used;
    311   LispObj used_by;
    312   LispObj names;
    313   LispObj shadowed;
    314 } package;
    315 
    316 /*
    317   The GC also needs to know what a catch_frame looks like.
    318 */
    319 
    320 typedef struct catch_frame {
    321   LispObj header;
    322   LispObj catch_tag;
    323   LispObj link;
    324   LispObj mvflag;
    325   LispObj csp;
    326   LispObj db_link;
    327   LispObj regs[8];
    328   LispObj xframe;
    329   LispObj tsp_segment;
    330 } catch_frame;
    331 
    332 #define catch_frame_element_count ((sizeof(catch_frame)/sizeof(LispObj))-1)
    333 #define catch_frame_header make_header(subtag_catch_frame,catch_frame_element_count)
    334 
    335 #define unbound SUBTAG(fulltag_imm, 6)
    336 #define undefined unbound
    337 #define subtag_character SUBTAG(fulltag_imm, 9)
    338 #define no_thread_local_binding_marker SUBTAG(fulltag_imm,30)
    339 
    340 /*
    341   All exception frames in a thread are linked together
    342   */
    343 typedef struct xframe_list {
    344   ExceptionInformationPowerPC *curr;
    345   struct xframe_list *prev;
    346 } xframe_list;
    347 
    348 #define fixnum_bitmask(n)  (1<<((n)+fixnumshift))
    349 
    350 /*
    351   The GC (at least) needs to know about hash-table-vectors and their flag bits.
    352 */
    353 
    354 typedef struct hash_table_vector_header {
    355   LispObj header;
    356   LispObj link;                 /* If weak */
    357   LispObj flags;                /* a fixnum; see below */
    358   LispObj free_alist;           /* preallocated conses for finalization_alist */
    359   LispObj finalization_alist;   /* key/value alist for finalization */
    360   LispObj weak_deletions_count; /* incremented when GC deletes weak pair */
    361   LispObj hash;                 /* backpointer to hash-table */
    362   LispObj deleted_count;        /* number of deleted entries */
    363   LispObj cache_idx;            /* index of last cached pair */
    364   LispObj cache_key;            /* value of last cached key */
    365   LispObj cache_value;          /* last cached value */
    366 } hash_table_vector_header;
    367 
    368 /*
    369   Bits (masks)  in hash_table_vector.flags:
    370 */
    371 
    372 /* GC should track keys when addresses change */
    373 #define nhash_track_keys_mask fixnum_bitmask(28)
    374 
    375 /* GC should set when nhash_track_keys_bit & addresses change */
    376 #define nhash_key_moved_mask  fixnum_bitmask(27)
    377 
    378 /* weak on key or value (need new "weak both" encoding.) */
    379 #define nhash_weak_mask       fixnum_bitmask(12)
    380 
    381 /* weak on value */
    382 #define nhash_weak_value_mask fixnum_bitmask(11)
    383 
    384 /* finalizable */
    385 #define nhash_finalizable_mask fixnum_bitmask(10)
    386 
    387 
    388 /* Lfun bits */
    389 
    390 #define lfbits_nonnullenv_mask fixnum_bitmask(0)
    391 #define lfbits_keys_mask fixnum_bitmask(1)
    392 #define lfbits_restv_mask fixnum_bitmask(7)
    393 #define lfbits_optinit_mask fixnum_bitmask(14)
    394 #define lfbits_rest_mask fixnum_bitmask(15)
    395 #define lfbits_aok_mask fixnum_bitmask(16)
    396 #define lfbits_lap_mask fixnum_bitmask(23)
    397 #define lfbits_trampoline_mask fixnum_bitmask(24)
    398 #define lfbits_evaluated_mask fixnum_bitmask(25)
    399 #define lfbits_cm_mask fixnum_bitmask(26)         /* combined_method */
    400 #define lfbits_nextmeth_mask fixnum_bitmask(26)   /* or call_next_method with method_mask */
    401 #define lfbits_gfn_mask fixnum_bitmask(27)        /* generic_function */
    402 #define lfbits_nextmeth_with_args_mask fixnum_bitmask(27)   /* or call_next_method_with_args with method_mask */
    403 #define lfbits_method_mask fixnum_bitmask(28)     /* method function */
    404 /* PPC only but want it defined for xcompile */
    405 #define lfbits_noname_mask fixnum_bitmask(29)
    406 
    407 /*
    408   known values of an "extended" (gcable) macptr's flags word:
    409 */
    410 
    411 typedef enum {
    412   xmacptr_flag_none = 0,        /* Maybe already disposed by Lisp */
    413   xmacptr_flag_recursive_lock,  /* recursive-lock */
    414   xmacptr_flag_ptr,             /* malloc/free */
    415   xmacptr_flag_rwlock,          /* read/write lock */
    416   xmacptr_flag_semaphore        /* semaphore */
    417 } xmacptr_flag;
    418 
    419 /* Creole */
    420 
    421 #define doh_quantum 400
    422 #define doh_block_slots ((doh_quantum >> 2) - 3)
    423 
    424 typedef struct doh_block {
    425   struct doh_block *link;
    426   unsigned size;
    427   unsigned free;
    428   LispObj data[doh_block_slots];
    429 } doh_block, *doh_block_ptr;
    430 
    431 
    432 #define population_weak_list (0<<fixnum_shift)
    433 #define population_weak_alist (1<<fixnum_shift)
    434 #define population_termination_bit (16+fixnum_shift)
    435 #define population_type_mask ((1<<population_termination_bit)-1)
    436 
    437 #define gc_retain_pages_bit fixnum_bitmask(0)
    438 #define gc_integrity_check_bit fixnum_bitmask(2)
    439 #define gc_allow_stack_overflows_bit fixnum_bitmask(5)
    440 #define gc_postgc_pending fixnum_bitmask(26)
    441 
    442 #include "lisp-errors.h"
    443 
    444 #define BA_MASK ((unsigned) ((-1<<26) | (1<<1)))
    445 #define BA_VAL  ((unsigned) ((18<<26) | (1<<1)))
    446 
    447 
    44860/*
    44961  These were previously global variables.  There are lots of implicit
     
    45567#define log2_heap_segment_size 16
    45668
    457 #define nil_value 0x00002015
    458 
    459 typedef struct tcr {
    460   struct tcr *next;
    461   struct tcr *prev;
    462   union {
    463     double d;
    464     struct {unsigned h, l;} words;
    465   } lisp_fpscr;                 /* lisp thread's fpscr (in low word) */
    466   special_binding *db_link;     /* special binding chain head */
    467   LispObj catch_top;            /* top catch frame */
    468   LispObj *save_vsp;            /* VSP when in foreign code */
    469   LispObj *save_tsp;            /* TSP when in foreign code */
    470   struct area *cs_area;         /* cstack area pointer */
    471   struct area *vs_area;         /* vstack area pointer */
    472   struct area *ts_area;         /* tstack area pointer */
    473   LispObj cs_limit;             /* stack overflow limit */
    474   unsigned long long bytes_allocated;
    475   int interrupt_level;          /* for w-o-i preemption */
    476   int interrupt_pending;        /* likewise */
    477   xframe_list *xframe;          /* exception-frame linked list */
    478   int *errno_loc;               /* per-thread (?) errno location */
    479   LispObj ffi_exception;        /* fpscr bits from ff-call */
    480   LispObj osid;                 /* OS thread id */
    481   int valence;                  /* odd when in foreign code */
    482   int foreign_exception_status; /* non-zero -> call lisp_exit_hook */
    483   void *native_thread_info;     /* platform-dependent */
    484   void *native_thread_id;       /* mach_thread_t, pid_t, etc. */
    485   void *last_allocptr;
    486   void *save_allocptr;
    487   void *save_allocbase;
    488   void *reset_completion;
    489   void *activate;
    490   int suspend_count;
    491   ExceptionInformation *suspend_context;
    492   ExceptionInformation *pending_exception_context;
    493   void *suspend;                /* suspension semaphore */
    494   void *resume;                 /* resumption semaphore */
    495   int flags;
    496   ExceptionInformation *gc_context;
    497   int suspend_total;
    498   int suspend_total_on_exception_entry;
    499   unsigned tlb_limit;
    500   LispObj *tlb_pointer;
    501   unsigned shutdown_count;
    502 } TCR;
     69#define BA_MASK ((unsigned) ((-1<<26) | (1<<1)))
     70#define BA_VAL  ((unsigned) ((18<<26) | (1<<1)))
    50371
    50472#define TCR_FLAG_BIT_FOREIGN fixnumshift
     
    51179#define TCR_STATE_EXCEPTION_RETURN (4)
    51280
    513 #define memo_size (1 << 15)
     81#ifdef PPC64
     82#include "constants64.h"
     83#else
     84#include "constants32.h"
    51485#endif
    51586
     87#define dnode_size (node_size*2)
     88#define dnode_shift node_shift+1
     89
     90#endif
  • trunk/ccl/lisp-kernel/constants64.s

    r527 r557  
    9393/* There's some room for expansion in non-array ivector space. */
    9494define_subtag(bignum,ivector_class_64_bit,0)
    95 define_subtag(macptr,ivector_class_64_bit,1)
    96 define_subtag(dead_macptr,ivector_class_64_bit,2)
    9795define_subtag(double_float,ivector_class_64_bit,3)
     96define_subtag(macptr,ivector_class_64_bit,5)
     97define_subtag(dead_macptr,ivector_class_64_bit,6)
    9898define_subtag(code_vector,ivector_class_32_bit,0)
    9999define_subtag(xcode_vector,ivector_class_32_bit,1)
    100100
    101 ;; Size doesn't matter for non-CL-array gvectors; I can't think of a good
    102 ;; reason to classify them in any particular way.  Let's put funcallable
    103 ;; things in the first slice by themselves, though it's not clear that
    104 ;; that helps FUNCALL much.
     101
     102
     103       
     104/*       
     105 Size doesn't matter for non-CL-array gvectors; I can't think of a good
     106 reason to classify them in any particular way.  Let's put funcallable
     107 things in the first slice by themselves, though it's not clear that
     108 that helps FUNCALL much.
     109*/       
    105110gvector_funcallable = fulltag_nodeheader_0
    106111       
     
    134139
    135140define_subtag(single_float,fulltag_imm_0,0)
    136 define_subtag(slot_unbound,fulltag_imm_0,1)
    137 slot_unbound_marker = subtag_slot_unbound
    138 define_subtag(illegal,fulltag_imm_0,2)
    139 illegal_marker = subtag_illegal
    140141
    141142define_subtag(go_tag,fulltag_imm_1,0)
    142143define_subtag(block_tag,fulltag_imm_1,1)
     144
    143145define_subtag(character,fulltag_imm_2,0)
     146                       
    144147define_subtag(unbound,fulltag_imm_3,0)
    145148unbound_marker = subtag_unbound
    146149undefined = unbound_marker
    147 define_subtag(no_thread_local_binding,fulltag_imm_3,1)
     150define_subtag(slot_unbound,fulltag_imm_3,1)
     151slot_unbound_marker = subtag_slot_unbound
     152define_subtag(illegal,fulltag_imm_3,2)
     153illegal_marker = subtag_illegal
     154define_subtag(no_thread_local_binding,fulltag_imm_3,3)
     155no_thread_local_binding_marker = subtag_no_thread_local_binding       
    148156
    149157       
  • trunk/ccl/lisp-kernel/darwin/.gdb_history

    r6 r557  
    2525x/i _SPfuncall
    2626quit
     27x/i wait_for_exception_lock_in_handler
     28break *wait_for_exception_lock_in_handler
     29run
     30stepi
     31x/x $r2
     32kill
     33quit
  • trunk/ccl/lisp-kernel/darwin/Makefile

    r523 r557  
    5252CDEFINES = -DDARWIN $(BROKEN_PREPROCESSOR_WORKAROUND) -DOPENMCL_MAJOR_VERSION=$(OPENMCL_MAJOR_VERSION) -DOPENMCL_MINOR_VERSION=$(OPENMCL_MINOR_VERSION)
    5353CDEBUG = -g
    54 COPT = -O2
     54COPT = #-O2
    5555
    5656.s.o:
  • trunk/ccl/lisp-kernel/gc.c

    r54 r557  
    4747  area *a = (area *) (zalloc(sizeof(area)));
    4848  if (a) {
    49     unsigned ndwords = area_dword(highaddr, lowaddr);
     49    unsigned ndnodes = area_dnode(highaddr, lowaddr);
    5050    a->low = lowaddr;
    5151    a->high = highaddr;
    5252    a->active = (code == AREA_DYNAMIC) ? lowaddr : highaddr;
    5353    a->code = code;
    54     a->ndwords = ndwords;
     54    a->ndnodes = ndnodes;
    5555    /* Caller must allocate markbits when allocating heap ! */
    5656   
     
    183183  case fulltag_even_fixnum:
    184184  case fulltag_odd_fixnum:
     185#ifdef PPC64
     186  case fulltag_imm_0:
     187  case fulltag_imm_1:
     188  case fulltag_imm_2:
     189  case fulltag_imm_3:
     190#else
    185191  case fulltag_imm:
     192#endif
    186193    return;
    187194
     195#ifndef PPC64
    188196  case fulltag_nil:
    189197    if (n != lisp_nil) {
     
    191199    }
    192200    return;
    193 
     201#endif
     202
     203#ifdef PPC64
     204  case fulltag_nodeheader_0:
     205  case fulltag_nodeheader_1:
     206  case fulltag_nodeheader_2:
     207  case fulltag_nodeheader_3:
     208  case fulltag_immheader_0:
     209  case fulltag_immheader_1:
     210  case fulltag_immheader_2:
     211  case fulltag_immheader_3:
     212#else
    194213  case fulltag_nodeheader:
    195214  case fulltag_immheader:
     215#endif
    196216    Bug(NULL, "Header not expected : 0x%08x", n);
    197217    return;
     
    199219  case fulltag_misc:
    200220  case fulltag_cons:
    201     a = heap_area_containing((BytePtr)n);
     221    a = heap_area_containing((BytePtr)ptr_from_lispobj(n));
    202222   
    203223    if (a == NULL) {
     
    207227         bad .. */
    208228      a = active_dynamic_area;
    209       if ((n > ((LispObj)a->active)) &&
    210           (n < ((LispObj)a->high))) {
     229      if ((n > (ptr_to_lispobj(a->active))) &&
     230          (n < (ptr_to_lispobj(a->high)))) {
    211231        Bug(NULL, "Node points to heap free space: 0x%08x", n);
    212232      }
     
    219239  header_tag = fulltag_of(header);
    220240  if (tag == fulltag_cons) {
    221     if ((header_tag == fulltag_nodeheader) ||
    222         (header_tag == fulltag_immheader)) {
     241    if ((nodeheader_tag_p(header_tag)) ||
     242        (immheader_tag_p(header_tag))) {
    223243      Bug(NULL, "Cons cell at 0x%08x has bogus header : 0x%08x", n, header);
    224244    }
     
    226246  }
    227247
    228   if ((header_tag != fulltag_nodeheader) &&
    229       (header_tag != fulltag_immheader)) {
     248  if ((!nodeheader_tag_p(header_tag)) &&
     249      (!immheader_tag_p(header_tag))) {
    230250    Bug(NULL,"Vector at 0x%08x has bogus header : 0x%08x", n, header);
    231251  }
     
    244264    node = *current++;
    245265    tag = fulltag_of(node);
    246     if (tag == fulltag_immheader) {
     266    if (immheader_tag_p(tag)) {
    247267      current = (LispObj *)skip_over_ivector((unsigned)prev, node);
    248     } else if (tag == fulltag_nodeheader) {
     268    } else if (nodeheader_tag_p(tag)) {
    249269      elements = header_element_count(node) | 1;
    250270      while (elements--) {
     
    299319             end != limit;
    300320             current = next) {
    301           next = (LispObj *) *current;
     321          next = ptr_from_lispobj(*current);
    302322          end = ((next >= start) && (next < limit)) ? next : limit;
    303323          if (current[1] == 0) {
     
    332352    }
    333353   
    334     if (tag == fulltag_immheader) {
    335       q = (LispObj *)skip_over_ivector((LispObj)p, header);
     354    if (immheader_tag_p(tag)) {
     355      q = (LispObj *)skip_over_ivector(ptr_to_lispobj(p), header);
    336356      if (q >= nextpage) {
    337357        bucket->halfword = 0;
    338358        return q;
    339359      }
    340     } else if (tag == fulltag_nodeheader) {
     360    } else if (nodeheader_tag_p(tag)) {
    341361      q = p + ((2 + header_element_count(header)) & ~1);
    342362      if (p >= page) {
     
    376396  LispObj *p, *page = (LispObj *)truncate_to_power_of_2(start,12);
    377397  pageentry
    378     *buckets = pagemap + (((LispObj)page - lisp_global(HEAP_START)) >> 12);
     398    *buckets = pagemap + (((ptr_to_lispobj(page)) - lisp_global(HEAP_START)) >> 12);
    379399
    380400  if (start != page) {
     
    398418                        LispObj *end,
    399419                        LispObj ephemeral_start,
    400                         unsigned long ephemeral_dwords)
     420                        unsigned long ephemeral_dnodes)
    401421{
    402422  LispObj node, oldspacestart = lisp_global(HEAP_START);
     
    407427    node = *start;
    408428    tag = fulltag_of(node);
    409     if (tag == fulltag_immheader) {     /* An ivector */
    410       start = (LispObj *)skip_over_ivector((LispObj)start, node);
     429    if (immheader_tag_p(tag)) { /* An ivector */
     430      start = ptr_from_lispobj(skip_over_ivector(ptr_to_lispobj(start), node));
    411431    } else {
    412432      if ((header_subtag(node) == subtag_hash_vector) ||
     
    414434             least if we have to track key movement */
    415435          (((tag == fulltag_cons) || (tag == fulltag_misc)) &&
    416            (area_dword(node, ephemeral_start) < ephemeral_dwords))) {
     436           (area_dnode(node, ephemeral_start) < ephemeral_dnodes))) {
    417437        /* Tagged pointer to (some) younger generation; update refmap */
    418         set_bit(refbits,area_dword(start, oldspacestart));
     438        set_bit(refbits,area_dnode(start, oldspacestart));
    419439      } else {
    420440        node = start[1];
    421441        tag = fulltag_of(node);
    422442        if (((tag == fulltag_cons) || (tag == fulltag_misc)) &&
    423             (area_dword(node, ephemeral_start) < ephemeral_dwords)) {
    424           set_bit(refbits,area_dword(start, oldspacestart));
     443            (area_dnode(node, ephemeral_start) < ephemeral_dnodes)) {
     444          set_bit(refbits,area_dnode(start, oldspacestart));
    425445        }
    426446      }
     
    434454                       LispObj *page,
    435455                       LispObj ephemeral_start,
    436                        unsigned ephemeral_dwords)
     456                       unsigned ephemeral_dnodes)
    437457{
    438458  LispObj *start;
     
    441461      start = page + bucket->bits.offset;
    442462      update_refmap_for_range(start,
    443                               (LispObj *) align_to_power_of_2((LispObj)start+1,12),
     463                              (LispObj *) align_to_power_of_2(ptr_to_lispobj(start+1),12),
    444464                              ephemeral_start,
    445                               ephemeral_dwords);
     465                              ephemeral_dnodes);
    446466    }
    447467  }
     
    452472update_refmap_for_area(area *a, BytePtr curfree)
    453473{
    454   if (a->ndwords) {
     474  if (a->ndnodes) {
    455475    LispObj
    456476      *start = (LispObj *) a->low,
     
    458478      *last_whole_page_end = (LispObj *) truncate_to_power_of_2(limit,12),
    459479      *first_partial_page_start = (LispObj *) truncate_to_power_of_2(start,12);
    460     pageentry *p = pagemap + ((LispObj)start - lisp_global(HEAP_START) >> 12);
    461     unsigned younger_dwords = area_dword((LispObj)curfree,(LispObj)limit);
     480    pageentry *p = pagemap + (ptr_to_lispobj(start) - lisp_global(HEAP_START) >> 12);
     481    unsigned younger_dnodes = area_dnode(ptr_to_lispobj(curfree),ptr_to_lispobj(limit));
    462482   
    463483    if (last_whole_page_end == first_partial_page_start) {
    464484      if (p->bits.modified && p->bits.hasnode) {
    465         update_refmap_for_range(start,limit,(LispObj)limit,younger_dwords);
     485        update_refmap_for_range(start,limit,ptr_to_lispobj(limit),younger_dnodes);
    466486      }
    467487    } else {
     
    470490          *page_end = first_partial_page_start + (4096 / sizeof(LispObj *));
    471491        if (p->bits.modified && p->bits.hasnode) {
    472           update_refmap_for_range(start,page_end,(LispObj)limit,younger_dwords);
     492          update_refmap_for_range(start,page_end,ptr_to_lispobj(limit),younger_dnodes);
    473493        }
    474494        start = page_end;
     
    478498           start < last_whole_page_end;
    479499           start += (4096 / sizeof(LispObj *)), p++) {
    480         update_refmap_for_page(p,start,(LispObj)limit,younger_dwords);
     500        update_refmap_for_page(p,start,ptr_to_lispobj(limit),younger_dnodes);
    481501      }
    482502      if (start < limit) {
    483503        if (p->bits.modified && p->bits.hasnode) {
    484           update_refmap_for_range(start+p->bits.offset,limit,(LispObj)limit,younger_dwords);
     504          update_refmap_for_range(start+p->bits.offset,limit,ptr_to_lispobj(limit),younger_dnodes);
    485505        }
    486506      }
     
    523543    tenured_low = tenured_area->low;
    524544  unsigned
    525     dynamic_dwords = area_dword(curfree, a->low),
    526     new_tenured_dwords = area_dword(curfree, tenured_area->low);
     545    dynamic_dnodes = area_dnode(curfree, a->low),
     546    new_tenured_dnodes = area_dnode(curfree, tenured_area->low);
    527547  bitvector
    528548    refbits = tenured_area->refbits,
     
    531551
    532552  target->high = target->active = curfree;
    533   target->ndwords = area_dword(curfree, target_low);
     553  target->ndnodes = area_dnode(curfree, target_low);
    534554
    535555  for (child = target->younger; child != a; child = child->younger) {
    536556    child->high = child->low = child->active = curfree;
    537     child->ndwords = 0;
     557    child->ndnodes = 0;
    538558  }
    539559
    540560  a->low = curfree;
    541   a->ndwords = area_dword(a->high, curfree);
    542 
    543   new_markbits = refbits + ((new_tenured_dwords + 31) >> 5);
     561  a->ndnodes = area_dnode(a->high, curfree);
     562
     563  new_markbits = refbits + ((new_tenured_dnodes + 31) >> 5);
    544564 
    545565  if (target == tenured_area) {
    546     zero_bits(refbits, new_tenured_dwords);
    547     lisp_global(OLDEST_EPHEMERAL) = (LispObj) curfree;
     566    zero_bits(refbits, new_tenured_dnodes);
     567    lisp_global(OLDEST_EPHEMERAL) = ptr_to_lispobj(curfree);
    548568  } else {
    549569    /* Need more (zeroed) refbits & fewer markbits */
     
    572592    area *a = active_dynamic_area, *child;
    573593    BytePtr curlow = from->low;
    574     unsigned new_tenured_dwords = area_dword(curlow, tenured_area->low);
     594    unsigned new_tenured_dnodes = area_dnode(curlow, tenured_area->low);
    575595   
    576596    for (child = from; child != a; child = child->younger) {
    577597      child->low = child->active = child->high = curlow;
    578       child->ndwords = 0;
     598      child->ndnodes = 0;
    579599    }
    580600   
    581601    a->low = curlow;
    582     a->ndwords = area_dword(a->high, curlow);
     602    a->ndnodes = area_dnode(a->high, curlow);
    583603   
    584     a->markbits = (tenured_area->refbits) + ((new_tenured_dwords+31)>>5);
     604    a->markbits = (tenured_area->refbits) + ((new_tenured_dnodes+31)>>5);
    585605    if (from == tenured_area) {
    586606      /* Everything's in the dynamic area */
     
    602622    }
    603623    if (activate) {
    604       LispObj *heap_start = (LispObj *)lisp_global(HEAP_START);
     624      LispObj *heap_start = ptr_from_lispobj(lisp_global(HEAP_START));
    605625
    606626      a->older = g1_area;
     
    709729bitvector GCmarkbits = NULL;
    710730LispObj GCarealow;
    711 unsigned GCndwords_in_area;
     731unsigned GCndnodes_in_area;
    712732LispObj GCweakvll = (LispObj)NULL;
    713733LispObj GCephemeral_low;
    714 unsigned GCn_ephemeral_dwords;
     734unsigned GCn_ephemeral_dnodes;
    715735
    716736
     
    722742{
    723743  int tag_n = fulltag_of(n);
    724   unsigned dword, bits, *bitsp, mask;
     744  unsigned dnode, bits, *bitsp, mask;
    725745
    726746  if (!is_node_fulltag(tag_n)) {
     
    728748  }
    729749
    730   dword = gc_area_dword(n);
    731   if (dword >= GCndwords_in_area) {
     750  dnode = gc_area_dnode(n);
     751  if (dnode >= GCndnodes_in_area) {
    732752    return;
    733753  }
    734   set_bits_vars(GCmarkbits,dword,bitsp,bits,mask);
     754  set_bits_vars(GCmarkbits,dnode,bitsp,bits,mask);
    735755  if (bits & mask) {
    736756    return;
     
    739759
    740760  if (tag_n == fulltag_cons) {
    741     cons *c = (cons *) untag(n);
     761    cons *c = (cons *) ptr_from_lispobj(untag(n));
    742762    rmark(c->car);
    743763    rmark(c->cdr);
     
    745765  }
    746766  {
    747     LispObj *base = (LispObj *) untag(n);
    748     unsigned
    749       header = *((unsigned *) base),
     767    LispObj *base = (LispObj *) ptr_from_lispobj(untag(n));
     768    natural
     769      header = *((natural *) base),
    750770      subtag = header_subtag(header),
    751771      element_count = header_element_count(header),
    752772      total_size_in_bytes,      /* including 4-byte header */
    753       suffix_dwords;
     773      suffix_dnodes;
    754774
    755775    tag_n = fulltag_of(header);
    756776
     777#ifdef PPC64
     778    if ((nodeheader_tag_p(tag_n)) ||
     779        (tag_n == ivector_class_64_bit)) {
     780      total_size_in_bytes = 8 + (element_count<<3);
     781    } else if (tag_n == ivector_class_8_bit) {
     782      total_size_in_bytes = 8 + element_count;
     783    } else if (tag_n == ivector_class_32_bit) {
     784      total_size_in_bytes = 8 + (element_count<<2);
     785    } else {
     786      /* ivector_class_other_bit contains 16-bit arrays & bitvector */
     787      if (subtag == subtag_bit_vector) {
     788        total_size_in_bytes = 8 + ((element_count+7)>>3);
     789      } else {
     790        total_size_in_bytes = 8 + (element_count<<1);
     791      }
     792    }
     793#else
    757794    if ((tag_n == fulltag_nodeheader) ||
    758795        (subtag <= max_32_bit_ivector_subtag)) {
     
    767804      total_size_in_bytes = 4 + ((element_count+7)>>3);
    768805    }
    769     suffix_dwords = ((total_size_in_bytes+7)>>3) -1;
    770 
    771     if (suffix_dwords) {
    772       set_n_bits(GCmarkbits, dword+1, suffix_dwords);
    773     }
    774 
    775     if (tag_n == fulltag_nodeheader) {
     806#endif
     807    suffix_dnodes = ((total_size_in_bytes+(dnode_size-1))>>dnode_shift) -1;
     808
     809    if (suffix_dnodes) {
     810      set_n_bits(GCmarkbits, dnode+1, suffix_dnodes);
     811    }
     812
     813    if (nodeheader_tag_p(tag_n)) {
    776814      if (subtag == subtag_hash_vector) {
    777815        ((hash_table_vector_header *) base)->cache_key = undefined;
     
    820858{
    821859  int tag_n = fulltag_of(n);
    822   unsigned eph_dword;
    823 
    824   if (tag_n == fulltag_nodeheader) {
     860  unsigned eph_dnode;
     861
     862  if (nodeheader_tag_p(tag_n)) {
    825863    return (header_subtag(n) == subtag_hash_vector);
    826864  }
     
    828866  if ((tag_n == fulltag_cons) ||
    829867      (tag_n == fulltag_misc)) {
    830     eph_dword = area_dword(n, GCephemeral_low);
    831     if (eph_dword < GCn_ephemeral_dwords) {
     868    eph_dnode = area_dnode(n, GCephemeral_low);
     869    if (eph_dnode < GCn_ephemeral_dnodes) {
    832870      mark_root(n);             /* May or may not mark it */
    833871      return true;              /* but return true 'cause it's an ephemeral node */
     
    855893    mark_root(pc);
    856894  } else {
    857     unsigned dword = gc_area_dword(pc);
    858     if ((dword < GCndwords_in_area) &&
    859         !ref_bit(GCmarkbits,dword)) {
     895    natural dnode = gc_area_dnode(pc);
     896    if ((dnode < GCndnodes_in_area) &&
     897        !ref_bit(GCmarkbits,dnode)) {
    860898      LispObj
    861899        *headerP,
    862900        header;
    863901
    864       for(headerP = (LispObj*)(untag(pc));
    865           dword < GCndwords_in_area;
    866           headerP-=2, --dword) {
     902      for(headerP = (LispObj*)ptr_from_lispobj(untag(pc));
     903          dnode < GCndnodes_in_area;
     904          headerP-=2, --dnode) {
    867905        header = *headerP;
    868906
    869907        if ((header & code_header_mask) == subtag_code_vector) {
    870           set_n_bits(GCmarkbits, dword, (2+header_element_count(header))>>1);
     908          set_n_bits(GCmarkbits, dnode, (2+header_element_count(header))>>1);
    871909          return;
    872910        }
     
    892930  int tag_n = fulltag_of(n);
    893931  bitvector markbits = GCmarkbits;
    894   unsigned dword, bits, *bitsp, mask;
     932  unsigned dnode, bits, *bitsp, mask;
    895933
    896934  if (!is_node_fulltag(tag_n)) {
     
    898936  }
    899937
    900   dword = gc_area_dword(n);
    901   if (dword >= GCndwords_in_area) {
     938  dnode = gc_area_dnode(n);
     939  if (dnode >= GCndnodes_in_area) {
    902940    return;
    903941  }
    904   set_bits_vars(markbits,dword,bitsp,bits,mask);
     942  set_bits_vars(markbits,dnode,bitsp,bits,mask);
    905943  if (bits & mask) {
    906944    return;
     
    958996    tag_n = fulltag_of(next);
    959997    if (!is_node_fulltag(tag_n)) goto MarkCdr;
    960     dword = gc_area_dword(next);
    961     if (dword >= GCndwords_in_area) goto MarkCdr;
    962     set_bits_vars(markbits,dword,bitsp,bits,mask);
     998    dnode = gc_area_dnode(next);
     999    if (dnode >= GCndnodes_in_area) goto MarkCdr;
     1000    set_bits_vars(markbits,dnode,bitsp,bits,mask);
    9631001    if (bits & mask) goto MarkCdr;
    9641002    *bitsp = (bits | mask);
     
    9761014    tag_n = fulltag_of(next);
    9771015    if (!is_node_fulltag(tag_n)) goto Climb;
    978     dword = gc_area_dword(next);
    979     if (dword >= GCndwords_in_area) goto Climb;
    980     set_bits_vars(markbits,dword,bitsp,bits,mask);
     1016    dnode = gc_area_dnode(next);
     1017    if (dnode >= GCndnodes_in_area) goto Climb;
     1018    set_bits_vars(markbits,dnode,bitsp,bits,mask);
    9811019    if (bits & mask) goto Climb;
    9821020    *bitsp = (bits | mask);
     
    9911029  MarkVector:
    9921030    {
    993       LispObj *base = (LispObj *) untag(this);
    994       unsigned
    995         header = *((unsigned *) base),
    996       subtag = header_subtag(header),
    997       element_count = header_element_count(header),
    998       total_size_in_bytes,
    999       suffix_dwords;
     1031      LispObj *base = (LispObj *) ptr_from_lispobj(untag(this));
     1032      natural
     1033        header = *((natural *) base),
     1034        subtag = header_subtag(header),
     1035        element_count = header_element_count(header),
     1036        total_size_in_bytes,
     1037        suffix_dnodes;
    10001038
    10011039      tag_n = fulltag_of(header);
    10021040
     1041#ifdef PPC64
     1042    if ((nodeheader_tag_p(tag_n)) ||
     1043        (tag_n == ivector_class_64_bit)) {
     1044      total_size_in_bytes = 8 + (element_count<<3);
     1045    } else if (tag_n == ivector_class_8_bit) {
     1046      total_size_in_bytes = 8 + element_count;
     1047    } else if (tag_n == ivector_class_32_bit) {
     1048      total_size_in_bytes = 8 + (element_count<<2);
     1049    } else {
     1050      /* ivector_class_other_bit contains 16-bit arrays & bitvector */
     1051      if (subtag == subtag_bit_vector) {
     1052        total_size_in_bytes = 8 + ((element_count+7)>>3);
     1053      } else {
     1054        total_size_in_bytes = 8 + (element_count<<1);
     1055      }
     1056    }
     1057#else
    10031058      if ((tag_n == fulltag_nodeheader) ||
    10041059          (subtag <= max_32_bit_ivector_subtag)) {
     
    10131068        total_size_in_bytes = 4 + ((element_count+7)>>3);
    10141069      }
    1015       suffix_dwords = ((total_size_in_bytes+7)>>3)-1;
    1016 
    1017       if (suffix_dwords) {
    1018         set_n_bits(GCmarkbits, dword+1, suffix_dwords);
    1019       }
    1020 
    1021       if (tag_n != fulltag_nodeheader) goto Climb;
     1070#endif
     1071      suffix_dnodes = ((total_size_in_bytes+(dnode_size-1))>>dnode_shift)-1;
     1072
     1073      if (suffix_dnodes) {
     1074        set_n_bits(GCmarkbits, dnode+1, suffix_dnodes);
     1075      }
     1076
     1077      if (!nodeheader_tag_p(tag_n)) goto Climb;
    10221078
    10231079      if (subtag == subtag_hash_vector) {
     
    10421098      }
    10431099
    1044       this = untag(this) + ((element_count+1) << 2);
     1100      this = untag(this) + ((element_count+1) << node_shift);
    10451101      goto MarkVectorLoop;
    10461102    }
    10471103
    10481104  ClimbVector:
    1049     prev = *((LispObj *) this);
    1050     *((LispObj *) this) = next;
     1105    prev = *((LispObj *) ptr_from_lispobj(this));
     1106    *((LispObj *) ptr_from_lispobj(this)) = next;
    10511107
    10521108  MarkVectorLoop:
    1053     this -= 4;
    1054     next = *((LispObj *) this);
     1109    this -= node_size;
     1110    next = *((LispObj *) ptr_from_lispobj(this));
    10551111    tag_n = fulltag_of(next);
    1056     if (tag_n == fulltag_nodeheader) goto MarkVectorDone;
     1112    if (nodeheader_tag_p(tag_n)) goto MarkVectorDone;
    10571113    if (!is_node_fulltag(tag_n)) goto MarkVectorLoop;
    1058     dword = gc_area_dword(next);
    1059     if (dword >= GCndwords_in_area) goto MarkVectorLoop;
    1060     set_bits_vars(markbits,dword,bitsp,bits,mask);
     1114    dnode = gc_area_dnode(next);
     1115    if (dnode >= GCndnodes_in_area) goto MarkVectorLoop;
     1116    set_bits_vars(markbits,dnode,bitsp,bits,mask);
    10611117    if (bits & mask) goto MarkVectorLoop;
    10621118    *bitsp = (bits | mask);
    1063     *((LispObj *) this) = prev;
     1119    *(ptr_from_lispobj(this)) = prev;
    10641120    if (tag_n == fulltag_cons) goto DescendCons;
    10651121    goto DescendVector;
     
    10781134}
    10791135
    1080 unsigned
    1081 skip_over_ivector(unsigned start, LispObj header)
    1082 {
    1083   unsigned
     1136LispObj *
     1137skip_over_ivector(natural start, LispObj header)
     1138{
     1139  natural
    10841140    element_count = header_element_count(header),
    10851141    subtag = header_subtag(header),
    10861142    nbytes;
    10871143
     1144#ifdef PPC64
     1145  switch (fulltag_of(header)) {
     1146  case ivector_class_64_bit:
     1147    nbytes = element_count << 3;
     1148    break;
     1149  case ivector_class_32_bit:
     1150    nbytes = element_count << 2;
     1151    break;
     1152  case ivector_class_8_bit:
     1153    nbytes = element_count;
     1154    break;
     1155  case ivector_class_other_bit:
     1156  default:
     1157    if (subtag == subtag_bit_vector) {
     1158      nbytes = (element_count+7)>>3;
     1159    } else {
     1160      nbytes = element_count << 1;
     1161    }
     1162  }
     1163  return ptr_from_lispobj(start+(~15 & (nbytes + 8 + 15)));
     1164#else
    10881165  if (subtag <= max_32_bit_ivector_subtag) {
    10891166    nbytes = element_count << 2;
     
    10971174    nbytes = (element_count+7) >> 3;
    10981175  }
    1099   return start+(~7 & (nbytes + 4 + 7));
     1176  return ptr_from_lispobj(start+(~7 & (nbytes + 4 + 7)));
     1177#endif
    11001178}
    11011179
     
    11061184  LispObj x1, *base = start;
    11071185  int tag;
    1108   unsigned ref_dword, node_dword;
     1186  natural ref_dnode, node_dnode;
    11091187  Boolean intergen_ref;
    11101188
    11111189  while (start < end) {
    11121190    x1 = *start;
    1113     if ((tag = fulltag_of(x1)) == fulltag_immheader) {
    1114       start = (LispObj *)skip_over_ivector((unsigned) start, x1);
     1191    tag = fulltag_of(x1);
     1192    if (immheader_tag_p(tag)) {
     1193      start = skip_over_ivector(ptr_to_lispobj(start), x1);
    11151194    } else {
    11161195      intergen_ref = false;
    11171196      if ((tag == fulltag_misc) || (tag == fulltag_cons)) {       
    1118         node_dword = gc_area_dword(x1);
    1119         if (node_dword < GCndwords_in_area) {
     1197        node_dnode = gc_area_dnode(x1);
     1198        if (node_dnode < GCndnodes_in_area) {
    11201199          intergen_ref = true;
    11211200        }
     
    11251204        tag = fulltag_of(x1);
    11261205        if ((tag == fulltag_misc) || (tag == fulltag_cons)) {
    1127           node_dword = gc_area_dword(x1);
    1128           if (node_dword < GCndwords_in_area) {
     1206          node_dnode = gc_area_dnode(x1);
     1207          if (node_dnode < GCndnodes_in_area) {
    11291208            intergen_ref = true;
    11301209          }
     
    11321211      }
    11331212      if (intergen_ref) {
    1134         ref_dword = area_dword(start, base);
    1135         if (!ref_bit(refbits, ref_dword)) {
     1213        ref_dnode = area_dnode(start, base);
     1214        if (!ref_bit(refbits, ref_dnode)) {
    11361215          Bug(NULL, "Missing memoization in doubleword at 0x%08X", start);
    1137           set_bit(refbits, ref_dword);
     1216          set_bit(refbits, ref_dnode);
    11381217        }
    11391218      }
     
    11461225
    11471226void
    1148 mark_memoized_area(area *a, unsigned num_memo_dwords)
     1227mark_memoized_area(area *a, unsigned num_memo_dnodes)
    11491228{
    11501229  bitvector refbits = a->refbits;
    11511230  LispObj *p = (LispObj *) a->low, x1, x2;
    1152   unsigned inbits, outbits, bits, bitidx, *bitsp, nextbit, diff, memo_dword = 0;
     1231  unsigned inbits, outbits, bits, bitidx, *bitsp, nextbit, diff, memo_dnode = 0;
    11531232  Boolean keep_x1, keep_x2;
    11541233
    11551234  if (GCDebug) {
    1156     check_refmap_consistency(p, p+(num_memo_dwords << 1), refbits);
     1235    check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits);
    11571236  }
    11581237
     
    11701249
    11711250  /*
    1172     We need to ensure that there are no bits set at or beyond "num_memo_dwords"
     1251    We need to ensure that there are no bits set at or beyond "num_memo_dnodes"
    11731252    in the bitvector.  (This can happen as the EGC tenures/untenures things.)
    11741253    We find bits by grabbing a fullword at a time and doing a cntlzw instruction;
    1175     and don't want to have to check for (< memo_dword num_memo_dwords) in the loop.
     1254    and don't want to have to check for (< memo_dnode num_memo_dnodes) in the loop.
    11761255    */
    11771256
    11781257  {
    11791258    unsigned
    1180       bits_in_last_word = (num_memo_dwords & 0x1f),
    1181       index_of_last_word = (num_memo_dwords >> 5);
     1259      bits_in_last_word = (num_memo_dnodes & 0x1f),
     1260      index_of_last_word = (num_memo_dnodes >> 5);
    11821261
    11831262    if (bits_in_last_word != 0) {
     
    11881267  set_bitidx_vars(refbits, 0, bitsp, bits, bitidx);
    11891268  inbits = outbits = bits;
    1190   while (memo_dword < num_memo_dwords) {
     1269  while (memo_dnode < num_memo_dnodes) {
    11911270    if (bits == 0) {
    11921271      int remain = 0x20 - bitidx;
    1193       memo_dword += remain;
     1272      memo_dnode += remain;
    11941273      p += (remain+remain);
    11951274      if (outbits != inbits) {
     
    12021281      nextbit = count_leading_zeros(bits);
    12031282      if ((diff = (nextbit - bitidx)) != 0) {
    1204         memo_dword += diff;
     1283        memo_dnode += diff;
    12051284        bitidx = nextbit;
    12061285        p += (diff+diff);
     
    12151294        outbits &= ~(BIT0_MASK >> bitidx);
    12161295      }
    1217       memo_dword++;
     1296      memo_dnode++;
    12181297      bitidx++;
    12191298    }
     
    12211300  if (GCDebug) {
    12221301    p = (LispObj *) a->low;
    1223     check_refmap_consistency(p, p+(num_memo_dwords << 1), refbits);
     1302    check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits);
    12241303  }
    12251304}
     
    12351314  while (start < end) {
    12361315    x1 = *start;
    1237     if ((tag = fulltag_of(x1)) == fulltag_immheader) {
    1238       start = (LispObj *)skip_over_ivector((unsigned) start, x1);
    1239     } else if (tag != fulltag_nodeheader) {
     1316    tag = fulltag_of(x1);
     1317    if (immheader_tag_p(tag)) {
     1318      start = (LispObj *)ptr_from_lispobj(skip_over_ivector(ptr_to_lispobj(start), x1));
     1319    } else if (!nodeheader_tag_p(tag)) {
    12401320      ++start;
    12411321      mark_root(x1);
     
    12431323    } else {
    12441324      int subtag = header_subtag(x1);
    1245       int element_count = header_element_count(x1);
    1246       int size = (element_count+1 + 1) & ~1;
     1325      natural element_count = header_element_count(x1);
     1326      natural size = (element_count+1 + 1) & ~1;
    12471327
    12481328      if (subtag == subtag_hash_vector) {
     
    12771357}
    12781358
    1279 void
    1280 mark_dohs( void )
    1281 {
    1282   doh_block_ptr doh_block = (doh_block_ptr) lisp_global(DOH_HEAD);
    1283   while( doh_block ) {
    1284     mark_simple_area_range( &doh_block->data[0], &doh_block->data[doh_block_slots] );
    1285     doh_block = doh_block->link;
    1286   }
    1287 }
    12881359
    12891360/* Mark a tstack area */
     
    13011372       end != limit;
    13021373       current = next) {
    1303     next = (LispObj *) *current;
     1374    next = (LispObj *) ptr_from_lispobj(*current);
    13041375    end = ((next >= start) && (next < limit)) ? next : limit;
    13051376    if (current[1] == 0) {
     
    13781449    N.B. : elements 0 and 1 are already marked (or are immediate, etc.)
    13791450    */
    1380   LispObj *prev = ((LispObj *) untag(weakv))+(1+2), cell = *prev;
     1451  LispObj *prev = ((LispObj *) ptr_from_lispobj(untag(weakv))+(1+2)), cell = *prev;
    13811452  LispObj termination_list = lisp_nil;
    13821453  int weak_type = (int) deref(weakv,2);
     
    13851456  Boolean done = false;
    13861457  cons *rawcons;
    1387   unsigned dword, car_dword;
     1458  unsigned dnode, car_dnode;
    13881459  bitvector markbits = GCmarkbits;
    13891460
     
    13971468    /* weak alist */
    13981469    while (! done) {
    1399       dword = gc_area_dword(cell);
    1400       if ((dword >= GCndwords_in_area) ||
    1401           (ref_bit(markbits, dword))) {
     1470      dnode = gc_area_dnode(cell);
     1471      if ((dnode >= GCndnodes_in_area) ||
     1472          (ref_bit(markbits, dnode))) {
    14021473        done = true;
    14031474      } else {
     
    14061477        unsigned cell_tag;
    14071478
    1408         rawcons = (cons *) untag(cell);
     1479        rawcons = (cons *) ptr_from_lispobj(untag(cell));
    14091480        alist_cell = rawcons->car;
    14101481        cell_tag = fulltag_of(alist_cell);
    14111482
    14121483        if ((cell_tag == fulltag_cons) &&
    1413             ((car_dword = gc_area_dword(alist_cell)) < GCndwords_in_area) &&
    1414             (! ref_bit(markbits, car_dword)) &&
     1484            ((car_dnode = gc_area_dnode(alist_cell)) < GCndnodes_in_area) &&
     1485            (! ref_bit(markbits, car_dnode)) &&
    14151486            (is_node_fulltag(fulltag_of(thecar = car(alist_cell)))) &&
    1416             ((car_dword = gc_area_dword(thecar)) < GCndwords_in_area) &&
    1417             (! ref_bit(markbits, car_dword))) {
     1487            ((car_dnode = gc_area_dnode(thecar)) < GCndnodes_in_area) &&
     1488            (! ref_bit(markbits, car_dnode))) {
    14181489          *prev = rawcons->cdr;
    14191490          if (terminatablep) {
     
    14221493          }
    14231494        } else {
    1424           set_bit(markbits, dword);
     1495          set_bit(markbits, dnode);
    14251496          prev = (LispObj *)(&(rawcons->cdr));
    14261497          mark_root(alist_cell);
     
    14321503    /* weak list */
    14331504    while (! done) {
    1434       dword = gc_area_dword(cell);
    1435       if ((dword >= GCndwords_in_area) ||
    1436           (ref_bit(markbits, dword))) {
     1505      dnode = gc_area_dnode(cell);
     1506      if ((dnode >= GCndnodes_in_area) ||
     1507          (ref_bit(markbits, dnode))) {
    14371508        done = true;
    14381509      } else {
     
    14461517
    14471518        if (is_node_fulltag(cartag) &&
    1448             ((car_dword = gc_area_dword(thecar)) < GCndwords_in_area) &&
    1449             (! ref_bit(markbits, car_dword))) {
     1519            ((car_dnode = gc_area_dnode(thecar)) < GCndnodes_in_area) &&
     1520            (! ref_bit(markbits, car_dnode))) {
    14501521          *prev = rawcons->cdr;
    14511522          if (terminatablep) {
     
    14541525          }
    14551526        } else {
    1456           set_bit(markbits, dword);
     1527          set_bit(markbits, dnode);
    14571528          prev = (LispObj *)(&(rawcons->cdr));
    14581529        }
     
    14781549reaphashv(LispObj hashv)
    14791550{
    1480   hash_table_vector_header *hashp = (hash_table_vector_header *) untag(hashv);
    1481   unsigned
    1482     dword,
     1551  hash_table_vector_header
     1552    *hashp = (hash_table_vector_header *) ptr_from_lispobj(untag(hashv));
     1553  natural
     1554    dnode,
    14831555    npairs = (header_element_count(hashp->header) -
    14841556              ((sizeof(hash_table_vector_header)/sizeof(LispObj)) -1)) >> 1;
     
    14971569    tag = fulltag_of(weakelement);
    14981570    if (is_node_fulltag(tag)) {
    1499       dword = gc_area_dword(weakelement);
    1500       if ((dword < GCndwords_in_area) &&
    1501           ! ref_bit(markbits, dword)) {
     1571      dnode = gc_area_dnode(weakelement);
     1572      if ((dnode < GCndnodes_in_area) &&
     1573          ! ref_bit(markbits, dnode)) {
    15021574        pairp[0] = undefined;
    15031575        pairp[1] = lisp_nil;
     
    15141586mark_weak_hash_vector(hash_table_vector_header *hashp, unsigned elements)
    15151587{
    1516   unsigned flags = hashp->flags, key_dword, val_dword;
     1588  unsigned flags = hashp->flags, key_dnode, val_dnode;
    15171589  Boolean
    15181590    marked_new = false,
     
    15451617    val_tag = fulltag_of(val);
    15461618    if (is_node_fulltag(key_tag)) {
    1547       key_dword = gc_area_dword(key);
    1548       if ((key_dword < GCndwords_in_area) &&
    1549           ! ref_bit(GCmarkbits,key_dword)) {
     1619      key_dnode = gc_area_dnode(key);
     1620      if ((key_dnode < GCndnodes_in_area) &&
     1621          ! ref_bit(GCmarkbits,key_dnode)) {
    15501622        key_marked = false;
    15511623      }
    15521624    }
    15531625    if (is_node_fulltag(val_tag)) {
    1554       val_dword = gc_area_dword(val);
    1555       if ((val_dword < GCndwords_in_area) &&
    1556           ! ref_bit(GCmarkbits,val_dword)) {
     1626      val_dnode = gc_area_dnode(val);
     1627      if ((val_dnode < GCndnodes_in_area) &&
     1628          ! ref_bit(GCmarkbits,val_dnode)) {
    15571629        val_marked = false;
    15581630      }
     
    15791651{
    15801652  int elements = header_element_count(header_of(weak_alist));
    1581   unsigned dword;
     1653  unsigned dnode;
    15821654  int pair_tag;
    15831655  Boolean marked_new = false;
     
    15901662  for(alist = deref(weak_alist, elements);
    15911663      (fulltag_of(alist) == fulltag_cons) &&
    1592       ((dword = gc_area_dword(alist)) < GCndwords_in_area) &&
    1593       (! ref_bit(markbits,dword));
     1664      ((dnode = gc_area_dnode(alist)) < GCndnodes_in_area) &&
     1665      (! ref_bit(markbits,dnode));
    15941666      alist = cdr(alist)) {
    15951667    pair = car(alist);
    15961668    pair_tag = fulltag_of(pair);
    15971669    if ((is_node_fulltag(pair_tag)) &&
    1598         ((dword = gc_area_dword(pair_tag)) < GCndwords_in_area) &&
    1599         (! ref_bit(markbits,dword))) {
     1670        ((dnode = gc_area_dnode(pair_tag)) < GCndnodes_in_area) &&
     1671        (! ref_bit(markbits,dnode))) {
    16001672      if (pair_tag == fulltag_cons) {
    16011673        key = car(pair);
    16021674        if ((! is_node_fulltag(fulltag_of(key))) ||
    1603             ((dword = gc_area_dword(key)) >= GCndwords_in_area) ||
    1604             ref_bit(markbits,dword)) {
     1675            ((dnode = gc_area_dnode(key)) >= GCndnodes_in_area) ||
     1676            ref_bit(markbits,dnode)) {
    16051677          /* key is marked, mark value if necessary */
    16061678          value = cdr(pair);
    16071679          if (is_node_fulltag(fulltag_of(value)) &&
    1608               ((dword = gc_area_dword(value)) < GCndwords_in_area) &&
    1609               (! ref_bit(markbits,dword))) {
     1680              ((dnode = gc_area_dnode(value)) < GCndnodes_in_area) &&
     1681              (! ref_bit(markbits,dnode))) {
    16101682            mark_root(value);
    16111683            marked_new = true;
     
    17141786mark_xp(ExceptionInformation *xp)
    17151787{
    1716   unsigned long *regs = (unsigned long *) xpGPRvector(xp);
     1788  natural *regs = (natural *) xpGPRvector(xp);
    17171789  int r;
    17181790
     
    17881860  LispObj *prev = &(lisp_global(GCABLE_POINTERS)), next, ptr;
    17891861  xmacptr_flag flag;
    1790   unsigned dword;
     1862  unsigned dnode;
    17911863  xmacptr *x;
    17921864
    17931865  while((next = *prev) != (LispObj)NULL) {
    1794     dword = gc_area_dword(next);
    1795     x = (xmacptr *) untag(next);
    1796 
    1797     if ((dword >= GCndwords_in_area) ||
    1798         (ref_bit(GCmarkbits,dword))) {
     1866    dnode = gc_area_dnode(next);
     1867    x = (xmacptr *) ptr_from_lispobj(untag(next));
     1868
     1869    if ((dnode >= GCndnodes_in_area) ||
     1870        (ref_bit(GCmarkbits,dnode))) {
    17991871      prev = &(x->link);
    18001872    } else {
     
    18101882
    18111883        case xmacptr_flag_ptr:
    1812           deallocate((char *)ptr);
     1884          deallocate((char *)ptr_from_lispobj(ptr));
    18131885          break;
    18141886
     
    18631935/* A "pagelet" contains 32 doublewords.  The relocation table contains
    18641936   a word for each pagelet which defines the lowest address to which
    1865    dwords on that pagelet will be relocated.
     1937   dnodes on that pagelet will be relocated.
    18661938
    18671939   The relocation address of a given pagelet is the sum of the relocation
     
    18771949  bitvector markbits = GCmarkbits;
    18781950  unsigned char *bytep = (unsigned char *) markbits;
    1879   unsigned npagelets = ((GCndwords_in_area+31)>>5);
     1951  unsigned npagelets = ((GCndnodes_in_area+31)>>5);
    18801952  unsigned thesebits;
    18811953  LispObj first = 0;
     
    19061978
    19071979LispObj
    1908 dword_forwarding_address(unsigned dword, int tag_n)
     1980dnode_forwarding_address(unsigned dnode, int tag_n)
    19091981{
    19101982  unsigned pagelet, nbits;
     
    19131985
    19141986  if (GCDebug) {
    1915     if (! ref_bit(GCmarkbits, dword)) {
     1987    if (! ref_bit(GCmarkbits, dnode)) {
    19161988      Bug(NULL, "unmarked object being forwarded!\n");
    19171989    }
    19181990  }
    19191991
    1920   pagelet = dword >> 5;
    1921   nbits = dword & 0x1f;
    1922   near_bits = ((unsigned short *)GCmarkbits)[dword>>4];
     1992  pagelet = dnode >> 5;
     1993  nbits = dnode & 0x1f;
     1994  near_bits = ((unsigned short *)GCmarkbits)[dnode>>4];
    19231995
    19241996  if (nbits < 16) {
    19251997    new = GCrelocptr[pagelet] + tag_n;;
    1926     /* Increment "new" by the count of 1 bits which precede the dword */
     1998    /* Increment "new" by the count of 1 bits which precede the dnode */
    19271999    if (near_bits == 0xffff) {
    19282000      return (new + (nbits << 3));
     
    19552027{
    19562028  int tag_n = fulltag_of(obj);
    1957   unsigned dword;
     2029  unsigned dnode;
    19582030
    19592031  /* Locatives can be tagged as conses, "fulltag_misc"
     
    19622034     doesn't hurt to check ... */
    19632035
     2036#ifdef PPC64
     2037  if ((tag_n & lowtag_mask) != lowtag_primary) {
     2038    return obj;
     2039  }
     2040#else
    19642041  if ((1<<tag_n) & ((1<<fulltag_immheader) |
    19652042                    (1<<fulltag_nodeheader) |
     
    19682045    return obj;
    19692046  }
    1970 
    1971   dword = gc_area_dword(obj);
    1972 
    1973   if ((dword >= GCndwords_in_area) ||
     2047#endif
     2048
     2049  dnode = gc_area_dnode(obj);
     2050
     2051  if ((dnode >= GCndnodes_in_area) ||
    19742052      (obj < GCfirstunmarked)) {
    19752053    return obj;
    19762054  }
    19772055
    1978   return dword_forwarding_address(dword, tag_n);
     2056  return dnode_forwarding_address(dnode, tag_n);
    19792057}
    19802058
     
    19832061{
    19842062  int tag_n;
    1985   unsigned dword = gc_area_dword(node);
    1986 
    1987   if ((dword >= GCndwords_in_area) ||
     2063  unsigned dnode = gc_area_dnode(node);
     2064
     2065  if ((dnode >= GCndnodes_in_area) ||
    19882066      (node < GCfirstunmarked)) {
    19892067    return node;
     
    19952073  }
    19962074
    1997   return dword_forwarding_address(dword, tag_n);
     2075  return dnode_forwarding_address(dnode, tag_n);
    19982076}
    19992077
     
    20312109  while ((next = *prev) != (LispObj)NULL) {
    20322110    *prev = node_forwarding_address(next);
    2033     prev = &(((xmacptr *)(untag(next)))->link);
     2111    prev = &(((xmacptr *)ptr_from_lispobj(untag(next)))->link);
    20342112  }
    20352113}
     
    20452123    node = *p;
    20462124    tag_n = fulltag_of(node);
    2047     if (tag_n == fulltag_immheader) {
     2125    if (immheader_tag_p(tag_n)) {
    20482126      p = (LispObj *) skip_over_ivector((unsigned) p, node);
    2049     } else if (tag_n == fulltag_nodeheader) {
     2127    } else if (nodeheader_tag_p(tag_n)) {
    20502128      nwords = header_element_count(node);
    20512129      nwords += (1- (nwords&1));
     
    20962174
    20972175void
    2098 forward_memoized_area(area *a, unsigned num_memo_dwords)
     2176forward_memoized_area(area *a, unsigned num_memo_dnodes)
    20992177{
    21002178  bitvector refbits = a->refbits;
    21012179  LispObj *p = (LispObj *) a->low, x1, x2, new;
    2102   unsigned bits, bitidx, *bitsp, nextbit, diff, memo_dword = 0, hash_dword_limit = 0;
     2180  unsigned bits, bitidx, *bitsp, nextbit, diff, memo_dnode = 0, hash_dnode_limit = 0;
    21032181  int tag_x1;
    21042182  hash_table_vector_header *hashp = NULL;
     
    21062184
    21072185  if (GCDebug) {
    2108     check_refmap_consistency(p, p+(num_memo_dwords << 1), refbits);
     2186    check_refmap_consistency(p, p+(num_memo_dnodes << 1), refbits);
    21092187  }
    21102188
     
    21142192
    21152193  set_bitidx_vars(refbits, 0, bitsp, bits, bitidx);
    2116   while (memo_dword < num_memo_dwords) {
     2194  while (memo_dnode < num_memo_dnodes) {
    21172195    if (bits == 0) {
    21182196      int remain = 0x20 - bitidx;
    2119       memo_dword += remain;
     2197      memo_dnode += remain;
    21202198      p += (remain+remain);
    21212199      bits = *++bitsp;
     
    21242202      nextbit = count_leading_zeros(bits);
    21252203      if ((diff = (nextbit - bitidx)) != 0) {
    2126         memo_dword += diff;
     2204        memo_dnode += diff;
    21272205        bitidx = nextbit;
    21282206        p += (diff+diff);
     
    21322210      tag_x1 = fulltag_of(x1);
    21332211      bits &= ~(BIT0_MASK >> bitidx);
    2134       header_p = (tag_x1 == fulltag_nodeheader);
     2212      header_p = (nodeheader_tag_p(tag_x1));
    21352213
    21362214      if (header_p &&
     
    21382216        hashp = (hash_table_vector_header *) p;
    21392217        if (hashp->flags & nhash_track_keys_mask) {
    2140           hash_dword_limit = memo_dword + ((header_element_count(x1)+2)>>1);
     2218          hash_dnode_limit = memo_dnode + ((header_element_count(x1)+2)>>1);
    21412219        } else {
    21422220          hashp = NULL;
     
    21562234      if (new != x2) {
    21572235        *p = new;
    2158         if (memo_dword < hash_dword_limit) {
     2236        if (memo_dnode < hash_dnode_limit) {
    21592237          hashp->flags |= nhash_key_moved_mask;
    2160           hash_dword_limit = 0;
     2238          hash_dnode_limit = 0;
    21612239          hashp = NULL;
    21622240        }
    21632241      }
    21642242      p++;
    2165       memo_dword++;
     2243      memo_dnode++;
    21662244      bitidx++;
    21672245
     
    21702248}
    21712249
    2172 void
    2173 forward_dohs( void )
    2174 {
    2175   doh_block_ptr doh_block = (doh_block_ptr) lisp_global(DOH_HEAD);
    2176   while( doh_block ) {
    2177     forward_range( &doh_block->data[0], &doh_block->data[doh_block_slots] );
    2178     doh_block = doh_block->link;
    2179   }
    2180 }
    21812250
    21822251
     
    23062375{
    23072376  LispObj *src = (LispObj*) GCfirstunmarked, *dest = src, node, new;
    2308   unsigned elements, dword = gc_area_dword(GCfirstunmarked), node_dwords = 0, imm_dwords = 0;
     2377  unsigned elements, dnode = gc_area_dnode(GCfirstunmarked), node_dnodes = 0, imm_dnodes = 0;
    23092378  unsigned bitidx, *bitsp, bits, nextbit, diff;
    23102379  int tag;
     
    23142383  Boolean GCrelocated_code_vector = false;
    23152384
    2316   if (dword < GCndwords_in_area) {
     2385  if (dnode < GCndnodes_in_area) {
    23172386    lisp_global(FWDNUM) += (1<<fixnum_shift);
    23182387 
    2319     set_bitidx_vars(markbits,dword,bitsp,bits,bitidx);
    2320     while (dword < GCndwords_in_area) {
     2388    set_bitidx_vars(markbits,dnode,bitsp,bits,bitidx);
     2389    while (dnode < GCndnodes_in_area) {
    23212390      if (bits == 0) {
    23222391        int remain = 0x20 - bitidx;
    2323         dword += remain;
     2392        dnode += remain;
    23242393        src += (remain+remain);
    23252394        bits = *++bitsp;
     
    23292398           "bitidx" are 0.  Count leading zeros in "bits" (there'll be
    23302399           at least "bitidx" of them.)  If there are more than "bitidx"
    2331            leading zeros, bump "dword", "bitidx", and "src" by the difference. */
     2400           leading zeros, bump "dnode", "bitidx", and "src" by the difference. */
    23322401        nextbit = count_leading_zeros(bits);
    23332402        if ((diff = (nextbit - bitidx)) != 0) {
    2334           dword += diff;
     2403          dnode += diff;
    23352404          bitidx = nextbit;
    23362405          src += (diff+diff);
     
    23462415        node = *src++;
    23472416        tag = fulltag_of(node);
    2348         if (tag == fulltag_nodeheader) {
     2417        if (nodeheader_tag_p(tag)) {
    23492418          elements = header_element_count(node);
    2350           node_dwords = (elements+2)>>1;
    2351           dword += node_dwords;
     2419          node_dnodes = (elements+2)>>1;
     2420          dnode += node_dnodes;
    23522421          if ((header_subtag(node) == subtag_hash_vector) &&
    23532422              (((hash_table_vector_header *) (src-1))->flags & nhash_track_keys_mask)) {
     
    23842453            *dest++ = node;
    23852454            *dest++ = node_forwarding_address(*src++);
    2386             while(--node_dwords) {
     2455            while(--node_dnodes) {
    23872456              *dest++ = node_forwarding_address(*src++);
    23882457              *dest++ = node_forwarding_address(*src++);
    23892458            }
    23902459          }
    2391           set_bitidx_vars(markbits,dword,bitsp,bits,bitidx);
    2392         } else if (tag == fulltag_immheader) {
     2460          set_bitidx_vars(markbits,dnode,bitsp,bits,bitidx);
     2461        } else if (immheader_tag_p(tag)) {
    23932462          *dest++ = node;
    23942463          *dest++ = *src++;
    23952464          elements = header_element_count(node);
    23962465          tag = header_subtag(node);
     2466#ifdef PPC64
     2467          switch(fulltag_of(tag)) {
     2468          case ivector_class_64_bit:
     2469            imm_dnodes = ((elements+1)+1)>>1;
     2470            break;
     2471          case ivector_class_32_bit:
     2472            if (tag == subtag_code_vector) {
     2473              GCrelocated_code_vector = true;
     2474            }
     2475            imm_dnodes = (((elements+2)+3)>>2);
     2476            break;
     2477          case ivector_class_8_bit:
     2478            imm_dnodes = (((elements+8)+15)>>4);
     2479            break;
     2480          case ivector_class_other_bit:
     2481            if (tag == subtag_bit_vector) {
     2482              imm_dnodes = (((elements+64)+127)>>7);
     2483            } else {
     2484              imm_dnodes = (((elements+4)+7)>>3);
     2485            }
     2486          }
     2487#else
    23972488          if (tag <= max_32_bit_ivector_subtag) {
    23982489            if (tag == subtag_code_vector) {
    23992490              GCrelocated_code_vector = true;
    24002491            }
    2401             imm_dwords = (((elements+1)+1)>>1);
     2492            imm_dnodes = (((elements+1)+1)>>1);
    24022493          } else if (tag <= max_8_bit_ivector_subtag) {
    2403             imm_dwords = (((elements+4)+7)>>3);
     2494            imm_dnodes = (((elements+4)+7)>>3);
    24042495          } else if (tag <= max_16_bit_ivector_subtag) {
    2405             imm_dwords = (((elements+2)+3)>>2);
     2496            imm_dnodes = (((elements+2)+3)>>2);
    24062497          } else if (tag == subtag_bit_vector) {
    2407             imm_dwords = (((elements+32)+63)>>6);
     2498            imm_dnodes = (((elements+32)+63)>>6);
    24082499          } else {
    2409             imm_dwords = elements+1;
     2500            imm_dnodes = elements+1;
    24102501          }
    2411           dword += imm_dwords;
    2412           while (--imm_dwords) {
     2502#endif
     2503          dnode += imm_dnodes;
     2504          while (--imm_dnodes) {
    24132505            *dest++ = *src++;
    24142506            *dest++ = *src++;
    24152507          }
    2416           set_bitidx_vars(markbits,dword,bitsp,bits,bitidx);
     2508          set_bitidx_vars(markbits,dnode,bitsp,bits,bitidx);
    24172509        } else {
    24182510          *dest++ = node_forwarding_address(node);
    24192511          *dest++ = node_forwarding_address(*src++);
    24202512          bits &= ~(BIT0_MASK >> bitidx);
    2421           dword++;
     2513          dnode++;
    24222514          bitidx++;
    24232515        }
     
    24272519
    24282520    {
    2429       unsigned nbytes = (unsigned)dest - (unsigned)GCfirstunmarked;
     2521      natural nbytes = (natural)dest - (natural)GCfirstunmarked;
    24302522      if ((nbytes != 0) && GCrelocated_code_vector) {
    2431         xMakeDataExecutable((LogicalAddress)GCfirstunmarked, nbytes);
    2432       }
    2433     }
    2434   }
    2435   return (LispObj)dest;
     2523        xMakeDataExecutable((LogicalAddress)ptr_from_lispobj(GCfirstunmarked), nbytes);
     2524      }
     2525    }
     2526  }
     2527  return ptr_to_lispobj(dest);
    24362528}
    24372529
     
    24862578  GCephemeral_low = lisp_global(OLDEST_EPHEMERAL);
    24872579  if (GCephemeral_low) {
    2488     GCn_ephemeral_dwords=area_dword(oldfree, GCephemeral_low);
     2580    GCn_ephemeral_dnodes=area_dnode(oldfree, GCephemeral_low);
    24892581    update_area_refmaps(oldfree);
    24902582  } else {
     
    24922584      unprotect_area(oldspace_protected_area);
    24932585    }
    2494     GCn_ephemeral_dwords = 0;
     2586    GCn_ephemeral_dnodes = 0;
    24952587  }
    24962588 
     
    25312623     
    25322624  GCmarkbits = a->markbits;
    2533   GCarealow = (LispObj) a->low,
    2534   GCndwords_in_area = gc_area_dword(oldfree);
    2535 
    2536   zero_bits(GCmarkbits, GCndwords_in_area);
     2625  GCarealow = ptr_to_lispobj(a->low);
     2626  GCndnodes_in_area = gc_area_dnode(oldfree);
     2627
     2628  zero_bits(GCmarkbits, GCndnodes_in_area);
    25372629  GCweakvll = (LispObj)NULL;
    25382630
    25392631
    2540   if (GCn_ephemeral_dwords == 0) {
     2632  if (GCn_ephemeral_dnodes == 0) {
    25412633    /* For GCTWA, mark the internal package hash table vector of
    25422634     *PACKAGE*, but don't mark its contents. */
     
    25452637        itab;
    25462638      unsigned
    2547         dword, ndwords;
     2639        dnode, ndnodes;
    25482640     
    25492641      pkg = nrs_PACKAGE.vcell;
    25502642      if ((fulltag_of(pkg) == fulltag_misc) &&
    25512643          (header_subtag(header_of(pkg)) == subtag_package)) {
    2552         itab = ((package *)(untag(pkg)))->itab;
     2644        itab = ((package *)ptr_from_lispobj(untag(pkg)))->itab;
    25532645        itabvec = car(itab);
    2554         dword = gc_area_dword(itabvec);
    2555         if (dword < GCndwords_in_area) {
    2556           ndwords = (header_element_count(header_of(itabvec))+1) >> 1;
    2557           set_n_bits(GCmarkbits, dword, ndwords);
     2646        dnode = gc_area_dnode(itabvec);
     2647        if (dnode < GCndnodes_in_area) {
     2648          ndnodes = (header_element_count(header_of(itabvec))+1) >> 1;
     2649          set_n_bits(GCmarkbits, dnode, ndnodes);
    25582650        }
    25592651      }
     
    25992691 
    26002692  if (lisp_global(OLDEST_EPHEMERAL)) {
    2601     mark_memoized_area(tenured_area, area_dword(a->low,tenured_area->low));
     2693    mark_memoized_area(tenured_area, area_dnode(a->low,tenured_area->low));
    26022694  }
    26032695
     
    26092701  } while (other_tcr != tcr);
    26102702
    2611   mark_dohs();          /* Creole */
    26122703
    26132704
     
    26292720      if (fulltag_of(sym) == fulltag_misc) {
    26302721        lispsymbol *rawsym = (lispsymbol *)(untag(sym));
    2631         unsigned dword = gc_area_dword(sym);
     2722        unsigned dnode = gc_area_dnode(sym);
    26322723         
    2633         if ((dword < GCndwords_in_area) &&
    2634             (!ref_bit(GCmarkbits,dword))) {
     2724        if ((dnode < GCndnodes_in_area) &&
     2725            (!ref_bit(GCmarkbits,dnode))) {
    26352726          /* Symbol is in GC area, not marked.
    26362727             Mark it if fboundp, boundp, or if
     
    26642755      if (fulltag_of(sym) == fulltag_misc) {
    26652756        lispsymbol *rawsym = (lispsymbol *)(untag(sym));
    2666         unsigned dword = gc_area_dword(sym);
    2667 
    2668         if ((dword < GCndwords_in_area) &&
    2669             (!ref_bit(GCmarkbits,dword))) {
    2670           *raw = unbound;
     2757        unsigned dnode = gc_area_dnode(sym);
     2758
     2759        if ((dnode < GCndnodes_in_area) &&
     2760            (!ref_bit(GCmarkbits,dnode))) {
     2761          *raw = unbound_marker;
    26712762        }
    26722763      }
     
    26882779  } while (other_tcr != tcr);
    26892780
    2690   forward_dohs();               /* Creole */
    26912781 
    26922782  forward_gcable_ptrs();
     
    27282818 
    27292819  if (GCephemeral_low) {
    2730     forward_memoized_area(tenured_area, area_dword(a->low, tenured_area->low));
     2820    forward_memoized_area(tenured_area, area_dnode(a->low, tenured_area->low));
    27312821  }
    27322822
     
    28022892        (header_subtag(header_of(val)) == subtag_macptr)) {
    28032893      long long justfreed = oldfree - a->active;
    2804       *( (long long *) ((macptr *) (untag(val)))->address) += justfreed;
     2894      *( (long long *) ((macptr *) ptr_from_lispobj(untag(val)))->address) += justfreed;
    28052895    }
    28062896  }
     
    28232913    tag = fulltag_of(header);
    28242914   
    2825     if ((tag == fulltag_nodeheader) ||
    2826         (tag == fulltag_immheader)) {
     2915    if ((nodeheader_tag_p(tag)) ||
     2916        (immheader_tag_p(tag))) {
    28272917      elements = header_element_count(header);
    2828       if (tag == fulltag_nodeheader) {
     2918      if (nodeheader_tag_p(tag)) {
    28292919        start += ((elements+2) & ~1);
    28302920      } else {
    28312921        subtag = header_subtag(header);
    28322922
     2923#ifdef PPC64
     2924        switch(fulltag_of(header)) {
     2925        case ivector_class_64_bit:
     2926          bytes = 8 + (elements<<3);
     2927          break;
     2928        case ivector_class_32_bit:
     2929          bytes = 8 + (elements<<2);
     2930          break;
     2931        case ivector_class_8_bit:
     2932          bytes = 8 + elements;
     2933          break;
     2934        case ivector_class_other_bit:
     2935        default:
     2936          if (subtag == subtag_bit_vector) {
     2937            bytes = 8 + ((elements+7)>>3);
     2938          } else {
     2939            bytes = 8 + (elements<<1);
     2940          }
     2941        }
     2942#else
    28332943        if (subtag <= max_32_bit_ivector_subtag) {
    28342944          bytes = 4 + (elements<<2);
     
    28422952          bytes = 4 + ((elements+7)>>3);
    28432953        }
    2844         bytes = (bytes+7) & ~7;
     2954#endif
     2955        bytes = (bytes+dnode_size-1) & ~(dnode_size-1);
    28452956        total += bytes;
    2846         start += (bytes >> 2);
     2957        start += (bytes >> node_shift);
    28472958      }
    28482959    } else {
     
    28662977  BytePtr
    28672978    free = dest->active,
    2868     *old = (BytePtr *) untag(obj);
     2979    *old = (BytePtr *) ptr_from_lispobj(untag(obj));
    28692980  LispObj
    28702981    header = header_of(obj),
     
    28802991    break;
    28812992
    2882   case subtag_simple_general_string:
    2883     physbytes = 4 + (element_count << 1);
    2884     break;
    2885 
    28862993  case subtag_code_vector:
    28872994    physbytes = 4 + (element_count << 2);
     
    28953002  dest->active += physbytes;
    28963003
    2897   new = (LispObj)free+disp;
     3004  new = ptr_to_lispobj(free)+disp;
    28983005
    28993006  memcpy(free, (BytePtr)old, physbytes);
     
    29043011     look like a header.
    29053012     b) We'd like to be able to forward code-vector locatives, and
    2906      it's easiest to do so if we leave a {forward_marker, dword_locative}
     3013     it's easiest to do so if we leave a {forward_marker, dnode_locative}
    29073014     pair at every doubleword in the old vector.
    29083015     */
     
    29343041
    29353042  if ((tag == fulltag_misc) &&
    2936       (((BytePtr)obj) > low) &&
    2937       (((BytePtr)obj) < high)) {
     3043      (((BytePtr)ptr_from_lispobj(obj)) > low) &&
     3044      (((BytePtr)ptr_from_lispobj(obj)) < high)) {
    29383045    header = deref(obj, 0);
    29393046    if (header == forward_marker) { /* already copied */
     
    29413048    } else {
    29423049      header_tag = fulltag_of(header);
    2943       if (header_tag == fulltag_immheader) {
     3050      if (immheader_tag_p(header_tag)) {
    29443051        header_subtag = header_subtag(header);
    29453052        if (((header_subtag == subtag_code_vector) && (what_to_copy & COPY_CODE)) ||
    29463053            ((what_to_copy & COPY_STRINGS) &&
    2947              ((header_subtag == subtag_simple_base_string) ||
    2948               (header_subtag == subtag_simple_general_string)))) {
     3054             ((header_subtag == subtag_simple_base_string)))) {
    29493055          *ref = purify_object(obj, dest);
    29503056        }
     
    29633069    tag = fulltag_of(loc);
    29643070
    2965   if (((BytePtr)loc > low) &&
    2966       ((BytePtr)loc < high)) {
    2967     LispObj *p = (LispObj *)(untag(loc));
     3071  if (((BytePtr)ptr_from_lispobj(loc) > low) &&
     3072      ((BytePtr)ptr_from_lispobj(loc) < high)) {
     3073    LispObj *p = (LispObj *)ptr_from_lispobj(untag(loc));
    29683074    switch (tag) {
    29693075    case fulltag_even_fixnum:
     
    29803086          header = *p;
    29813087        } while ((header & code_header_mask) != subtag_code_vector);
    2982         *locaddr = purify_displaced_object((LispObj)p, to, tag);
     3088        *locaddr = purify_displaced_object(ptr_to_lispobj(p), to, tag);
    29833089      }
    29843090      break;
     
    30033109    } else {
    30043110      tag = fulltag_of(header);
    3005       if (tag == fulltag_immheader) {
     3111      if (immheader_tag_p(tag)) {
    30063112        start = (LispObj *)skip_over_ivector((unsigned)start, header);
    30073113      } else {
    3008         if (tag != fulltag_nodeheader) {
     3114        if (!nodeheader_tag_p(tag)) {
    30093115          copy_ivector_reference(start, low, high, to, what);
    30103116        }
     
    30313137       end != limit;
    30323138       current = next) {
    3033     next = (LispObj *) *current;
     3139    next = (LispObj *) ptr_from_lispobj(*current);
    30343140    end = ((next >= start) && (next < limit)) ? next : limit;
    30353141    if (current[1] == 0) {
     
    31263232}
    31273233
    3128 void
    3129 purify_dohs(BytePtr low, BytePtr high, area *to, int what)
    3130 {
    3131   doh_block_ptr doh_block = (doh_block_ptr) lisp_global(DOH_HEAD);
    3132   while( doh_block ) {
    3133     purify_range( &doh_block->data[0], &doh_block->data[doh_block_slots],
    3134                  low, high, to, what );
    3135     doh_block = doh_block->link;
    3136   }
    3137 }
    31383234
    31393235void
     
    32173313
    32183314      while (fulltag_of(pkg_list) == fulltag_cons) {
    3219         c = (cons *) untag(pkg_list);
    3220         p = (package *) untag(c->car);
     3315        c = (cons *) ptr_from_lispobj(untag(pkg_list));
     3316        p = (package *) ptr_from_lispobj(untag(c->car));
    32213317        pkg_list = c->cdr;
    3222         c = (cons *) untag(p->itab);
     3318        c = (cons *) ptr_from_lispobj(untag(p->itab));
    32233319        htab = c->car;
    32243320        elements = header_element_count(header_of(htab));
     
    32263322          obj = deref(htab,i);
    32273323          if (fulltag_of(obj) == fulltag_misc) {
    3228             rawsym = (lispsymbol *) untag(obj);
     3324            rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
    32293325            copy_ivector_reference(&(rawsym->pname), a->low, a->active, new_pure_area, COPY_STRINGS);
    32303326          }
    32313327        }
    3232         c = (cons *) untag(p->etab);
     3328        c = (cons *) ptr_from_lispobj(untag(p->etab));
    32333329        htab = c->car;
    32343330        elements = header_element_count(header_of(htab));
     
    32363332          obj = deref(htab,i);
    32373333          if (fulltag_of(obj) == fulltag_misc) {
    3238             rawsym = (lispsymbol *) untag(obj);
     3334            rawsym = (lispsymbol *) ptr_from_lispobj(untag(obj));
    32393335            copy_ivector_reference(&(rawsym->pname), a->low, a->active, new_pure_area, COPY_STRINGS);
    32403336          }
     
    32523348    } while (other_tcr != tcr);
    32533349
    3254     purify_dohs(a->low, a->active, new_pure_area, COPY_CODE);
    32553350
    32563351    {
     
    33543449    header = *start;
    33553450    tag = fulltag_of(header);
    3356     if (tag == fulltag_immheader) {
     3451    if (immheader_tag_p(tag)) {
    33573452      start = (LispObj *)skip_over_ivector((unsigned)start, header);
    33583453    } else {
    3359       if (tag != fulltag_nodeheader) {
     3454      if (!nodeheader_tag_p(tag)) {
    33603455        impurify_noderef(start, low, high, delta);
    33613456        }
     
    34083503       end != limit;
    34093504       current = next) {
    3410     next = (LispObj *) *current;
     3505    next = (LispObj *) ptr_from_lispobj(*current);
    34113506    end = ((next >= start) && (next < limit)) ? next : limit;
    34123507    if (current[1] == 0) {
     
    34793574      bcopy(ro_base, oldfree, n);
    34803575      munmap(ro_base, n);
    3481       a->ndwords = area_dword(a, a->active);
     3576      a->ndnodes = area_dnode(a, a->active);
    34823577      pure_space_active = r->active = r->low;
    3483       r->ndwords = 0;
    3484 
    3485       impurify_areas((LispObj)ro_base, (LispObj)ro_limit, delta);
     3578      r->ndnodes = 0;
     3579
     3580      impurify_areas(ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    34863581
    34873582      other_tcr = tcr;
    34883583      do {
    3489         impurify_tcr_xframes(other_tcr, (LispObj)ro_base, (LispObj)ro_limit, delta);
    3490         impurify_tcr_tlb(other_tcr, (LispObj)ro_base, (LispObj)ro_limit, delta);
     3584        impurify_tcr_xframes(other_tcr, ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
     3585        impurify_tcr_tlb(other_tcr, ptr_to_lispobj(ro_base), ptr_to_lispobj(ro_limit), delta);
    34913586        other_tcr = other_tcr->next;
    34923587      } while (other_tcr != tcr);
  • trunk/ccl/lisp-kernel/gc.h

    r12 r557  
    3838
    3939extern LispObj GCarealow;
    40 extern unsigned GCndwords_in_area;
     40extern unsigned GCndnodes_in_area;
    4141extern bitvector GCmarkbits;
    4242LispObj *global_reloctab, *GCrelocptr;
     
    4848void mark_locative_root(LispObj);
    4949void rmark(LispObj);
    50 unsigned skip_over_ivector(unsigned, LispObj);
     50LispObj *skip_over_ivector(LispObj, LispObj);
    5151void mark_simple_area_range(LispObj *,LispObj *);
    5252LispObj calculate_relocation();
     
    6464
    6565
    66 #define area_dword(w,low) ((((LispObj)w) - (LispObj)low)>>3)
    67 #define gc_area_dword(w)  area_dword(w,GCarealow)
     66#define area_dnode(w,low) (((ptr_to_lispobj(w)) - ptr_to_lispobj(low))>>dnode_shift)
     67#define gc_area_dnode(w)  area_dnode(w,GCarealow)
    6868
     69#ifdef PPC64
     70#define forward_marker subtag_forward_marker
     71#else
    6972#define forward_marker fulltag_nil
     73#endif
    7074
    71 #define VOID_ALLOCPTR 0xFFFFFFF8
     75#define VOID_ALLOCPTR ((LispObj)(-dnode_size))
    7276
    7377
  • trunk/ccl/lisp-kernel/lisp-exceptions.h

    r173 r557  
    8787
    8888
    89 typedef unsigned opcode, *pc;
     89typedef u_int32_t opcode, *pc;
    9090
    9191#ifdef LINUX
  • trunk/ccl/lisp-kernel/lisp.h

    r6 r557  
    1717#ifndef __lisp__
    1818#define __lisp__
     19
     20/*
     21  On some platforms (the G5 under Panther when -mpowerpc64 is in effect)
     22  the C compiler belives that pointers are only 32 bits wide, even though
     23  the machine's in 64-bit mode.  If that's the case, prepand a gensym'ed
     24  word to any pointer fields in any structure accessed by both C and Lisp
     25  code.
     26
     27  This means that C and Lisp will have a slightly different notion of the
     28  offset of each such field.  The alternative - representing the pointer
     29  as a 64-bit int and casting on every reference - seems just as ugly.
     30*/
     31
     32#if defined(PPC64) && defined(FOREIGN_POINTER_32BIT)
     33#define NATURAL_POINTER_FIELD(type,name) unsigned _ ## name; type * name
     34#else
     35#define NATURAL_POINTER_FIELD(type,name) type *name;
     36#endif
     37
    1938
    2039#include "lisptypes.h"
  • trunk/ccl/lisp-kernel/lisp_globals.h

    r217 r557  
    7777#define SUBPRIMS_TARGET_N (-257) /* absolute address of subprim 255 jump target */
    7878
    79 
     79#ifdef PPC64
     80#define lisp_global(g) (((LispObj *) 0x2000)[(g)])
     81#define nrs_symbol(s) (((lispsymbol *) 0x2000)[(s)])
     82#else
    8083#define lisp_global(g) (((LispObj *) (nil_value-fulltag_nil))[(g)])
    8184#define nrs_symbol(s) (((lispsymbol *) (nil_value+(8-fulltag_nil)+8))[(s)])
     85#endif
    8286
    8387#define nrs_T                           (nrs_symbol(0))         /* t */
  • trunk/ccl/lisp-kernel/lisptypes.h

    r6 r557  
    1818#define __lisptypes__
    1919
    20 typedef unsigned LispObj;
     20#include <sys/types.h>
     21#ifdef PPC64
     22typedef u_int64_t LispObj;
     23typedef u_int64_t natural;
     24typedef int64_t signed_natural;
     25#ifdef FOREIGN_POINTER_32BIT
     26typedef u_int32_t unsigned_of_pointer_size;
     27#else
     28typedef u_int64_t unsigned_of_pointer_size;
     29#endif
     30#else
     31typedef u_int32_t LispObj;
     32typedef u_int32_t natural;
     33typedef int32_t signed_natural;
     34typedef u_int32_t unsigned_of_pointer_size;
     35#endif
    2136
    2237typedef struct ucontext ExceptionInformation, ExceptionInformationPowerPC;
    2338
    24 typedef char *BytePtr;
    2539typedef int OSStatus, OSErr;
    2640#define noErr ((OSErr) 0)
    2741typedef int Boolean;
    2842typedef void *LogicalAddress;
    29 typedef char *StringPtr;
    30 typedef char *Ptr;
     43typedef char *Ptr, *BytePtr, *StringPtr;
    3144typedef unsigned int UInt32;
     45
    3246typedef union {
    3347  unsigned short halfword;
    3448  struct {
     49#ifdef PPC64
     50    unsigned short offset:13;
     51    unsigned short pad:1;
     52#else
    3553    unsigned short offset:14;
     54#endif
    3655    unsigned short hasnode:1;
    3756    unsigned short modified:1;
  • trunk/ccl/lisp-kernel/macros.h

    r6 r557  
    2222#define __macros__
    2323
     24#define ptr_to_lispobj(p) ((LispObj)((unsigned_of_pointer_size)(p)))
     25#define ptr_from_lispobj(o) ((LispObj*)((unsigned_of_pointer_size)(o)))
    2426#define lisp_reg_p(reg)  ((reg) >= fn)
    2527
     
    2830#define untag(o) ((o) & ~fulltagmask)
    2931
    30 #define deref(o,n) (*((LispObj*) ((LispObj *)(untag((LispObj)o)))+(n)))
     32#define deref(o,n) (*((LispObj*) (ptr_from_lispobj(untag((LispObj)o)))+(n)))
    3133#define header_of(o) deref(o,0)
    3234
     
    4749#define FBOUNDP(sym) ((((lispsymbol *)(sym))->fcell) != nrs_UDF.vcell)
    4850
     51#ifdef PPC64
     52#define nodeheader_tag_p(tag) (((tag) & lowtag_mask) == lowtag_nodeheader)
     53#else
     54#define nodeheader_tag_p(tag) (tag == fulltag_nodeheader)
     55#endif
     56
     57#ifdef PPC64
     58#define immheader_tag_p(tag) (((tag) & lowtag_mask) == lowtag_immheader)
     59#else
     60#define immheader_tag_p(tag) (tag == fulltag_immheader)
     61#endif
    4962
    5063/* lfuns */
  • trunk/ccl/lisp-kernel/macros.s

    r528 r557  
    5959        ldx $@
    6060        ])
     61        define([ldru],[
     62        ldu $@
     63        ])
    6164        define([str],[
    6265        std $@
    6366        ])
    6467        define([strx],[
    65         stdx %@
     68        stdx $@
    6669        ])
    6770        define([stru],[
     
    102105        ])
    103106        define([srari],[
    104         sradi #@
     107        sradi $@
    105108        ])
    106109        define([srri],[
     
    125128        define([ldrx],[
    126129        lwzx $@
     130        ])
     131        define([ldru],[
     132        lwzu $@
    127133        ])
    128134        define([str],[
     
    169175        ])
    170176        define([srari],[
    171         srawi #@
     177        srawi $@
    172178        ])
    173179        define([srri],[
     
    229235
    230236define([box_fixnum],[
    231         slwi $1,$2,fixnumshift])
     237        slri($1,$2,fixnumshift)])
    232238
    233239define([unbox_fixnum],[
    234         srawi $1,$2,fixnumshift])
     240        srari($1,$2,fixnumshift)])
    235241
    236242define([loaddf],[
     
    294300        /* "Length" is fixnum element count */
    295301define([header_length],[
    296         rlwinm $1,$2,nbits_in_word-(num_subtag_bits-nfixnumtagbits),(num_subtag_bits-nfixnumtagbits),31-nfixnumtagbits])
     302ifdef([PPC64],[
     303        clrlsldi $1,$2,nbits_in_word-num_subtag_bits,fixnum_shift
     304        ],[               
     305        rlwinm $1,$2,nbits_in_word-(num_subtag_bits-nfixnumtagbits),(num_subtag_bits-nfixnumtagbits),31-nfixnumtagbits
     306        ])
     307])       
    297308
    298309
  • trunk/ccl/lisp-kernel/pantherg5/Makefile

    r530 r557  
    4848AS = as
    4949M4 = gm4
    50 M4FLAGS = -DDARWIN -DPPC64 -DPANTHERG5
     50M4FLAGS = -DDARWIN -DPPC64 -DFOREIGN_POINTER_32BIT
    5151ASFLAGS = -force_cpusubtype_ALL
    52 CDEFINES = -DDARWIN $(BROKEN_PREPROCESSOR_WORKAROUND) -DOPENMCL_MAJOR_VERSION=$(OPENMCL_MAJOR_VERSION) -DOPENMCL_MINOR_VERSION=$(OPENMCL_MINOR_VERSION)
     52CDEFINES = -DPPC64 -DFOREIGN_POINTER_32BIT -DDARWIN $(BROKEN_PREPROCESSOR_WORKAROUND) -DOPENMCL_MAJOR_VERSION=$(OPENMCL_MAJOR_VERSION) -DOPENMCL_MINOR_VERSION=$(OPENMCL_MINOR_VERSION)
    5353CDEBUG = -g
    54 COPT = -O2 -mpowerpc64 -DPPC64 -DPANTHERG5
     54COPT = -O2 -mpowerpc64
    5555
    5656.s.o:
     
    7878
    7979KSPOBJ= $(SPOBJ)
    80 all:    ../../dppccl
     80all:    ../../dppccl64
    8181
    8282
     
    8989
    9090
    91 ../../dppccl:    $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ)
     91../../dppccl64:  $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ)
    9292        $(LD)  $(LDFLAGS) $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ)   $(OSLIBS)
    9393
     
    115115
    116116cclean:
    117         $(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../dppccl 
     117        $(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../dppccl64
    118118
    119119# Some earlier versions of this Makefile built "subprims_r.o". 
     
    122122        $(RM) -f $(SPOBJ) $(KSPOBJ) subprims_r.o
    123123
    124 strip:  ../../dppccl
    125         strip -s retain ../../dppccl
     124strip:  ../../dppccl64
     125        strip -s retain ../../dppccl64
  • trunk/ccl/lisp-kernel/plsym.c

    r6 r557  
    3131 
    3232 
    33 unsigned skip_over_ivector(unsigned, LispObj);
    3433
    3534/*
  • trunk/ccl/lisp-kernel/pmcl-kernel.c

    r510 r557  
    547547  reserved->low += size;
    548548  reserved->active = reserved->low;
    549   reserved->ndwords -= (size>>3);
     549  reserved->ndnodes -= (size>>dnode_shift);
    550550  return low;
    551551}
     
    600600{
    601601  unsigned
    602     ndwords = area_dword(lisp_global(HEAP_END),lisp_global(HEAP_START)),
     602    ndnodes = area_dnode(lisp_global(HEAP_END),lisp_global(HEAP_START)),
    603603    npages = (lisp_global(HEAP_END)-lisp_global(HEAP_START)) >> 12,
    604     markbits_size = 12+((ndwords+7)>>3),
    605     reloctab_size = (sizeof(LispObj)*(((ndwords+31)>>5)+1)),
     604    markbits_size = 12+((ndnodes+7)>>dnode_shift),
     605    reloctab_size = (sizeof(LispObj)*(((ndnodes+31)>>5)+1)),
    606606    pagemap_size = align_to_power_of_2(npages*sizeof(pageentry),12);
    607607  BytePtr
     
    676676
    677677  a->high += delta;
    678   a->ndwords = area_dword(a->high, a->low);
     678  a->ndnodes = area_dnode(a->high, a->low);
    679679  a->hardlimit = a->high;
    680680  oldspace_protected_area->end = a->high;
     
    697697
    698698  a->high -= delta;
    699   a->ndwords = area_dword(a->high, a->low);
     699  a->ndnodes = area_dnode(a->high, a->low);
    700700  a->hardlimit = a->high;
    701701  oldspace_protected_area->end = a->high;
    702702  uncommit_pages(a->high, delta);
    703703  reserved->low -= delta;
    704   reserved->ndwords += (delta>>3);
     704  reserved->ndnodes += (delta>>dnode_shift);
    705705  lisp_global(HEAP_END) -= delta;
    706706  return true;
     
    11851185  lisp_global(LEXPR_RETURN) = (LispObj)&nvalret;
    11861186  lisp_global(LEXPR_RETURN1V) = (LispObj)&popj;
    1187   lisp_global(ALL_AREAS) = (LispObj) (all_areas);
     1187  lisp_global(ALL_AREAS) = ptr_to_lispobj(all_areas);
    11881188
    11891189
     
    11961196 
    11971197
    1198   lisp_global(IMAGE_NAME) = (LispObj) image_name;
    1199   lisp_global(ARGV) = (LispObj) argv;
    1200   lisp_global(KERNEL_IMPORTS) = (LispObj) import_ptrs_base;
     1198  lisp_global(IMAGE_NAME) = ptr_to_lispobj(image_name);
     1199  lisp_global(ARGV) = ptr_to_lispobj(argv);
     1200  lisp_global(KERNEL_IMPORTS) = (LispObj)import_ptrs_base;
    12011201
    12021202  lisp_global(METERING_INFO) = (LispObj) &lisp_metering;
     
    12041204  *(double *) &(lisp_global(DOUBLE_FLOAT_ONE)) = (double) 1.0;
    12051205
    1206   lisp_global(ARGV) = (LispObj) argv;
    12071206  lisp_global(HOST_PLATFORM) = (LispObj)
    12081207#ifdef LINUX
     
    12421241    tenured_area->younger = g2_area;
    12431242    tenured_area->refbits = a->markbits;
    1244     lisp_global(TENURED_AREA) = (LispObj)(tenured_area);
     1243    lisp_global(TENURED_AREA) = ptr_to_lispobj(tenured_area);
    12451244    g2_area->threshold = (4<<20); /* 4MB */
    12461245    g1_area->threshold = (2<<20); /* 2MB */
     
    12531252  thread_init_tcr(tcr, current_sp, current_sp-stack_base);
    12541253
    1255   lisp_global(EXCEPTION_LOCK) = (LispObj)new_recursive_lock();
     1254  lisp_global(EXCEPTION_LOCK) = ptr_to_lispobj(new_recursive_lock());
    12561255  enable_fp_exceptions();
    12571256  start_vbl();
     
    12621261#endif
    12631262  tcr->prev = tcr->next = tcr;
    1264   lisp_global(TCR_LOCK) = (LispObj)new_recursive_lock();
     1263  lisp_global(TCR_LOCK) = ptr_to_lispobj(new_recursive_lock());
    12651264  lisp_global(INTERRUPT_SIGNAL) = (LispObj) box_fixnum(SIGNAL_FOR_PROCESS_INTERRUPT);
    12661265  tcr->interrupt_level = (-1<<fixnumshift);
  • trunk/ccl/lisp-kernel/spentry.s

    r529 r557  
    100100        __(li fn,0)
    101101        __(add imm1,vsp,nargs)
    102         __(la imm1,-4(imm1))
     102        __(la imm1,-node_size(imm1))
    103103        __(bne cr0,local_label(_throw_all_values))
    104104        __(set_nargs(1))
     
    127127        __(bne cr1,local_label(_throw_multiple))
    128128/* Catcher expects single value in arg_z */
    129         __(ldr(arg_z,-4(imm0)))
     129        __(ldr(arg_z,-node_size(imm0)))
    130130        __(b local_label(_throw_pushed_values))
    131131local_label(_throw_multiple):
     
    135135        __(subi imm2,imm2,fixnum_one)
    136136        __(cmpri(imm2,0))
    137         __(lwzu temp0,-4(imm0))
     137        __(ldru(temp0,-node_size(imm0)))
    138138        __(push(temp0,imm1))
    139139        __(bgt local_label(_throw_mvloop))
     
    190190        __(b local_label(_nthrowv_push_test))
    191191local_label(_nthrowv_push_loop):
    192         __(lwzu temp1,-4(imm1))
     192        __(ldru(temp1,-node_size(imm1)))
    193193        __(push(temp1,imm0))
    194194local_label(_nthrowv_push_test):
     
    227227        __(add imm1,nargs,vsp)
    228228        __(ldr(imm0,tsp_frame.backlink(tsp)))                      /* end of tsp frame */
    229         __(str(rzero,-4(imm0)))
     229        __(str(rzero,-node_size(imm0)))
    230230        __(la imm0,tsp_frame.data_offset(tsp))
    231231        __(str(nargs,0(imm0)))
    232232        __(b local_label(_nthrowv_tpushtest))
    233233local_label(_nthrowv_tpushloop):
    234         __(lwzu temp0,-4(imm1))
    235         __(stru(temp0,4(imm0)))
     234        __(ldru(temp0,-node_size(imm1)))
     235        __(stru(temp0,node_size(imm0)))
    236236        __(subi imm2,imm2,fixnum_one)
    237237local_label(_nthrowv_tpushtest):
    238238        __(cmpri(imm2,0))
    239239        __(bne local_label(_nthrowv_tpushloop))
    240         __(stru(imm4,4(imm0)))
     240        __(stru(imm4,node_size(imm0)))
    241241        __(ldr(vsp,lisp_frame.savevsp(sp)))
    242242        __(str(rzero,lisp_frame.savevsp(sp)))       /* tell stack overflow code to skip this frame */
     
    251251        __(b local_label(_nthrowv_tpoptest))
    252252local_label(_nthrowv_tpoploop):
    253         __(lwzu temp0,4(imm0))
     253        __(ldru(temp0,node_size(imm0)))
    254254        __(vpush(temp0))
    255255        __(subi imm2,imm2,fixnum_one)
     
    257257        __(cmpri(imm2,0))
    258258        __(bne local_label(_nthrowv_tpoploop))
    259         __(ldr(imm4,4(imm0)))
     259        __(ldr(imm4,node_size(imm0)))
    260260        __(unlink(tsp))
    261261        __(b local_label(_nthrowv_nextframe))
     
    319319        __(TSP_Alloc_Fixed_Boxed(8)) /* tsp overhead, value, throw count */
    320320        __(str(arg_z,tsp_frame.data_offset(tsp)))
    321         __(str(imm4,tsp_frame.data_offset+4(tsp)))
     321        __(str(imm4,tsp_frame.data_offset+node_size(tsp)))
    322322        __(ldr(vsp,lisp_frame.savevsp(sp)))
    323323        __(str(rzero,lisp_frame.savevsp(sp)))       /* Tell stack overflow code to ignore this frame */
    324324        __(bctrl)
    325325        __(ldr(arg_z,tsp_frame.data_offset(tsp)))
    326         __(ldr(imm4,tsp_frame.data_offset+4(tsp)))
     326        __(ldr(imm4,tsp_frame.data_offset+node_size(tsp)))
    327327        __(ldr(fn,lisp_frame.savefn(sp)))
    328328        __(ldr(loc_pc,lisp_frame.savelr(sp)))
     
    367367        __(ldr(temp0,0(vsp)))
    368368        __(cmpri(nargs,fixnum_one))
    369         __(la vsp,4(vsp))
     369        __(la vsp,node_size(vsp))
    370370        __(Cons(arg_z,temp0,arg_z))
    371371        __(subi nargs,nargs,fixnum_one)
     
    382382        __(ldr(temp0,0(vsp)))
    383383        __(cmpri(nargs,fixnum_one))
    384         __(la vsp,4(vsp))
     384        __(la vsp,node_size(vsp))
    385385        __(Cons(arg_z,temp0,arg_z))
    386386        __(subi nargs,nargs,fixnum_one)
     
    4014011:      __(ldr(temp0,0(vsp)))
    402402        __(cmpri(cr1,nargs,fixnum_one))
    403         __(la vsp,4(vsp))
     403        __(la vsp,node_size(vsp))
    404404        __(rplaca(imm1,temp0))
    405405        __(rplacd(imm1,arg_z))
     
    4224221:      __(ldr(temp0,0(vsp)))
    423423        __(cmpri(cr1,nargs,fixnum_one))
    424         __(la vsp,4(vsp))
     424        __(la vsp,node_size(vsp))
    425425        __(rplaca(imm1,temp0))
    426426        __(rplacd(imm1,arg_z))
     
    447447        __(add imm1,imm0,nargs)
    4484481:
    449         __(la nargs,-4(nargs))
     449        __(la nargs,-node_size(nargs))
    450450        __(cmpri(cr1,nargs,0))
    451451        __(ldr(temp1,0(vsp)))
    452         __(la vsp,4(vsp))
    453         __(stwu temp1,-4(imm1))
     452        __(la vsp,node_size(vsp))
     453        __(stru(temp1,-node_size(imm1)))
    454454        __(bne cr1,1b)
    4554552:
     
    504504   heap-cons the object if there's no room on the tstack.) */
    505505_spentry(stack_misc_alloc)
     506ifdef([PPC64],[
     507        ],[       
    506508        __(rlwinm. imm2,arg_y,32-fixnumshift,0,(8+fixnumshift)-1)
    507509        __(unbox_fixnum(imm0,arg_z))
     
    550552        __(srwi imm2,imm2,fixnumshift+3)
    551553        __(b 1b)
    552 
     554])
     555       
    553556/* subtype (boxed, of course) is vpushed, followed by nargs bytes worth of */
    554557/* initial-contents.  Note that this can be used to cons any type of initialized */
     
    638641        __(li arg_z,nil_value)
    639642        __(neg imm1,imm1)
    640         __(subi imm1,imm1,4)
     643        __(subi imm1,imm1,node_size)
    641644        __(bge 1f)
    642645        __(ldrx(arg_z,imm0,imm1))
    6436461:     
    644         __(la vsp,4(imm0))
     647        __(la vsp,node_size(imm0))
    645648        __(blr)
    646649       
     
    665668        __(add imm0,nargs,vsp)
    666669        __(blt- cr0,1f)
    667         __(ldr(arg_z,-4(imm0)))
     670        __(ldr(arg_z,-node_size(imm0)))
    6686711:
    669672        __(mr vsp,temp0)
     
    696699        __(cmpr(cr0,imm2,nargs))
    697700        __(addi imm2,imm2,fixnum_one)
    698         __(lwzu arg_z,-4(imm1))
     701        __(ldru(arg_z,-node_size(imm1)))
    699702        __(push(arg_z,imm0))
    700703        __(bne cr0,5b)
     
    756759        __(ldr(temp0,0(vsp)))
    757760        __(cmpri(imm1,fixnum_one))
    758         __(la vsp,4(vsp))
     761        __(la vsp,node_size(vsp))
    759762        __(Cons(arg_z,temp0,arg_z))
    760763        __(subi imm1,imm1,fixnum_one)
     
    776779        __(ldr(temp0,0(vsp)))
    777780        __(cmpri(imm1,fixnum_one))
    778         __(la vsp,4(vsp))
     781        __(la vsp,node_size(vsp))
    779782        __(Cons(arg_z,temp0,arg_z))
    780783        __(subi imm1,imm1,fixnum_one)
     
    793796        __(ldr(temp0,0(vsp)))
    794797        __(cmpri(imm1,fixnum_one))
    795         __(la vsp,4(vsp))
     798        __(la vsp,node_size(vsp))
    796799        __(Cons(arg_z,temp0,arg_z))
    797800        __(subi imm1,imm1,fixnum_one)
     
    890893        __(subi arg_z,arg_z,2<<fixnumshift)
    891894        __(cmplri(cr0,arg_z,0))
    892         __(ldr(arg_x,0(varptr)))
    893         __(ldr(arg_y,4(varptr)))
    894         __(str(imm4,0(varptr)))
    895         __(str(imm4,4(varptr)))
    896         __(la varptr,8(varptr))
    897         __(str(arg_x,0(valptr)))
    898         __(str(arg_y,4(valptr)))
    899         __(la valptr,8(valptr))
     895        __(ldr(arg_x,node_size*0(varptr)))
     896        __(ldr(arg_y,node_size*1(varptr)))
     897        __(str(imm4,node_size*0(varptr)))
     898        __(str(imm4,node_size*1(varptr)))
     899        __(la varptr,node_size*2(varptr))
     900        __(str(arg_x,node_size*0(valptr)))
     901        __(str(arg_y,node_size*1(valptr)))
     902        __(la valptr,node_size*2(valptr))
    900903        __(bne cr0,4b)
    901904
     
    9139165:
    914917        __(cmpwi cr0,keyword_flags,16<<fixnumshift) /* seen :a-o-k yet ? */
    915         __(lwzu arg_z,-4(valptr))
    916         __(lwzu arg_y,-4(valptr))
     918        __(ldru(arg_z,-node_size(valptr)))
     919        __(ldru(arg_y,-node_size(valptr)))
    917920        __(cmpri(cr1,arg_y,nil_value))
    918921        __(li arg_x,nrs.kallowotherkeys)
     
    13371340/* Argument in arg_z, result in imm0.  May use temp0. */
    13381341_spentry(getxlong)
     1342ifdef([PPC64],[
     1343        ],[       
    13391344        __(extract_lisptag(imm0,arg_z))
    13401345        __(cmpri(cr0,imm0,tag_fixnum))
     
    13681373local_label(error):
    13691374        __(uuo_interr(error_object_not_integer,arg_z)) /* not quite right but what 68K MCL said */
    1370        
     1375
     1376])
     1377               
    13711378/* Everything up to the last arg has been vpushed, nargs is set to
    13721379   the (boxed) count of things already pushed.
     
    13751382   ppc2-invoke-fn assumes that temp1 is preserved here. */
    13761383_spentry(spreadargz)
     1384ifdef([PPC64],[
     1385        ],[       
    13771386        __(extract_lisptag(imm1,arg_z))
    13781387        __(cmpri(cr1,imm1,tag_list))
     
    14081417        __(set_nargs(2))
    14091418        __(b _SPksignalerr)
    1410 
     1419])
    14111420       
    14121421/* Tail-recursively funcall temp0. */
     
    14241433        __(add imm1,imm1,vsp)
    142514341:
    1426         __(lwzu temp2,-4(imm1))
     1435        __(ldru(temp2,-node_size(imm1)))
    14271436        __(cmpr(cr0,imm1,vsp))
    14281437        __(push(temp2,imm0))
     
    14481457        __(mtlr loc_pc)
    144914581:
    1450         __(lwzu temp2,-4(imm1))
     1459        __(ldru(temp2,-node_size(imm1)))
    14511460        __(cmpr(cr0,imm1,vsp))
    14521461        __(push(temp2,imm0))
     
    14821491        __(add imm1,imm1,vsp)
    148314921:
    1484         __(lwzu temp2,-4(imm1))
     1493        __(ldru(temp2,-node_size(imm1)))
    14851494        __(cmpr(cr0,imm1,vsp))
    14861495        __(push(temp2,imm0))
     
    15071516        __(add imm1,imm1,vsp)
    150815171:
    1509         __(lwzu temp2,-4(imm1))
     1518        __(ldru(temp2,-node_size(imm1)))
    15101519        __(cmpr(cr0,imm1,vsp))
    15111520        __(push(temp2,imm0))
     
    15421551        __(add imm1,imm1,vsp)
    154315521:
    1544         __(lwzu fname,-4(imm1))
     1553        __(ldru(fname,-node_size(imm1)))
    15451554        __(cmpr(cr0,imm1,vsp))
    15461555        __(push(fname,imm0))
     
    15581567       
    15591568_spentry(misc_ref)
     1569ifdef([PPC64],[
     1570        ],[
    15601571        __(trap_unless_fulltag_equal(arg_y,fulltag_misc,imm0))
    15611572        __(trap_unless_lisptag_equal(arg_z,tag_fixnum,imm0))
     
    15681579   lisp object in arg_z.  Do type and bounds-checking.
    15691580*/
    1570        
     1581])       
    15711582misc_ref_common:
     1583ifdef([PPC64],[
     1584        ],[       
    15721585        __(extract_fulltag(imm2,imm1))
    15731586        __(cmpri(cr0,imm2,fulltag_nodeheader))
     
    16671680        __(str(imm1,double_float.value+4(arg_z)))
    16681681        __(blr)
     1682])       
    16691683       
    16701684       
     
    16871701        __(vpush(imm0))
    16881702        __(vpush(imm0))
    1689         __(andi. imm0,vsp,1<<2) /* (oddp vsp ?) */
     1703        __(andi. imm0,vsp,1<<word_shift) /* (oddp vsp ?) */
    16901704        __(beq cr0,1f)
    1691         __(str(arg_y,8(vsp))) /* car */
    1692         __(str(arg_z,4(vsp))) /* cdr */
    1693         __(la arg_z,fulltag_cons+4(vsp))
    1694         __(blr)
    1695 1:
    1696         __(str(arg_y,4(vsp))) /* car, again */
     1705        __(str(arg_y,node_size*2(vsp))) /* car */
     1706        __(str(arg_z,node_size(vsp))) /* cdr */
     1707        __(la arg_z,fulltag_cons+node_size(vsp))
     1708        __(blr)
     17091:
     1710        __(str(arg_y,node_size(vsp))) /* car, again */
    16971711        __(str(arg_z,0(vsp)))
    16981712        __(la arg_z,fulltag_cons(vsp))
     
    18151829        __(li arg_z,nil_value)
    18161830        __(ldr(imm2,tsp_frame.backlink(tsp)))
    1817         __(la imm2,-8+tag_list(imm2))
     1831        __(la imm2,-tsp_frame.fixed_overhead+fulltag_cons(imm2))
    18181832        __(b 2f)
    181918331:
     
    18471861
    18481862_spentry(stkgvector)
    1849         __(la imm0,-4(nargs))
     1863        __(la imm0,-fixnum_one(nargs))
    18501864        __(cmpri(cr1,imm0,0))
    18511865        __(add imm1,vsp,nargs)
    1852         __(lwzu temp0,-4(imm1))
     1866        __(ldru(temp0,-node_size(imm1)))
    18531867        __(slwi imm2,imm0,num_subtag_bits-fixnumshift)
    18541868        __(rlwimi imm2,temp0,32-fixnumshift,32-num_subtag_bits,31)
     
    18631877        __(addi imm0,imm0,fixnum1)
    18641878        __(cmpr(cr1,imm0,nargs))
    1865         __(lwzu temp0,-4(imm1))
    1866         __(stwu temp0,4(imm3))
     1879        __(ldru(temp0,-node_size(imm1)))
     1880        __(stru(temp0,node_size(imm3)))
    186718812:
    18681882        __(bne cr1,1b)
     
    18871901
    18881902_spentry(misc_alloc)
     1903ifdef([PPC64],[
     1904        ],[       
    18891905        __(extract_unsigned_byte_bits_(imm2,arg_y,24))
    18901906        __(unbox_fixnum(imm0,arg_z))
     
    191919359:
    19201936        __(uuo_interr(error_object_not_unsigned_byte_24,arg_y))
     1937])       
    19211938       
    19221939/* almost exactly as above, but "swap exception handling info"
     
    19962013        __(b 1f)
    199720140:      __(mr imm1,imm2)
    1998         __(ldr(temp0,4(imm1)))
     2015        __(ldr(temp0,binding.sym(imm1)))
    19992016        __(cmpr(temp0,arg_y))
    2000         __(ldr(imm2,0(imm1)))
     2017        __(ldr(imm2,binding.link(imm1)))
    20012018        __(cmpri(cr1,imm2,0))
    20022019        __(bne 1f)
    2003         __(ldr(arg_z,8(imm1)))
     2020        __(ldr(arg_z,binding.val(imm1)))
    20042021        __(b 9f)
    200520221:      __(bne cr1,0b)
     
    20322049
    20332050_spentry(macro_bind)
     2051ifdef([PPC64],[
     2052        ],[       
    20342053        __(mr whole_reg,arg_reg)
    20352054        __(extract_lisptag(imm0,arg_reg))
     
    20432062        __(set_nargs(2))
    20442063        __(b _SPksignalerr)
    2045 
     2064])
    20462065
    20472066_spentry(destructuring_bind)
     
    20512070_spentry(destructuring_bind_inner)
    20522071        __(mr whole_reg,arg_z)
    2053 destbind1:     
     2072destbind1:
     2073ifdef([PPC64],[
     2074        ],[
    20542075        /* Extract required arg count. */
    20552076         /* A bug in gas: can't handle shift count of "32" (= 0 */
     
    22272248        __(li temp0,t_value)
    22282249        __(bne cr0,match_keys_loop)     /* already saw this */
    2229         __(str(arg_y,4(imm0)))
    2230         __(str(temp0,0(imm0)))
     2250        __(str(arg_y,node_size*1(imm0)))
     2251        __(str(temp0,node_size*2(imm0)))
    22312252        __(b match_keys_loop)
    22322253match_test:
     
    22592280        __(set_nargs(2))
    22602281        __(b _SPksignalerr)
    2261        
     2282])     
    22622283/* vpush the values in the value set atop the vsp, incrementing nargs. */
    22632284/* Discard the tsp frame; leave values atop the vsp. */
     
    22712292        __(mr imm2,tsp) /* last segment */
    22722293local_label(walkloop):
    2273         __(ldr(imm3,12(imm1))) /* next segment */
     2294        __(ldr(imm3,tsp_frame.fixed_overhead+node_size(imm1))) /* next segment */
    22742295        __(cmpr(cr0,imm0,imm3)) /* last segment? */
    2275         __(str(imm2,12(imm1))) /* reverse pointer */
     2296        __(str(imm2,tsp_frame.fixed_overhead+node_size(imm1))) /* reverse pointer */
    22762297        __(mr imm2,imm1) /* last segment <- current segment */
    22772298        __(mr imm1,imm3) /* current segment <- next segment */
     
    22812302/* walk backwards, pushing values on VSP and incrementing NARGS */
    22822303local_label(pushloop):
    2283         __(ldr(imm0,8(imm2))) /* nargs in segment */
     2304        __(ldr(imm0,tsp_frame.data_offset(imm2))) /* nargs in segment */
    22842305        __(cmpri(cr0,imm0,0))
    22852306        __(cmpr(cr1,imm2,tsp))
    2286         __(la imm3,16(imm2))
     2307        __(la imm3,tsp_frame.data_offset+(2*node_size)(imm2))
    22872308        __(add imm3,imm3,imm0)
    22882309        __(add nargs,nargs,imm0)
    22892310        __(b 2f)
    229023111:
    2291         __(lwzu arg_z,-4(imm3))
     2312        __(ldru(arg_z,-node_size(imm3)))
    22922313        __(cmpri(cr0,imm0,fixnum_one))
    22932314        __(subi imm0,imm0,fixnum_one)
     
    229523162:
    22962317        __(bne cr0,1b)
    2297         __(ldr(imm2,12(imm2))) /* previous segment */
     2318        __(ldr(imm2,tsp_frame.data_offset+node_size(imm2))) /* previous segment */
    22982319        __(bne cr1,local_label(pushloop))
    22992320        __(unlink(tsp))
     
    23092330        __(beq cr1,local_label(yz))
    23102331        __(blt cr1,local_label(z))
    2311         __(ldr(arg_z,0(vsp)))
    2312         __(ldr(arg_y,4(vsp)))
    2313         __(ldr(arg_x,8(vsp)))
    2314         __(la vsp,12(vsp))
     2332        __(ldr(arg_z,node_size*0(vsp)))
     2333        __(ldr(arg_y,node_size*1(vsp)))
     2334        __(ldr(arg_x,node_size*2(vsp)))
     2335        __(la vsp,node_size*3(vsp))
    23152336        __(blr)
    23162337local_label(yz):
    2317         __(ldr(arg_z,0(vsp)))
    2318         __(ldr(arg_y,4(vsp)))
    2319         __(la vsp,8(vsp))
     2338        __(ldr(arg_z,node_size*0(vsp)))
     2339        __(ldr(arg_y,node_size*1(vsp)))
     2340        __(la vsp,node_size*2(vsp))
    23202341        __(blr)
    23212342local_label(z):
    2322         __(ldr(arg_z,0(vsp)))
    2323         __(la vsp,4(vsp))
     2343        __(ldr(arg_z,node_size*0(vsp)))
     2344        __(la vsp,node_size*1(vsp))
    23242345        __(blr)
    23252346
     
    23472368/* like misc_set, only pass the (boxed) subtag in temp0 */
    23482369_spentry(subtag_misc_set)
     2370ifdef([PPC64],[
     2371],[               
    23492372        __(trap_unless_fulltag_equal(arg_x,fulltag_misc,imm0))
    23502373        __(trap_unless_lisptag_equal(arg_y,tag_fixnum,imm0))
     
    23522375        __(trlge(arg_y,imm0))
    23532376        __(unbox_fixnum(imm1,temp0))
     2377])       
    23542378misc_set_common:
     2379        ifdef([PPC64],[
     2380        ],[
    23552381        __(extract_fulltag(imm2,imm1))
    23562382        __(cmpri(cr0,imm2,fulltag_nodeheader))
     
    25142540        __(strx(imm2,arg_x,imm0))
    25152541        __(blr)
    2516        
     2542])       
    25172543
    25182544/* "spread" the lexpr in arg_z.
     
    25272553        __(cmpri(cr1,nargs,0))
    25282554        __(cmpri(cr2,nargs,2<<fixnumshift))
    2529         __(la imm1,4(imm1))
     2555        __(la imm1,node_size(imm1))
    25302556        __(bge cr3,9f)
    25312557        __(beq cr4,2f)
     
    25472573        __(cmpri(cr3,imm0,4<<fixnumshift))
    25482574        __(subi imm0,imm0,fixnumone)
    2549         __(lwzu arg_z,-4(imm1))
     2575        __(ldru(arg_z,-node_size(imm1)))
    25502576        __(vpush(arg_z))
    255125779:
    25522578        __(bne cr3,8b)
    2553         __(ldr(arg_x,-4(imm1)))
    2554         __(ldr(arg_y,-8(imm1)))
    2555         __(ldr(arg_z,-12(imm1)))
     2579        __(ldr(arg_x,-node_size*1(imm1)))
     2580        __(ldr(arg_y,-node_size*2(imm1)))
     2581        __(ldr(arg_z,-node_size*3(imm1)))
    25562582        __(blr)
    25572583
     
    25592585        /* lexpr, maybe vpop arg_x */
    256025862:     
    2561         __(ldr(arg_y,-4(imm1)))
    2562         __(ldr(arg_z,-8(imm1)))
     2587        __(ldr(arg_y,-node_size*1(imm1)))
     2588        __(ldr(arg_z,-node_size*2(imm1)))
    25632589        __(beqlr cr2)           /* return if (new) nargs = 2 */
    25642590        __(vpop(arg_x))
     
    25682594        /* maybe vpop arg_y, arg_x */
    256925951:     
    2570         __(ldr(arg_z,-4(imm1)))
     2596        __(ldr(arg_z,-node_size(imm1)))
    25712597        __(bltlr cr2)           /* return if (new) nargs < 2 */
    25722598        __(vpop(arg_y))
     
    26032629        __(cmpri(cr0,imm3,1<<fixnumshift))
    26042630        __(subi imm3,imm3,1<<fixnumshift)
    2605         __(lwzu temp0,-4(imm0))
    2606         __(stwu temp0,-4(imm2))
     2631        __(ldru(temp0,-node_size(imm0)))
     2632        __(stru(temp0,-node_size(imm2)))
    26072633        __(bne cr0,1b)
    260826342:
     
    26362662        __(str(imm1,tsp_frame.backlink(tsp))) /* keep one tsp "frame" as far as rest of lisp is concerned */
    26372663        __(str(nargs,tsp_frame.data_offset(tsp)))
    2638         __(str(imm2,tsp_frame.data_offset+4(tsp))) /* previous tsp */
    2639         __(la imm3,tsp_frame.data_offset+8(tsp))
     2664        __(str(imm2,tsp_frame.data_offset+node_size(tsp))) /* previous tsp */
     2665        __(la imm3,tsp_frame.data_offset+node_size*2(tsp))
    26402666        __(add imm3,imm3,nargs)
    26412667        __(add imm0,vsp,nargs)
     
    26432669        __(b 2f)
    264426701:
    2645         __(lwzu arg_z,-4(imm0))
     2671        __(ldru(arg_z,-node_size(imm0)))
    26462672        __(cmpr(cr0,imm0,vsp))
    2647         __(stwu arg_z,-4(imm3))
     2673        __(stru(arg_z,-node_size(imm3)))
    264826742:
    26492675        __(bne cr0,1b)
     
    28612887        /* Next, determine the length of arg_y.  We */
    28622888        /* know that it's a proper list. */
    2863         __(li imm0,-4)
     2889        __(li imm0,-node_size)
    28642890        __(mr temp0,arg_y)
    286528911:
    28662892        __(cmpri(cr0,temp0,nil_value))
    2867         __(la imm0,4(imm0))
     2893        __(la imm0,node_size(imm0))
    28682894        __(_cdr(temp0,temp0))
    28692895        __(bne 1b)
     
    32793305
    32803306_spentry(builtin_eql)
     3307ifdef([PPC64],[
     3308        ],[       
    32813309        __(cmpr(cr0,arg_y,arg_z))
    32823310        __(extract_lisptag(imm0,arg_y))
     
    329233202:      __(li arg_z,nil_value)
    32933321        __(blr)
     3322])       
    32943323       
    32953324_spentry(builtin_length)
     3325ifdef([PPC64],[
     3326        ],[   
    32963327        __(extract_typecode(imm0,arg_z))
    32973328        __(cmpri(cr0,imm0,min_vector_subtag))
     
    33293360        __(mr arg_z,temp2)
    33303361        __(blr)
     3362])       
    33313363
    33323364_spentry(builtin_seqtype)
     3365ifdef([PPC64],[
     3366],[               
    33333367        __(extract_typecode(imm0,arg_z))
    33343368        __(cmpri(cr0,imm0,tag_list))
     
    334233762:
    33433377        __(jump_builtin(_builtin_seqtype,1))
     3378])       
    33443379       
    33453380_spentry(builtin_assq)
     
    43194354        /* Next, determine the length of arg_y.  We */
    43204355        /* know that it's a proper list. */
    4321         __(li imm0,-4)
     4356        __(li imm0,-node_size)
    43224357        __(mr temp4,arg_y)
    432343581:
    43244359        __(cmpri(cr0,temp4,nil_value))
    4325         __(la imm0,4(imm0))
     4360        __(la imm0,node_size(imm0))
    43264361        __(_cdr(temp4,temp4))
    43274362        __(bne 1b)
Note: See TracChangeset for help on using the changeset viewer.