1 ;;;; unknown-values VOPs for the x86 VM
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 (define-vop (reset-stack-pointer)
15 (:args (ptr :scs (any-reg)))
19 ;;; Push some values onto the stack, returning the start and number of values
20 ;;; pushed as results. It is assumed that the Vals are wired to the standard
21 ;;; argument locations. Nvals is the number of values to push.
23 ;;; The generator cost is pseudo-random. We could get it right by defining a
24 ;;; bogus SC that reflects the costs of the memory-to-memory moves for each
25 ;;; operand, but this seems unworthwhile.
26 (define-vop (push-values)
27 (:args (vals :more t))
28 (:temporary (:sc unsigned-reg :to (:result 0) :target start) temp)
29 (:results (start) (count))
32 (move temp esp-tn) ; WARN pointing 1 below
33 (do ((val vals (tn-ref-across val)))
35 (inst push (tn-ref-tn val)))
37 (inst mov count (fixnumize nvals))))
39 ;;; Push a list of values on the stack, returning Start and Count as used in
40 ;;; unknown values continuations.
41 (define-vop (values-list)
42 (:args (arg :scs (descriptor-reg) :target list))
45 (:results (start :scs (any-reg))
46 (count :scs (any-reg)))
47 (:temporary (:sc descriptor-reg :from (:argument 0) :to (:result 1)) list)
48 (:temporary (:sc descriptor-reg :to (:result 1)) nil-temp)
49 (:temporary (:sc unsigned-reg :offset eax-offset :to (:result 1)) eax)
51 (:save-p :compute-only)
54 (move start esp-tn) ; WARN pointing 1 below
55 (inst mov nil-temp nil-value)
58 (inst cmp list nil-temp)
60 (pushw list cons-car-slot list-pointer-type)
61 (loadw list list cons-cdr-slot list-pointer-type)
63 (inst and al-tn lowtag-mask)
64 (inst cmp al-tn list-pointer-type)
66 (error-call vop bogus-argument-to-values-list-error list)
69 (inst mov count start) ; start is high address
70 (inst sub count esp-tn))) ; stackp is low address
72 ;;; Copy the more arg block to the top of the stack so we can use them
73 ;;; as function arguments.
75 ;;; Accepts a context as produced by more-arg-context; points to the first
76 ;;; value on the stack, not 4 bytes above as in other contexts.
78 ;;; Return a context that is 4 bytes above the first value, suitable for
79 ;;; defining a new stack frame.
80 (define-vop (%more-arg-values)
81 (:args (context :scs (descriptor-reg any-reg) :target src)
82 (skip :scs (any-reg immediate))
83 (num :scs (any-reg) :target count))
84 (:arg-types * positive-fixnum positive-fixnum)
85 (:temporary (:sc any-reg :offset esi-offset :from (:argument 0)) src)
86 (:temporary (:sc descriptor-reg :offset eax-offset) temp)
87 (:temporary (:sc unsigned-reg :offset ecx-offset) temp1)
88 (:results (start :scs (any-reg))
89 (count :scs (any-reg)))
93 (cond ((zerop (tn-value skip))
97 (inst lea src (make-ea :dword :base context
98 :disp (- (* (tn-value skip) word-bytes))))
100 (inst sub count (* (tn-value skip) word-bytes)))))
106 (inst sub count skip)))
109 (inst mov start esp-tn)
110 (inst jecxz done) ; check for 0 count?
112 (inst shr temp1 word-shift) ; convert the fixnum to a count.
114 (inst std) ; move down the stack as more value are copied to the bottom.