Changeset 8746


Ignore:
Timestamp:
Mar 13, 2008, 3:55:49 AM (12 years ago)
Author:
rme
Message:

Heap-walking functions WALK-STATIC-AREA, %WALK-DYNAMIC-AREA,
and WALK-DYNAMIC-AREA.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ia32/level-0/X86/X8632/x8632-utils.lisp

    r8633 r8746  
    6565  (single-value-return))
    6666
    67 
    68 
     67;;; In these heap-walking functions, all other threads should be
     68;;; suspended; the only consing that should happen is any consing
     69;;; that the function (the "f" argument) does when we call it.
     70;;;
     71;;; We can therefore basically walk dnode-aligned addresses (but we
     72;;; have to be careful, especially in the %WALK-DYNAMIC-AREA case,
     73;;; to hold onto only tagged pointers when we call the funtion, since
     74;;; consing by the called function could cause a gc).
     75
     76(defx8632lapfunction walk-static-area ((a arg_y) (f arg_z))
     77  (let ((obj temp0)
     78        (fun -4)
     79        (limit -8))
     80    (save-simple-frame)
     81    (push (% f))
     82    (pushl (@ x8632::area.active (% a)))
     83    (movl (@ x8632::area.low (% a)) (% obj))
     84    (jmp @test)
     85    @loop
     86    (movb (@ (% obj)) (% imm0.b))
     87    (andb ($ x8632::fulltagmask) (% imm0.b))
     88    (cmpb ($ x8632::fulltag-immheader) (% imm0.b))
     89    (je @misc)
     90    (cmpb ($ x8632::fulltag-nodeheader) (% imm0.b))
     91    (je @misc)
     92    ;; not a header, so must be a cons
     93    (add ($ x8632::fulltag-cons) (% obj))
     94    (mov (% obj) (% arg_z))
     95    (set-nargs 1)
     96    (push (% obj))
     97    (:talign 5)
     98    (call (@ fun (% ebp)))
     99    (recover-fn)
     100    (pop (% obj))
     101    (add ($ (- x8632::cons.size x8632::fulltag-cons)) (% obj))
     102    (jmp @test)
     103    @misc
     104    (add ($ x8632::fulltag-misc) (% obj))
     105    (mov (% obj) (% arg_z))
     106    (set-nargs 1)
     107    (push (% obj))
     108    (:talign 5)
     109    (call (@ fun (% ebp)))
     110    (recover-fn)
     111    (pop (% obj))
     112    (sub ($ x8632::fulltag-misc) (% obj))
     113    (mov (% obj) (% imm0))
     114    (andb ($ x8632::fulltagmask) (% imm0.b))
     115    (cmpb ($ x8632::fulltag-nodeheader) (% imm0.b))
     116    (je @32)
     117    (mov (% obj) (% imm0))
     118    (cmpb ($ x8632::max-32-bit-ivector-subtag) (% imm0.b))
     119    (jle @32)
     120    (cmpb ($ x8632::max-8-bit-ivector-subtag) (% imm0.b))
     121    (jle @8)
     122    (cmpb ($ x8632::max-16-bit-ivector-subtag) (% imm0.b))
     123    (jle @16)
     124    (cmpb ($ x8632::subtag-double-float-vector) (% imm0.b))
     125    (je @double-float)
     126    ;; if we get here, it's a bit vector
     127    (shrl ($ x8632::num-subtag-bits) (% imm0))
     128    (add ($ 7) (% imm0))
     129    (shrl ($ 3) (% imm0))
     130    (jmp @uvector-next)
     131    @double-float
     132    (shrl ($ x8632::num-subtag-bits) (% imm0))
     133    (shll ($ 3) (% imm0))
     134    (jmp @uvector-next)
     135    @8
     136    (shrl ($ x8632::num-subtag-bits) (% imm0))
     137    (jmp @uvector-next)
     138    @16
     139    (shrl ($ x8632::num-subtag-bits) (% imm0))
     140    (shll ($ 1) (% imm0))
     141    (jmp @uvector-next)
     142    @32
     143    (shrl ($ x8632::num-subtag-bits) (% imm0))
     144    (shll ($ 2) (% imm0))
     145    ;; size of obj in bytes (without header or alignment padding)
     146    ;; is in imm0
     147    @uvector-next
     148    (add ($ (+ x8632::node-size (1- x8632::dnode-size))) (% imm0))
     149    (andb ($ (lognot (1- x8632::dnode-size))) (% imm0.b))
     150    (add (% imm0) (% obj))
     151    @test
     152    (cmpl (@ limit (% ebp)) (% obj))
     153    (jb @loop)
     154    (movl ($ x8632::nil-value) (% arg_z))
     155    (restore-simple-frame)
     156    (single-value-return)))
     157
     158;;; This walks the active "dynamic" area.  Objects might be moving around
     159;;; while we're doing this, so we have to be a lot more careful than we
     160;;; are when walking a static area.
     161;;; There are a couple of approaches to termination:
     162;;;  a) Allocate a "sentinel" cons, and terminate when we run into it.
     163;;;  b) Check the area limit (which is changing if we're consing) and
     164;;;     terminate when we hit it.
     165;;; (b) loses if the function conses.  (a) conses.  I can't think of anything
     166;;; better than (a).
     167;;; This, of course, assumes that any GC we're doing does in-place compaction
     168;;; (or at least preserves the relative order of objects in the heap.)
     169
     170(defx8632lapfunction %walk-dynamic-area ((a arg_y) (f arg_z))
     171  (let ((obj temp0)
     172        (fun -4)
     173        (sentinel -8))
     174    (save-simple-frame)
     175    (push (% f))
     176    (subl ($ (- x8632::cons.size x8632::fulltag-cons))
     177          (@ (% :rcontext) x8632::tcr.save-allocptr))
     178    (movl (@ (% :rcontext) x8632::tcr.save-allocptr) (% allocptr)) ;aka temp0
     179    (cmpl (@ (% :rcontext) x8632::tcr.save-allocbase) (% allocptr))
     180    (jg @ok)
     181    (uuo-alloc)
     182    @ok
     183    (andb ($ (lognot x8632::fulltagmask))
     184          (@ (% :rcontext) x8632::tcr.save-allocptr))
     185    (push (% allocptr))                 ;sentinel
     186    (ref-global tenured-area a)
     187    (movl (@ x8632::area.low (% a)) (% obj))
     188    (jmp @test)
     189    @loop
     190    (movb (@ (% obj)) (% imm0.b))
     191    (andb ($ x8632::fulltagmask) (% imm0.b))
     192    (cmpb ($ x8632::fulltag-immheader) (% imm0.b))
     193    (je @misc)
     194    (cmpb ($ x8632::fulltag-nodeheader) (% imm0.b))
     195    (je @misc)
     196    ;; not a header, so must be a cons
     197    (add ($ x8632::fulltag-cons) (% obj))
     198    (mov (% obj) (% arg_z))
     199    (set-nargs 1)
     200    (push (% obj))
     201    (:talign 5)
     202    (call (@ fun (% ebp)))
     203    (recover-fn)
     204    (pop (% obj))
     205    (add ($ (- x8632::cons.size x8632::fulltag-cons)) (% obj))
     206    (jmp @test)
     207    @misc
     208    (add ($ x8632::fulltag-misc) (% obj))
     209    (mov (% obj) (% arg_z))
     210    (set-nargs 1)
     211    (push (% obj))
     212    (:talign 5)
     213    (call (@ fun (% ebp)))
     214    (recover-fn)
     215    (pop (% obj))
     216    (sub ($ x8632::fulltag-misc) (% obj))
     217    (mov (% obj) (% imm0))
     218    (andb ($ x8632::fulltagmask) (% imm0.b))
     219    (cmpb ($ x8632::fulltag-nodeheader) (% imm0.b))
     220    (je @32)
     221    (mov (% obj) (% imm0))
     222    (cmpb ($ x8632::max-32-bit-ivector-subtag) (% imm0.b))
     223    (jle @32)
     224    (cmpb ($ x8632::max-8-bit-ivector-subtag) (% imm0.b))
     225    (jle @8)
     226    (cmpb ($ x8632::max-16-bit-ivector-subtag) (% imm0.b))
     227    (jle @16)
     228    (cmpb ($ x8632::subtag-double-float-vector) (% imm0.b))
     229    (je @double-float)
     230    ;; if we get here, it's a bit vector
     231    (shrl ($ x8632::num-subtag-bits) (% imm0))
     232    (add ($ 7) (% imm0))
     233    (shrl ($ 3) (% imm0))
     234    (jmp @uvector-next)
     235    @double-float
     236    (shrl ($ x8632::num-subtag-bits) (% imm0))
     237    (shll ($ 3) (% imm0))
     238    (jmp @uvector-next)
     239    @8
     240    (shrl ($ x8632::num-subtag-bits) (% imm0))
     241    (jmp @uvector-next)
     242    @16
     243    (shrl ($ x8632::num-subtag-bits) (% imm0))
     244    (shll ($ 1) (% imm0))
     245    (jmp @uvector-next)
     246    @32
     247    (shrl ($ x8632::num-subtag-bits) (% imm0))
     248    (shll ($ 2) (% imm0))
     249    ;; size of obj in bytes (without header or alignment padding)
     250    ;; is in imm0
     251    @uvector-next
     252    (add ($ (+ x8632::node-size (1- x8632::dnode-size))) (% imm0))
     253    (andb ($ (lognot (1- x8632::dnode-size))) (% imm0.b))
     254    (add (% imm0) (% obj))
     255    @test
     256    (cmpl (@ sentinel (% ebp)) (% obj))
     257    (jb @loop)
     258    @done
     259    (movl ($ x8632::nil-value) (% arg_z))
     260    (restore-simple-frame)
     261    (single-value-return)))
     262
     263;;; xxx duplicated in level-0/x86-utils.lisp
     264(defun walk-dynamic-area (area func)
     265  (with-other-threads-suspended
     266      (%walk-dynamic-area area func)))
    69267
    70268(defx8632lapfunction use-lisp-heap-gc-threshold ()
Note: See TracChangeset for help on using the changeset viewer.