(declare (type unsigned-byte n))
(if (< n register-arg-count)
(make-wired-tn *backend-t-primitive-type* register-arg-scn
- (elt *register-arg-offsets* n))
+ (elt *register-arg-offsets* n))
(make-wired-tn *backend-t-primitive-type* control-stack-arg-scn n)))
(specify-save-tn
(physenv-debug-live-tn (make-normal-tn *fixnum-primitive-type*) env)
(make-wired-tn *fixnum-primitive-type*
- control-stack-arg-scn
- ocfp-save-offset)))
+ control-stack-arg-scn
+ ocfp-save-offset)))
(!def-vm-support-routine make-return-pc-save-location (env)
(specify-save-tn
(physenv-debug-live-tn (make-normal-tn *backend-t-primitive-type*) env)
(make-wired-tn *backend-t-primitive-type*
- control-stack-arg-scn
- lra-save-offset)))
+ control-stack-arg-scn
+ lra-save-offset)))
;;; Make a TN for the standard argument count passing location. We
;;; only need to make the standard location, since a count is never
;;; continuation within a function.
(!def-vm-support-routine make-unknown-values-locations ()
(list (make-stack-pointer-tn)
- (make-normal-tn *fixnum-primitive-type*)))
+ (make-normal-tn *fixnum-primitive-type*)))
;;; This function is called by the ENTRY-ANALYZE phase, allowing
;;; VM-dependent initialization of the IR2-COMPONENT structure. We push
(declare (type component component))
(dotimes (i code-constants-offset)
(vector-push-extend nil
- (ir2-component-constants (component-info component))))
+ (ir2-component-constants (component-info component))))
(values))
\f
;;;; Frame hackery:
-;;; this is the first function in this file that differs materially from
+;;; this is the first function in this file that differs materially from
;;; ../alpha/call.lisp
(defun bytes-needed-for-non-descriptor-stack-frame ()
(logandc2 (+ +stack-alignment-bytes+ number-stack-displacement
- (* (sb-allocated-size 'non-descriptor-stack) n-word-bytes))
- +stack-alignment-bytes+))
+ (* (sb-allocated-size 'non-descriptor-stack) n-word-bytes))
+ +stack-alignment-bytes+))
;;; Used for setting up the Old-FP in local call.
(:generator 1
(let ((nfp (current-nfp-tn vop)))
(when nfp
- (inst addi val nfp (bytes-needed-for-non-descriptor-stack-frame))))))
+ (inst addi val nfp (bytes-needed-for-non-descriptor-stack-frame))))))
(define-vop (xep-allocate-frame)
(:info start-lab copy-more-arg-follows)
(:generator 1
;; Make sure the function is aligned, and drop a label pointing to this
;; function header.
- (align n-lowtag-bits)
+ (emit-alignment n-lowtag-bits)
(trace-table-entry trace-table-fun-prologue)
(emit-label start-lab)
;; Allocate function header.
(inst word 0))
(let* ((entry-point (gen-label)))
(emit-label entry-point)
- (inst compute-code-from-fn code-tn lip-tn entry-point temp))
+ (inst compute-code-from-lip code-tn lip-tn entry-point temp))
;; FIXME alpha port has a ### note here saying we should "save it
;; on the stack" so that GC sees it. No idea what "it" is -dan 20020110
;; Build our stack frames.
(inst addi csp-tn cfp-tn
- (* n-word-bytes (sb-allocated-size 'control-stack)))
+ (* n-word-bytes (sb-allocated-size 'control-stack)))
(let ((nfp-tn (current-nfp-tn vop)))
(when nfp-tn
- (let* ((nbytes (bytes-needed-for-non-descriptor-stack-frame)))
- (when (> nbytes number-stack-displacement)
- (inst stwu nsp-tn nsp-tn (- nbytes))
- (inst addi nfp-tn nsp-tn number-stack-displacement)))))
+ (let* ((nbytes (bytes-needed-for-non-descriptor-stack-frame)))
+ (when (> nbytes number-stack-displacement)
+ (inst stwu nsp-tn nsp-tn (- nbytes))
+ (inst addi nfp-tn nsp-tn number-stack-displacement)))))
(trace-table-entry trace-table-normal)))
(define-vop (allocate-frame)
(:results (res :scs (any-reg))
- (nfp :scs (any-reg)))
+ (nfp :scs (any-reg)))
(:info callee)
(:generator 2
(trace-table-entry trace-table-fun-prologue)
(move res csp-tn)
(inst addi csp-tn csp-tn
- (* n-word-bytes (sb-allocated-size 'control-stack)))
+ (* n-word-bytes (sb-allocated-size 'control-stack)))
(when (ir2-physenv-number-stack-p callee)
(let* ((nbytes (bytes-needed-for-non-descriptor-stack-frame)))
- (when (> nbytes number-stack-displacement)
- (inst stwu nsp-tn nsp-tn (- (bytes-needed-for-non-descriptor-stack-frame)))
- (inst addi nfp nsp-tn number-stack-displacement))))
+ (when (> nbytes number-stack-displacement)
+ (inst stwu nsp-tn nsp-tn (- (bytes-needed-for-non-descriptor-stack-frame)))
+ (inst addi nfp nsp-tn number-stack-displacement))))
(trace-table-entry trace-table-normal)))
;;; Allocate a partial frame for passing stack arguments in a full call. Nargs
;;;
;;; The general-case code looks like this:
#|
- b regs-defaulted ; Skip if MVs
- nop
+ b regs-defaulted ; Skip if MVs
+ nop
- move a1 null-tn ; Default register values
- ...
- loadi nargs 1 ; Force defaulting of stack values
- move old-fp csp ; Set up args for SP resetting
+ move a1 null-tn ; Default register values
+ ...
+ loadi nargs 1 ; Force defaulting of stack values
+ move old-fp csp ; Set up args for SP resetting
regs-defaulted
- subcc temp nargs register-arg-count
+ subcc temp nargs register-arg-count
- b :lt default-value-7 ; jump to default code
- loadw move-temp ocfp-tn 6 ; Move value to correct location.
+ b :lt default-value-7 ; jump to default code
+ loadw move-temp ocfp-tn 6 ; Move value to correct location.
subcc temp 1
- store-stack-tn val4-tn move-temp
+ store-stack-tn val4-tn move-temp
- b :lt default-value-8
- loadw move-temp ocfp-tn 7
+ b :lt default-value-8
+ loadw move-temp ocfp-tn 7
subcc temp 1
- store-stack-tn val5-tn move-temp
+ store-stack-tn val5-tn move-temp
- ...
+ ...
defaulting-done
- move csp ocfp ; Reset SP.
+ move csp ocfp ; Reset SP.
<end of code>
<elsewhere>
default-value-7
- store-stack-tn val4-tn null-tn ; Nil out 7'th value. (first on stack)
+ store-stack-tn val4-tn null-tn ; Nil out 7'th value. (first on stack)
default-value-8
- store-stack-tn val5-tn null-tn ; Nil out 8'th value.
+ store-stack-tn val5-tn null-tn ; Nil out 8'th value.
- ...
+ ...
- br defaulting-done
+ br defaulting-done
nop
|#
;;; differences from alpha: (1) alpha tests for lra-label before
-;;; compute-code-from-lra and skips if nil. (2) loop termination is
+;;; compute-code-from-lra and skips if nil. (2) loop termination is
;;; different when clearing stack defaults
(defun default-unknown-values (vop values nvals move-temp temp lra-label)
(declare (type (or tn-ref null) values)
- (type unsigned-byte nvals) (type tn move-temp temp))
+ (type unsigned-byte nvals) (type tn move-temp temp))
(if (<= nvals 1)
(progn
- (sb!assem:without-scheduling ()
- (note-this-location vop :single-value-return)
- (move csp-tn ocfp-tn)
- (inst nop))
- (inst compute-code-from-lra code-tn code-tn lra-label temp))
+ (sb!assem:without-scheduling ()
+ (note-this-location vop :single-value-return)
+ (move csp-tn ocfp-tn)
+ (inst nop))
+ (inst compute-code-from-lra code-tn code-tn lra-label temp))
(let ((regs-defaulted (gen-label))
- (defaulting-done (gen-label))
- (default-stack-vals (gen-label)))
- ;; Branch off to the MV case.
- (sb!assem:without-scheduling ()
- (note-this-location vop :unknown-return)
- (if (> nvals register-arg-count)
- (inst addic. temp nargs-tn (- (fixnumize register-arg-count)))
- (move csp-tn ocfp-tn))
- (inst b regs-defaulted))
-
- ;; Do the single value case.
- (do ((i 1 (1+ i))
- (val (tn-ref-across values) (tn-ref-across val)))
- ((= i (min nvals register-arg-count)))
- (move (tn-ref-tn val) null-tn))
- (when (> nvals register-arg-count)
- (move ocfp-tn csp-tn)
- (inst b default-stack-vals))
-
- (emit-label regs-defaulted)
- (when (> nvals register-arg-count)
- (collect ((defaults))
- (do ((i register-arg-count (1+ i))
- (val (do ((i 0 (1+ i))
- (val values (tn-ref-across val)))
- ((= i register-arg-count) val))
- (tn-ref-across val)))
- ((null val))
-
- (let ((default-lab (gen-label))
- (tn (tn-ref-tn val)))
- (defaults (cons default-lab tn))
-
- (inst lwz move-temp ocfp-tn (* i n-word-bytes))
- (inst ble default-lab)
- (inst addic. temp temp (- (fixnumize 1)))
- (store-stack-tn tn move-temp)))
-
- (emit-label defaulting-done)
- (move csp-tn ocfp-tn)
-
- (let ((defaults (defaults)))
- (when defaults
- (assemble (*elsewhere*)
- (emit-label default-stack-vals)
- (trace-table-entry trace-table-fun-prologue)
- (do ((remaining defaults (cdr remaining)))
- ((null remaining))
- (let ((def (car remaining)))
- (emit-label (car def))
- (store-stack-tn (cdr def) null-tn)))
- (inst b defaulting-done)
- (trace-table-entry trace-table-normal))))))
-
- (inst compute-code-from-lra code-tn code-tn lra-label temp)))
+ (defaulting-done (gen-label))
+ (default-stack-vals (gen-label)))
+ ;; Branch off to the MV case.
+ (sb!assem:without-scheduling ()
+ (note-this-location vop :unknown-return)
+ (if (> nvals register-arg-count)
+ (inst addic. temp nargs-tn (- (fixnumize register-arg-count)))
+ (move csp-tn ocfp-tn))
+ (inst b regs-defaulted))
+
+ ;; Do the single value case.
+ (do ((i 1 (1+ i))
+ (val (tn-ref-across values) (tn-ref-across val)))
+ ((= i (min nvals register-arg-count)))
+ (move (tn-ref-tn val) null-tn))
+ (when (> nvals register-arg-count)
+ (move ocfp-tn csp-tn)
+ (inst b default-stack-vals))
+
+ (emit-label regs-defaulted)
+ (when (> nvals register-arg-count)
+ (collect ((defaults))
+ (do ((i register-arg-count (1+ i))
+ (val (do ((i 0 (1+ i))
+ (val values (tn-ref-across val)))
+ ((= i register-arg-count) val))
+ (tn-ref-across val)))
+ ((null val))
+
+ (let ((default-lab (gen-label))
+ (tn (tn-ref-tn val)))
+ (defaults (cons default-lab tn))
+
+ (inst lwz move-temp ocfp-tn (* i n-word-bytes))
+ (inst ble default-lab)
+ (inst addic. temp temp (- (fixnumize 1)))
+ (store-stack-tn tn move-temp)))
+
+ (emit-label defaulting-done)
+ (move csp-tn ocfp-tn)
+
+ (let ((defaults (defaults)))
+ (when defaults
+ (assemble (*elsewhere*)
+ (emit-label default-stack-vals)
+ (trace-table-entry trace-table-fun-prologue)
+ (do ((remaining defaults (cdr remaining)))
+ ((null remaining))
+ (let ((def (car remaining)))
+ (emit-label (car def))
+ (store-stack-tn (cdr def) null-tn)))
+ (inst b defaulting-done)
+ (trace-table-entry trace-table-normal))))))
+
+ (inst compute-code-from-lra code-tn code-tn lra-label temp)))
(values))
\f
(defun receive-unknown-values (args nargs start count lra-label temp)
(declare (type tn args nargs start count temp))
(let ((variable-values (gen-label))
- (done (gen-label)))
+ (done (gen-label)))
(sb!assem:without-scheduling ()
(inst b variable-values)
(inst nop))
-
+
(inst compute-code-from-lra code-tn code-tn lra-label temp)
(inst addi csp-tn csp-tn 4)
(storew (first *register-arg-tns*) csp-tn -1)
(inst subi start csp-tn 4)
(inst li count (fixnumize 1))
-
+
(emit-label done)
-
+
(assemble (*elsewhere*)
(trace-table-entry trace-table-fun-prologue)
(emit-label variable-values)
(inst compute-code-from-lra code-tn code-tn lra-label temp)
(do ((arg *register-arg-tns* (rest arg))
- (i 0 (1+ i)))
- ((null arg))
- (storew (first arg) args i))
+ (i 0 (1+ i)))
+ ((null arg))
+ (storew (first arg) args i))
(move start args)
(move count nargs)
(inst b done)
(start :scs (any-reg))
(count :scs (any-reg)))
(:temporary (:sc descriptor-reg :offset ocfp-offset
- :from :eval :to (:result 0))
- values-start)
+ :from :eval :to (:result 0))
+ values-start)
(:temporary (:sc any-reg :offset nargs-offset
- :from :eval :to (:result 1))
- nvals)
+ :from :eval :to (:result 1))
+ nvals)
(:temporary (:scs (non-descriptor-reg)) temp))
;;; MAYBE-LOAD-STACK-TN.
(define-vop (call-local)
(:args (fp)
- (nfp)
- (args :more t))
+ (nfp)
+ (args :more t))
(:results (values :more t))
(:save-p t)
(:move-args :local-call)
(:generator 5
(trace-table-entry trace-table-call-site)
(let ((label (gen-label))
- (cur-nfp (current-nfp-tn vop)))
+ (cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (store-stack-tn nfp-save cur-nfp))
+ (store-stack-tn nfp-save cur-nfp))
(let ((callee-nfp (callee-nfp-tn callee)))
- (when callee-nfp
- (maybe-load-stack-tn callee-nfp nfp)))
+ (when callee-nfp
+ (maybe-load-stack-tn callee-nfp nfp)))
(maybe-load-stack-tn cfp-tn fp)
(inst compute-lra-from-code
- (callee-return-pc-tn callee) code-tn label temp)
+ (callee-return-pc-tn callee) code-tn label temp)
(note-this-location vop :call-site)
(inst b target)
(emit-return-pc label)
;; alpha uses (maybe-load-stack-nfp-tn cur-nfp nfp-save temp)
;; instead of the clause below
(when cur-nfp
- (load-stack-tn cur-nfp nfp-save)))
+ (load-stack-tn cur-nfp nfp-save)))
(trace-table-entry trace-table-normal)))
;;; MAYBE-LOAD-STACK-TN.
(define-vop (multiple-call-local unknown-values-receiver)
(:args (fp)
- (nfp)
- (args :more t))
+ (nfp)
+ (args :more t))
(:save-p t)
(:move-args :local-call)
(:info save callee target)
(:generator 20
(trace-table-entry trace-table-call-site)
(let ((label (gen-label))
- (cur-nfp (current-nfp-tn vop)))
+ (cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (store-stack-tn nfp-save cur-nfp))
+ (store-stack-tn nfp-save cur-nfp))
(let ((callee-nfp (callee-nfp-tn callee)))
- ;; alpha doesn't test this before the maybe-load
- (when callee-nfp
- (maybe-load-stack-tn callee-nfp nfp)))
+ ;; alpha doesn't test this before the maybe-load
+ (when callee-nfp
+ (maybe-load-stack-tn callee-nfp nfp)))
(maybe-load-stack-tn cfp-tn fp)
(inst compute-lra-from-code
- (callee-return-pc-tn callee) code-tn label temp)
+ (callee-return-pc-tn callee) code-tn label temp)
(note-this-location vop :call-site)
(inst b target)
(emit-return-pc label)
(note-this-location vop :unknown-return)
(receive-unknown-values values-start nvals start count label temp)
(when cur-nfp
- (load-stack-tn cur-nfp nfp-save)))
+ (load-stack-tn cur-nfp nfp-save)))
(trace-table-entry trace-table-normal)))
\f
;;; MAYBE-LOAD-STACK-TN.
(define-vop (known-call-local)
(:args (fp)
- (nfp)
- (args :more t))
+ (nfp)
+ (args :more t))
(:results (res :more t))
(:move-args :local-call)
(:save-p t)
(:generator 5
(trace-table-entry trace-table-call-site)
(let ((label (gen-label))
- (cur-nfp (current-nfp-tn vop)))
+ (cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (store-stack-tn nfp-save cur-nfp))
+ (store-stack-tn nfp-save cur-nfp))
(let ((callee-nfp (callee-nfp-tn callee)))
- (when callee-nfp
- (maybe-load-stack-tn callee-nfp nfp)))
+ (when callee-nfp
+ (maybe-load-stack-tn callee-nfp nfp)))
(maybe-load-stack-tn cfp-tn fp)
(inst compute-lra-from-code
- (callee-return-pc-tn callee) code-tn label temp)
+ (callee-return-pc-tn callee) code-tn label temp)
(note-this-location vop :call-site)
(inst b target)
(emit-return-pc label)
(note-this-location vop :known-return)
(when cur-nfp
- (load-stack-tn cur-nfp nfp-save)))
+ (load-stack-tn cur-nfp nfp-save)))
(trace-table-entry trace-table-normal)))
;;; Return from known values call. We receive the return locations as
;;; MAYBE-LOAD-STACK-TN.
(define-vop (known-return)
(:args (old-fp :target old-fp-temp)
- (return-pc :target return-pc-temp)
- (vals :more t))
+ (return-pc :target return-pc-temp)
+ (vals :more t))
(:temporary (:sc any-reg :from (:argument 0)) old-fp-temp)
(:temporary (:sc descriptor-reg :from (:argument 1)) return-pc-temp)
(:move-args :known-return)
(move csp-tn cfp-tn)
(let ((cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (inst addi nsp-tn cur-nfp
- (- (bytes-needed-for-non-descriptor-stack-frame)
- number-stack-displacement))))
+ (inst addi nsp-tn cur-nfp
+ (- (bytes-needed-for-non-descriptor-stack-frame)
+ number-stack-displacement))))
(move cfp-tn old-fp-temp)
(inst j return-pc-temp (- n-word-bytes other-pointer-lowtag))
(trace-table-entry trace-table-normal)))
;;; replication in defining the cross-product VOPs.
;;;
;;; NAME is the name of the VOP to define.
-;;;
+;;;
;;; NAMED is true if the first argument is a symbol whose global function
;;; definition is to be called.
;;;
(defmacro define-full-call (name named return variable)
(aver (not (and variable (eq return :tail))))
`(define-vop (,name
- ,@(when (eq return :unknown)
- '(unknown-values-receiver)))
+ ,@(when (eq return :unknown)
+ '(unknown-values-receiver)))
(:args
,@(unless (eq return :tail)
- '((new-fp :scs (any-reg) :to :eval)))
+ '((new-fp :scs (any-reg) :to :eval)))
,(if named
- '(name :target name-pass)
- '(arg-fun :target lexenv))
-
+ '(name :target name-pass)
+ '(arg-fun :target lexenv))
+
,@(when (eq return :tail)
- '((old-fp :target old-fp-pass)
- (return-pc :target return-pc-pass)))
-
+ '((old-fp :target old-fp-pass)
+ (return-pc :target return-pc-pass)))
+
,@(unless variable '((args :more t :scs (descriptor-reg)))))
,@(when (eq return :fixed)
- '((:results (values :more t))))
-
+ '((:results (values :more t))))
+
(:save-p ,(if (eq return :tail) :compute-only t))
,@(unless (or (eq return :tail) variable)
- '((:move-args :full-call)))
+ '((:move-args :full-call)))
- (:vop-var vop)
- (:info ,@(unless (or variable (eq return :tail)) '(arg-locs))
- ,@(unless variable '(nargs))
- ,@(when (eq return :fixed) '(nvals)))
+ (:vop-var vop)
+ (:info ,@(unless (or variable (eq return :tail)) '(arg-locs))
+ ,@(unless variable '(nargs))
+ ,@(when (eq return :fixed) '(nvals))
+ step-instrumenting)
(:ignore
,@(unless (or variable (eq return :tail)) '(arg-locs))
,@(unless variable '(args)))
(:temporary (:sc descriptor-reg
- :offset ocfp-offset
- :from (:argument 1)
- ,@(unless (eq return :fixed)
- '(:to :eval)))
- old-fp-pass)
+ :offset ocfp-offset
+ :from (:argument 1)
+ ,@(unless (eq return :fixed)
+ '(:to :eval)))
+ old-fp-pass)
(:temporary (:sc descriptor-reg
- :offset lra-offset
- :from (:argument ,(if (eq return :tail) 2 1))
- :to :eval)
- return-pc-pass)
+ :offset lra-offset
+ :from (:argument ,(if (eq return :tail) 2 1))
+ :to :eval)
+ return-pc-pass)
,(if named
- `(:temporary (:sc descriptor-reg :offset fdefn-offset ; -dan
- :from (:argument ,(if (eq return :tail) 0 1))
- :to :eval)
- name-pass)
- `(:temporary (:sc descriptor-reg :offset lexenv-offset
- :from (:argument ,(if (eq return :tail) 0 1))
- :to :eval)
- lexenv))
+ `(:temporary (:sc descriptor-reg :offset fdefn-offset ; -dan
+ :from (:argument ,(if (eq return :tail) 0 1))
+ :to :eval)
+ name-pass)
+ `(:temporary (:sc descriptor-reg :offset lexenv-offset
+ :from (:argument ,(if (eq return :tail) 0 1))
+ :to :eval)
+ lexenv))
,@(unless named
- '((:temporary (:scs (descriptor-reg) :from (:argument 0) :to :eval)
- function)))
+ '((:temporary (:scs (descriptor-reg) :from (:argument 0) :to :eval)
+ function)))
(:temporary (:sc any-reg :offset nargs-offset :to :eval)
- nargs-pass)
+ nargs-pass)
,@(when variable
- (mapcar #'(lambda (name offset)
- `(:temporary (:sc descriptor-reg
- :offset ,offset
- :to :eval)
- ,name))
- register-arg-names *register-arg-offsets*))
+ (mapcar #'(lambda (name offset)
+ `(:temporary (:sc descriptor-reg
+ :offset ,offset
+ :to :eval)
+ ,name))
+ register-arg-names *register-arg-offsets*))
,@(when (eq return :fixed)
- '((:temporary (:scs (descriptor-reg) :from :eval) move-temp)))
+ '((:temporary (:scs (descriptor-reg) :from :eval) move-temp)))
+
+ (:temporary (:scs (descriptor-reg) :to :eval) stepping)
,@(unless (eq return :tail)
- '((:temporary (:scs (non-descriptor-reg)) temp)
- (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)))
+ '((:temporary (:scs (non-descriptor-reg)) temp)
+ (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)))
(:temporary (:sc interior-reg :offset lip-offset) entry-point)
(:generator ,(+ (if named 5 0)
- (if variable 19 1)
- (if (eq return :tail) 0 10)
- 15
- (if (eq return :unknown) 25 0))
+ (if variable 19 1)
+ (if (eq return :tail) 0 10)
+ 15
+ (if (eq return :unknown) 25 0))
(trace-table-entry trace-table-call-site)
+
(let* ((cur-nfp (current-nfp-tn vop))
- ,@(unless (eq return :tail)
- '((lra-label (gen-label))))
- (filler
- (remove nil
- (list :load-nargs
- ,@(if (eq return :tail)
- '((unless (location= old-fp old-fp-pass)
- :load-old-fp)
- (unless (location= return-pc
- return-pc-pass)
- :load-return-pc)
- (when cur-nfp
- :frob-nfp))
- '(:comp-lra
- (when cur-nfp
- :frob-nfp)
- :save-fp
- :load-fp))))))
- (flet ((do-next-filler ()
- (let* ((next (pop filler))
- (what (if (consp next) (car next) next)))
- (ecase what
- (:load-nargs
- ,@(if variable
- `((inst sub nargs-pass csp-tn new-fp)
- ,@(let ((index -1))
- (mapcar #'(lambda (name)
- `(loadw ,name new-fp
- ,(incf index)))
- register-arg-names)))
- '((inst lr nargs-pass (fixnumize nargs)))))
- ,@(if (eq return :tail)
- '((:load-old-fp
- (sc-case old-fp
- (any-reg
- (inst mr old-fp-pass old-fp))
- (control-stack
- (loadw old-fp-pass cfp-tn
- (tn-offset old-fp)))))
- (:load-return-pc
- (sc-case return-pc
- (descriptor-reg
- (inst mr return-pc-pass return-pc))
- (control-stack
- (loadw return-pc-pass cfp-tn
- (tn-offset return-pc)))))
- (:frob-nfp
- (inst addi nsp-tn cur-nfp
- (- (bytes-needed-for-non-descriptor-stack-frame)
- number-stack-displacement))))
- `((:comp-lra
- (inst compute-lra-from-code
- return-pc-pass code-tn lra-label temp))
- (:frob-nfp
- (store-stack-tn nfp-save cur-nfp))
- (:save-fp
- (inst mr old-fp-pass cfp-tn))
- (:load-fp
- ,(if variable
- '(move cfp-tn new-fp)
- '(if (> nargs register-arg-count)
- (move cfp-tn new-fp)
- (move cfp-tn csp-tn))))))
- ((nil))))))
- ,@(if named
- `((sc-case name
- (descriptor-reg (move name-pass name))
- (control-stack
- (loadw name-pass cfp-tn (tn-offset name))
- (do-next-filler))
- (constant
- (loadw name-pass code-tn (tn-offset name)
- other-pointer-lowtag)
- (do-next-filler)))
- (loadw entry-point name-pass fdefn-raw-addr-slot
- other-pointer-lowtag)
- (do-next-filler))
- `((sc-case arg-fun
- (descriptor-reg (move lexenv arg-fun))
- (control-stack
- (loadw lexenv cfp-tn (tn-offset arg-fun))
- (do-next-filler))
- (constant
- (loadw lexenv code-tn (tn-offset arg-fun)
- other-pointer-lowtag)
- (do-next-filler)))
- (loadw function lexenv closure-fun-slot
- fun-pointer-lowtag)
- (do-next-filler)
- (inst addi entry-point function
- (- (ash simple-fun-code-offset word-shift)
- fun-pointer-lowtag))
- ))
- (loop
- (if filler
- (do-next-filler)
- (return)))
-
- (note-this-location vop :call-site)
- (inst mtctr entry-point)
- ;; this following line is questionable. or else the alpha
- ;; code (which doesn't do it) is questionable
- ;; (inst mr code-tn function)
- (inst bctr))
-
- ,@(ecase return
- (:fixed
- '((emit-return-pc lra-label)
- (default-unknown-values vop values nvals move-temp
- temp lra-label)
- (when cur-nfp
- (load-stack-tn cur-nfp nfp-save))))
- (:unknown
- '((emit-return-pc lra-label)
- (note-this-location vop :unknown-return)
- (receive-unknown-values values-start nvals start count
- lra-label temp)
- (when cur-nfp
- (load-stack-tn cur-nfp nfp-save))))
- (:tail)))
+ ,@(unless (eq return :tail)
+ '((lra-label (gen-label))))
+ (step-done-label (gen-label))
+ (filler
+ (remove nil
+ (list :load-nargs
+ ,@(if (eq return :tail)
+ '((unless (location= old-fp old-fp-pass)
+ :load-old-fp)
+ (unless (location= return-pc
+ return-pc-pass)
+ :load-return-pc)
+ (when cur-nfp
+ :frob-nfp))
+ '(:comp-lra
+ (when cur-nfp
+ :frob-nfp)
+ :save-fp
+ :load-fp))))))
+ (flet ((do-next-filler ()
+ (let* ((next (pop filler))
+ (what (if (consp next) (car next) next)))
+ (ecase what
+ (:load-nargs
+ ,@(if variable
+ `((inst sub nargs-pass csp-tn new-fp)
+ ,@(let ((index -1))
+ (mapcar #'(lambda (name)
+ `(loadw ,name new-fp
+ ,(incf index)))
+ register-arg-names)))
+ '((inst lr nargs-pass (fixnumize nargs)))))
+ ,@(if (eq return :tail)
+ '((:load-old-fp
+ (sc-case old-fp
+ (any-reg
+ (inst mr old-fp-pass old-fp))
+ (control-stack
+ (loadw old-fp-pass cfp-tn
+ (tn-offset old-fp)))))
+ (:load-return-pc
+ (sc-case return-pc
+ (descriptor-reg
+ (inst mr return-pc-pass return-pc))
+ (control-stack
+ (loadw return-pc-pass cfp-tn
+ (tn-offset return-pc)))))
+ (:frob-nfp
+ (inst addi nsp-tn cur-nfp
+ (- (bytes-needed-for-non-descriptor-stack-frame)
+ number-stack-displacement))))
+ `((:comp-lra
+ (inst compute-lra-from-code
+ return-pc-pass code-tn lra-label temp))
+ (:frob-nfp
+ (store-stack-tn nfp-save cur-nfp))
+ (:save-fp
+ (inst mr old-fp-pass cfp-tn))
+ (:load-fp
+ ,(if variable
+ '(move cfp-tn new-fp)
+ '(if (> nargs register-arg-count)
+ (move cfp-tn new-fp)
+ (move cfp-tn csp-tn))))))
+ ((nil)))))
+ (insert-step-instrumenting (callable-tn)
+ ;; Conditionally insert a conditional trap:
+ (when step-instrumenting
+ ;; Get the symbol-value of SB!IMPL::*STEPPING*
+ (loadw stepping
+ null-tn
+ (+ symbol-value-slot
+ (truncate (static-symbol-offset 'sb!impl::*stepping*)
+ n-word-bytes))
+ other-pointer-lowtag)
+ (inst cmpw stepping null-tn)
+ ;; If it's not null, trap.
+ (inst beq step-done-label)
+ ;; CONTEXT-PC will be pointing here when the
+ ;; interrupt is handled, not after the UNIMP.
+ (note-this-location vop :step-before-vop)
+ ;; Construct a trap code with the low bits from
+ ;; SINGLE-STEP-AROUND-TRAP and the high bits from
+ ;; the register number of CALLABLE-TN.
+ (inst unimp (logior single-step-around-trap
+ (ash (reg-tn-encoding callable-tn)
+ 5)))
+ (emit-label step-done-label))))
+ ,@(if named
+ `((sc-case name
+ (descriptor-reg (move name-pass name))
+ (control-stack
+ (loadw name-pass cfp-tn (tn-offset name))
+ (do-next-filler))
+ (constant
+ (loadw name-pass code-tn (tn-offset name)
+ other-pointer-lowtag)
+ (do-next-filler)))
+ ;; The step instrumenting must be done after
+ ;; FUNCTION is loaded, but before ENTRY-POINT is
+ ;; calculated.
+ (insert-step-instrumenting name-pass)
+ (loadw entry-point name-pass fdefn-raw-addr-slot
+ other-pointer-lowtag)
+ (do-next-filler))
+ `((sc-case arg-fun
+ (descriptor-reg (move lexenv arg-fun))
+ (control-stack
+ (loadw lexenv cfp-tn (tn-offset arg-fun))
+ (do-next-filler))
+ (constant
+ (loadw lexenv code-tn (tn-offset arg-fun)
+ other-pointer-lowtag)
+ (do-next-filler)))
+ (loadw function lexenv closure-fun-slot
+ fun-pointer-lowtag)
+ (do-next-filler)
+ ;; The step instrumenting must be done before
+ ;; after FUNCTION is loaded, but before ENTRY-POINT
+ ;; is calculated.
+ (insert-step-instrumenting function)
+ (inst addi entry-point function
+ (- (ash simple-fun-code-offset word-shift)
+ fun-pointer-lowtag))
+ ))
+ (loop
+ (if filler
+ (do-next-filler)
+ (return)))
+
+ (note-this-location vop :call-site)
+ (inst mtctr entry-point)
+ ;; this following line is questionable. or else the alpha
+ ;; code (which doesn't do it) is questionable
+ ;; (inst mr code-tn function)
+ (inst bctr))
+
+ ,@(ecase return
+ (:fixed
+ '((emit-return-pc lra-label)
+ (default-unknown-values vop values nvals move-temp
+ temp lra-label)
+ (when cur-nfp
+ (load-stack-tn cur-nfp nfp-save))))
+ (:unknown
+ '((emit-return-pc lra-label)
+ (note-this-location vop :unknown-return)
+ (receive-unknown-values values-start nvals start count
+ lra-label temp)
+ (when cur-nfp
+ (load-stack-tn cur-nfp nfp-save))))
+ (:tail)))
(trace-table-entry trace-table-normal))))
(define-full-call call-variable nil :fixed t)
(define-full-call multiple-call-variable nil :unknown t)
-
;;; Defined separately, since needs special code that BLT's the
;;; arguments down.
(define-vop (tail-call-variable)
(function-arg :scs (descriptor-reg) :target lexenv)
(old-fp-arg :scs (any-reg) :target old-fp)
(lra-arg :scs (descriptor-reg) :target lra))
-
(:temporary (:sc any-reg :offset nl0-offset :from (:argument 0)) args)
(:temporary (:sc any-reg :offset lexenv-offset :from (:argument 1)) lexenv)
(:temporary (:sc any-reg :offset ocfp-offset :from (:argument 2)) old-fp)
(:temporary (:sc any-reg :offset lra-offset :from (:argument 3)) lra)
-
-
+ (:temporary (:sc any-reg) temp)
(:vop-var vop)
-
(:generator 75
-
;; Move these into the passing locations if they are not already there.
(move args args-arg)
(move lexenv function-arg)
(move old-fp old-fp-arg)
(move lra lra-arg)
-
-
;; Clear the number stack if anything is there.
(let ((cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (inst addi nsp-tn cur-nfp
- (- (bytes-needed-for-non-descriptor-stack-frame)
- number-stack-displacement))))
-
-
- (inst ba (make-fixup 'tail-call-variable :assembly-routine))))
+ (inst addi nsp-tn cur-nfp
+ (- (bytes-needed-for-non-descriptor-stack-frame)
+ number-stack-displacement))))
+ (inst lr temp (make-fixup 'tail-call-variable :assembly-routine))
+ (inst mtlr temp)
+ (inst blr)))
\f
;;;; Unknown values return:
;;; Return a single value using the unknown-values convention.
(define-vop (return-single)
(:args (old-fp :scs (any-reg))
- (return-pc :scs (descriptor-reg))
- (value))
+ (return-pc :scs (descriptor-reg))
+ (value))
(:ignore value)
(:temporary (:scs (interior-reg)) lip)
(:vop-var vop)
;; Clear the number stack.
(let ((cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (inst addi nsp-tn cur-nfp
- (- (bytes-needed-for-non-descriptor-stack-frame)
- number-stack-displacement))))
+ (inst addi nsp-tn cur-nfp
+ (- (bytes-needed-for-non-descriptor-stack-frame)
+ number-stack-displacement))))
;; Clear the control stack, and restore the frame pointer.
(move csp-tn cfp-tn)
(move cfp-tn old-fp)
;; Clear the number stack.
(let ((cur-nfp (current-nfp-tn vop)))
(when cur-nfp
- (inst addi nsp-tn cur-nfp
- (- (bytes-needed-for-non-descriptor-stack-frame)
- number-stack-displacement))))
+ (inst addi nsp-tn cur-nfp
+ (- (bytes-needed-for-non-descriptor-stack-frame)
+ number-stack-displacement))))
(cond ((= nvals 1)
- ;; Clear the control stack, and restore the frame pointer.
- (move csp-tn cfp-tn)
- (move cfp-tn old-fp)
- ;; Out of here.
- (lisp-return return-pc lip :offset 2))
- (t
- ;; Establish the values pointer and values count.
- (move val-ptr cfp-tn)
- (inst lr nargs (fixnumize nvals))
- ;; restore the frame pointer and clear as much of the control
- ;; stack as possible.
- (move cfp-tn old-fp)
- (inst addi csp-tn val-ptr (* nvals n-word-bytes))
- ;; pre-default any argument register that need it.
- (when (< nvals register-arg-count)
- (dolist (reg (subseq (list a0 a1 a2 a3) nvals))
- (move reg null-tn)))
- ;; And away we go.
- (lisp-return return-pc lip)))
+ ;; Clear the control stack, and restore the frame pointer.
+ (move csp-tn cfp-tn)
+ (move cfp-tn old-fp)
+ ;; Out of here.
+ (lisp-return return-pc lip :offset 2))
+ (t
+ ;; Establish the values pointer and values count.
+ (move val-ptr cfp-tn)
+ (inst lr nargs (fixnumize nvals))
+ ;; restore the frame pointer and clear as much of the control
+ ;; stack as possible.
+ (move cfp-tn old-fp)
+ (inst addi csp-tn val-ptr (* nvals n-word-bytes))
+ ;; pre-default any argument register that need it.
+ (when (< nvals register-arg-count)
+ (dolist (reg (subseq (list a0 a1 a2 a3) nvals))
+ (move reg null-tn)))
+ ;; And away we go.
+ (lisp-return return-pc lip)))
(trace-table-entry trace-table-normal)))
;;; Do unknown-values return of an arbitrary number of values (passed
(lra-arg :scs (descriptor-reg) :to (:eval 1))
(vals-arg :scs (any-reg) :target vals)
(nvals-arg :scs (any-reg) :target nvals))
-
(:temporary (:sc any-reg :offset nl1-offset :from (:argument 0)) old-fp)
(:temporary (:sc descriptor-reg :offset lra-offset :from (:argument 1)) lra)
(:temporary (:sc any-reg :offset nl0-offset :from (:argument 2)) vals)
(:temporary (:sc any-reg :offset nargs-offset :from (:argument 3)) nvals)
(:temporary (:sc descriptor-reg :offset a0-offset) a0)
(:temporary (:scs (interior-reg)) lip)
-
-
+ (:temporary (:sc any-reg) temp)
(:vop-var vop)
-
(:generator 13
(trace-table-entry trace-table-fun-epilogue)
(let ((not-single (gen-label)))
;; Clear the number stack.
(let ((cur-nfp (current-nfp-tn vop)))
- (when cur-nfp
- (inst addi nsp-tn cur-nfp
- (- (bytes-needed-for-non-descriptor-stack-frame)
- number-stack-displacement))))
-
+ (when cur-nfp
+ (inst addi nsp-tn cur-nfp
+ (- (bytes-needed-for-non-descriptor-stack-frame)
+ number-stack-displacement))))
;; Check for the single case.
(inst cmpwi nvals-arg (fixnumize 1))
(inst lwz a0 vals-arg 0)
(inst bne not-single)
-
;; Return with one value.
(move csp-tn cfp-tn)
(move cfp-tn old-fp-arg)
(lisp-return lra-arg lip :offset 2)
-
;; Nope, not the single case.
(emit-label not-single)
(move old-fp old-fp-arg)
(move lra lra-arg)
(move vals vals-arg)
(move nvals nvals-arg)
- (inst ba (make-fixup 'return-multiple :assembly-routine)))
+ (inst lr temp (make-fixup 'return-multiple :assembly-routine))
+ (inst mtlr temp)
+ (inst blr))
(trace-table-entry trace-table-normal)))
\f
;;;; XEP hackery:
;;; Get the lexical environment from its passing location.
(define-vop (setup-closure-environment)
(:temporary (:sc descriptor-reg :offset lexenv-offset :target closure
- :to (:result 0))
- lexenv)
+ :to (:result 0))
+ lexenv)
(:results (closure :scs (descriptor-reg)))
(:info label)
(:ignore label)
(move closure lexenv)))
;;; Copy a more arg from the argument area to the end of the current frame.
-;;; Fixed is the number of non-more arguments.
+;;; Fixed is the number of non-more arguments.
(define-vop (copy-more-arg)
(:temporary (:sc any-reg :offset nl0-offset) result)
(:temporary (:sc any-reg :offset nl1-offset) count)
(:info fixed)
(:generator 20
(let ((loop (gen-label))
- (do-regs (gen-label))
- (done (gen-label)))
+ (do-regs (gen-label))
+ (done (gen-label)))
(when (< fixed register-arg-count)
- ;; Save a pointer to the results so we can fill in register args.
- ;; We don't need this if there are more fixed args than reg args.
- (move result csp-tn))
+ ;; Save a pointer to the results so we can fill in register args.
+ ;; We don't need this if there are more fixed args than reg args.
+ (move result csp-tn))
;; Allocate the space on the stack.
(cond ((zerop fixed)
- (inst cmpwi nargs-tn 0)
- (inst add csp-tn csp-tn nargs-tn)
- (inst beq done))
- (t
- (inst addic. count nargs-tn (- (fixnumize fixed)))
- (inst ble done)
- (inst add csp-tn csp-tn count)))
+ (inst cmpwi nargs-tn 0)
+ (inst add csp-tn csp-tn nargs-tn)
+ (inst beq done))
+ (t
+ (inst addic. count nargs-tn (- (fixnumize fixed)))
+ (inst ble done)
+ (inst add csp-tn csp-tn count)))
(when (< fixed register-arg-count)
- ;; We must stop when we run out of stack args, not when we run out of
- ;; more args.
- (inst addic. count nargs-tn (- (fixnumize register-arg-count)))
- ;; Everything of interest is in registers.
- (inst ble do-regs))
+ ;; We must stop when we run out of stack args, not when we run out of
+ ;; more args.
+ (inst addic. count nargs-tn (- (fixnumize register-arg-count)))
+ ;; Everything of interest is in registers.
+ (inst ble do-regs))
;; Initialize dst to be end of stack.
(move dst csp-tn)
;; Initialize src to be end of args.
(emit-label loop)
;; *--dst = *--src, --count
- (inst addi src src (- n-word-bytes))
+ (inst lwzu temp src (- n-word-bytes))
(inst addic. count count (- (fixnumize 1)))
- (loadw temp src)
- (inst addi dst dst (- n-word-bytes))
- (storew temp dst)
+ (inst stwu temp dst (- n-word-bytes))
(inst bgt loop)
(emit-label do-regs)
(when (< fixed register-arg-count)
- ;; Now we have to deposit any more args that showed up in registers.
- (inst subic. count nargs-tn (fixnumize fixed))
- (do ((i fixed (1+ i)))
- ((>= i register-arg-count))
- ;; Don't deposit any more than there are.
- (inst beq done)
- (inst subic. count count (fixnumize 1))
- ;; Store it relative to the pointer saved at the start.
- (storew (nth i *register-arg-tns*) result (- i fixed))))
+ ;; Now we have to deposit any more args that showed up in registers.
+ (inst subic. count nargs-tn (fixnumize fixed))
+ (do ((i fixed (1+ i)))
+ ((>= i register-arg-count))
+ ;; Don't deposit any more than there are.
+ (inst beq done)
+ (inst subic. count count (fixnumize 1))
+ ;; Store it relative to the pointer saved at the start.
+ (storew (nth i *register-arg-tns*) result (- i fixed))))
(emit-label done))))
;;; Turn more arg (context, count) into a list.
(define-vop (listify-rest-args)
(:args (context-arg :target context :scs (descriptor-reg))
- (count-arg :target count :scs (any-reg)))
+ (count-arg :target count :scs (any-reg)))
(:arg-types * tagged-num)
(:temporary (:scs (any-reg) :from (:argument 0)) context)
(:temporary (:scs (any-reg) :from (:argument 1)) count)
(:results (result :scs (descriptor-reg)))
(:translate %listify-rest-args)
(:policy :safe)
+ (:node-var node)
(:generator 20
- (move context context-arg)
- (move count count-arg)
- ;; Check to see if there are any arguments.
- (inst cmpwi count 0)
- (move result null-tn)
- (inst beq done)
+ (let* ((enter (gen-label))
+ (loop (gen-label))
+ (done (gen-label))
+ (dx-p (node-stack-allocate-p node)))
+ (move context context-arg)
+ (move count count-arg)
+ ;; Check to see if there are any arguments.
+ (inst cmpwi count 0)
+ (move result null-tn)
+ (inst beq done)
;; We need to do this atomically.
(pseudo-atomic (pa-flag)
- (assemble ()
- ;; Allocate a cons (2 words) for each item.
- (inst clrrwi result alloc-tn n-lowtag-bits)
- (inst ori result result list-pointer-lowtag)
- (move dst result)
- (inst slwi temp count 1)
- (inst add alloc-tn alloc-tn temp)
- (inst b enter)
-
- ;; Compute the next cons and store it in the current one.
- LOOP
- (inst addi dst dst (* 2 n-word-bytes))
- (storew dst dst -1 list-pointer-lowtag)
-
- ;; Grab one value.
- ENTER
- (loadw temp context)
- (inst addi context context n-word-bytes)
-
- ;; Dec count, and if != zero, go back for more.
- (inst addic. count count (- (fixnumize 1)))
- ;; Store the value into the car of the current cons (in the delay
- ;; slot).
- (storew temp dst 0 list-pointer-lowtag)
- (inst bgt loop)
-
-
- ;; NIL out the last cons.
- (storew null-tn dst 1 list-pointer-lowtag)))
- DONE))
+ ;; Allocate a cons (2 words) for each item.
+ (if dx-p
+ (progn
+ (align-csp temp)
+ (inst clrrwi result csp-tn n-lowtag-bits)
+ (inst ori result result list-pointer-lowtag)
+ (move dst result)
+ (inst slwi temp count 1)
+ (inst add csp-tn csp-tn temp))
+ (progn
+ (inst slwi temp count 1)
+ (allocation result temp list-pointer-lowtag
+ :temp-tn dst
+ :flag-tn pa-flag)
+ (move dst result)))
+ (inst b enter)
+
+ ;; Compute the next cons and store it in the current one.
+ (emit-label loop)
+ (inst addi dst dst (* 2 n-word-bytes))
+ (storew dst dst -1 list-pointer-lowtag)
+
+ ;; Grab one value.
+ (emit-label enter)
+ (loadw temp context)
+ (inst addi context context n-word-bytes)
+
+ ;; Dec count, and if != zero, go back for more.
+ (inst addic. count count (- (fixnumize 1)))
+ ;; Store the value into the car of the current cons (in the delay
+ ;; slot).
+ (storew temp dst 0 list-pointer-lowtag)
+ (inst bgt loop)
+
+ ;; NIL out the last cons.
+ (storew null-tn dst 1 list-pointer-lowtag))
+ (emit-label done))))
;;; Return the location and size of the more arg glob created by
(:arg-types tagged-num (:constant fixnum))
(:info fixed)
(:results (context :scs (descriptor-reg))
- (count :scs (any-reg)))
+ (count :scs (any-reg)))
(:result-types t tagged-num)
(:note "more-arg-context")
(:generator 5
;;; Signal various errors.
(macrolet ((frob (name error translate &rest args)
- `(define-vop (,name)
- ,@(when translate
- `((:policy :fast-safe)
- (:translate ,translate)))
- (:args ,@(mapcar #'(lambda (arg)
- `(,arg :scs (any-reg descriptor-reg)))
- args))
- (:vop-var vop)
- (:save-p :compute-only)
- (:generator 1000
- (error-call vop ,error ,@args)))))
+ `(define-vop (,name)
+ ,@(when translate
+ `((:policy :fast-safe)
+ (:translate ,translate)))
+ (:args ,@(mapcar #'(lambda (arg)
+ `(,arg :scs (any-reg descriptor-reg)))
+ args))
+ (:vop-var vop)
+ (:save-p :compute-only)
+ (:generator 1000
+ (error-call vop ',error ,@args)))))
(frob arg-count-error invalid-arg-count-error
sb!c::%arg-count-error nargs)
(frob type-check-error object-not-type-error sb!c::%type-check-error
(frob unknown-key-arg-error unknown-key-arg-error
sb!c::%unknown-key-arg-error key)
(frob nil-fun-returned-error nil-fun-returned-error nil fun))
+
+(define-vop (step-instrument-before-vop)
+ (:temporary (:scs (descriptor-reg)) stepping)
+ (:policy :fast-safe)
+ (:vop-var vop)
+ (:generator 3
+ ;; Get the symbol-value of SB!IMPL::*STEPPING*
+ (loadw stepping
+ null-tn
+ (+ symbol-value-slot
+ (truncate (static-symbol-offset 'sb!impl::*stepping*)
+ n-word-bytes))
+ other-pointer-lowtag)
+ (inst cmpw stepping null-tn)
+ ;; If it's not null, trap.
+ (inst beq DONE)
+ ;; CONTEXT-PC will be pointing here when the interrupt is handled,
+ ;; not after the UNIMP.
+ (note-this-location vop :step-before-vop)
+ ;; CALLEE-REGISTER-OFFSET isn't needed for before-traps, so we
+ ;; can just use a bare SINGLE-STEP-BEFORE-TRAP as the code.
+ (inst unimp single-step-before-trap)
+ DONE))