2 ;;; Written by William Lott.
10 (define-vop (length/list)
12 (:args (object :scs (descriptor-reg) :target ptr))
14 (:temporary (:scs (descriptor-reg) :from (:argument 0)) ptr)
15 (:temporary (:scs (non-descriptor-reg)) temp)
16 (:temporary (:scs (any-reg) :type fixnum :to (:result 0) :target result)
18 (:results (result :scs (any-reg descriptor-reg)))
21 (:save-p :compute-only)
23 (let ((done (gen-label))
25 (not-list (gen-label)))
31 (inst cmpw ptr null-tn)
34 (test-type ptr not-list t (list-pointer-lowtag) :temp temp)
36 (loadw ptr ptr cons-cdr-slot list-pointer-lowtag)
37 (inst addi count count (fixnumize 1))
38 (test-type ptr loop nil (list-pointer-lowtag) :temp temp)
41 (error-call vop 'object-not-list-error ptr)
44 (move result count))))
47 (define-static-fun length (object) :translate length)