Changeset 13645


Ignore:
Timestamp:
Apr 19, 2010, 11:36:19 AM (10 years ago)
Author:
gb
Message:

Some new files (just started to define things based on ppc32 versions,
tried to pick off low-hanging fruit) and changes. (Way too early to
consider changes significant.)

Location:
branches/arm/lisp-kernel
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/arm/lisp-kernel/arm-constants.h

    r13630 r13645  
    2424#define temp1 4
    2525#define temp2 5
    26 #define temp3 6
    27 #define fn    7
    28 #define rcontext 8
    29 #define imm0 9
    30 #define imm1 10
     26#define fn    6
     27#define rcontext 7
     28#define imm0 8
     29#define imm1 9
     30#define imm2 10
    3131#define allocptr 11
    3232#define vsp 12
     
    3535#define pc 15
    3636
    37 #define fname temp3
     37#define fname temp1
    3838#define nfn temp2
    3939#define next_method_context temp1
    40 #define nargs imm1
     40#define nargs imm2
    4141#define allocbase temp0         /* while consing */
    4242
     
    5959#define node_shift 2
    6060
    61 #define TCR_FLAG_BIT_FOREIGN fixnumshift
    62 #define TCR_FLAG_BIT_AWAITING_PRESET (fixnumshift+1)
    63 #define TCR_FLAG_BIT_ALT_SUSPEND (fixnumshift+2)
    64 #define TCR_FLAG_BIT_PROPAGATE_EXCEPTION (fixnumshift+3)
    65 #define TCR_FLAG_BIT_SUSPEND_ACK_PENDING (fixnumshift+4)
    66 #define TCR_FLAG_BIT_PENDING_EXCEPTION (fixnumshift+5)
    67 #define TCR_FLAG_BIT_FOREIGN_EXCEPTION (fixnumshift+6)
    68 #define TCR_FLAG_BIT_PENDING_SUSPEND (fixnumshift+7)
    69 
    70 #define TCR_STATE_FOREIGN (1)
    71 #define TCR_STATE_LISP    (0)
    72 #define TCR_STATE_EXCEPTION_WAIT (2)
    73 #define TCR_STATE_EXCEPTION_RETURN (4)
    7461
    7562/*  Tags. */
     
    10794
    10895
    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;
    11796
    11897
     
    227206#define max_non_array_node_subtag ((19<<ntagbits)|fulltag_immheader)
    228207       
    229 /*  The objects themselves look something like this: */
    230 
    231 typedef struct lispsymbol {
    232   LispObj header;
    233   LispObj pname;
    234   LispObj vcell;
    235   LispObj fcell;
    236   LispObj package_predicate;
    237   LispObj flags;
    238   LispObj plist;
    239   LispObj binding_index;
    240 } lispsymbol;
    241 
    242 typedef struct ratio {
    243   LispObj header;
    244   LispObj numer;
    245   LispObj denom;
    246 } ratio;
    247208
    248209typedef struct double_float {
     
    258219} single_float;
    259220
    260 typedef struct macptr {
    261   LispObj header;
    262   LispObj address;
    263   LispObj class;
    264   LispObj type;
    265 } macptr;
    266 
    267 typedef struct xmacptr {
    268   LispObj header;
    269   LispObj address;
    270   LispObj class;
    271   LispObj type;
    272   LispObj flags;
    273   LispObj link;
    274 } xmacptr;
    275  
    276 
    277 typedef struct eabi_c_frame {
    278   struct eabi_c_frame *backlink;
    279   unsigned savelr;
    280   unsigned params[8];
    281 } eabi_c_frame;
    282 
    283 /* PowerOpen ABI C frame */
    284 
    285 typedef struct c_frame {
    286   struct c_frame *backlink;
    287   unsigned crsave;
    288   unsigned savelr;
    289   unsigned unused[2];
    290   unsigned savetoc;             /* Used with CFM */
    291   unsigned params[8];           /* Space for callee to save r3-r10 */
    292 } c_frame;
    293 
    294 typedef struct lisp_frame {
    295   struct lisp_frame *backlink;
    296   LispObj savefn;
    297   LispObj savelr;
    298   LispObj savevsp;
    299 } lisp_frame;
    300 
    301 typedef struct special_binding {
    302   struct special_binding *link;
    303   struct lispsymbol *sym;
    304   LispObj value;
    305 } special_binding;
    306 
    307 /* The GC (at least) needs to know what a
    308    package looks like, so that it can do GCTWA. */
    309 typedef struct package {
    310   LispObj header;
    311   LispObj itab;                 /* itab and etab look like (vector (fixnum . fixnum) */
    312   LispObj etab;
    313   LispObj used;
    314   LispObj used_by;
    315   LispObj names;
    316   LispObj shadowed;
    317 } package;
    318221
    319222/*
     
    352255} xframe_list;
    353256
    354 #define fixnum_bitmask(n)  (1<<((n)+fixnumshift))
    355 
    356 /*
    357   The GC (at least) needs to know about hash-table-vectors and their flag bits.
    358 */
    359 
    360 typedef struct hash_table_vector_header {
    361   LispObj header;
    362   LispObj link;                 /* If weak */
    363   LispObj flags;                /* a fixnum; see below */
    364   LispObj gc_count;             /* gc-count kernel global */
    365   LispObj free_alist;           /* preallocated conses for finalization_alist */
    366   LispObj finalization_alist;   /* key/value alist for finalization */
    367   LispObj weak_deletions_count; /* incremented when GC deletes weak pair */
    368   LispObj hash;                 /* backpointer to hash-table */
    369   LispObj deleted_count;        /* number of deleted entries [not maintained if lock-free] */
    370   LispObj count;                /* number of valid entries [not maintained if lock-free] */
    371   LispObj cache_idx;            /* index of last cached pair */
    372   LispObj cache_key;            /* value of last cached key */
    373   LispObj cache_value;          /* last cached value */
    374   LispObj size;                 /* number of entries in table */
    375   LispObj size_reciprocal;      /* shifted reciprocal of size */
    376 } hash_table_vector_header;
    377 
    378 /*
    379   Bits (masks)  in hash_table_vector.flags:
    380 */
    381 
    382 /* GC should track keys when addresses change */
    383 #define nhash_track_keys_mask fixnum_bitmask(28)
    384 
    385 /* GC should set when nhash_track_keys_bit & addresses change */
    386 #define nhash_key_moved_mask  fixnum_bitmask(27)
    387 
    388 /* weak on key or value (need new "weak both" encoding.) */
    389 #define nhash_weak_mask       fixnum_bitmask(12)
    390 
    391 /* weak on value */
    392 #define nhash_weak_value_mask fixnum_bitmask(11)
    393 
    394 /* finalizable */
    395 #define nhash_finalizable_mask fixnum_bitmask(10)
    396 
    397 /* keys frozen, i.e. don't clobber keys, only values */
    398 #define nhash_keys_frozen_mask fixnum_bitmask(9)
    399 
    400 /* Lfun bits */
    401 
    402 #define lfbits_nonnullenv_mask fixnum_bitmask(0)
    403 #define lfbits_keys_mask fixnum_bitmask(1)
    404 #define lfbits_restv_mask fixnum_bitmask(7)
    405 #define lfbits_optinit_mask fixnum_bitmask(14)
    406 #define lfbits_rest_mask fixnum_bitmask(15)
    407 #define lfbits_aok_mask fixnum_bitmask(16)
    408 #define lfbits_lap_mask fixnum_bitmask(23)
    409 #define lfbits_trampoline_mask fixnum_bitmask(24)
    410 #define lfbits_evaluated_mask fixnum_bitmask(25)
    411 #define lfbits_cm_mask fixnum_bitmask(26)         /* combined_method */
    412 #define lfbits_nextmeth_mask fixnum_bitmask(26)   /* or call_next_method with method_mask */
    413 #define lfbits_gfn_mask fixnum_bitmask(27)        /* generic_function */
    414 #define lfbits_nextmeth_with_args_mask fixnum_bitmask(27)   /* or call_next_method_with_args with method_mask */
    415 #define lfbits_method_mask fixnum_bitmask(28)     /* method function */
    416 /* PPC only but want it defined for xcompile */
    417 #define lfbits_noname_mask fixnum_bitmask(29)
    418 
    419 
    420 /* Creole */
    421 
    422 #define doh_quantum 400
    423 #define doh_block_slots ((doh_quantum >> 2) - 3)
    424 
    425 typedef struct doh_block {
    426   struct doh_block *link;
    427   unsigned size;
    428   unsigned free;
    429   LispObj data[doh_block_slots];
    430 } doh_block, *doh_block_ptr;
    431 
    432 
    433 #define population_weak_list (0<<fixnum_shift)
    434 #define population_weak_alist (1<<fixnum_shift)
    435 #define population_termination_bit (16+fixnum_shift)
    436 #define population_type_mask ((1<<population_termination_bit)-1)
    437 
    438 #define gc_retain_pages_bit fixnum_bitmask(0)
    439 #define gc_integrity_check_bit fixnum_bitmask(2)
    440 #define egc_verbose_bit fixnum_bitmask(3)
    441 #define gc_verbose_bit fixnum_bitmask(4)
    442 #define gc_allow_stack_overflows_bit fixnum_bitmask(5)
    443 #define gc_postgc_pending fixnum_bitmask(26)
    444 
    445257#include "lisp-errors.h"
    446258
     
    448260
    449261
    450 #define nil_value (0x00003015+(LOWMEM_BIAS))
     262#define nil_value (0x10000000+fulltag_nil)
    451263
    452264#define TCR_BIAS (0)
  • branches/arm/lisp-kernel/arm-macros.s

    r13632 r13645  
    5858
    5959define(`box_fixnum',`
    60         __(mov #1,$2 lsl #fixnumshift)
     60        __(mov #1,$2, lsl #fixnumshift)
    6161        ')
    6262
    6363define(`unbox_fixnum',`
    64         __(mov $1,$2 asr #fixnumshift)
     64        __(mov $1,$2, asr #fixnumshift)
    6565        ')
    6666
     
    7272        ')
    7373
    74 define(`push',`
    75         __(stru($1,-node_size($2)))
     74define(`push1',`
     75        __(str $1,[$2,#-node_size]!)
    7676        ')
    7777       
    7878        /* Generally not a great idea. */
    79 define(`pop',`
    80         __(ldr($1,0($2)))
    81         __(la $2,node_size($2))
    82         ')
    83        
    84 define(`vpush',`
    85         __(push($1,vsp))
    86         ')
    87        
    88 define(`vpop',`
    89         __(pop($1,vsp))
     79define(`pop1',`
     80        __(ldr $1,[$2],#node_size)
     81        ')
     82       
     83define(`vpush1',`
     84        __(push1($1,vsp))
     85        ')
     86       
     87define(`vpop1',`
     88        __(pop1($1,vsp))
    9089        ')
    9190       
     
    106105
    107106define(`vref32',`
    108         __(lwz $1,misc_data_offset+(($3)<<2)($2))
     107        __(ldr #1,[$2,#misc_data_offset+(($3)<<2)])
    109108        ')
    110109       
     
    113112        ')
    114113       
    115 ifdef(`PPC64',`
    116         define(`vref64',`
    117         __(ld $1,misc_data_offset+(($3)<<3)($2))
    118         ')
    119 
    120         define(`vrefr',`
    121         __(vref64($1,$2,$3))
    122         ')
    123 ',`
    124         define(`vrefr',`
     114define(`vrefr',`
    125115        __(vref32($1,$2,$3))
    126116        ')
    127 ')
     117
     118
    128119       
    129120                       
     
    132123        ')
    133124       
    134         /* Size is unboxed element count */
    135 define(`header_size',`
    136         __(srri($1,$2,num_subtag_bits))
    137         ')
    138125       
    139126        /* "Length" is fixnum element count */
    140127define(`header_length',`
    141 ifdef(`PPC64',`
    142         __(rldicr $1,$2,nbits_in_word-(num_subtag_bits-nfixnumtagbits),63-nfixnumtagbits)
    143         __(clrldi $1,$1,(num_subtag_bits-nfixnumtagbits))
    144         ',`               
    145         __(rlwinm $1,$2,nbits_in_word-(num_subtag_bits-nfixnumtagbits),(num_subtag_bits-nfixnumtagbits),31-nfixnumtagbits)
     128        mov $1,#-1<<fixnumshift
     129        and $1,$1,$2,lsr #num_subtag_bits-fixnumshift
    146130        ')
    147131')       
    148132
    149133
    150 define(`vector_size',`
    151         __(getvheader(ifelse($3.`',$1,$3),$2))
    152         __(header_size($1,ifelse($3.`',$1,$3)))
    153         ')
    154        
    155134define(`vector_length',`
    156135        __(getvheader($3,$2))
     
    193172        /* vpop argregs - nargs is known to be non-zero */
    194173define(`vpop_argregs_nz',`
    195         new_macro_labels()
    196         __(cmplri(cr1,nargs,node_size*2))
    197         __(vpop(arg_z))
    198         __(blt cr1,macro_label(l0))
    199         __(vpop(arg_y))
    200         __(bne cr1,macro_label(l0))
    201         __(vpop(arg_x))
    202 macro_label(l0):')
     174        __(cmp nargs,#node_size*2)
     175        __(vpop1(arg_z))
     176        __(ldrhs arg_y,[vsp],#node_size)
     177        __(ldrhi arg_x,[vsp],#node_size)
     178        ')
    203179
    204180               
     
    238214       
    239215define(`_car',`
    240         __(ldr($1,cons.car($2)))
     216        __(ldr $1,[$2,#cons.car])
    241217')
    242218       
    243219define(`_cdr',`
    244         __(ldr($1,cons.cdr($2)))
     220        __(ldr $1,[$2,#cons.cdr])
    245221        ')
    246222       
    247223define(`_rplaca',`
    248         __(str($2,cons.car($1)))
     224        __(str $2,[$1,#cons.car])
    249225        ')
    250226       
    251227define(`_rplacd',`
    252         __(str($2,cons.cdr($1)))
    253         ')
    254 
    255 define(`vpush_saveregs',`
    256         __(vpush(save7))
    257         __(vpush(save6))
    258         __(vpush(save5))
    259         __(vpush(save4))
    260         __(vpush(save3))
    261         __(vpush(save2))
    262         __(vpush(save1))
    263         __(vpush(save0))
    264         ')
    265        
    266 define(`restore_saveregs',`
    267         __(ldr(save0,node_size*0($1)))
    268         __(ldr(save1,node_size*1($1)))
    269         __(ldr(save2,node_size*2($1)))
    270         __(ldr(save3,node_size*3($1)))
    271         __(ldr(save4,node_size*4($1)))
    272         __(ldr(save5,node_size*5($1)))
    273         __(ldr(save6,node_size*6($1)))
    274         __(ldr(save7,node_size*7($1)))
    275 ')
    276 
    277 define(`vpop_saveregs',`
    278         __(restore_saveregs(vsp))
    279         __(la vsp,node_size*8(vsp))
    280 ')
     228        __(str $2,[$1,#cons.cdr])
     229        ')
     230
    281231
    282232define(`trap_unless_lisptag_equal',`
     
    285235')
    286236
    287 ifdef(`PPC64',`
    288 define(`trap_unless_list',`
    289         new_macro_labels()
    290         __(cmpdi ifelse($3,$3,cr0),$1,nil_value)
    291         __(extract_fulltag($2,$1))
    292         __(beq ifelse($3,$3,cr0),macro_label(is_list))
    293         __(tdnei $2,fulltag_cons)
    294 macro_label(is_list):   
    295 
    296 ')',`   
    297237define(`trap_unless_list',`
    298238        __(trap_unless_lisptag_equal($1,tag_list,$2))
    299 ')
    300239')
    301240
     
    312251/* "jump" to the code-vector of the function in nfn. */
    313252define(`jump_nfn',`
    314         __(ldr(temp0,_function.codevector(nfn)))
    315         __(mtctr temp0)
    316         __(bctr)
     253        __(ldr pc,[nfn,#_function.codevector])
    317254')
    318255
    319256/* "call the code-vector of the function in nfn. */
    320257define(`call_nfn',`
    321         __(ldr(temp0,_function.codevector(nfn)))
    322         __(mtctr temp0)
    323         __(bctrl)
     258        __(ldr lr,[nfn,#_function.codevector])
     259        __(blx lr)
    324260')
    325261       
     
    327263/* "jump" to the function in fnames function cell. */
    328264define(`jump_fname',`
    329         __(ldr(nfn,symbol.fcell(fname)))
     265        __(ldr nfn,[fname,#symbol.fcell])
    330266        __(jump_nfn())
    331267')
     
    333269/* call the function in fnames function cell. */
    334270define(`call_fname',`
    335         __(ldr(nfn,symbol.fcell(fname)))
     271        __(ldr nfn,[fname,#symbol.fcell])
    336272        __(call_nfn())
    337273')
    338274
    339 define(`do_funcall',`
    340         new_macro_labels()
    341         __(extract_fulltag(imm0,temp0))
    342         __(cmpri(imm0,fulltag_misc))
    343         __(mr nfn,temp0)
    344         __(bne- macro_label(bad))
    345         __(extract_subtag(imm0,temp0))
    346         __(cmpri(imm0,subtag_function))
    347         __(cmpri(cr1,imm0,subtag_symbol))
    348         __(bne cr0,macro_label(_sym))
    349         __(jump_nfn())
    350 macro_label(_sym):             
    351         __(mr fname,temp0)
    352         __(bne cr1,macro_label(bad))
    353         __(jump_fname())
    354 macro_label(bad):
    355         __(uuo_interr(error_cant_call,temp0))
     275define(`funcall_nfn',`
     276        __(extract_typecode(imm0,nfn))
     277        __(cmp imm0,#subtag_symbol)
     278        __(moveq fname,nfn)
     279        __(ldreq nfn,[fname,#symbol.fcell])
     280        __(cmpne imm0,#subtag_function)
     281        __(ldreq pc,[nfn,#_function.entrypoint])
     282        __(uuo_error_cant_call(nfn,al))
     283
    356284')     
    357285
     
    393321')     
    394322
    395 define(`restore_catch_nvrs',`
    396         __(ldr(first_nvr,catch_frame.regs+(node_size*0)($1)))
    397         __(ldr(second_nvr,catch_frame.regs+(node_size*1)($1)))
    398         __(ldr(third_nvr,catch_frame.regs+(node_size*2)($1)))
    399         __(ldr(fourth_nvr,catch_frame.regs+(node_size*3)($1)))
    400         __(ldr(fifth_nvr,catch_frame.regs+(node_size*4)($1)))
    401         __(ldr(sixth_nvr,catch_frame.regs+(node_size*5)($1)))
    402         __(ldr(seventh_nvr,catch_frame.regs+(node_size*6)($1)))
    403         __(ldr(eighth_nvr,catch_frame.regs+(node_size*7)($1)))
    404 ')               
    405 
    406 define(`DCBZL',`
    407         __(.long (31<<26)+(1<<21)+($1<<16)+($2<<11)+(1014<<1))
    408 ')
     323
    409324       
    410325define(`check_stack_alignment',`
     
    419334
    420335define(`clear_alloc_tag',`
    421         __(clrrri(allocptr,allocptr,ntagbits))
    422 ')
    423 
    424 /* If the GC interrupts the current thread (after the trap), it needs */
    425 /*   to ensure that the cons cell that's been "reserved" stays reserved */
    426 /*   (e.g. the tagged allocptr has to be treated as a node.)  If that */
    427 /*   reserved cons cell gets tenured, the car and cdr are of a generation */
    428 /*   that's at least as old (so memoization isn't an issue.) */
    429 
    430 /*   More generally, if the GC interrupts a thread when allocptr is */
    431 /*   tagged as a cons: */
    432 
    433 /*    a) if the trap hasn't been taken (yet), the GC should force the */
    434 /*       thread to resume in such a way that the trap will be taken ; */
    435 /*       the segment allocator should worry about allocating the object. */
    436 
    437 /*    b) If the trap has been taken, allocptr is treated as a node as */
    438 /*       described above.  Allocbase is made to point to the base of the */
    439 /*       cons cell, so that the thread's next allocation attempt will */
    440 /*       invoke the segment allocator. */
    441        
     336        __(bic allocptr,allocptr,#fulltagmask)
     337')
     338
    442339define(`Cons',`
    443         __(la allocptr,(-cons.size+fulltag_cons)(allocptr))
    444         __(alloc_trap())
    445         __(str($3,cons.cdr(allocptr)))
    446         __(str($2,cons.car(allocptr)))
    447         __(mr $1,allocptr)
     340        __(ldr allocbase,[rcontext,#tcr.save_allocbase])
     341        __(add allocptr,allocptr,#-cons.size+fulltag_cons)
     342        __(cmp allocptr,allocbase)
     343        __(uuo_alloc_trap(lo))
     344        __(str $3,[allocptr,#cons.cdr])
     345        __(str $2,[allocptr,#cons.car])
     346        __(mov $1,allocptr)
    448347        __(clear_alloc_tag())
    449348')
Note: See TracChangeset for help on using the changeset viewer.