Nearly eliminate bignum consing in the x86-64 disassembler.
[sbcl.git] / src / compiler / fndb.lisp
blob4657f4068d441bfc8491745c867390bee89a20aa
1 ;;;; This file defines all the standard functions to be known
2 ;;;; functions. Each function has type and side-effect information,
3 ;;;; and may also have IR1 optimizers.
5 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; more information.
7 ;;;;
8 ;;;; This software is derived from the CMU CL system, which was
9 ;;;; written at Carnegie Mellon University and released into the
10 ;;;; public domain. The software is in the public domain and is
11 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
12 ;;;; files for more information.
14 (in-package "SB!C")
16 ;;;; information for known functions:
18 (defknown coerce (t type-specifier) t
19 ;; Note:
20 ;; This is not FLUSHABLE because it's defined to signal errors.
21 (movable)
22 ;; :DERIVE-TYPE RESULT-TYPE-SPEC-NTH-ARG 2 ? Nope... (COERCE 1 'COMPLEX)
23 ;; returns REAL/INTEGER, not COMPLEX.
25 ;; These each check their input sequence for type-correctness,
26 ;; but not the output type specifier, because MAKE-SEQUENCE will do that.
27 (defknown list-to-vector* (list type-specifier) vector ())
28 (defknown vector-to-vector* (vector type-specifier) vector ())
30 ;; FIXME: Is this really FOLDABLE? A counterexample seems to be:
31 ;; (LET ((S :S)) (VALUES (TYPE-OF S) (UNINTERN S 'KEYWORD) (TYPE-OF S) S))
32 ;; Anyway, the TYPE-SPECIFIER type is more inclusive than the actual
33 ;; possible return values. Most of the time it will be (OR LIST SYMBOL).
34 ;; CLASS can be returned only when you've got an object whose class-name
35 ;; does not properly name its class.
36 (defknown type-of (t) (or list symbol class)
37 (foldable flushable))
39 ;;; These can be affected by type definitions, so they're not FOLDABLE.
40 (defknown (sb!xc:upgraded-complex-part-type sb!xc:upgraded-array-element-type)
41 (type-specifier &optional lexenv-designator) (or list symbol)
42 (unsafely-flushable))
44 ;;;; from the "Predicates" chapter:
46 ;;; FIXME: Is it right to have TYPEP (and TYPE-OF, elsewhere; and
47 ;;; perhaps SPECIAL-OPERATOR-P and others) be FOLDABLE in the
48 ;;; cross-compilation host? After all, some type relationships (e.g.
49 ;;; FIXNUMness) might be different between host and target. Perhaps
50 ;;; this property should be protected by #-SB-XC-HOST? Perhaps we need
51 ;;; 3-stage bootstrapping after all? (Ugh! It's *so* slow already!)
52 (defknown typep (t type-specifier &optional lexenv-designator) t
53 ;; Unlike SUBTYPEP or UPGRADED-ARRAY-ELEMENT-TYPE and friends, this
54 ;; seems to be FOLDABLE. Like SUBTYPEP, it's affected by type
55 ;; definitions, but unlike SUBTYPEP, there should be no way to make
56 ;; a TYPEP expression with constant arguments which doesn't return
57 ;; an error before the type declaration (because of undefined
58 ;; type). E.g. you can do
59 ;; (SUBTYPEP 'INTEGER 'FOO) => NIL, NIL
60 ;; (DEFTYPE FOO () T)
61 ;; (SUBTYPEP 'INTEGER 'FOO) => T, T
62 ;; but the analogous
63 ;; (TYPEP 12 'FOO)
64 ;; (DEFTYPE FOO () T)
65 ;; (TYPEP 12 'FOO)
66 ;; doesn't work because the first call is an error.
68 ;; (UPGRADED-ARRAY-ELEMENT-TYPE and UPGRADED-COMPLEX-PART-TYPE have
69 ;; behavior like SUBTYPEP in this respect, not like TYPEP.)
70 (foldable))
71 (defknown subtypep (type-specifier type-specifier &optional lexenv-designator)
72 (values boolean boolean)
73 ;; This is not FOLDABLE because its value is affected by type
74 ;; definitions.
76 ;; FIXME: Is it OK to fold this when the types have already been
77 ;; defined? Does the code inherited from CMU CL already do this?
78 (unsafely-flushable))
80 (defknown (null symbolp atom consp listp numberp integerp rationalp floatp
81 complexp characterp stringp bit-vector-p vectorp
82 simple-vector-p simple-string-p simple-bit-vector-p arrayp
83 packagep functionp compiled-function-p not)
84 (t) boolean (movable foldable flushable))
86 (defknown (eq eql %eql/integer) (t t) boolean
87 (movable foldable flushable commutative))
88 (defknown (equal equalp) (t t) boolean (foldable flushable recursive))
90 #!+(or x86 x86-64 arm arm64)
91 (defknown fixnum-mod-p (t fixnum) boolean
92 (movable foldable flushable always-translatable))
95 ;;;; classes
97 (sb!xc:deftype name-for-class () t) ; FIXME: disagrees w/ LEGAL-CLASS-NAME-P
98 (defknown classoid-name (classoid) symbol (flushable))
99 (defknown find-classoid (name-for-class &optional t)
100 (or classoid null) ())
101 (defknown classoid-of (t) classoid (flushable))
102 (defknown layout-of (t) layout (flushable))
103 (defknown copy-structure (structure-object) structure-object
104 (flushable)) ;; FIXME: can derive the type based on the structure
106 ;;;; from the "Control Structure" chapter:
108 ;;; This is not FLUSHABLE, since it's required to signal an error if
109 ;;; unbound.
110 (defknown (symbol-value) (symbol) t ())
111 (defknown about-to-modify-symbol-value (symbol t &optional t t) null
113 ;;; From CLHS, "If the symbol is globally defined as a macro or a
114 ;;; special operator, an object of implementation-dependent nature and
115 ;;; identity is returned. If the symbol is not globally defined as
116 ;;; either a macro or a special operator, and if the symbol is fbound,
117 ;;; a function object is returned". Our objects of
118 ;;; implementation-dependent nature happen to be functions.
119 (defknown (symbol-function) (symbol) function ())
121 (defknown boundp (symbol) boolean (flushable))
122 (defknown fboundp ((or symbol cons)) boolean (unsafely-flushable))
123 (defknown special-operator-p (symbol) t
124 ;; The set of special operators never changes.
125 (movable foldable flushable))
126 (defknown set (symbol t) t ()
127 :derive-type #'result-type-last-arg)
128 (defknown fdefinition ((or symbol cons)) function ())
129 (defknown %set-fdefinition ((or symbol cons) function) function ()
130 :derive-type #'result-type-last-arg)
131 (defknown makunbound (symbol) symbol ()
132 :derive-type #'result-type-first-arg)
133 (defknown fmakunbound ((or symbol cons)) (or symbol cons)
135 :derive-type #'result-type-first-arg)
136 (defknown apply (callable t &rest t) *) ; ### Last arg must be List...
137 (defknown funcall (callable &rest t) *)
139 (defknown (mapcar maplist) (callable list &rest list) list
140 (call))
142 ;;; According to CLHS the result must be a LIST, but we do not check
143 ;;; it.
144 (defknown (mapcan mapcon) (callable list &rest list) t
145 (call))
147 (defknown (mapc mapl) (callable list &rest list) list (foldable call))
149 ;;; We let VALUES-LIST be foldable, since constant-folding will turn
150 ;;; it into VALUES. VALUES is not foldable, since MV constants are
151 ;;; represented by a call to VALUES.
152 (defknown values (&rest t) * (movable flushable))
153 (defknown values-list (list) * (movable foldable unsafely-flushable))
155 ;;;; from the "Macros" chapter:
157 (defknown macro-function (symbol &optional lexenv-designator)
158 (or function null)
159 (flushable))
160 (defknown (macroexpand macroexpand-1 %macroexpand %macroexpand-1)
161 (t &optional lexenv-designator)
162 (values form &optional boolean))
164 (defknown compiler-macro-function (t &optional lexenv-designator)
165 (or function null)
166 (flushable))
168 ;;;; from the "Declarations" chapter:
170 (defknown proclaim (list) (values) (recursive))
172 ;;;; from the "Symbols" chapter:
174 (defknown get (symbol t &optional t) t (flushable))
175 (defknown sb!impl::get3 (symbol t t) t (flushable))
176 (defknown remprop (symbol t) t)
177 (defknown symbol-plist (symbol) list (flushable))
178 (defknown getf (list t &optional t) t (foldable flushable))
179 (defknown get-properties (list list) (values t t list) (foldable flushable))
180 (defknown symbol-name (symbol) simple-string (movable foldable flushable))
181 (defknown make-symbol (string) symbol (flushable))
182 (defknown %make-symbol (simple-string) symbol (flushable))
183 (defknown copy-symbol (symbol &optional t) symbol (flushable))
184 (defknown gensym (&optional (or string unsigned-byte)) symbol ())
185 (defknown symbol-package (symbol) (or package null) (flushable))
186 (defknown keywordp (t) boolean (flushable)) ; If someone uninterns it...
188 ;;;; from the "Packages" chapter:
190 (defknown gentemp (&optional string package-designator) symbol)
192 (defknown make-package (string-designator &key
193 (:use list)
194 (:nicknames list)
195 ;; ### extensions...
196 (:internal-symbols index)
197 (:external-symbols index))
198 package)
199 (defknown find-package (package-designator) (or package null)
200 (flushable))
201 (defknown find-undeleted-package-or-lose (package-designator)
202 package) ; not flushable
203 (defknown package-name (package-designator) (or simple-string null)
204 (unsafely-flushable))
205 (defknown package-nicknames (package-designator) list (unsafely-flushable))
206 (defknown rename-package (package-designator package-designator &optional list)
207 package)
208 (defknown package-use-list (package-designator) list (unsafely-flushable))
209 (defknown package-used-by-list (package-designator) list (unsafely-flushable))
210 (defknown package-shadowing-symbols (package-designator) list (unsafely-flushable))
211 (defknown list-all-packages () list (flushable))
212 (defknown intern (string &optional package-designator)
213 (values symbol (member :internal :external :inherited nil))
215 (defknown find-symbol (string &optional package-designator)
216 (values symbol (member :internal :external :inherited nil))
217 (flushable))
218 (defknown (export import) (symbols-designator &optional package-designator)
219 (eql t))
220 (defknown unintern (symbol &optional package-designator) boolean)
221 (defknown unexport (symbols-designator &optional package-designator) (eql t))
222 (defknown shadowing-import (symbols-designator &optional package-designator)
223 (eql t))
224 (defknown shadow ((or symbol character string list) &optional package-designator)
225 (eql t))
226 (defknown (use-package unuse-package)
227 ((or list package-designator) &optional package-designator) (eql t))
228 (defknown find-all-symbols (string-designator) list (flushable))
229 ;; private
230 (defknown package-iter-step (fixnum index simple-vector list)
231 (values fixnum index simple-vector list symbol symbol))
233 ;;;; from the "Numbers" chapter:
235 (defknown zerop (number) boolean (movable foldable flushable))
236 (defknown (plusp minusp) (real) boolean
237 (movable foldable flushable))
238 (defknown (oddp evenp) (integer) boolean
239 (movable foldable flushable))
240 (defknown (=) (number &rest number) boolean
241 (movable foldable flushable commutative))
242 (defknown (/=) (number &rest number) boolean
243 (movable foldable flushable))
244 (defknown (< > <= >=) (real &rest real) boolean
245 (movable foldable flushable))
246 (defknown (max min) (real &rest real) real
247 (movable foldable flushable))
249 (defknown (+ *) (&rest number) number
250 (movable foldable flushable commutative))
251 (defknown - (number &rest number) number
252 (movable foldable flushable))
253 (defknown / (number &rest number) number
254 (movable foldable unsafely-flushable))
255 (defknown (1+ 1-) (number) number
256 (movable foldable flushable))
258 (defknown conjugate (number) number
259 (movable foldable flushable))
261 (defknown gcd (&rest integer) unsigned-byte
262 (movable foldable flushable)
263 #|:derive-type 'boolean-result-type|#)
264 (defknown lcm (&rest integer) unsigned-byte
265 (movable foldable flushable))
267 #+sb-xc-host ; (See CROSS-FLOAT-INFINITY-KLUDGE.)
268 (defknown exp (number) irrational
269 (movable foldable flushable recursive)
270 :derive-type #'result-type-float-contagion)
272 #-sb-xc-host ; (See CROSS-FLOAT-INFINITY-KLUDGE.)
273 (defknown exp (number) irrational
274 (movable foldable flushable recursive))
276 (defknown expt (number number) number
277 (movable foldable flushable recursive))
278 (defknown log (number &optional real) irrational
279 (movable foldable flushable recursive))
280 (defknown sqrt (number) irrational
281 (movable foldable flushable))
282 (defknown isqrt (unsigned-byte) unsigned-byte
283 (movable foldable flushable recursive))
285 (defknown (abs phase signum) (number) number
286 (movable foldable flushable))
287 (defknown cis (real) (complex float)
288 (movable foldable flushable))
290 #+sb-xc-host ; (See CROSS-FLOAT-INFINITY-KLUDGE.)
291 (progn
292 (defknown (sin cos) (number)
293 (or (float -1.0 1.0) (complex float))
294 (movable foldable flushable recursive)
295 :derive-type #'result-type-float-contagion)
297 (defknown atan
298 (number &optional real) irrational
299 (movable foldable unsafely-flushable recursive)
300 :derive-type #'result-type-float-contagion)
302 (defknown (tan sinh cosh tanh asinh)
303 (number) irrational (movable foldable flushable recursive)
304 :derive-type #'result-type-float-contagion)
305 ) ; PROGN
307 #-sb-xc-host ; (See CROSS-FLOAT-INFINITY-KLUDGE.)
308 (progn
309 (defknown (sin cos) (number)
310 (or (float -1.0 1.0) (complex float))
311 (movable foldable flushable recursive))
313 (defknown atan
314 (number &optional real) irrational
315 (movable foldable unsafely-flushable recursive))
317 (defknown (tan sinh cosh tanh asinh)
318 (number) irrational (movable foldable flushable recursive))
319 ) ; PROGN
321 (defknown (asin acos acosh atanh)
322 (number) irrational
323 (movable foldable flushable recursive))
325 (defknown float (real &optional float) float
326 (movable foldable flushable))
328 (defknown (rational) (real) rational
329 (movable foldable flushable))
331 (defknown (rationalize) (real) rational
332 (movable foldable flushable recursive))
334 (defknown (numerator denominator) (rational) integer
335 (movable foldable flushable))
337 (defknown (floor ceiling round)
338 (real &optional real) (values integer real)
339 (movable foldable flushable))
341 (defknown truncate
342 (real &optional real) (values integer real)
343 (movable foldable flushable recursive))
345 (defknown %multiply-high (word word) word
346 (movable foldable flushable))
348 (defknown (mod rem) (real real) real
349 (movable foldable flushable))
351 (defknown (ffloor fceiling fround ftruncate)
352 (real &optional real) (values float real)
353 (movable foldable flushable))
355 (defknown decode-float (float) (values float float-exponent float)
356 (movable foldable unsafely-flushable))
357 (defknown scale-float (float integer) float
358 (movable foldable unsafely-flushable))
359 (defknown float-radix (float) float-radix
360 (movable foldable unsafely-flushable))
361 (defknown float-sign (float &optional float) float
362 (movable foldable unsafely-flushable))
363 (defknown (float-digits float-precision) (float) float-digits
364 (movable foldable unsafely-flushable))
365 (defknown integer-decode-float (float)
366 (values integer float-int-exponent (member -1 1))
367 (movable foldable unsafely-flushable))
369 (defknown complex (real &optional real) number
370 (movable foldable flushable))
372 (defknown (realpart imagpart) (number) real (movable foldable flushable))
374 (defknown (logior logxor logand logeqv) (&rest integer) integer
375 (movable foldable flushable commutative))
377 (defknown (lognand lognor logandc1 logandc2 logorc1 logorc2)
378 (integer integer) integer
379 (movable foldable flushable))
381 (defknown boole (boole-code integer integer) integer
382 (movable foldable flushable))
384 (defknown lognot (integer) integer (movable foldable flushable))
385 (defknown logtest (integer integer) boolean (movable foldable flushable commutative))
386 (defknown logbitp (unsigned-byte integer) boolean (movable foldable flushable))
387 (defknown ash (integer integer) integer
388 (movable foldable flushable))
389 #!+ash-right-vops
390 (defknown %ash/right ((or word sb!vm:signed-word) (mod #.sb!vm:n-word-bits))
391 (or word sb!vm:signed-word)
392 (movable foldable flushable always-translatable))
393 (defknown (logcount integer-length) (integer) bit-index
394 (movable foldable flushable))
395 ;;; FIXME: According to the ANSI spec, it's legal to use any
396 ;;; nonnegative indices for BYTE arguments, not just BIT-INDEX. It's
397 ;;; hard to come up with useful ways to do this, but it is possible to
398 ;;; come up with *legal* ways to do this, so it would be nice
399 ;;; to fix this so we comply with the spec.
400 (defknown byte (bit-index bit-index) byte-specifier
401 (movable foldable flushable))
402 (defknown (byte-size byte-position) (byte-specifier) bit-index
403 (movable foldable flushable))
404 (defknown ldb (byte-specifier integer) unsigned-byte (movable foldable flushable))
405 (defknown ldb-test (byte-specifier integer) boolean
406 (movable foldable flushable))
407 (defknown mask-field (byte-specifier integer) unsigned-byte
408 (movable foldable flushable))
409 (defknown dpb (integer byte-specifier integer) integer
410 (movable foldable flushable))
411 (defknown deposit-field (integer byte-specifier integer) integer
412 (movable foldable flushable))
413 (defknown random ((or (float (0.0)) (integer 1)) &optional random-state)
414 (or (float 0.0) (integer 0))
416 (defknown make-random-state (&optional (or random-state (member nil t)))
417 random-state (flushable))
418 (defknown seed-random-state (&optional ; SBCL extension
419 (or (member nil t) random-state unsigned-byte
420 (simple-array (unsigned-byte 8) (*))
421 (simple-array (unsigned-byte 32) (*))))
422 random-state (flushable))
424 (defknown random-state-p (t) boolean (movable foldable flushable))
426 ;;;; from the "Characters" chapter:
427 (defknown (standard-char-p graphic-char-p alpha-char-p
428 upper-case-p lower-case-p both-case-p alphanumericp)
429 (character) boolean (movable foldable flushable))
431 (defknown digit-char-p (character &optional (integer 2 36))
432 (or (integer 0 35) null) (movable foldable flushable))
434 ;; Character predicates: if the 2-argument predicate which underlies
435 ;; the N-argument predicate unavoidably type-checks its 2 args,
436 ;; then the N-argument form should not type-check anything
437 ;; except in the degenerate case of 1 actual argument.
438 ;; All of the case-sensitive functions have the check of the first arg
439 ;; generated by the compiler, and successive args checked by hand.
440 ;; The case-insensitive functions don't need any checks, since the underlying
441 ;; two-arg case-insensitive function does it, except when it isn't called.
442 (defknown (char=)
443 (character &rest character) boolean (movable foldable flushable commutative))
445 (defknown (char/= char< char> char<= char>= char-not-equal)
446 (character &rest character) boolean (movable foldable flushable))
447 (defknown (char-equal char-lessp char-greaterp char-not-greaterp char-not-lessp)
448 (character &rest character) boolean (movable foldable flushable))
450 (defknown (two-arg-char-equal)
451 (character character) boolean (movable foldable flushable commutative))
453 (defknown (two-arg-char-not-equal
454 two-arg-char-lessp
455 two-arg-char-not-lessp
456 two-arg-char-greaterp
457 two-arg-char-not-greaterp)
458 (character character) boolean (movable foldable flushable))
460 (defknown char-equal-constant (character character character)
461 boolean
462 (movable foldable flushable))
464 (defknown character (t) character (movable foldable unsafely-flushable))
465 (defknown char-code (character) char-code (movable foldable flushable))
466 (defknown (char-upcase char-downcase) (character) character
467 (movable foldable flushable))
468 (defknown digit-char (unsigned-byte &optional (integer 2 36))
469 (or character null) (movable foldable flushable))
470 (defknown char-int (character) char-code (movable foldable flushable))
471 (defknown char-name (character) (or simple-string null)
472 (movable foldable flushable))
473 (defknown name-char (string-designator) (or character null)
474 (movable foldable flushable))
475 (defknown code-char (char-code) character
476 ;; By suppressing constant folding on CODE-CHAR when the
477 ;; cross-compiler is running in the cross-compilation host vanilla
478 ;; ANSI Common Lisp, we can use CODE-CHAR expressions to delay until
479 ;; target Lisp run time the generation of CHARACTERs which aren't
480 ;; STANDARD-CHARACTERs. That way, we don't need to rely on the host
481 ;; Common Lisp being able to handle any characters other than those
482 ;; guaranteed by the ANSI spec.
483 (movable #-sb-xc-host foldable flushable))
485 ;;;; from the "Sequences" chapter:
487 (defknown elt (sequence index) t (foldable unsafely-flushable))
489 (defknown subseq (sequence index &optional sequence-end) consed-sequence
490 (flushable))
492 (defknown copy-seq (sequence) consed-sequence (flushable)
493 :derive-type (sequence-result-nth-arg 1 :preserve-dimensions t))
495 (defknown length (sequence) index (foldable flushable dx-safe))
497 (defknown reverse (sequence) consed-sequence (flushable)
498 :derive-type (sequence-result-nth-arg 1 :preserve-dimensions t))
500 (defknown nreverse (sequence) sequence (important-result)
501 :derive-type (sequence-result-nth-arg 1 :preserve-dimensions t
502 :preserve-vector-type t)
503 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
505 (defknown make-sequence (type-specifier index
506 &key
507 (:initial-element t))
508 consed-sequence
509 (movable)
510 :derive-type (creation-result-type-specifier-nth-arg 1))
512 (defknown concatenate (type-specifier &rest sequence) consed-sequence ()
513 :derive-type (creation-result-type-specifier-nth-arg 1))
515 (defknown %concatenate-to-string (&rest sequence) simple-string
516 (flushable))
517 (defknown %concatenate-to-base-string (&rest sequence) simple-base-string
518 (flushable))
519 (defknown %concatenate-to-list (&rest sequence) list
520 (flushable))
521 (defknown %concatenate-to-simple-vector (&rest sequence) simple-vector
522 (flushable))
523 (defknown %concatenate-to-vector ((unsigned-byte #.sb!vm:n-widetag-bits) &rest sequence)
524 vector
525 (flushable))
527 (defknown map (type-specifier (callable &rest) sequence &rest sequence)
528 consed-sequence (call)
529 ; :DERIVE-TYPE 'TYPE-SPEC-ARG1 ? Nope... (MAP NIL ...) returns NULL, not NIL.
531 (defknown %map (type-specifier callable &rest sequence) consed-sequence (call))
532 (defknown %map-for-effect-arity-1 (callable sequence) null (call))
533 (defknown %map-to-list-arity-1 (callable sequence) list (flushable call))
534 (defknown %map-to-simple-vector-arity-1 (callable sequence) simple-vector
535 (flushable call))
537 (defknown map-into (sequence (callable &rest) &rest sequence)
538 sequence
539 (call)
540 :derive-type #'result-type-first-arg
541 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
543 (defknown #.(loop for info across sb!vm:*specialized-array-element-type-properties*
544 collect
545 (intern (concatenate 'string "VECTOR-MAP-INTO/"
546 (string (sb!vm:saetp-primitive-type-name info)))
547 :sb!impl))
548 (simple-array index index function list)
549 index
550 (call))
552 ;;; returns the result from the predicate...
553 (defknown some (callable sequence &rest sequence) t
554 (foldable unsafely-flushable call))
556 (defknown (every notany notevery) (callable sequence &rest sequence) boolean
557 (foldable unsafely-flushable call))
559 (defknown reduce ((callable 2) sequence &rest t &key (:from-end t) (:start index)
560 (:end sequence-end) (:initial-value t) (:key (callable 1)))
562 (foldable flushable call))
564 (defknown fill (sequence t &rest t &key
565 (:start index) (:end sequence-end)) sequence
567 :derive-type #'result-type-first-arg
568 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1)
569 :result-arg 0)
571 (defknown replace (sequence sequence &rest t &key (:start1 index)
572 (:end1 sequence-end) (:start2 index) (:end2 sequence-end))
573 sequence ()
574 :derive-type #'result-type-first-arg
575 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1)
576 :result-arg 0)
578 (defknown remove
579 (t sequence &rest t &key (:from-end t) (:test (callable 2))
580 (:test-not (callable 2)) (:start index) (:end sequence-end)
581 (:count sequence-count) (:key (callable 1)))
582 consed-sequence
583 (flushable call)
584 :derive-type (sequence-result-nth-arg 2))
586 (defknown substitute
587 (t t sequence &rest t &key (:from-end t) (:test (callable 2))
588 (:test-not (callable 2)) (:start index) (:end sequence-end)
589 (:count sequence-count) (:key (callable 1)))
590 consed-sequence
591 (flushable call)
592 :derive-type (sequence-result-nth-arg 3))
594 (defknown (remove-if remove-if-not)
595 ((callable 1) sequence &rest t &key (:from-end t) (:start index)
596 (:end sequence-end) (:count sequence-count) (:key (callable 1)))
597 consed-sequence
598 (flushable call)
599 :derive-type (sequence-result-nth-arg 2))
601 (defknown (substitute-if substitute-if-not)
602 (t (callable 1) sequence &rest t &key (:from-end t) (:start index)
603 (:end sequence-end) (:count sequence-count) (:key (callable 1)))
604 consed-sequence
605 (flushable call)
606 :derive-type (sequence-result-nth-arg 3))
608 (defknown delete
609 (t sequence &rest t &key (:from-end t) (:test (callable 2))
610 (:test-not (callable 2)) (:start index) (:end sequence-end)
611 (:count sequence-count) (:key (callable 1)))
612 sequence
613 (flushable call important-result)
614 :derive-type (sequence-result-nth-arg 2)
615 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2))
617 (defknown nsubstitute
618 (t t sequence &rest t &key (:from-end t) (:test (callable 2))
619 (:test-not (callable 2)) (:start index) (:end sequence-end)
620 (:count sequence-count) (:key (callable 1)))
621 sequence
622 (flushable call)
623 :derive-type (sequence-result-nth-arg 3)
624 :destroyed-constant-args (nth-constant-nonempty-sequence-args 3))
626 (defknown (delete-if delete-if-not)
627 ((callable 1) sequence &rest t &key (:from-end t) (:start index)
628 (:end sequence-end) (:count sequence-count) (:key (callable 1)))
629 sequence
630 (flushable call important-result)
631 :derive-type (sequence-result-nth-arg 2)
632 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2))
634 (defknown (nsubstitute-if nsubstitute-if-not)
635 (t (callable 1) sequence &rest t &key (:from-end t) (:start index)
636 (:end sequence-end) (:count sequence-count) (:key (callable 1)))
637 sequence
638 (flushable call)
639 :derive-type (sequence-result-nth-arg 3)
640 :destroyed-constant-args (nth-constant-nonempty-sequence-args 3))
642 (defknown remove-duplicates
643 (sequence &rest t &key (:test (callable 2)) (:test-not (callable 2)) (:start index)
644 (:from-end t) (:end sequence-end) (:key (callable 1)))
645 consed-sequence
646 (unsafely-flushable call)
647 :derive-type (sequence-result-nth-arg 1))
649 (defknown delete-duplicates
650 (sequence &rest t &key (:test (callable 2)) (:test-not (callable 2)) (:start index)
651 (:from-end t) (:end sequence-end) (:key (callable 1)))
652 sequence
653 (unsafely-flushable call important-result)
654 :derive-type (sequence-result-nth-arg 1)
655 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
657 (defknown find (t sequence &rest t &key (:test (callable 2))
658 (:test-not (callable 2)) (:start index) (:from-end t)
659 (:end sequence-end) (:key (callable 1)))
661 (foldable flushable call))
663 (defknown (find-if find-if-not)
664 ((callable 1) sequence &rest t &key (:from-end t) (:start index)
665 (:end sequence-end) (:key (callable 1)))
667 (foldable flushable call))
669 (defknown position (t sequence &rest t &key (:test (callable 2))
670 (:test-not (callable 2)) (:start index) (:from-end t)
671 (:end sequence-end) (:key (callable 1)))
672 (or (mod #.(1- sb!xc:array-dimension-limit)) null)
673 (foldable flushable call))
675 (defknown (position-if position-if-not)
676 ((callable 1) sequence &rest t &key (:from-end t) (:start index)
677 (:end sequence-end) (:key (callable 1)))
678 (or (mod #.(1- sb!xc:array-dimension-limit)) null)
679 (foldable flushable call))
681 (defknown count (t sequence &rest t &key
682 (:test (callable 2)) (:test-not (callable 2)) (:start index)
683 (:from-end t) (:end sequence-end) (:key (callable 1)))
684 index
685 (foldable flushable call))
687 (defknown (count-if count-if-not)
688 ((callable 1) sequence &rest t &key
689 (:from-end t) (:start index) (:end sequence-end) (:key (callable 1)))
690 index
691 (foldable flushable call))
693 (defknown (mismatch search)
694 (sequence sequence &rest t &key (:from-end t) (:test (callable 2))
695 (:test-not (callable 2)) (:start1 index) (:end1 sequence-end)
696 (:start2 index) (:end2 sequence-end) (:key (callable 1)))
697 (or index null)
698 (foldable flushable call))
700 ;;; not FLUSHABLE, since vector sort guaranteed in-place...
701 (defknown (stable-sort sort) (sequence (callable 2) &rest t &key (:key (callable 1)))
702 sequence
703 (call)
704 :derive-type #'result-type-first-arg
705 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
706 (defknown sb!impl::stable-sort-list (list function function) list
707 (call important-result)
708 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
709 (defknown sb!impl::sort-vector (vector index index function (or function null))
710 * ; SORT-VECTOR works through side-effect
711 (call)
712 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
714 (defknown sb!impl::stable-sort-vector
715 (vector function (or function null))
716 vector
717 (call)
718 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
720 (defknown sb!impl::stable-sort-simple-vector
721 (simple-vector function (or function null))
722 simple-vector
723 (call)
724 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
726 (defknown merge (type-specifier sequence sequence (callable 2)
727 &key (:key (callable 1)))
728 sequence
729 (call important-result)
730 :derive-type (creation-result-type-specifier-nth-arg 1)
731 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2 3))
733 (defknown read-sequence (sequence stream
734 &key
735 (:start index)
736 (:end sequence-end))
737 (index)
740 (defknown write-sequence (sequence stream
741 &key
742 (:start index)
743 (:end sequence-end))
744 sequence
746 :derive-type #'result-type-first-arg)
748 ;;;; from the "Manipulating List Structure" chapter:
749 (defknown (car cdr first rest)
750 (list)
752 (foldable flushable))
754 ;; Correct argument type restrictions for these functions are
755 ;; complicated, so we just declare them to accept LISTs and suppress
756 ;; flushing is safe code.
757 (defknown (caar cadr cdar cddr
758 caaar caadr cadar caddr cdaar cdadr cddar cdddr
759 caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
760 cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
761 second third fourth fifth sixth seventh eighth ninth tenth)
762 (list)
764 (foldable unsafely-flushable))
766 (defknown cons (t t) cons (movable flushable))
768 (defknown tree-equal (t t &key (:test (callable 2)) (:test-not (callable 2))) boolean
769 (foldable flushable call))
770 (defknown endp (list) boolean (foldable flushable movable))
771 (defknown list-length (list) (or index null) (foldable unsafely-flushable))
772 (defknown (nth fast-&rest-nth) (unsigned-byte list) t (foldable flushable))
773 (defknown nthcdr (unsigned-byte list) t (foldable unsafely-flushable))
775 (defknown last (list &optional unsigned-byte) t (foldable flushable))
776 (defknown %last0 (list) t (foldable flushable))
777 (defknown %last1 (list) t (foldable flushable))
778 (defknown %lastn/fixnum (list (and unsigned-byte fixnum)) t (foldable flushable))
779 (defknown %lastn/bignum (list (and unsigned-byte bignum)) t (foldable flushable))
781 (defknown list (&rest t) list (movable flushable))
782 (defknown list* (t &rest t) t (movable flushable))
783 (defknown make-list (index &key (:initial-element t)) list
784 (movable flushable))
785 (defknown %make-list (index t) list (movable flushable))
787 (defknown sb!impl::|List| (&rest t) list (movable flushable foldable))
788 (defknown sb!impl::|List*| (t &rest t) t (movable flushable foldable))
789 (defknown sb!impl::|Append| (&rest t) t (flushable foldable))
790 (defknown sb!impl::|Vector| (&rest t) simple-vector (flushable foldable))
792 ;;; All but last must be of type LIST, but there seems to be no way to
793 ;;; express that in this syntax.
794 (defknown append (&rest t) t (flushable))
795 (defknown sb!impl::append2 (list t) t (flushable))
797 (defknown copy-list (list) list (flushable))
798 (defknown copy-alist (list) list (flushable))
799 (defknown copy-tree (t) t (flushable recursive))
800 (defknown revappend (list t) t (flushable))
802 ;;; All but last must be of type LIST, but there seems to be no way to
803 ;;; express that in this syntax. The result must be LIST, but we do
804 ;;; not check it now :-).
805 (defknown nconc (&rest t) t ()
806 :destroyed-constant-args (remove-non-constants-and-nils #'butlast))
808 (defknown nreconc (list t) t (important-result)
809 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
810 (defknown butlast (list &optional unsigned-byte) list (flushable))
811 (defknown nbutlast (list &optional unsigned-byte) list ()
812 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
814 (defknown ldiff (list t) list (flushable))
815 (defknown (rplaca rplacd) (cons t) cons ()
816 :destroyed-constant-args (nth-constant-args 1))
818 (defknown subst (t t t &key (:key (callable 1)) (:test (callable 2))
819 (:test-not (callable 2)))
820 t (flushable call))
821 (defknown nsubst (t t t &key (:key (callable 1)) (:test (callable 2))
822 (:test-not (callable 2)))
823 t (call)
824 :destroyed-constant-args (nth-constant-nonempty-sequence-args 3))
826 (defknown (subst-if subst-if-not)
827 (t (callable 1) t &key (:key (callable 1)))
828 t (flushable call))
829 (defknown (nsubst-if nsubst-if-not)
830 (t (callable 1) t &key (:key (callable 1)))
831 t (call)
832 :destroyed-constant-args (nth-constant-nonempty-sequence-args 3))
834 (defknown sublis (list t &key (:key (callable 1)) (:test (callable 2))
835 (:test-not (callable 2)))
836 t (flushable call))
837 (defknown nsublis (list t &key (:key (callable 1)) (:test (callable 2))
838 (:test-not (callable 2)))
839 t (flushable call)
840 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2))
842 (defknown member (t list &key (:key (callable 1)) (:test (callable 2))
843 (:test-not (callable 2)))
844 list (foldable flushable call))
845 (defknown (member-if member-if-not) ((callable 1) list &key (:key (callable 1)))
846 list (foldable flushable call))
848 (defknown tailp (t list) boolean (foldable flushable))
850 (defknown adjoin (t list &key (:key (callable 1)) (:test (callable 2))
851 (:test-not (callable 2)))
852 cons (flushable call))
854 (defknown (union intersection set-difference set-exclusive-or)
855 (list list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
856 list
857 (foldable flushable call))
859 (defknown (nunion nintersection nset-difference nset-exclusive-or)
860 (list list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
861 list
862 (foldable flushable call important-result)
863 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1 2))
865 (defknown subsetp
866 (list list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
867 boolean
868 (foldable flushable call))
870 (defknown acons (t t t) cons (movable flushable))
871 (defknown pairlis (t t &optional t) list (flushable))
873 (defknown (rassoc assoc)
874 (t list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
875 list (foldable flushable call))
876 (defknown (assoc-if-not assoc-if rassoc-if rassoc-if-not)
877 ((callable 1) list &key (:key (callable 1))) list (foldable flushable call))
879 (defknown (memq assq) (t list) list (foldable flushable))
880 (defknown delq (t list) list (flushable)
881 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2))
883 ;;;; from the "Hash Tables" chapter:
885 (defknown make-hash-table
886 (&key (:test callable) (:size unsigned-byte)
887 (:rehash-size (or (integer 1) (float (1.0))))
888 (:rehash-threshold (real 0 1))
889 (:hash-function (or null callable))
890 (:weakness (member nil :key :value :key-and-value :key-or-value))
891 (:synchronized t))
892 hash-table
893 (flushable))
894 (defknown hash-table-p (t) boolean (movable foldable flushable))
895 (defknown gethash (t hash-table &optional t) (values t boolean)
896 (flushable)) ; not FOLDABLE, since hash table contents can change
897 (defknown sb!impl::gethash3 (t hash-table t) (values t boolean)
898 (flushable)) ; not FOLDABLE, since hash table contents can change
899 (defknown %puthash (t hash-table t) t ()
900 :destroyed-constant-args (nth-constant-args 2)
901 :derive-type #'result-type-last-arg)
902 (defknown remhash (t hash-table) boolean ()
903 :destroyed-constant-args (nth-constant-args 2))
904 (defknown maphash ((callable 2) hash-table) null (flushable call))
905 (defknown clrhash (hash-table) hash-table ()
906 :destroyed-constant-args (nth-constant-args 2))
907 (defknown hash-table-count (hash-table) index (flushable))
908 (defknown hash-table-rehash-size (hash-table) (or index (single-float (1.0)))
909 (foldable flushable))
910 (defknown hash-table-rehash-threshold (hash-table) (single-float (0.0) 1.0)
911 (foldable flushable))
912 (defknown hash-table-size (hash-table) index (flushable))
913 (defknown hash-table-test (hash-table) symbol (foldable flushable))
914 (defknown sxhash (t) hash (#-sb-xc-host foldable flushable))
915 (defknown psxhash (t &optional t) hash (#-sb-xc-host foldable flushable))
916 (defknown hash-table-equalp (hash-table hash-table) boolean (foldable flushable))
918 ;;;; from the "Arrays" chapter
920 (defknown make-array ((or index list)
921 &key
922 (:element-type type-specifier)
923 (:initial-element t)
924 (:initial-contents t)
925 (:adjustable t)
926 (:fill-pointer (or index boolean))
927 (:displaced-to (or array null))
928 (:displaced-index-offset index))
929 array (flushable))
931 (defknown %make-array ((or index list)
932 (unsigned-byte #.sb!vm:n-widetag-bits)
933 (unsigned-byte 16)
934 &key
935 (:element-type type-specifier)
936 (:initial-element t)
937 (:initial-contents t)
938 (:adjustable t)
939 (:fill-pointer (or index boolean))
940 (:displaced-to (or array null))
941 (:displaced-index-offset index))
942 array (flushable))
944 (defknown fill-data-vector (vector list sequence) t ())
946 ;; INITIAL-CONTENTS is the first argument to FILL-ARRAY because
947 ;; of the possibility of source-transforming it for various recognized
948 ;; contents after the source-transform for MAKE-ARRAY has run.
949 ;; The original MAKE-ARRAY call might resemble either of:
950 ;; (MAKE-ARRAY DIMS :ELEMENT-TYPE (F) :INITIAL-CONTENTS (G))
951 ;; (MAKE-ARRAY DIMS :INITIAL-CONTENTS (F) :ELEMENT-TYPE (G))
952 ;; and in general we must bind temporaries to preserve left-to-right
953 ;; evaluation of F and G if they have side effects.
954 ;; Now ideally :ELEMENT-TYPE will be a constant, so it doesn't matter
955 ;; if it moves. But if INITIAL-CONTENTS were the second argument to FILL-ARRAY,
956 ;; then the multi-dimensional array creation form would look like
957 ;; (FILL-ARRAY (allocate-array) initial-contents)
958 ;; which would mean that if the user expressed the MAKE- call the
959 ;; second way shown above, we would have to bind INITIAL-CONTENTS,
960 ;; to ensure its evaluation before the allocation,
961 ;; causing difficulty if doing any futher macro-like processing.
962 (defknown fill-array (sequence simple-array) (simple-array) (flushable)
963 :result-arg 1)
965 (defknown vector (&rest t) simple-vector (flushable))
967 (defknown aref (array &rest index) t (foldable)
968 :call-type-deriver #'array-call-type-deriver)
969 (defknown row-major-aref (array index) t (foldable))
971 (defknown array-element-type (array) (or list symbol)
972 (foldable flushable))
973 (defknown array-rank (array) array-rank (foldable flushable))
974 ;; FIXME: there's a fencepost bug, but for all practical purposes our
975 ;; ARRAY-RANK-LIMIT is infinite, thus masking the bug. e.g. if the
976 ;; exclusive limit on rank were 8, then your dimension numbers can
977 ;; be in the range 0 through 6, not 0 through 7.
978 (defknown array-dimension (array array-rank) index (foldable flushable))
979 (defknown array-dimensions (array) list (foldable flushable))
980 (defknown array-in-bounds-p (array &rest integer) boolean (foldable flushable)
981 :call-type-deriver #'array-call-type-deriver)
982 (defknown array-row-major-index (array &rest index) array-total-size
983 (foldable flushable)
984 :call-type-deriver #'array-call-type-deriver)
985 (defknown array-total-size (array) array-total-size (foldable flushable))
986 (defknown adjustable-array-p (array) boolean (movable foldable flushable))
988 (defknown svref (simple-vector index) t (foldable flushable))
989 (defknown bit ((array bit) &rest index) bit (foldable flushable))
990 (defknown sbit ((simple-array bit) &rest index) bit (foldable flushable))
992 ;;; FIXME: :DESTROYED-CONSTANT-ARGS for these is complicated.
993 (defknown (bit-and bit-ior bit-xor bit-eqv bit-nand bit-nor bit-andc1 bit-andc2
994 bit-orc1 bit-orc2)
995 ((array bit) (array bit) &optional (or (array bit) (member t nil)))
996 (array bit)
998 #|:derive-type #'result-type-last-arg|#)
1000 (defknown bit-not ((array bit) &optional (or (array bit) (member t nil)))
1001 (array bit)
1003 #|:derive-type #'result-type-last-arg|#)
1005 (defknown bit-vector-= (bit-vector bit-vector) boolean
1006 (movable foldable flushable))
1008 (defknown array-has-fill-pointer-p (array) boolean
1009 (movable foldable flushable))
1010 (defknown fill-pointer (complex-vector) index
1011 (unsafely-flushable))
1012 (defknown sb!impl::fill-pointer-error (t &optional t) nil)
1014 (defknown vector-push (t complex-vector) (or index null) ()
1015 :destroyed-constant-args (nth-constant-args 2))
1016 (defknown vector-push-extend (t complex-vector &optional (and index (integer 1))) index
1018 :destroyed-constant-args (nth-constant-args 2))
1019 (defknown vector-pop (complex-vector) t ()
1020 :destroyed-constant-args (nth-constant-args 1))
1022 ;;; FIXME: complicated :DESTROYED-CONSTANT-ARGS
1023 ;;; Also, an important-result warning could be provided if the array
1024 ;;; is known to be not expressly adjustable.
1025 (defknown adjust-array
1026 (array (or index list) &key (:element-type type-specifier)
1027 (:initial-element t) (:initial-contents t)
1028 (:fill-pointer (or index boolean))
1029 (:displaced-to (or array null))
1030 (:displaced-index-offset index))
1031 array ())
1032 ; :derive-type 'result-type-arg1) Not even close...
1034 ;;;; from the "Strings" chapter:
1036 (defknown char (string index) character (foldable flushable))
1037 (defknown schar (simple-string index) character (foldable flushable))
1039 (defknown (string= string-equal)
1040 (string-designator string-designator &key (:start1 index) (:end1 sequence-end)
1041 (:start2 index) (:end2 sequence-end))
1042 boolean
1043 (foldable flushable))
1045 (defknown (string< string> string<= string>= string/= string-lessp
1046 string-greaterp string-not-lessp string-not-greaterp
1047 string-not-equal)
1048 (string-designator string-designator &key (:start1 index) (:end1 sequence-end)
1049 (:start2 index) (:end2 sequence-end))
1050 (or index null)
1051 (foldable flushable))
1053 (defknown make-string (index &key (:element-type type-specifier)
1054 (:initial-element character))
1055 simple-string (flushable))
1057 (defknown (string-trim string-left-trim string-right-trim)
1058 (sequence string-designator) string (flushable))
1060 (defknown (string-upcase string-downcase string-capitalize)
1061 (string-designator &key (:start index) (:end sequence-end))
1062 simple-string (flushable))
1064 (defknown (nstring-upcase nstring-downcase nstring-capitalize)
1065 (string &key (:start index) (:end sequence-end))
1066 string ()
1067 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1)
1068 :derive-type #'result-type-first-arg)
1070 (defknown string (string-designator) string (flushable))
1072 ;;;; internal non-keyword versions of string predicates:
1074 (defknown (string<* string>* string<=* string>=* string/=*)
1075 (string-designator string-designator index sequence-end index sequence-end)
1076 (or index null)
1077 (foldable flushable))
1079 (defknown string=*
1080 (string-designator string-designator index sequence-end index sequence-end)
1081 boolean
1082 (foldable flushable))
1084 ;;;; from the "Eval" chapter:
1086 (defknown eval (t) * (recursive))
1087 (defknown constantp (t &optional lexenv-designator) boolean
1088 (foldable flushable))
1090 ;;;; from the "Streams" chapter:
1092 (defknown make-synonym-stream (symbol) stream (flushable))
1093 (defknown make-broadcast-stream (&rest stream) stream (unsafely-flushable))
1094 (defknown make-concatenated-stream (&rest stream) stream (unsafely-flushable))
1095 (defknown make-two-way-stream (stream stream) stream (unsafely-flushable))
1096 (defknown make-echo-stream (stream stream) stream (flushable))
1097 (defknown make-string-input-stream (string &optional index sequence-end)
1098 stream
1099 (flushable))
1100 (defknown make-string-output-stream
1101 (&key (:element-type type-specifier)) sb!impl::string-output-stream
1102 (flushable))
1103 (defknown get-output-stream-string (stream) simple-string ())
1104 (defknown streamp (t) boolean (movable foldable flushable))
1105 (defknown stream-element-type (stream) type-specifier ; can it return a CLASS?
1106 (movable foldable flushable))
1107 (defknown stream-external-format (stream) t (flushable))
1108 (defknown (output-stream-p input-stream-p) (stream) boolean
1109 (movable foldable flushable))
1110 (defknown open-stream-p (stream) boolean (flushable))
1111 (defknown close (stream &key (:abort t)) (eql t) ())
1112 (defknown file-string-length (ansi-stream (or string character))
1113 (or unsigned-byte null)
1114 (flushable))
1116 ;;;; from the "Input/Output" chapter:
1118 ;;; (The I/O functions are given effects ANY under the theory that
1119 ;;; code motion over I/O operations is particularly confusing and not
1120 ;;; very important for efficiency.)
1122 (defknown copy-readtable (&optional (or readtable null) (or readtable null))
1123 readtable
1125 (defknown readtablep (t) boolean (movable foldable flushable))
1127 (defknown set-syntax-from-char
1128 (character character &optional readtable (or readtable null)) (eql t)
1131 (defknown set-macro-character (character (callable 2) &optional t (or readtable null))
1132 (eql t)
1133 (call))
1134 (defknown get-macro-character (character &optional (or readtable null))
1135 (values callable boolean) (flushable))
1137 (defknown make-dispatch-macro-character (character &optional t readtable)
1138 (eql t) ())
1139 (defknown set-dispatch-macro-character
1140 (character character callable &optional (or readtable null)) (eql t)
1142 (defknown get-dispatch-macro-character
1143 (character character &optional (or readtable null)) (or callable null)
1146 (defknown copy-pprint-dispatch
1147 (&optional (or sb!pretty:pprint-dispatch-table null))
1148 sb!pretty:pprint-dispatch-table
1150 (defknown pprint-dispatch
1151 (t &optional (or sb!pretty:pprint-dispatch-table null))
1152 (values callable boolean)
1154 (defknown (pprint-fill pprint-linear)
1155 (stream-designator t &optional t t)
1156 null
1158 (defknown pprint-tabular
1159 (stream-designator t &optional t t unsigned-byte)
1160 null
1162 (defknown pprint-indent
1163 ((member :block :current) real &optional stream-designator)
1164 null
1166 (defknown pprint-newline
1167 ((member :linear :fill :miser :mandatory) &optional stream-designator)
1168 null
1170 (defknown pprint-tab
1171 ((member :line :section :line-relative :section-relative)
1172 unsigned-byte unsigned-byte &optional stream-designator)
1173 null
1175 (defknown set-pprint-dispatch
1176 (type-specifier (or null callable)
1177 &optional real sb!pretty:pprint-dispatch-table)
1178 null
1181 ;;; may return any type due to eof-value...
1182 ;;; and because READ generally returns anything.
1183 (defknown (read read-preserving-whitespace)
1184 (&optional stream-designator t t t) t ())
1186 (defknown read-char (&optional stream-designator t t t) t ()
1187 :derive-type (read-elt-type-deriver nil 'character nil))
1188 (defknown read-char-no-hang (&optional stream-designator t t t) t ()
1189 :derive-type (read-elt-type-deriver nil 'character t))
1191 (defknown read-delimited-list (character &optional stream-designator t) list ())
1192 ;; FIXME: add a type-deriver => (values (or string eof-value) boolean)
1193 (defknown read-line (&optional stream-designator t t t) (values t boolean) ())
1194 (defknown unread-char (character &optional stream-designator) t ())
1195 (defknown peek-char (&optional (or character (member nil t))
1196 stream-designator t t t) t
1198 :derive-type (read-elt-type-deriver t 'character nil))
1200 (defknown listen (&optional stream-designator) boolean (flushable))
1202 (defknown clear-input (&optional stream-designator) null ())
1204 (defknown read-from-string
1205 (string &optional t t
1206 &key
1207 (:start index)
1208 (:end sequence-end)
1209 (:preserve-whitespace t))
1210 (values t index))
1211 (defknown parse-integer
1212 (string &key
1213 (:start index)
1214 (:end sequence-end)
1215 (:radix (integer 2 36))
1216 (:junk-allowed t))
1217 (values (or integer null ()) index))
1219 (defknown read-byte (stream &optional t t) t ()
1220 :derive-type (read-elt-type-deriver nil 'integer nil))
1222 (defknown (prin1 print princ) (t &optional stream-designator)
1224 (any)
1225 :derive-type #'result-type-first-arg)
1227 (defknown output-object (t stream) null (any))
1228 (defknown %write (t stream-designator) t (any))
1230 (defknown (pprint) (t &optional stream-designator) (values)
1233 (macrolet
1234 ((deffrob (name keys returns attributes &rest more)
1235 `(defknown ,name
1236 (t &key ,@keys
1237 (:escape t)
1238 (:radix t)
1239 (:base (integer 2 36))
1240 (:circle t)
1241 (:pretty t)
1242 (:readably t)
1243 (:level (or unsigned-byte null))
1244 (:length (or unsigned-byte null))
1245 (:case t)
1246 (:array t)
1247 (:gensym t)
1248 (:lines (or unsigned-byte null))
1249 (:right-margin (or unsigned-byte null))
1250 (:miser-width (or unsigned-byte null))
1251 (:pprint-dispatch t)
1252 (:suppress-errors t))
1253 ,returns ,attributes ,@more)))
1254 (deffrob write ((:stream stream-designator)) t (any)
1255 :derive-type #'result-type-first-arg)
1256 ;;; xxx-TO-STRING functions are not foldable because they depend on
1257 ;;; the dynamic environment, the state of the pretty printer dispatch
1258 ;;; table, and probably other run-time factors.
1259 (deffrob write-to-string () simple-string
1260 (unsafely-flushable)))
1262 (defknown (prin1-to-string princ-to-string) (t) simple-string (flushable))
1263 (defknown sb!impl::stringify-object (t) simple-string)
1265 (defknown write-char (character &optional stream-designator) character ()
1266 :derive-type #'result-type-first-arg)
1268 (defknown (write-string write-line)
1269 (string &optional stream-designator &key (:start index) (:end sequence-end))
1270 string
1272 :derive-type #'result-type-first-arg)
1274 (defknown (terpri finish-output force-output clear-output)
1275 (&optional stream-designator) null
1278 (defknown fresh-line (&optional stream-designator) boolean ())
1280 (defknown write-byte (integer stream) integer ()
1281 :derive-type #'result-type-first-arg)
1283 ;;; FIXME: complicated :DESTROYED-CONSTANT-ARGS
1284 (defknown format ((or (member nil t) stream string)
1285 (or string function) &rest t)
1286 (or string null)
1288 (defknown sb!format::args-exhausted (string integer) nil)
1290 (defknown (y-or-n-p yes-or-no-p) (&optional string &rest t) boolean
1293 ;;;; from the "File System Interface" chapter:
1295 ;;; (No pathname functions are FOLDABLE because they all potentially
1296 ;;; depend on *DEFAULT-PATHNAME-DEFAULTS*, e.g. to provide a default
1297 ;;; host when parsing a namestring. They are not FLUSHABLE because
1298 ;;; parsing of a PATHNAME-DESIGNATOR might signal an error.)
1300 (defknown wild-pathname-p (pathname-designator
1301 &optional
1302 (member nil :host :device
1303 :directory :name
1304 :type :version))
1305 generalized-boolean
1306 (recursive))
1308 (defknown pathname-match-p (pathname-designator pathname-designator)
1309 generalized-boolean
1312 (defknown translate-pathname (pathname-designator
1313 pathname-designator
1314 pathname-designator &key)
1315 pathname
1318 (defknown logical-pathname (pathname-designator) logical-pathname ())
1319 (defknown translate-logical-pathname (pathname-designator &key) pathname
1320 (recursive))
1321 (defknown load-logical-pathname-translations (string) t ())
1322 (defknown logical-pathname-translations (logical-host-designator) list ())
1324 (defknown pathname (pathname-designator) pathname ())
1325 (defknown truename (pathname-designator) pathname ())
1327 (defknown parse-namestring
1328 (pathname-designator &optional
1329 (or list host string (member :unspecific))
1330 pathname-designator
1331 &key
1332 (:start index)
1333 (:end sequence-end)
1334 (:junk-allowed t))
1335 (values (or pathname null) sequence-end)
1336 (recursive))
1338 (defknown merge-pathnames
1339 (pathname-designator &optional pathname-designator pathname-version)
1340 pathname
1343 (defknown make-pathname
1344 (&key (:defaults pathname-designator)
1345 (:host (or string pathname-host))
1346 (:device (or string pathname-device))
1347 (:directory (or pathname-directory string (member :wild)))
1348 (:name (or pathname-name string (member :wild)))
1349 (:type (or pathname-type string (member :wild)))
1350 (:version pathname-version) (:case (member :local :common)))
1351 pathname (unsafely-flushable))
1353 (defknown pathnamep (t) boolean (movable flushable))
1355 (defknown pathname-host (pathname-designator
1356 &key (:case (member :local :common)))
1357 pathname-host (flushable))
1358 (defknown pathname-device (pathname-designator
1359 &key (:case (member :local :common)))
1360 pathname-device (flushable))
1361 (defknown pathname-directory (pathname-designator
1362 &key (:case (member :local :common)))
1363 pathname-directory (flushable))
1364 (defknown pathname-name (pathname-designator
1365 &key (:case (member :local :common)))
1366 pathname-name (flushable))
1367 (defknown pathname-type (pathname-designator
1368 &key (:case (member :local :common)))
1369 pathname-type (flushable))
1370 (defknown pathname-version (pathname-designator)
1371 pathname-version (flushable))
1373 (defknown pathname= (pathname pathname) boolean (movable foldable flushable))
1375 (defknown (namestring file-namestring directory-namestring host-namestring)
1376 (pathname-designator) (or simple-string null)
1377 (unsafely-flushable))
1379 (defknown enough-namestring (pathname-designator &optional pathname-designator)
1380 simple-string
1381 (unsafely-flushable))
1383 (defknown user-homedir-pathname (&optional t) pathname (flushable))
1385 (defknown open
1386 (pathname-designator &key
1387 (:class symbol)
1388 (:direction (member :input :output :io :probe))
1389 (:element-type type-specifier)
1390 (:if-exists (member :error :new-version :rename
1391 :rename-and-delete :overwrite
1392 :append :supersede nil))
1393 (:if-does-not-exist (member :error :create nil))
1394 (:external-format external-format-designator))
1395 (or stream null))
1397 (defknown rename-file (pathname-designator filename)
1398 (values pathname pathname pathname))
1399 (defknown delete-file (pathname-designator) (eql t))
1400 (defknown probe-file (pathname-designator) (or pathname null) ())
1401 (defknown file-write-date (pathname-designator) (or unsigned-byte null)
1403 (defknown file-author (pathname-designator) (or simple-string null)
1406 (defknown file-position (stream &optional
1407 (or unsigned-byte (member :start :end)))
1408 (or unsigned-byte (member t nil)))
1409 (defknown file-length (stream) (or unsigned-byte null) (unsafely-flushable))
1411 (defknown load
1412 ((or filename stream)
1413 &key
1414 (:verbose t)
1415 (:print t)
1416 (:if-does-not-exist t)
1417 (:external-format external-format-designator))
1418 boolean)
1420 (defknown directory (pathname-designator &key (:resolve-symlinks t))
1421 list ())
1423 ;;;; from the "Conditions" chapter:
1425 (defknown error (t &rest t) nil)
1426 (defknown cerror (format-control t &rest t) null)
1427 (defknown invalid-method-error (t format-control &rest t) *) ; FIXME: first arg is METHOD
1428 (defknown method-combination-error (format-control &rest t) *)
1429 (defknown signal (t &rest t) null)
1430 (defknown warn (t &rest t) null)
1431 (defknown invoke-debugger (condition) nil)
1432 (defknown break (&optional format-control &rest t) null)
1433 (defknown make-condition (type-specifier &rest t) condition ())
1434 (defknown compute-restarts (&optional (or condition null)) list)
1435 (defknown find-restart (restart-designator &optional (or condition null))
1436 (or restart null))
1437 (defknown invoke-restart (restart-designator &rest t) *)
1438 (defknown invoke-restart-interactively (restart-designator) *)
1439 (defknown restart-name (restart) symbol)
1440 (defknown (abort muffle-warning) (&optional (or condition null)) nil)
1441 (defknown continue (&optional (or condition null)) null)
1442 (defknown (store-value use-value) (t &optional (or condition null))
1443 null)
1445 ;;; and analogous SBCL extension:
1446 (defknown sb!impl::%failed-aver (t) nil)
1447 (defknown bug (t &rest t) nil) ; never returns
1448 (defknown sb!int:simple-reader-error (stream string &rest t) nil)
1449 (defknown sb!kernel:reader-eof-error (stream string) nil)
1452 ;;;; from the "Miscellaneous" Chapter:
1454 (defknown compile ((or symbol cons) &optional (or list function null))
1455 (values (or function symbol cons) boolean boolean))
1457 (defknown compile-file
1458 (pathname-designator
1459 &key
1461 ;; ANSI options
1462 (:output-file (or pathname-designator
1463 null
1464 ;; FIXME: This last case is a non-ANSI hack.
1465 (member t)))
1466 (:verbose t)
1467 (:print t)
1468 (:external-format external-format-designator)
1470 ;; extensions
1471 (:trace-file t)
1472 (:block-compile t)
1473 (:emit-cfasl t))
1474 (values (or pathname null) boolean boolean))
1476 (defknown (compile-file-pathname)
1477 (pathname-designator &key (:output-file (or pathname-designator
1478 null
1479 (member t)))
1480 &allow-other-keys)
1481 pathname)
1483 ;; FIXME: consider making (OR CALLABLE CONS) something like
1484 ;; EXTENDED-FUNCTION-DESIGNATOR
1485 (defknown disassemble ((or callable cons) &key
1486 (:stream stream) (:use-labels t))
1487 null)
1489 (defknown describe (t &optional (or stream (member t nil))) (values))
1490 (defknown function-lambda-expression (function) (values t boolean t))
1491 (defknown inspect (t) (values))
1492 (defknown room (&optional (member t nil :default)) (values))
1493 (defknown ed (&optional (or symbol cons filename))
1495 (defknown dribble (&optional filename &key (:if-exists t)) (values))
1497 (defknown apropos (string-designator &optional package-designator t) (values))
1498 (defknown apropos-list (string-designator &optional package-designator t) list
1499 (flushable recursive))
1501 (defknown get-decoded-time ()
1502 (values (integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1503 (integer 1 12) unsigned-byte (integer 0 6) boolean (rational -24 24))
1504 (flushable))
1506 (defknown get-universal-time () unsigned-byte (flushable))
1508 (defknown decode-universal-time
1509 (unsigned-byte &optional (or null (rational -24 24)))
1510 (values (integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1511 (integer 1 12) unsigned-byte (integer 0 6) boolean (rational -24 24))
1512 (flushable))
1514 (defknown encode-universal-time
1515 ((integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1516 (integer 1 12) unsigned-byte &optional (or null (rational -24 24)))
1517 unsigned-byte
1518 (flushable))
1520 (defknown (get-internal-run-time get-internal-real-time)
1521 () internal-time (flushable))
1523 (defknown sleep ((real 0)) null ())
1525 (defknown call-with-timing (callable callable &rest t) *
1526 (call))
1528 ;;; Even though ANSI defines LISP-IMPLEMENTATION-TYPE and
1529 ;;; LISP-IMPLEMENTATION-VERSION to possibly punt and return NIL, we
1530 ;;; know that there's no valid reason for our implementations to ever
1531 ;;; do so, so we can safely guarantee that they'll return strings.
1532 (defknown (lisp-implementation-type lisp-implementation-version)
1533 () simple-string (flushable))
1535 ;;; For any of these functions, meaningful information might not be
1536 ;;; available, so -- unlike the related LISP-IMPLEMENTATION-FOO
1537 ;;; functions -- these really can return NIL.
1538 (defknown (machine-type machine-version machine-instance
1539 software-type software-version
1540 short-site-name long-site-name)
1541 () (or simple-string null) (flushable))
1543 (defknown identity (t) t (movable foldable flushable)
1544 :derive-type #'result-type-first-arg)
1546 (defknown constantly (t) function (movable flushable))
1547 (defknown complement (function) function (movable flushable))
1549 ;;;; miscellaneous extensions
1551 (defknown symbol-global-value (symbol) t ())
1552 (defknown set-symbol-global-value (symbol t) t ()
1553 :derive-type #'result-type-last-arg)
1555 (defknown get-bytes-consed () unsigned-byte (flushable))
1556 (defknown mask-signed-field ((integer 0 *) integer) integer
1557 (movable flushable foldable))
1559 (defknown array-storage-vector (array) (simple-array * (*))
1560 (any))
1562 ;;;; magical compiler frobs
1564 (defknown %rest-values (t t t) * (always-translatable))
1565 (defknown %rest-ref (t t t t &optional boolean) * (always-translatable))
1566 (defknown %rest-length (t t t) * (always-translatable))
1567 (defknown %rest-null (t t t t) * (always-translatable))
1568 (defknown %rest-true (t t t) * (always-translatable))
1570 (defknown %unary-truncate/single-float (single-float) integer (movable foldable flushable))
1571 (defknown %unary-truncate/double-float (double-float) integer (movable foldable flushable))
1573 ;;; We can't fold this in general because of SATISFIES. There is a
1574 ;;; special optimizer anyway.
1575 (defknown %typep (t (or type-specifier ctype)) boolean (movable flushable))
1576 (defknown %instance-typep (t (or type-specifier ctype)) boolean
1577 (movable flushable always-translatable))
1578 ;;; We should never emit a call to %typep-wrapper
1579 (defknown %typep-wrapper (t t (or type-specifier ctype)) t
1580 (movable flushable always-translatable))
1582 (defknown %cleanup-point () t)
1583 (defknown %special-bind (t t) t)
1584 (defknown %special-unbind (index) t)
1585 (defknown %listify-rest-args (t index) list (flushable))
1586 (defknown %more-arg-context (t t) (values t index) (flushable))
1587 (defknown %more-arg (t index) t)
1588 #!+stack-grows-downward-not-upward
1589 ;;; FIXME: The second argument here should really be NEGATIVE-INDEX, but doing that
1590 ;;; breaks the build, and I cannot seem to figure out why. --NS 2006-06-29
1591 (defknown %more-kw-arg (t fixnum) (values t t))
1592 (defknown %more-arg-values (t index index) * (flushable))
1594 #!-precise-arg-count-error
1595 (defknown %verify-arg-count (index index) (values))
1597 (defknown %arg-count-error (t t) nil)
1598 (defknown %unknown-values () *)
1599 (defknown %catch (t t) t)
1600 (defknown %unwind-protect (t t) t)
1601 (defknown (%catch-breakup %unwind-protect-breakup) () t)
1602 (defknown %lexical-exit-breakup (t) t)
1603 (defknown %continue-unwind (t t t) nil)
1604 (defknown %throw (t &rest t) nil) ; This is MV-called.
1605 (defknown %nlx-entry (t) *)
1606 (defknown %%primitive (t t &rest t) *)
1607 (defknown %pop-values (t) t)
1608 (defknown %nip-values (t t &rest t) (values))
1609 (defknown %dummy-dx-alloc (t t) t)
1610 (defknown %allocate-closures (t) *)
1611 (defknown %type-check-error (t t) nil)
1612 (defknown %type-check-error/c (t t) nil)
1614 ;; FIXME: This function does not return, but due to the implementation
1615 ;; of FILTER-LVAR we cannot write it here.
1616 (defknown %compile-time-type-error (t t t t t) *)
1617 (defknown (etypecase-failure ecase-failure) (t t) nil)
1619 (defknown %odd-key-args-error () nil)
1620 (defknown %unknown-key-arg-error (t) nil)
1621 (defknown (%ldb %mask-field) (bit-index bit-index integer) unsigned-byte
1622 (movable foldable flushable))
1623 (defknown (%dpb %deposit-field) (integer bit-index bit-index integer) integer
1624 (movable foldable flushable))
1625 (defknown %negate (number) number (movable foldable flushable))
1626 (defknown (%check-bound check-bound) (array index t) index
1627 (dx-safe))
1628 (defknown data-vector-ref (simple-array index) t
1629 (foldable unsafely-flushable always-translatable))
1630 (defknown data-vector-ref-with-offset (simple-array fixnum fixnum) t
1631 (foldable unsafely-flushable always-translatable))
1632 (defknown data-nil-vector-ref (simple-array index) nil
1633 (always-translatable))
1634 (defknown data-vector-set (array index t) t
1635 (always-translatable))
1636 (defknown data-vector-set-with-offset (array fixnum fixnum t) t
1637 (always-translatable))
1638 (defknown hairy-data-vector-ref (array index) t (foldable))
1639 (defknown hairy-data-vector-set (array index t) t ())
1640 (defknown hairy-data-vector-ref/check-bounds (array index) t (foldable))
1641 (defknown hairy-data-vector-set/check-bounds (array index t) t ())
1642 (defknown %caller-frame () t (flushable))
1643 (defknown %caller-pc () system-area-pointer (flushable))
1644 (defknown %with-array-data (array index (or index null))
1645 (values (simple-array * (*)) index index index)
1646 (foldable flushable))
1647 (defknown %with-array-data/fp (array index (or index null))
1648 (values (simple-array * (*)) index index index)
1649 (foldable flushable))
1650 (defknown %set-symbol-package (symbol t) t ())
1651 (defknown %coerce-callable-to-fun (callable) function (flushable))
1652 (defknown array-bounding-indices-bad-error (t t t) nil)
1653 (defknown sequence-bounding-indices-bad-error (t t t) nil)
1654 (defknown %find-position
1655 (t sequence t index sequence-end function function)
1656 (values t (or index null))
1657 (flushable call))
1658 (defknown (%find-position-if %find-position-if-not)
1659 (function sequence t index sequence-end function)
1660 (values t (or index null))
1661 (call))
1662 (defknown effective-find-position-test (callable callable)
1663 function
1664 (flushable foldable))
1665 (defknown effective-find-position-key (callable)
1666 function
1667 (flushable foldable))
1669 (defknown (%adjoin %adjoin-eq)
1670 (t list)
1671 list
1672 (flushable))
1674 (defknown (%member %member-eq
1675 %assoc %assoc-eq %rassoc %rassoc-eq)
1676 (t list)
1677 list
1678 (foldable flushable))
1680 (defknown (%adjoin-key %adjoin-key-eq)
1681 (t list function)
1682 list
1683 (flushable call))
1685 (defknown (%member-key %member-key-eq
1686 %assoc-key %assoc-key-eq %rassoc-key %rassoc-key-eq)
1687 (t list function)
1688 list
1689 (foldable flushable call))
1691 (defknown (%assoc-if %assoc-if-not %rassoc-if %rassoc-if-not
1692 %member-if %member-if-not)
1693 (function list)
1694 list
1695 (foldable flushable call))
1697 (defknown (%assoc-if-key %assoc-if-not-key %rassoc-if-key %rassoc-if-not-key
1698 %member-if-key %member-if-not-key)
1699 (function list function)
1700 list
1701 (foldable flushable call))
1703 (defknown (%adjoin-test %adjoin-test-not)
1704 (t list function)
1705 list
1706 (flushable call))
1708 (defknown (%member-test %member-test-not
1709 %assoc-test %assoc-test-not
1710 %rassoc-test %rassoc-test-not)
1711 (t list function)
1712 list
1713 (foldable flushable call))
1715 (defknown (%adjoin-key-test %adjoin-key-test-not)
1716 (t list function function)
1717 list
1718 (flushable call))
1720 (defknown (%member-key-test %member-key-test-not
1721 %assoc-key-test %assoc-key-test-not
1722 %rassoc-key-test %rassoc-key-test-not)
1723 (t list function function)
1724 list
1725 (foldable flushable call))
1727 (defknown %check-vector-sequence-bounds (vector index sequence-end)
1728 index
1729 (unwind))
1731 ;;;; SETF inverses
1733 (defknown (setf aref) (t array &rest index) t ()
1734 :destroyed-constant-args (nth-constant-args 2)
1735 :call-type-deriver #'array-call-type-deriver)
1736 (defknown %set-row-major-aref (array index t) t ()
1737 :destroyed-constant-args (nth-constant-args 1))
1738 (defknown (%rplaca %rplacd) (cons t) t ()
1739 :destroyed-constant-args (nth-constant-args 1)
1740 :derive-type #'result-type-last-arg)
1741 (defknown %put (symbol t t) t ())
1742 (defknown %setelt (sequence index t) t ()
1743 :destroyed-constant-args (nth-constant-args 1)
1744 :derive-type #'result-type-last-arg)
1745 (defknown %svset (simple-vector index t) t ()
1746 :destroyed-constant-args (nth-constant-args 1))
1747 (defknown (setf bit) (bit (array bit) &rest index) bit ()
1748 :destroyed-constant-args (nth-constant-args 2))
1749 (defknown (setf sbit) (bit (simple-array bit) &rest index) bit ()
1750 :destroyed-constant-args (nth-constant-args 2))
1751 (defknown %charset (string index character) character ()
1752 :destroyed-constant-args (nth-constant-args 1))
1753 (defknown %scharset (simple-string index character) character ()
1754 :destroyed-constant-args (nth-constant-args 1))
1755 (defknown %set-symbol-value (symbol t) t ())
1756 (defknown (setf symbol-function) (function symbol) function ())
1757 (defknown %set-symbol-plist (symbol list) list ()
1758 :derive-type #'result-type-last-arg)
1759 (defknown %setnth (unsigned-byte list t) t ()
1760 :destroyed-constant-args (nth-constant-args 2)
1761 :derive-type #'result-type-last-arg)
1762 (defknown %set-fill-pointer (complex-vector index) index ()
1763 :destroyed-constant-args (nth-constant-args 1)
1764 :derive-type #'result-type-last-arg)
1766 ;;;; ALIEN and call-out-to-C stuff
1768 ;; Used by WITH-PINNED-OBJECTS
1769 #!+(or x86 x86-64)
1770 (defknown sb!vm::touch-object (t) (values)
1771 (always-translatable))
1773 #!+linkage-table
1774 (defknown foreign-symbol-dataref-sap (simple-string)
1775 system-area-pointer
1776 (movable flushable))
1778 (defknown foreign-symbol-sap (simple-string &optional boolean)
1779 system-area-pointer
1780 (movable flushable))
1782 (defknown foreign-symbol-address (simple-string &optional boolean)
1783 (values integer boolean)
1784 (movable flushable))
1786 ;;;; miscellaneous internal utilities
1788 (defknown %fun-name (function) t (flushable))
1789 (defknown (setf %fun-name) (t function) t ())
1791 (defknown policy-quality (policy symbol) policy-quality
1792 (flushable))
1794 (defknown compiler-error (t &rest t) nil ())
1795 (defknown (compiler-warn compiler-style-warn) (t &rest t) (values) ())
1796 (defknown (compiler-notify maybe-compiler-notify) ((or string symbol) &rest t)
1797 (values)
1799 (defknown style-warn (t &rest t) null ())
1801 (defknown coerce-to-condition ((or condition symbol string function)
1802 list type-specifier symbol)
1803 condition
1806 (defknown coerce-symbol-to-fun (symbol)
1807 function
1810 (defknown sc-number-or-lose (symbol) sc-number
1811 (foldable))
1813 (defknown set-info-value (t info-number t) t ()
1814 :derive-type #'result-type-last-arg)
1816 ;;;; memory barriers
1818 (defknown sb!vm:%compiler-barrier () (values) ())
1819 (defknown sb!vm:%memory-barrier () (values) ())
1820 (defknown sb!vm:%read-barrier () (values) ())
1821 (defknown sb!vm:%write-barrier () (values) ())
1822 (defknown sb!vm:%data-dependency-barrier () (values) ())
1824 #!+sb-safepoint
1825 ;;; Note: This known function does not have an out-of-line definition;
1826 ;;; and if such a definition were needed, it would not need to "call"
1827 ;;; itself inline, but could be a no-op, because the compiler inserts a
1828 ;;; use of the VOP in the function prologue anyway.
1829 (defknown sb!kernel::gc-safepoint () (values) ())
1831 ;;;; atomic ops
1832 (defknown %compare-and-swap-svref (simple-vector index t t) t
1834 (defknown %compare-and-swap-symbol-value (symbol t t) t
1835 (unwind))
1836 (defknown (%atomic-dec-symbol-global-value %atomic-inc-symbol-global-value)
1837 (symbol fixnum) fixnum)
1838 (defknown (%atomic-dec-car %atomic-inc-car %atomic-dec-cdr %atomic-inc-cdr)
1839 (cons fixnum) fixnum)
1840 (defknown spin-loop-hint () (values)
1841 (always-translatable))
1843 ;;;; Stream methods
1845 ;;; Avoid a ton of FBOUNDP checks in the string stream constructors etc,
1846 ;;; by wiring in the needed functions instead of dereferencing their fdefns.
1847 (defknown (ill-in ill-bin ill-out ill-bout
1848 sb!impl::string-inch sb!impl::string-in-misc
1849 sb!impl::string-ouch sb!impl::string-sout sb!impl::string-out-misc
1850 sb!impl::fill-pointer-ouch sb!impl::fill-pointer-sout
1851 sb!impl::fill-pointer-misc
1852 sb!impl::case-frob-upcase-out sb!impl::case-frob-upcase-sout
1853 sb!impl::case-frob-downcase-out sb!impl::case-frob-downcase-sout
1854 sb!impl::case-frob-capitalize-out sb!impl::case-frob-capitalize-sout
1855 sb!impl::case-frob-capitalize-first-out sb!impl::case-frob-capitalize-first-sout
1856 sb!impl::case-frob-capitalize-aux-out sb!impl::case-frob-capitalize-aux-sout
1857 sb!impl::case-frob-misc
1858 sb!pretty::pretty-out sb!pretty::pretty-misc) * *)
1859 (defknown sb!pretty::pretty-sout * * (recursive))
1861 ;;;; PCL
1863 (defknown sb!pcl::pcl-instance-p (t) boolean
1864 (movable foldable flushable))
1866 ;; FIXME: should T be be (OR INSTANCE FUNCALLABLE-INSTANCE) etc?
1867 (defknown slot-value (t symbol) t (any))
1868 (defknown (slot-boundp slot-exists-p) (t symbol) boolean)
1869 (defknown sb!pcl::set-slot-value (t symbol t) t (any))
1871 (defknown find-class (symbol &optional t lexenv-designator) (or class null) ())
1872 (defknown class-of (t) class (flushable))
1873 (defknown class-name (class) symbol (flushable))