117e3824678af274f5b7eb5d2056fd4dbc5144fc
[sbcl.git] / src / compiler / mips / call.lisp
1 (in-package "SB!VM")
2
3 \f
4 ;;;; Interfaces to IR2 conversion:
5
6 ;;; Return a wired TN describing the N'th full call argument passing
7 ;;; location.
8 (!def-vm-support-routine standard-arg-location (n)
9   (declare (type unsigned-byte n))
10   (if (< n register-arg-count)
11       (make-wired-tn *backend-t-primitive-type*
12                      register-arg-scn
13                      (elt *register-arg-offsets* n))
14       (make-wired-tn *backend-t-primitive-type*
15                      control-stack-arg-scn n)))
16
17
18 ;;; Make a passing location TN for a local call return PC.  If standard is
19 ;;; true, then use the standard (full call) location, otherwise use any legal
20 ;;; location.  Even in the non-standard case, this may be restricted by a
21 ;;; desire to use a subroutine call instruction.
22 (!def-vm-support-routine make-return-pc-passing-location (standard)
23   (if standard
24       (make-wired-tn *backend-t-primitive-type* register-arg-scn lra-offset)
25       (make-restricted-tn *backend-t-primitive-type* register-arg-scn)))
26
27 ;;; This is similar to MAKE-RETURN-PC-PASSING-LOCATION, but makes a
28 ;;; location to pass Old-FP in. This is (obviously) wired in the
29 ;;; standard convention, but is totally unrestricted in non-standard
30 ;;; conventions, since we can always fetch it off of the stack using
31 ;;; the arg pointer.
32 (!def-vm-support-routine make-old-fp-passing-location (standard)
33   (if standard
34       (make-wired-tn *fixnum-primitive-type* immediate-arg-scn ocfp-offset)
35       (make-normal-tn *fixnum-primitive-type*)))
36
37 ;;; Make the TNs used to hold OLD-FP and RETURN-PC within the current
38 ;;; function. We treat these specially so that the debugger can find
39 ;;; them at a known location.
40 (!def-vm-support-routine make-old-fp-save-location (env)
41   (specify-save-tn
42    (physenv-debug-live-tn (make-normal-tn *fixnum-primitive-type*) env)
43    (make-wired-tn *fixnum-primitive-type*
44                   control-stack-arg-scn
45                   ocfp-save-offset)))
46 (!def-vm-support-routine make-return-pc-save-location (env)
47   (let ((ptype *backend-t-primitive-type*))
48     (specify-save-tn
49      (physenv-debug-live-tn (make-normal-tn ptype) env)
50      (make-wired-tn ptype control-stack-arg-scn lra-save-offset))))
51
52 ;;; Make a TN for the standard argument count passing location.  We only
53 ;;; need to make the standard location, since a count is never passed when we
54 ;;; are using non-standard conventions.
55 (!def-vm-support-routine make-arg-count-location ()
56   (make-wired-tn *fixnum-primitive-type* immediate-arg-scn nargs-offset))
57
58
59 ;;; Make a TN to hold the number-stack frame pointer.  This is allocated
60 ;;; once per component, and is component-live.
61 (!def-vm-support-routine make-nfp-tn ()
62   (component-live-tn
63    (make-wired-tn *fixnum-primitive-type* immediate-arg-scn nfp-offset)))
64
65 (!def-vm-support-routine make-stack-pointer-tn ()
66   (make-normal-tn *fixnum-primitive-type*))
67
68 (!def-vm-support-routine make-number-stack-pointer-tn ()
69   (make-normal-tn *fixnum-primitive-type*))
70
71 ;;; Return a list of TNs that can be used to represent an unknown-values
72 ;;; continuation within a function.
73 (!def-vm-support-routine make-unknown-values-locations ()
74   (list (make-stack-pointer-tn)
75         (make-normal-tn *fixnum-primitive-type*)))
76
77
78 ;;; This function is called by the ENTRY-ANALYZE phase, allowing
79 ;;; VM-dependent initialization of the IR2-COMPONENT structure.  We push
80 ;;; placeholder entries in the Constants to leave room for additional
81 ;;; noise in the code object header.
82 (!def-vm-support-routine select-component-format (component)
83   (declare (type component component))
84   (dotimes (i code-constants-offset)
85     (vector-push-extend nil
86                         (ir2-component-constants (component-info component))))
87   (values))
88
89 \f
90 ;;;; Frame hackery:
91
92 ;;; BYTES-NEEDED-FOR-NON-DESCRIPTOR-STACK-FRAME -- internal
93 ;;;
94 ;;; Return the number of bytes needed for the current non-descriptor stack
95 ;;; frame.  Non-descriptor stack frames must be multiples of 8 bytes on
96 ;;; the PMAX.
97 ;;; 
98 (defun bytes-needed-for-non-descriptor-stack-frame ()
99   (* (logandc2 (1+ (sb-allocated-size 'non-descriptor-stack)) 1)
100      n-word-bytes))
101
102 ;;; Used for setting up the Old-FP in local call.
103 ;;;
104 (define-vop (current-fp)
105   (:results (val :scs (any-reg)))
106   (:generator 1
107     (move val cfp-tn)))
108
109 ;;; Used for computing the caller's NFP for use in known-values return.  Only
110 ;;; works assuming there is no variable size stuff on the nstack.
111 ;;;
112 (define-vop (compute-old-nfp)
113   (:results (val :scs (any-reg)))
114   (:vop-var vop)
115   (:generator 1
116     (let ((nfp (current-nfp-tn vop)))
117       (when nfp
118         (inst addu val nfp (bytes-needed-for-non-descriptor-stack-frame))))))
119
120
121 (define-vop (xep-allocate-frame)
122   (:info start-lab copy-more-arg-follows)
123   (:ignore copy-more-arg-follows)
124   (:vop-var vop)
125   (:temporary (:scs (non-descriptor-reg)) temp)
126   (:generator 1
127     ;; Make sure the function is aligned, and drop a label pointing to this
128     ;; function header.
129     (align n-lowtag-bits)
130     (trace-table-entry trace-table-fun-prologue)
131     (emit-label start-lab)
132     ;; Allocate function header.
133     (inst fun-header-word)
134     (dotimes (i (1- simple-fun-code-offset))
135       (inst word 0))
136     ;; The start of the actual code.
137     ;; Compute CODE from the address of this entry point.
138     (let ((entry-point (gen-label)))
139       (emit-label entry-point)
140       (inst compute-code-from-fn code-tn lip-tn entry-point temp)
141       ;; ### We should also save it on the stack so that the garbage collector
142       ;; won't forget about us if we call anyone else.
143       )
144     ;; Build our stack frames.
145     (inst addu csp-tn cfp-tn
146           (* n-word-bytes (sb-allocated-size 'control-stack)))
147     (let ((nfp (current-nfp-tn vop)))
148       (when nfp
149         (inst addu nsp-tn nsp-tn
150               (- (bytes-needed-for-non-descriptor-stack-frame)))
151         (move nfp nsp-tn)))
152     (trace-table-entry trace-table-normal)))
153
154 (define-vop (allocate-frame)
155   (:results (res :scs (any-reg))
156             (nfp :scs (any-reg)))
157   (:info callee)
158   (:generator 2
159     (trace-table-entry trace-table-fun-prologue)
160     (move res csp-tn)
161     (inst addu csp-tn csp-tn
162           (* n-word-bytes (sb-allocated-size 'control-stack)))
163     (when (ir2-physenv-number-stack-p callee)
164       (inst addu nsp-tn nsp-tn
165             (- (bytes-needed-for-non-descriptor-stack-frame)))
166       (move nfp nsp-tn))
167     (trace-table-entry trace-table-normal)))
168
169 ;;; Allocate a partial frame for passing stack arguments in a full call.  Nargs
170 ;;; is the number of arguments passed.  If no stack arguments are passed, then
171 ;;; we don't have to do anything.
172 ;;;
173 (define-vop (allocate-full-call-frame)
174   (:info nargs)
175   (:results (res :scs (any-reg)))
176   (:generator 2
177     (when (> nargs register-arg-count)
178       (move res csp-tn)
179       (inst addu csp-tn csp-tn (* nargs n-word-bytes)))))
180
181
182
183 \f
184 ;;; Emit code needed at the return-point from an unknown-values call for a
185 ;;; fixed number of values.  Values is the head of the TN-Ref list for the
186 ;;; locations that the values are to be received into.  Nvals is the number of
187 ;;; values that are to be received (should equal the length of Values).
188 ;;;
189 ;;;    MOVE-TEMP is a DESCRIPTOR-REG TN used as a temporary.
190 ;;;
191 ;;;    This code exploits the fact that in the unknown-values convention, a
192 ;;; single value return returns at the return PC + 8, whereas a return of other
193 ;;; than one value returns directly at the return PC.
194 ;;;
195 ;;;    If 0 or 1 values are expected, then we just emit an instruction to reset
196 ;;; the SP (which will only be executed when other than 1 value is returned.)
197 ;;;
198 ;;; In the general case, we have to do three things:
199 ;;;  -- Default unsupplied register values.  This need only be done when a
200 ;;;     single value is returned, since register values are defaulted by the
201 ;;;     called in the non-single case.
202 ;;;  -- Default unsupplied stack values.  This needs to be done whenever there
203 ;;;     are stack values.
204 ;;;  -- Reset SP.  This must be done whenever other than 1 value is returned,
205 ;;;     regardless of the number of values desired.
206 ;;;
207 ;;; The general-case code looks like this:
208 #|
209         b regs-defaulted                ; Skip if MVs
210         nop
211
212         move a1 null-tn                 ; Default register values
213         ...
214         loadi nargs 1                   ; Force defaulting of stack values
215         move ocfp csp                   ; Set up args for SP resetting
216
217 regs-defaulted
218         subu temp nargs register-arg-count
219
220         bltz temp default-value-7       ; jump to default code
221         addu temp temp -1
222         loadw move-temp ocfp-tn 6       ; Move value to correct location.
223         store-stack-tn val4-tn move-temp
224
225         bltz temp default-value-8
226         addu temp temp -1
227         loadw move-temp ocfp-tn 7
228         store-stack-tn val5-tn move-temp
229
230         ...
231
232 defaulting-done
233         move sp ocfp                    ; Reset SP.
234 <end of code>
235
236 <elsewhere>
237 default-value-7
238         store-stack-tn val4-tn null-tn  ; Nil out 7'th value. (first on stack)
239
240 default-value-8
241         store-stack-tn val5-tn null-tn  ; Nil out 8'th value.
242
243         ...
244
245         br defaulting-done
246         nop
247 |#
248 ;;;
249 (defun default-unknown-values (vop values nvals move-temp temp lra-label)
250   (declare (type (or tn-ref null) values)
251            (type unsigned-byte nvals) (type tn move-temp temp))
252   (if (<= nvals 1)
253       (progn
254         ;; Note that this is a single-value return point.  This is actually
255         ;; the multiple-value entry point for a single desired value, but
256         ;; the code location has to be here, or the debugger backtrace
257         ;; gets confused.
258         (without-scheduling ()
259           (note-this-location vop :single-value-return)
260           (move csp-tn ocfp-tn)
261           (inst nop))
262         (when lra-label
263           (inst compute-code-from-lra code-tn code-tn lra-label temp)))
264       (let ((regs-defaulted (gen-label))
265             (defaulting-done (gen-label))
266             (default-stack-vals (gen-label)))
267         (without-scheduling ()
268           ;; Note that this is an unknown-values return point.
269           (note-this-location vop :unknown-return)
270           ;; Branch off to the MV case.
271           (inst b regs-defaulted)
272           ;; If there are no stack results, clear the stack now.
273           (if (> nvals register-arg-count)
274               (inst addu temp nargs-tn (fixnumize (- register-arg-count)))
275               (move csp-tn ocfp-tn)))
276         
277         ;; Do the single value calse.
278         (do ((i 1 (1+ i))
279              (val (tn-ref-across values) (tn-ref-across val)))
280             ((= i (min nvals register-arg-count)))
281           (move (tn-ref-tn val) null-tn))
282         (when (> nvals register-arg-count)
283           (inst b default-stack-vals)
284           (move ocfp-tn csp-tn))
285         
286         (emit-label regs-defaulted)
287         
288         (when (> nvals register-arg-count)
289           ;; If there are stack results, we have to default them
290           ;; and clear the stack.
291           (collect ((defaults))
292             (do ((i register-arg-count (1+ i))
293                  (val (do ((i 0 (1+ i))
294                            (val values (tn-ref-across val)))
295                           ((= i register-arg-count) val))
296                       (tn-ref-across val)))
297                 ((null val))
298               
299               (let ((default-lab (gen-label))
300                     (tn (tn-ref-tn val)))
301                 (defaults (cons default-lab tn))
302                 
303                 (inst blez temp default-lab)
304                 (inst lw move-temp ocfp-tn (* i n-word-bytes))
305                 (inst addu temp temp (fixnumize -1))
306                 (store-stack-tn tn move-temp)))
307             
308             (emit-label defaulting-done)
309             (move csp-tn ocfp-tn)
310             
311             (let ((defaults (defaults)))
312               (assert defaults)
313               (assemble (*elsewhere*)
314                 (emit-label default-stack-vals)
315                 (do ((remaining defaults (cdr remaining)))
316                     ((null remaining))
317                   (let ((def (car remaining)))
318                     (emit-label (car def))
319                     (when (null (cdr remaining))
320                       (inst b defaulting-done))
321                     (store-stack-tn (cdr def) null-tn)))))))
322
323         (when lra-label
324           (inst compute-code-from-lra code-tn code-tn lra-label temp))))
325   (values))
326
327 \f
328 ;;;; Unknown values receiving:
329
330 ;;;    Emit code needed at the return point for an unknown-values call for an
331 ;;; arbitrary number of values.
332 ;;;
333 ;;;    We do the single and non-single cases with no shared code: there doesn't
334 ;;; seem to be any potential overlap, and receiving a single value is more
335 ;;; important efficiency-wise.
336 ;;;
337 ;;;    When there is a single value, we just push it on the stack, returning
338 ;;; the old SP and 1.
339 ;;;
340 ;;;    When there is a variable number of values, we move all of the argument
341 ;;; registers onto the stack, and return Args and Nargs.
342 ;;;
343 ;;;    Args and Nargs are TNs wired to the named locations.  We must
344 ;;; explicitly allocate these TNs, since their lifetimes overlap with the
345 ;;; results Start and Count (also, it's nice to be able to target them).
346 ;;;
347 (defun receive-unknown-values (args nargs start count lra-label temp)
348   (declare (type tn args nargs start count temp))
349   (let ((variable-values (gen-label))
350         (done (gen-label)))
351     (without-scheduling ()
352       (inst b variable-values)
353       (inst nop))
354
355     (when lra-label
356       (inst compute-code-from-lra code-tn code-tn lra-label temp))
357     (inst addu csp-tn csp-tn 4)
358     (storew (first register-arg-tns) csp-tn -1)
359     (inst addu start csp-tn -4)
360     (inst li count (fixnumize 1))
361     
362     (emit-label done)
363     
364     (assemble (*elsewhere*)
365       (emit-label variable-values)
366       (when lra-label
367         (inst compute-code-from-lra code-tn code-tn lra-label temp))
368       (do ((arg register-arg-tns (rest arg))
369            (i 0 (1+ i)))
370           ((null arg))
371         (storew (first arg) args i))
372       (move start args)
373       (move count nargs)
374       (inst b done)
375       (inst nop)))
376   (values))
377
378
379 ;;; VOP that can be inherited by unknown values receivers.  The main thing this
380 ;;; handles is allocation of the result temporaries.
381 ;;;
382 (define-vop (unknown-values-receiver)
383   (:results
384    (start :scs (any-reg))
385    (count :scs (any-reg)))
386   (:temporary (:sc descriptor-reg :offset ocfp-offset
387                    :from :eval :to (:result 0))
388               values-start)
389   (:temporary (:sc any-reg :offset nargs-offset
390                :from :eval :to (:result 1))
391               nvals)
392   (:temporary (:scs (non-descriptor-reg)) temp))
393
394
395 \f
396 ;;;; Local call with unknown values convention return:
397
398 ;;; Non-TR local call for a fixed number of values passed according to the
399 ;;; unknown values convention.
400 ;;;
401 ;;; Args are the argument passing locations, which are specified only to
402 ;;; terminate their lifetimes in the caller.
403 ;;;
404 ;;; Values are the return value locations (wired to the standard passing
405 ;;; locations).
406 ;;;
407 ;;; Save is the save info, which we can ignore since saving has been done.
408 ;;; Return-PC is the TN that the return PC should be passed in.
409 ;;; Target is a continuation pointing to the start of the called function.
410 ;;; Nvals is the number of values received.
411 ;;;
412 ;;; Note: we can't use normal load-tn allocation for the fixed args, since all
413 ;;; registers may be tied up by the more operand.  Instead, we use
414 ;;; MAYBE-LOAD-STACK-TN.
415 ;;;
416 (define-vop (call-local)
417   (:args (fp)
418          (nfp)
419          (args :more t))
420   (:results (values :more t))
421   (:save-p t)
422   (:move-args :local-call)
423   (:info arg-locs callee target nvals)
424   (:vop-var vop)
425   (:temporary (:scs (descriptor-reg) :from :eval) move-temp)
426   (:temporary (:scs (non-descriptor-reg)) temp)
427   (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)
428   (:temporary (:sc any-reg :offset ocfp-offset :from :eval) ocfp)
429   (:ignore arg-locs args ocfp)
430   (:generator 5
431     (let ((label (gen-label))
432           (cur-nfp (current-nfp-tn vop)))
433       (when cur-nfp
434         (store-stack-tn nfp-save cur-nfp))
435       (let ((callee-nfp (callee-nfp-tn callee)))
436         (when callee-nfp
437           (maybe-load-stack-tn callee-nfp nfp)))
438       (maybe-load-stack-tn cfp-tn fp)
439       (trace-table-entry trace-table-call-site)
440       (inst compute-lra-from-code
441             (callee-return-pc-tn callee) code-tn label temp)
442       (note-this-location vop :call-site)
443       (inst b target)
444       (inst nop)
445       (trace-table-entry trace-table-normal)
446       (emit-return-pc label)
447       (default-unknown-values vop values nvals move-temp temp label)
448       (when cur-nfp
449         (load-stack-tn cur-nfp nfp-save)))))
450
451
452 ;;; Non-TR local call for a variable number of return values passed according
453 ;;; to the unknown values convention.  The results are the start of the values
454 ;;; glob and the number of values received.
455 ;;;
456 ;;; Note: we can't use normal load-tn allocation for the fixed args, since all
457 ;;; registers may be tied up by the more operand.  Instead, we use
458 ;;; MAYBE-LOAD-STACK-TN.
459 ;;;
460 (define-vop (multiple-call-local unknown-values-receiver)
461   (:args (fp)
462          (nfp)
463          (args :more t))
464   (:save-p t)
465   (:move-args :local-call)
466   (:info save callee target)
467   (:ignore args save)
468   (:vop-var vop)
469   (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)
470   (:generator 20
471     (let ((label (gen-label))
472           (cur-nfp (current-nfp-tn vop)))
473       (when cur-nfp
474         (store-stack-tn nfp-save cur-nfp))
475       (let ((callee-nfp (callee-nfp-tn callee)))
476         (when callee-nfp
477           (maybe-load-stack-tn callee-nfp nfp)))
478       (maybe-load-stack-tn cfp-tn fp)
479       (trace-table-entry trace-table-call-site)
480       (inst compute-lra-from-code
481             (callee-return-pc-tn callee) code-tn label temp)
482       (note-this-location vop :call-site)
483       (inst b target)
484       (inst nop)
485       (trace-table-entry trace-table-normal)
486       (emit-return-pc label)
487       (note-this-location vop :unknown-return)
488       (receive-unknown-values values-start nvals start count label temp)
489       (when cur-nfp
490         (load-stack-tn cur-nfp nfp-save)))))
491
492 \f
493 ;;;; Local call with known values return:
494
495 ;;; Non-TR local call with known return locations.  Known-value return works
496 ;;; just like argument passing in local call.
497 ;;;
498 ;;; Note: we can't use normal load-tn allocation for the fixed args, since all
499 ;;; registers may be tied up by the more operand.  Instead, we use
500 ;;; MAYBE-LOAD-STACK-TN.
501 ;;;
502 (define-vop (known-call-local)
503   (:args (fp)
504          (nfp)
505          (args :more t))
506   (:results (res :more t))
507   (:move-args :local-call)
508   (:save-p t)
509   (:info save callee target)
510   (:ignore args res save)
511   (:vop-var vop)
512   (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)
513   (:temporary (:scs (non-descriptor-reg)) temp)
514   (:generator 5
515     (let ((label (gen-label))
516           (cur-nfp (current-nfp-tn vop)))
517       (when cur-nfp
518         (store-stack-tn nfp-save cur-nfp))
519       (let ((callee-nfp (callee-nfp-tn callee)))
520         (when callee-nfp
521           (maybe-load-stack-tn callee-nfp nfp)))
522       (maybe-load-stack-tn cfp-tn fp)
523       (trace-table-entry trace-table-call-site)
524       (inst compute-lra-from-code
525             (callee-return-pc-tn callee) code-tn label temp)
526       (note-this-location vop :call-site)
527       (inst b target)
528       (inst nop)
529       (trace-table-entry trace-table-normal)
530       (emit-return-pc label)
531       (note-this-location vop :known-return)
532       (when cur-nfp
533         (load-stack-tn cur-nfp nfp-save)))))
534
535 ;;; Return from known values call.  We receive the return locations as
536 ;;; arguments to terminate their lifetimes in the returning function.  We
537 ;;; restore FP and CSP and jump to the Return-PC.
538 ;;;
539 ;;; Note: we can't use normal load-tn allocation for the fixed args, since all
540 ;;; registers may be tied up by the more operand.  Instead, we use
541 ;;; MAYBE-LOAD-STACK-TN.
542 ;;;
543 (define-vop (known-return)
544   (:args (ocfp :target ocfp-temp)
545          (return-pc :target return-pc-temp)
546          (vals :more t))
547   (:temporary (:sc any-reg :from (:argument 0)) ocfp-temp)
548   (:temporary (:sc descriptor-reg :from (:argument 1))
549               return-pc-temp)
550   (:temporary (:scs (interior-reg)) lip)
551   (:move-args :known-return)
552   (:info val-locs)
553   (:ignore val-locs vals)
554   (:vop-var vop)
555   (:generator 6
556     (trace-table-entry trace-table-fun-epilogue)
557     (maybe-load-stack-tn ocfp-temp ocfp)
558     (maybe-load-stack-tn return-pc-temp return-pc)
559     (move csp-tn cfp-tn)
560     (let ((cur-nfp (current-nfp-tn vop)))
561       (when cur-nfp
562         (inst addu nsp-tn cur-nfp
563               (bytes-needed-for-non-descriptor-stack-frame))))
564     (inst addu lip return-pc-temp (- n-word-bytes other-pointer-lowtag))
565     (inst j lip)
566     (move cfp-tn ocfp-temp)
567     (trace-table-entry trace-table-normal)))
568
569 \f
570 ;;;; Full call:
571 ;;;
572 ;;;    There is something of a cross-product effect with full calls.  Different
573 ;;; versions are used depending on whether we know the number of arguments or
574 ;;; the name of the called function, and whether we want fixed values, unknown
575 ;;; values, or a tail call.
576 ;;;
577 ;;; In full call, the arguments are passed creating a partial frame on the
578 ;;; stack top and storing stack arguments into that frame.  On entry to the
579 ;;; callee, this partial frame is pointed to by FP.  If there are no stack
580 ;;; arguments, we don't bother allocating a partial frame, and instead set FP
581 ;;; to SP just before the call.
582
583 ;;;    This macro helps in the definition of full call VOPs by avoiding code
584 ;;; replication in defining the cross-product VOPs.
585 ;;;
586 ;;; Name is the name of the VOP to define.
587 ;;; 
588 ;;; Named is true if the first argument is a symbol whose global function
589 ;;; definition is to be called.
590 ;;;
591 ;;; Return is either :Fixed, :Unknown or :Tail:
592 ;;; -- If :Fixed, then the call is for a fixed number of values, returned in
593 ;;;    the standard passing locations (passed as result operands).
594 ;;; -- If :Unknown, then the result values are pushed on the stack, and the
595 ;;;    result values are specified by the Start and Count as in the
596 ;;;    unknown-values continuation representation.
597 ;;; -- If :Tail, then do a tail-recursive call.  No values are returned.
598 ;;;    The Ocfp and Return-PC are passed as the second and third arguments.
599 ;;;
600 ;;; In non-tail calls, the pointer to the stack arguments is passed as the last
601 ;;; fixed argument.  If Variable is false, then the passing locations are
602 ;;; passed as a more arg.  Variable is true if there are a variable number of
603 ;;; arguments passed on the stack.  Variable cannot be specified with :Tail
604 ;;; return.  TR variable argument call is implemented separately.
605 ;;;
606 ;;; In tail call with fixed arguments, the passing locations are passed as a
607 ;;; more arg, but there is no new-FP, since the arguments have been set up in
608 ;;; the current frame.
609 ;;;
610 (defmacro define-full-call (name named return variable)
611   (assert (not (and variable (eq return :tail))))
612   `(define-vop (,name
613                 ,@(when (eq return :unknown)
614                     '(unknown-values-receiver)))
615      (:args
616       ,@(unless (eq return :tail)
617           '((new-fp :scs (any-reg) :to :eval)))
618
619       ,(if named
620            '(name :target name-pass)
621            '(arg-fun :target lexenv))
622       
623       ,@(when (eq return :tail)
624           '((ocfp :target ocfp-pass)
625             (return-pc :target return-pc-pass)))
626       
627       ,@(unless variable '((args :more t :scs (descriptor-reg)))))
628
629      ,@(when (eq return :fixed)
630          '((:results (values :more t))))
631    
632      (:save-p ,(if (eq return :tail) :compute-only t))
633
634      ,@(unless (or (eq return :tail) variable)
635          '((:move-args :full-call)))
636
637      (:vop-var vop)
638      (:info ,@(unless (or variable (eq return :tail)) '(arg-locs))
639             ,@(unless variable '(nargs))
640             ,@(when (eq return :fixed) '(nvals)))
641
642      (:ignore ,@(unless (or variable (eq return :tail)) '(arg-locs))
643               ,@(unless variable '(args)))
644
645      (:temporary (:sc descriptor-reg
646                   :offset ocfp-offset
647                   :from (:argument 1)
648                   ,@(unless (eq return :fixed)
649                       '(:to :eval)))
650                  ocfp-pass)
651
652      (:temporary (:sc descriptor-reg
653                   :offset lra-offset 
654                   :from (:argument ,(if (eq return :tail) 2 1))
655                   :to :eval)
656                  return-pc-pass)
657
658      ,@(if named
659          `((:temporary (:sc descriptor-reg :offset fdefn-offset
660                         :from (:argument ,(if (eq return :tail) 0 1))
661                         :to :eval)
662                        name-pass))
663
664          `((:temporary (:sc descriptor-reg :offset lexenv-offset
665                         :from (:argument ,(if (eq return :tail) 0 1))
666                         :to :eval)
667                        lexenv)
668            (:temporary (:scs (descriptor-reg) :from (:argument 0) :to :eval)
669                        function)))
670
671      (:temporary (:sc any-reg :offset nargs-offset :to :eval)
672                  nargs-pass)
673
674      ,@(when variable
675          (mapcar #'(lambda (name offset)
676                      `(:temporary (:sc descriptor-reg
677                                    :offset ,offset
678                                    :to :eval)
679                          ,name))
680                  register-arg-names *register-arg-offsets*))
681      ,@(when (eq return :fixed)
682          '((:temporary (:scs (descriptor-reg) :from :eval) move-temp)))
683
684      ,@(unless (eq return :tail)
685          '((:temporary (:scs (non-descriptor-reg)) temp)
686            (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)))
687
688      (:temporary (:sc interior-reg :offset lip-offset) entry-point)
689
690      (:generator ,(+ (if named 5 0)
691                      (if variable 19 1)
692                      (if (eq return :tail) 0 10)
693                      15
694                      (if (eq return :unknown) 25 0))
695        (let* ((cur-nfp (current-nfp-tn vop))
696               ,@(unless (eq return :tail)
697                   '((lra-label (gen-label))))
698               (filler
699                (remove nil
700                        (list :load-nargs
701                              ,@(if (eq return :tail)
702                                    '((unless (location= ocfp ocfp-pass)
703                                        :load-ocfp)
704                                      (unless (location= return-pc
705                                                         return-pc-pass)
706                                        :load-return-pc)
707                                      (when cur-nfp
708                                        :frob-nfp))
709                                    '(:comp-lra
710                                      (when cur-nfp
711                                        :frob-nfp)
712                                      :save-fp
713                                      :load-fp))))))
714          (flet ((do-next-filler ()
715                   (let* ((next (pop filler))
716                          (what (if (consp next) (car next) next)))
717                     (ecase what
718                       (:load-nargs
719                        ,@(if variable
720                              `((inst subu nargs-pass csp-tn new-fp)
721                                ,@(let ((index -1))
722                                    (mapcar #'(lambda (name)
723                                                `(inst lw ,name new-fp
724                                                       ,(ash (incf index)
725                                                             word-shift)))
726                                            register-arg-names)))
727                              '((inst li nargs-pass (fixnumize nargs)))))
728                       ,@(if (eq return :tail)
729                             '((:load-ocfp
730                                (sc-case ocfp
731                                  (any-reg
732                                   (inst move ocfp-pass ocfp))
733                                  (control-stack
734                                   (inst lw ocfp-pass cfp-tn
735                                         (ash (tn-offset ocfp)
736                                              word-shift)))))
737                               (:load-return-pc
738                                (sc-case return-pc
739                                  (descriptor-reg
740                                   (inst move return-pc-pass return-pc))
741                                  (control-stack
742                                   (inst lw return-pc-pass cfp-tn
743                                         (ash (tn-offset return-pc)
744                                              word-shift)))))
745                               (:frob-nfp
746                                (inst addu nsp-tn cur-nfp
747                                      (bytes-needed-for-non-descriptor-stack-frame))))
748                             `((:comp-lra
749                                (inst compute-lra-from-code
750                                      return-pc-pass code-tn lra-label temp))
751                               (:frob-nfp
752                                (store-stack-tn nfp-save cur-nfp))
753                               (:save-fp
754                                (inst move ocfp-pass cfp-tn))
755                               (:load-fp
756                                ,(if variable
757                                     '(move cfp-tn new-fp)
758                                     '(if (> nargs register-arg-count)
759                                          (move cfp-tn new-fp)
760                                          (move cfp-tn csp-tn)))
761                                (trace-table-entry trace-table-call-site))))
762                       ((nil)
763                        (inst nop))))))
764
765            ,@(if named
766                  `((sc-case name
767                      (descriptor-reg (move name-pass name))
768                      (control-stack
769                       (inst lw name-pass cfp-tn
770                             (ash (tn-offset name) word-shift))
771                       (do-next-filler))
772                      (constant
773                       (inst lw name-pass code-tn
774                             (- (ash (tn-offset name) word-shift)
775                                other-pointer-lowtag))
776                       (do-next-filler)))
777                    (inst lw entry-point name-pass
778                          (- (ash fdefn-raw-addr-slot word-shift)
779                             other-pointer-lowtag))
780                    (do-next-filler))
781                  `((sc-case arg-fun
782                      (descriptor-reg (move lexenv arg-fun))
783                      (control-stack
784                       (inst lw lexenv cfp-tn
785                             (ash (tn-offset arg-fun) word-shift))
786                       (do-next-filler))
787                      (constant
788                       (inst lw lexenv code-tn
789                             (- (ash (tn-offset arg-fun) word-shift)
790                                other-pointer-lowtag))
791                       (do-next-filler)))
792                    (inst lw function lexenv
793                          (- (ash closure-fun-slot word-shift)
794                             fun-pointer-lowtag))
795                    (do-next-filler)
796                    (inst addu entry-point function
797                          (- (ash simple-fun-code-offset word-shift)
798                             fun-pointer-lowtag))))
799            (loop
800              (if (cdr filler)
801                  (do-next-filler)
802                  (return)))
803            
804            (note-this-location vop :call-site)
805            (inst j entry-point)
806            (do-next-filler))
807
808          ,@(ecase return
809              (:fixed
810               '((trace-table-entry trace-table-normal)
811                 (emit-return-pc lra-label)
812                 (default-unknown-values vop values nvals
813                                         move-temp temp lra-label)
814                 (when cur-nfp
815                   (load-stack-tn cur-nfp nfp-save))))
816              (:unknown
817               '((trace-table-entry trace-table-normal)
818                 (emit-return-pc lra-label)
819                 (note-this-location vop :unknown-return)
820                 (receive-unknown-values values-start nvals start count
821                                         lra-label temp)
822                 (when cur-nfp
823                   (load-stack-tn cur-nfp nfp-save))))
824              (:tail))))))
825
826
827 (define-full-call call nil :fixed nil)
828 (define-full-call call-named t :fixed nil)
829 (define-full-call multiple-call nil :unknown nil)
830 (define-full-call multiple-call-named t :unknown nil)
831 (define-full-call tail-call nil :tail nil)
832 (define-full-call tail-call-named t :tail nil)
833
834 (define-full-call call-variable nil :fixed t)
835 (define-full-call multiple-call-variable nil :unknown t)
836
837
838 ;;; Defined separately, since needs special code that BLT's the arguments
839 ;;; down.
840 ;;;
841 (define-vop (tail-call-variable)
842   (:args
843    (args-arg :scs (any-reg) :target args)
844    (function-arg :scs (descriptor-reg) :target lexenv)
845    (ocfp-arg :scs (any-reg) :target ocfp)
846    (lra-arg :scs (descriptor-reg) :target lra))
847
848   (:temporary (:sc any-reg :offset nl0-offset :from (:argument 0)) args)
849   (:temporary (:sc any-reg :offset lexenv-offset :from (:argument 1)) lexenv)
850   (:temporary (:sc any-reg :offset ocfp-offset :from (:argument 2)) ocfp)
851   (:temporary (:sc any-reg :offset lra-offset :from (:argument 3)) lra)
852
853   (:vop-var vop)
854
855   (:generator 75
856
857     ;; Move these into the passing locations if they are not already there.
858     (move args args-arg)
859     (move lexenv function-arg)
860     (move ocfp ocfp-arg)
861     (move lra lra-arg)
862
863     ;; Clear the number stack if anything is there.
864     (let ((cur-nfp (current-nfp-tn vop)))
865       (when cur-nfp
866         (inst addu nsp-tn cur-nfp
867               (bytes-needed-for-non-descriptor-stack-frame))))
868
869     ;; And jump to the assembly-routine that does the bliting.
870     (inst j (make-fixup 'tail-call-variable :assembly-routine))
871     (inst nop)))
872
873 \f
874 ;;;; Unknown values return:
875
876 ;;; Return a single value using the unknown-values convention.
877 ;;; 
878 (define-vop (return-single)
879   (:args (ocfp :scs (any-reg))
880          (return-pc :scs (descriptor-reg))
881          (value))
882   (:ignore value)
883   (:temporary (:scs (interior-reg)) lip)
884   (:vop-var vop)
885   (:generator 6
886     ;; Clear the number stack.
887     (trace-table-entry trace-table-fun-epilogue)
888     (let ((cur-nfp (current-nfp-tn vop)))
889       (when cur-nfp
890         (inst addu nsp-tn cur-nfp
891               (bytes-needed-for-non-descriptor-stack-frame))))
892     ;; Clear the control stack, and restore the frame pointer.
893     (move csp-tn cfp-tn)
894     (move cfp-tn ocfp)
895     ;; Out of here.
896     (lisp-return return-pc lip :offset 2)
897     (trace-table-entry trace-table-normal)))
898
899
900 ;;; Do unknown-values return of a fixed number of values.  The Values are
901 ;;; required to be set up in the standard passing locations.  Nvals is the
902 ;;; number of values returned.
903 ;;;
904 ;;; If returning a single value, then deallocate the current frame, restore
905 ;;; FP and jump to the single-value entry at Return-PC + 8.
906 ;;;
907 ;;; If returning other than one value, then load the number of values returned,
908 ;;; NIL out unsupplied values registers, restore FP and return at Return-PC.
909 ;;; When there are stack values, we must initialize the argument pointer to
910 ;;; point to the beginning of the values block (which is the beginning of the
911 ;;; current frame.)
912 ;;;
913 (define-vop (return)
914   (:args (ocfp :scs (any-reg))
915          (return-pc :scs (descriptor-reg) :to (:eval 1))
916          (values :more t))
917   (:ignore values)
918   (:info nvals)
919   (:temporary (:sc descriptor-reg :offset a0-offset :from (:eval 0)) a0)
920   (:temporary (:sc descriptor-reg :offset a1-offset :from (:eval 0)) a1)
921   (:temporary (:sc descriptor-reg :offset a2-offset :from (:eval 0)) a2)
922   (:temporary (:sc descriptor-reg :offset a3-offset :from (:eval 0)) a3)
923   (:temporary (:sc descriptor-reg :offset a4-offset :from (:eval 0)) a4)
924   (:temporary (:sc descriptor-reg :offset a5-offset :from (:eval 0)) a5)
925   (:temporary (:sc any-reg :offset nargs-offset) nargs)
926   (:temporary (:sc any-reg :offset ocfp-offset) val-ptr)
927   (:temporary (:scs (interior-reg)) lip)
928   (:vop-var vop)
929   (:generator 6
930     ;; Clear the number stack.
931     (trace-table-entry trace-table-fun-epilogue)
932     (let ((cur-nfp (current-nfp-tn vop)))
933       (when cur-nfp
934         (inst addu nsp-tn cur-nfp
935               (bytes-needed-for-non-descriptor-stack-frame))))
936     ;; Establish the values pointer and values count.
937     (move val-ptr cfp-tn)
938     (inst li nargs (fixnumize nvals))
939     ;; restore the frame pointer and clear as much of the control
940     ;; stack as possible.
941     (move cfp-tn ocfp)
942     (inst addu csp-tn val-ptr (* nvals n-word-bytes))
943     ;; pre-default any argument register that need it.
944     (when (< nvals register-arg-count)
945       (dolist (reg (subseq (list a0 a1 a2 a3 a4 a5) nvals))
946         (move reg null-tn)))
947     ;; And away we go.
948     (lisp-return return-pc lip)
949     (trace-table-entry trace-table-normal)))
950
951 ;;; Do unknown-values return of an arbitrary number of values (passed on the
952 ;;; stack.)  We check for the common case of a single return value, and do that
953 ;;; inline using the normal single value return convention.  Otherwise, we
954 ;;; branch off to code that calls an assembly-routine.
955 ;;;
956 (define-vop (return-multiple)
957   (:args (ocfp-arg :scs (any-reg) :target ocfp)
958          (lra-arg :scs (descriptor-reg) :target lra)
959          (vals-arg :scs (any-reg) :target vals)
960          (nvals-arg :scs (any-reg) :target nvals))
961
962   (:temporary (:sc any-reg :offset nl1-offset :from (:argument 0)) ocfp)
963   (:temporary (:sc descriptor-reg :offset lra-offset :from (:argument 1)) lra)
964   (:temporary (:sc any-reg :offset nl0-offset :from (:argument 2)) vals)
965   (:temporary (:sc any-reg :offset nargs-offset :from (:argument 3)) nvals)
966   (:temporary (:sc descriptor-reg :offset a0-offset) a0)
967   (:temporary (:scs (interior-reg)) lip)
968
969   (:vop-var vop)
970
971   (:generator 13
972     (trace-table-entry trace-table-fun-epilogue)
973     (let ((not-single (gen-label)))
974       ;; Clear the number stack.
975       (let ((cur-nfp (current-nfp-tn vop)))
976         (when cur-nfp
977           (inst addu nsp-tn cur-nfp
978                 (bytes-needed-for-non-descriptor-stack-frame))))
979
980       ;; Check for the single case.
981       (inst li a0 (fixnumize 1))
982       (inst bne nvals-arg a0 not-single)
983       (inst lw a0 vals-arg)
984
985       ;; Return with one value.
986       (move csp-tn cfp-tn)
987       (move cfp-tn ocfp-arg)
988       (lisp-return lra-arg lip :offset 2)
989
990       ;; Nope, not the single case.
991       (emit-label not-single)
992       (move ocfp ocfp-arg)
993       (move lra lra-arg)
994       (move vals vals-arg)
995       (move nvals nvals-arg)
996       (inst j (make-fixup 'return-multiple :assembly-routine))
997       (inst nop))
998     (trace-table-entry trace-table-normal)))
999
1000
1001 \f
1002 ;;;; XEP hackery:
1003
1004
1005 ;;; We don't need to do anything special for regular functions.
1006 ;;;
1007 (define-vop (setup-environment)
1008   (:info label)
1009   (:ignore label)
1010   (:generator 0
1011     ;; Don't bother doing anything.
1012     ))
1013
1014 ;;; Get the lexical environment from it's passing location.
1015 ;;;
1016 (define-vop (setup-closure-environment)
1017   (:temporary (:sc descriptor-reg :offset lexenv-offset :target closure
1018                :to (:result 0))
1019               lexenv)
1020   (:results (closure :scs (descriptor-reg)))
1021   (:info label)
1022   (:ignore label)
1023   (:generator 6
1024     ;; Get result.
1025     (move closure lexenv)))
1026
1027 ;;; Copy a more arg from the argument area to the end of the current frame.
1028 ;;; Fixed is the number of non-more arguments. 
1029 ;;;
1030 (define-vop (copy-more-arg)
1031   (:temporary (:sc any-reg :offset nl0-offset) result)
1032   (:temporary (:sc any-reg :offset nl1-offset) count)
1033   (:temporary (:sc any-reg :offset nl2-offset) src)
1034   (:temporary (:sc any-reg :offset nl4-offset) dst)
1035   (:temporary (:sc descriptor-reg :offset l0-offset) temp)
1036   (:info fixed)
1037   (:generator 20
1038     (let ((loop (gen-label))
1039           (do-regs (gen-label))
1040           (done (gen-label)))
1041       (when (< fixed register-arg-count)
1042         ;; Save a pointer to the results so we can fill in register args.
1043         ;; We don't need this if there are more fixed args than reg args.
1044         (move result csp-tn))
1045       ;; Allocate the space on the stack.
1046       (cond ((zerop fixed)
1047              (inst beq nargs-tn done)
1048              (inst addu csp-tn csp-tn nargs-tn))
1049             (t
1050              (inst addu count nargs-tn (fixnumize (- fixed)))
1051              (inst blez count done)
1052              (inst nop)
1053              (inst addu csp-tn csp-tn count)))
1054       (when (< fixed register-arg-count)
1055         ;; We must stop when we run out of stack args, not when we run out of
1056         ;; more args.
1057         (inst addu count nargs-tn (fixnumize (- register-arg-count))))
1058       ;; Everything of interest in registers.
1059       (inst blez count do-regs)
1060       ;; Initialize dst to be end of stack.
1061       (move dst csp-tn)
1062       ;; Initialize src to be end of args.
1063       (inst addu src cfp-tn nargs-tn)
1064
1065       (emit-label loop)
1066       ;; *--dst = *--src, --count
1067       (inst addu src src (- n-word-bytes))
1068       (inst addu count count (fixnumize -1))
1069       (loadw temp src)
1070       (inst addu dst dst (- n-word-bytes))
1071       (inst bgtz count loop)
1072       (storew temp dst)
1073
1074       (emit-label do-regs)
1075       (when (< fixed register-arg-count)
1076         ;; Now we have to deposit any more args that showed up in registers.
1077         ;; We know there is at least one more arg, otherwise we would have
1078         ;; branched to done up at the top.
1079         (inst subu count nargs-tn (fixnumize (1+ fixed)))
1080         (do ((i fixed (1+ i)))
1081             ((>= i register-arg-count))
1082           ;; Is this the last one?
1083           (inst beq count done)
1084           ;; Store it relative to the pointer saved at the start.
1085           (storew (nth i register-arg-tns) result (- i fixed))
1086           ;; Decrement count.
1087           (inst subu count (fixnumize 1))))
1088       (emit-label done))))
1089
1090
1091 ;;; More args are stored consequtively on the stack, starting immediately at
1092 ;;; the context pointer.  The context pointer is not typed, so the lowtag is 0.
1093 ;;;
1094 (define-full-reffer more-arg * 0 0 (descriptor-reg any-reg) * %more-arg)
1095
1096
1097 ;;; Turn more arg (context, count) into a list.
1098 ;;;
1099 (define-vop (listify-rest-args)
1100   (:args (context-arg :target context :scs (descriptor-reg))
1101          (count-arg :target count :scs (any-reg)))
1102   (:arg-types * tagged-num)
1103   (:temporary (:scs (any-reg) :from (:argument 0)) context)
1104   (:temporary (:scs (any-reg) :from (:argument 1)) count)
1105   (:temporary (:scs (descriptor-reg) :from :eval) temp dst)
1106   (:temporary (:sc non-descriptor-reg :offset nl4-offset) pa-flag)
1107   (:results (result :scs (descriptor-reg)))
1108   (:translate %listify-rest-args)
1109   (:policy :safe)
1110   (:generator 20
1111     (let ((enter (gen-label))
1112           (loop (gen-label))
1113           (done (gen-label)))
1114       (move context context-arg)
1115       (move count count-arg)
1116       ;; Check to see if there are any arguments.
1117       (inst beq count zero-tn done)
1118       (move result null-tn)
1119
1120       ;; We need to do this atomically.
1121       (pseudo-atomic (pa-flag)
1122         ;; Allocate a cons (2 words) for each item.
1123         (inst or result alloc-tn list-pointer-lowtag)
1124         (move dst result)
1125         (inst sll temp count 1)
1126         (inst b enter)
1127         (inst addu alloc-tn alloc-tn temp)
1128
1129         ;; Store the current cons in the cdr of the previous cons.
1130         (emit-label loop)
1131         (inst addu dst dst (* 2 n-word-bytes))
1132         (storew dst dst -1 list-pointer-lowtag)
1133
1134         (emit-label enter)
1135         ;; Grab one value.
1136         (loadw temp context)
1137         (inst addu context context n-word-bytes)
1138
1139         ;; Dec count, and if != zero, go back for more.
1140         (inst addu count count (fixnumize -1))
1141         (inst bne count zero-tn loop)
1142
1143         ;; Store the value in the car (in delay slot)
1144         (storew temp dst 0 list-pointer-lowtag)
1145
1146         ;; NIL out the last cons.
1147         (storew null-tn dst 1 list-pointer-lowtag))
1148       (emit-label done))))
1149
1150 ;;; Return the location and size of the more arg glob created by Copy-More-Arg.
1151 ;;; Supplied is the total number of arguments supplied (originally passed in
1152 ;;; NARGS.)  Fixed is the number of non-rest arguments.
1153 ;;;
1154 ;;; We must duplicate some of the work done by Copy-More-Arg, since at that
1155 ;;; time the environment is in a pretty brain-damaged state, preventing this
1156 ;;; info from being returned as values.  What we do is compute
1157 ;;; supplied - fixed, and return a pointer that many words below the current
1158 ;;; stack top.
1159 ;;;
1160 (define-vop (more-arg-context)
1161   (:policy :fast-safe)
1162   (:translate sb!c::%more-arg-context)
1163   (:args (supplied :scs (any-reg)))
1164   (:arg-types tagged-num (:constant fixnum))
1165   (:info fixed)
1166   (:results (context :scs (descriptor-reg))
1167             (count :scs (any-reg)))
1168   (:result-types t tagged-num)
1169   (:note "more-arg-context")
1170   (:generator 5
1171     (inst addu count supplied (fixnumize (- fixed)))
1172     (inst subu context csp-tn count)))
1173
1174
1175 ;;; Signal wrong argument count error if Nargs isn't = to Count.
1176 ;;;
1177 (define-vop (verify-arg-count)
1178   (:policy :fast-safe)
1179   (:translate sb!c::%verify-arg-count)
1180   (:args (nargs :scs (any-reg)))
1181   (:arg-types positive-fixnum (:constant t))
1182   (:temporary (:scs (any-reg) :type fixnum) temp)
1183   (:info count)
1184   (:vop-var vop)
1185   (:save-p :compute-only)
1186   (:generator 3
1187     (let ((err-lab
1188            (generate-error-code vop invalid-arg-count-error nargs)))
1189       (cond ((zerop count)
1190              (inst bne nargs zero-tn err-lab)
1191              (inst nop))
1192             (t
1193              (inst li temp (fixnumize count))
1194              (inst bne nargs temp err-lab)
1195              (inst nop))))))
1196
1197 ;;; Various other error signalers.
1198 ;;;
1199 (macrolet ((frob (name error translate &rest args)
1200              `(define-vop (,name)
1201                 ,@(when translate
1202                     `((:policy :fast-safe)
1203                       (:translate ,translate)))
1204                 (:args ,@(mapcar #'(lambda (arg)
1205                                      `(,arg :scs (any-reg descriptor-reg)))
1206                                  args))
1207                 (:vop-var vop)
1208                 (:save-p :compute-only)
1209                 (:generator 1000
1210                   (error-call vop ,error ,@args)))))
1211   (frob arg-count-error invalid-arg-count-error
1212     sb!c::%arg-count-error nargs)
1213   (frob type-check-error object-not-type-error sb!c::%type-check-error
1214     object type)
1215   (frob layout-invalid-error layout-invalid-error sb!c::%layout-invalid-error
1216     object layout)
1217   (frob odd-key-args-error odd-key-args-error
1218     sb!c::%odd-key-args-error)
1219   (frob unknown-key-arg-error unknown-key-arg-error
1220     sb!c::%unknown-key-arg-error key)
1221   (frob nil-fun-returned-error nil-fun-returned-error nil fun))