Changeset 13734


Ignore:
Timestamp:
May 23, 2010, 2:48:43 AM (9 years ago)
Author:
gb
Message:

Some notes on consing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/arm/lisp-kernel/ARM-notes.txt

    r13687 r13734  
    220220fault handler and unprotect pages there.)
    221221
     222
     223 - consing & pc-lusering
     224
     225The magic consing sequence (that pc_luser_xp() and maybe handle_alloc_trap()
     226will have to recognize) is basically:
     227
     2281: decrement allocptr by an amount that'll leave it tagged as either
     229   tag_misc or tag_cons. 
     230
     231  a) CONSes:
     232   (sub allocptr allocptr (:$ (- arm::cons.size arm::fulltag-cons)))
     233
     234  b) UVECTORs whose aligned size is known and <= 64K
     235   (sub allocptr allocptr (:$ (logand (- size arm::fulltag-misc) #xff)))
     236   (sub allocptr allocptr (:$ (logandc2 (- size arm::fulltag-misc)) #xff))
     237
     238   Note that the second instruction above can be omitted if (<= size 256);
     239   if two instructions are used to decrement allocptr, they should be
     240   done in this order.
     241
     242  c) UVECTORs whose size is > 64K or computed; this should be preceded
     243  something which loads (- size arm::fulltag-misc) into some imm reg REG:
     244
     245   (sub allocptr allocptr REG)
     246 
     247After this instruction (after the first in case (b)), allocptr is tagged
     248and the entire sequence needs to be completed or restarted by pc_luser_xp().
     249
     2502: Load (:@ rcontext (:$ arm::tcr.allocbase)) into some available GPR.
     251We can't afford to dedicate a register to contain allocbase, and
     252tcr.allobase can ordinarily change on any instruction boundardy so we
     253can only do this after decrementing and tagging allocptr in step 1 above.
     254
     255   (ldr reg2 (:@ rcontext (:$ arm::tcr.allocbase)))
     256
     257"reg2" can't be the same register used in 1c and shouldn't conflict with
     258anything used to contain headers/CAR/CDR values, but can otherwise be
     259any GPR.
     260
     2613: Compare allocptr to the register holding allocbase; do a uuo-alloc-trap
     262if allocptr is U< allocbase.  (We could encode the "lo" condition in
     263uuo-alloc-trap if we wanted to>)
     264
     265   (cmp allocptr reg2)
     266   (uuo-alloc-trap (:? lo))
     267
     268If the trap is taken, the handler should be able to determine the size
     269and tag of the allocation and resume execution at the next instruction
     270with allocptr pointing at zeroed memory.  The register used to hold
     271allocbase won't change, but its value may or may not have anything to
     272do with tcr.allocbase at this point.
     273
     2744: Initialize the object; if a UVECTOR, set its header.  If a CONS, set
     275its CAR and CDR.
     276
     277    (str header (:@ allocptr (:$ arm::misc-header-offset)))
     278
     279    or
     280
     281    (str Rcar (:@ allocptr (:$ arm::cons.car)))
     282    (str Rcdr (:@ allocptr (:$ arm::cons.cdr)))
     283
     2845: Copy allocptr to the destination register.  (In the CONS case, this may
     285have been one of Rcar/Rcdr);
     286
     287    (mov dest allocptr)
     288
     2896: Clear the low 3 bits of allocptr.
     290
     291     (bic allocptr allocptr (:$ arm::fulltagmask))
     292
     293This is basically the same sequence as is used on the PPC; the differences
     294are:
     295
     296  a) We might decrement allocptr twice in (1b)
     297  b) We don't use a dedicated register to contain allocbase, and have
     298     to load it from the TCR into a temp register after allocptr's been
     299     decremented.
     300  c) We don't exactly have conditional traps, so we have to do a compare
     301     followed by a conditional UUO.
     302
     303
Note: See TracChangeset for help on using the changeset viewer.