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.
17 (define-vop (reset-stack-pointer)
18 (:args (ptr :scs (any-reg)))
22 ;;; Push some values onto the stack, returning the start and number of values
23 ;;; pushed as results. It is assumed that the Vals are wired to the standard
24 ;;; argument locations. Nvals is the number of values to push.
26 ;;; The generator cost is pseudo-random. We could get it right by defining a
27 ;;; bogus SC that reflects the costs of the memory-to-memory moves for each
28 ;;; operand, but this seems unworthwhile.
29 (define-vop (push-values)
30 (:args (vals :more t))
31 (:temporary (:sc unsigned-reg :to (:result 0) :target start) temp)
32 (:results (start) (count))
35 (move temp esp-tn) ; WARN pointing 1 below
36 (do ((val vals (tn-ref-across val)))
38 (inst push (tn-ref-tn val)))
40 (inst mov count (fixnumize nvals))))
42 ;;; Push a list of values on the stack, returning Start and Count as used in
43 ;;; unknown values continuations.
44 (define-vop (values-list)
45 (:args (arg :scs (descriptor-reg) :target list))
48 (:results (start :scs (any-reg))
49 (count :scs (any-reg)))
50 (:temporary (:sc descriptor-reg :from (:argument 0) :to (:result 1)) list)
51 (:temporary (:sc descriptor-reg :to (:result 1)) nil-temp)
52 (:temporary (:sc unsigned-reg :offset eax-offset :to (:result 1)) eax)
54 (:save-p :compute-only)
57 (move start esp-tn) ; WARN pointing 1 below
58 (inst mov nil-temp nil-value)
61 (inst cmp list nil-temp)
63 (pushw list cons-car-slot list-pointer-type)
64 (loadw list list cons-cdr-slot list-pointer-type)
66 (inst and al-tn lowtag-mask)
67 (inst cmp al-tn list-pointer-type)
69 (error-call vop bogus-argument-to-values-list-error list)
72 (inst mov count start) ; start is high address
73 (inst sub count esp-tn))) ; stackp is low address
75 ;;; Copy the more arg block to the top of the stack so we can use them
76 ;;; as function arguments.
78 ;;; Accepts a context as produced by more-arg-context; points to the first
79 ;;; value on the stack, not 4 bytes above as in other contexts.
81 ;;; Return a context that is 4 bytes above the first value, suitable for
82 ;;; defining a new stack frame.
83 (define-vop (%more-arg-values)
84 (:args (context :scs (descriptor-reg any-reg) :target src)
85 (skip :scs (any-reg immediate))
86 (num :scs (any-reg) :target count))
87 (:arg-types * positive-fixnum positive-fixnum)
88 (:temporary (:sc any-reg :offset esi-offset :from (:argument 0)) src)
89 (:temporary (:sc descriptor-reg :offset eax-offset) temp)
90 (:temporary (:sc unsigned-reg :offset ecx-offset) temp1)
91 (:results (start :scs (any-reg))
92 (count :scs (any-reg)))
96 (cond ((zerop (tn-value skip))
100 (inst lea src (make-ea :dword :base context
101 :disp (- (* (tn-value skip) word-bytes))))
103 (inst sub count (* (tn-value skip) word-bytes)))))
109 (inst sub count skip)))
112 (inst mov start esp-tn)
113 (inst jecxz done) ; check for 0 count?
115 (inst shr temp1 word-shift) ; convert the fixnum to a count.
117 (inst std) ; move down the stack as more value are copied to the bottom.