- ,@(unless (eq return :tail)
- '((lra-label (gen-label))))
- (filler
- (list :load-nargs
- ,@(if (eq return :tail)
- '((unless (location= ocfp ocfp-pass)
- :load-ocfp)
- (unless (location= lra lra-pass)
- :load-lra)
- (when cur-nfp
- :frob-nfp))
- '((when cur-nfp
- :frob-nfp)
- :comp-lra
- :save-fp
- :load-fp)))))
- (labels
- ((do-next-filler ()
- (when filler
- (ecase (pop filler)
- ((nil) (do-next-filler))
- (:load-nargs
- ,@(if variable
- `((inst sub csp-tn new-fp nargs-pass)
- ,@(let ((index -1))
- (mapcar #'(lambda (name)
- `(loadw ,name new-fp
- ,(incf index)))
- register-arg-names)))
- '((inst li (fixnumize nargs) nargs-pass))))
- ,@(if (eq return :tail)
- '((:load-ocfp
- (sc-case ocfp
- (any-reg
- (inst move ocfp ocfp-pass))
- (control-stack
- (loadw ocfp-pass cfp-tn (tn-offset ocfp)))))
- (:load-lra
- (sc-case lra
- (descriptor-reg
- (inst move lra lra-pass))
- (control-stack
- (loadw lra-pass cfp-tn (tn-offset lra)))))
- (:frob-nfp
- (inst move cur-nfp nsp-tn)))
- `((:frob-nfp
- (store-stack-tn nfp-save cur-nfp))
- (:comp-lra
- (inst compute-lra-from-code
- code-tn lra-label temp lra-pass))
- (:save-fp
- (inst move cfp-tn ocfp-pass))
- (:load-fp
- ,(if variable
- '(move new-fp cfp-tn)
- '(if (> nargs register-arg-count)
- (move new-fp cfp-tn)
- (move csp-tn cfp-tn))))))))))
-
- ,@(if named
- `((sc-case fdefn
- (descriptor-reg (move fdefn fdefn-pass))
- (control-stack
- (loadw fdefn-pass cfp-tn (tn-offset fdefn))
- (do-next-filler))
- (constant
- (loadw fdefn-pass code-tn (tn-offset fdefn)
- other-pointer-lowtag)
- (do-next-filler)))
- (loadw lip fdefn-pass fdefn-raw-addr-slot
- other-pointer-lowtag)
- (do-next-filler))
- `((sc-case arg-fun
- (descriptor-reg (move arg-fun lexenv))
- (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 (- (ash simple-fun-code-offset word-shift)
- fun-pointer-lowtag)
- function lip)))
- (loop
- (cond ((null filler)
- (return))
- ((null (car filler))
- (pop filler))
- ((null (cdr filler))
- (return))
- (t
- (do-next-filler))))
-
- (note-this-location vop :call-site)
- (inst bv lip :nullify (null filler))
- (do-next-filler))
-
- ,@(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)))))
+ ,@(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= ocfp ocfp-pass)
+ :load-ocfp)
+ (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 csp-tn new-fp nargs-pass)
+ ,@(let ((index -1))
+ (mapcar (lambda (name)
+ `(inst ldw ,(ash (incf index)
+ word-shift)
+ new-fp
+ ,name))
+ register-arg-names)))
+ '((inst li (fixnumize nargs) nargs-pass))))
+ ,@(if (eq return :tail)
+ '((:load-ocfp
+ (sc-case ocfp
+ (any-reg
+ (move ocfp ocfp-pass t))
+ (control-stack
+ (inst ldw (ash (tn-offset ocfp)
+ word-shift)
+ cfp-tn ocfp-pass))))
+ (:load-return-pc
+ (sc-case return-pc
+ (descriptor-reg
+ (move return-pc return-pc-pass t))
+ (control-stack
+ (inst ldw (ash (tn-offset return-pc)
+ word-shift)
+ cfp-tn return-pc-pass))))
+ (:frob-nfp
+ (inst addi (- (bytes-needed-for-non-descriptor-stack-frame))
+ nsp-tn nsp-tn)))
+ `((:comp-lra
+ (inst compute-lra-from-code code-tn lra-label
+ temp return-pc-pass))
+ (:frob-nfp
+ (store-stack-tn nfp-save cur-nfp))
+ (:save-fp
+ (move cfp-tn ocfp-pass t))
+ (:load-fp
+ ,(if variable
+ '(move new-fp cfp-tn)
+ '(if (> nargs register-arg-count)
+ (move new-fp cfp-tn)
+ (move csp-tn cfp-tn)))
+ (trace-table-entry trace-table-call-site))))
+ ((nil)
+ (inst nop)))))
+ (insert-step-instrumenting (callable-tn)
+ ;; Conditionally insert a conditional trap:
+ (when step-instrumenting
+ (load-symbol-value stepping sb!impl::*stepping*)
+ ;; If it's not NIL, trap.
+ ;(inst comb := stepping null-tn step-done-label)
+ (inst comb := null-tn null-tn step-done-label :nullify t)
+ ;; CONTEXT-PC will be pointing here when the
+ ;; interrupt is handled, not after the BREAK.
+ (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 break 0 (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 name-pass))
+ (control-stack
+ (inst ldw (ash (tn-offset name) word-shift)
+ cfp-tn name-pass)
+ (do-next-filler))
+ (constant
+ (inst ldw (- (ash (tn-offset name) word-shift)
+ other-pointer-lowtag)
+ code-tn name-pass)
+ (do-next-filler)))
+ ;; The step instrumenting must be done after
+ ;; FUNCTION is loaded, but before ENTRY-POINT is
+ ;; calculated.
+ (insert-step-instrumenting name-pass)
+ (inst ldw (- (ash fdefn-raw-addr-slot word-shift)
+ other-pointer-lowtag)
+ name-pass entry-point)
+ (do-next-filler))
+ `((sc-case arg-fun
+ (descriptor-reg
+ (move arg-fun lexenv))
+ (control-stack
+ (inst ldw (ash (tn-offset arg-fun) word-shift)
+ cfp-tn lexenv)
+ (do-next-filler))
+ (constant
+ (inst ldw
+ (- (ash (tn-offset arg-fun) word-shift)
+ other-pointer-lowtag) code-tn lexenv)
+ (do-next-filler)))
+ (inst ldw (- (ash closure-fun-slot word-shift)
+ fun-pointer-lowtag)
+ lexenv function)
+ (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 (- (ash simple-fun-code-offset word-shift)
+ fun-pointer-lowtag)
+ function entry-point)))
+ (loop
+ (if (cdr filler)
+ (do-next-filler)
+ (return)))
+
+ (do-next-filler)
+ (note-this-location vop :call-site)
+ (inst bv entry-point :nullify t))
+
+ ,@(ecase return
+ (:fixed
+ '((trace-table-entry trace-table-normal)
+ (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
+ '((trace-table-entry trace-table-normal)
+ (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)))))))