Changeset 13734

May 23, 2010, 2:48:43 AM (10 years ago)

Some notes on consing.

1 edited


  • branches/arm/lisp-kernel/ARM-notes.txt

    r13687 r13734  
    220220fault handler and unprotect pages there.)
     223 - consing & pc-lusering
     225The magic consing sequence (that pc_luser_xp() and maybe handle_alloc_trap()
     226will have to recognize) is basically:
     2281: decrement allocptr by an amount that'll leave it tagged as either
     229   tag_misc or tag_cons. 
     231  a) CONSes:
     232   (sub allocptr allocptr (:$ (- arm::cons.size arm::fulltag-cons)))
     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))
     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.
     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:
     245   (sub allocptr allocptr REG)
     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().
     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.
     255   (ldr reg2 (:@ rcontext (:$ arm::tcr.allocbase)))
     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.
     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>)
     265   (cmp allocptr reg2)
     266   (uuo-alloc-trap (:? lo))
     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.
     2744: Initialize the object; if a UVECTOR, set its header.  If a CONS, set
     275its CAR and CDR.
     277    (str header (:@ allocptr (:$ arm::misc-header-offset)))
     279    or
     281    (str Rcar (:@ allocptr (:$
     282    (str Rcdr (:@ allocptr (:$ arm::cons.cdr)))
     2845: Copy allocptr to the destination register.  (In the CONS case, this may
     285have been one of Rcar/Rcdr);
     287    (mov dest allocptr)
     2896: Clear the low 3 bits of allocptr.
     291     (bic allocptr allocptr (:$ arm::fulltagmask))
     293This is basically the same sequence as is used on the PPC; the differences
     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.
Note: See TracChangeset for help on using the changeset viewer.