Fix comment about *code-coverage-info*.
[sbcl.git] / src / compiler / fndb.lisp
blob8a3dc7cf4cfa1fd803389df55a6765cd3b59945f
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)
491 :derive-type (sequence-result-nth-arg 1))
493 (defknown copy-seq (sequence) consed-sequence (flushable)
494 :derive-type (sequence-result-nth-arg 1))
496 (defknown length (sequence) index (foldable flushable dx-safe))
498 (defknown reverse (sequence) consed-sequence (flushable)
499 :derive-type (sequence-result-nth-arg 1))
501 (defknown nreverse (sequence) sequence (important-result)
502 :derive-type #'result-type-first-arg
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 index null)
673 (foldable flushable call)
674 :derive-type #'position-derive-type)
676 (defknown (position-if position-if-not)
677 ((callable 1) sequence &rest t &key (:from-end t) (:start index)
678 (:end sequence-end) (:key (callable 1)))
679 (or index null)
680 (foldable flushable call)
681 :derive-type #'position-derive-type)
683 (defknown count (t sequence &rest t &key
684 (:test (callable 2)) (:test-not (callable 2)) (:start index)
685 (:from-end t) (:end sequence-end) (:key (callable 1)))
686 index
687 (foldable flushable call)
688 :derive-type #'count-derive-type)
690 (defknown (count-if count-if-not)
691 ((callable 1) sequence &rest t &key
692 (:from-end t) (:start index) (:end sequence-end) (:key (callable 1)))
693 index
694 (foldable flushable call)
695 :derive-type #'count-derive-type)
697 (defknown (mismatch search)
698 (sequence sequence &rest t &key (:from-end t) (:test (callable 2))
699 (:test-not (callable 2)) (:start1 index) (:end1 sequence-end)
700 (:start2 index) (:end2 sequence-end) (:key (callable 1)))
701 (or index null)
702 (foldable flushable call))
704 ;;; not FLUSHABLE, since vector sort guaranteed in-place...
705 (defknown (stable-sort sort) (sequence (callable 2) &rest t &key (:key (callable 1)))
706 sequence
707 (call)
708 :derive-type (sequence-result-nth-arg 1)
709 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
710 (defknown sb!impl::stable-sort-list (list function function) list
711 (call important-result)
712 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
713 (defknown sb!impl::sort-vector (vector index index function (or function null))
714 * ; SORT-VECTOR works through side-effect
715 (call)
716 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
718 (defknown sb!impl::stable-sort-vector
719 (vector function (or function null))
720 vector
721 (call)
722 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
724 (defknown sb!impl::stable-sort-simple-vector
725 (simple-vector function (or function null))
726 simple-vector
727 (call)
728 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
730 (defknown merge (type-specifier sequence sequence (callable 2)
731 &key (:key (callable 1)))
732 sequence
733 (call important-result)
734 :derive-type (creation-result-type-specifier-nth-arg 1)
735 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2 3))
737 (defknown read-sequence (sequence stream
738 &key
739 (:start index)
740 (:end sequence-end))
741 (index)
744 (defknown write-sequence (sequence stream
745 &key
746 (:start index)
747 (:end sequence-end))
748 sequence
750 :derive-type #'result-type-first-arg)
752 ;;;; from the "Manipulating List Structure" chapter:
753 (defknown (car cdr first rest)
754 (list)
756 (foldable flushable))
758 ;; Correct argument type restrictions for these functions are
759 ;; complicated, so we just declare them to accept LISTs and suppress
760 ;; flushing is safe code.
761 (defknown (caar cadr cdar cddr
762 caaar caadr cadar caddr cdaar cdadr cddar cdddr
763 caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
764 cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
765 second third fourth fifth sixth seventh eighth ninth tenth)
766 (list)
768 (foldable unsafely-flushable))
770 (defknown cons (t t) cons (movable flushable))
772 (defknown tree-equal (t t &key (:test (callable 2)) (:test-not (callable 2))) boolean
773 (foldable flushable call))
774 (defknown endp (list) boolean (foldable flushable movable))
775 (defknown list-length (list) (or index null) (foldable unsafely-flushable))
776 (defknown (nth fast-&rest-nth) (unsigned-byte list) t (foldable flushable))
777 (defknown nthcdr (unsigned-byte list) t (foldable unsafely-flushable))
779 (defknown last (list &optional unsigned-byte) t (foldable flushable))
780 (defknown %last0 (list) t (foldable flushable))
781 (defknown %last1 (list) t (foldable flushable))
782 (defknown %lastn/fixnum (list (and unsigned-byte fixnum)) t (foldable flushable))
783 (defknown %lastn/bignum (list (and unsigned-byte bignum)) t (foldable flushable))
785 (defknown list (&rest t) list (movable flushable))
786 (defknown list* (t &rest t) t (movable flushable))
787 (defknown make-list (index &key (:initial-element t)) list
788 (movable flushable))
789 (defknown %make-list (index t) list (movable flushable))
791 (defknown sb!impl::|List| (&rest t) list (movable flushable foldable))
792 (defknown sb!impl::|List*| (t &rest t) t (movable flushable foldable))
793 (defknown sb!impl::|Append| (&rest t) t (flushable foldable))
794 (defknown sb!impl::|Vector| (&rest t) simple-vector (flushable foldable))
796 ;;; All but last must be of type LIST, but there seems to be no way to
797 ;;; express that in this syntax.
798 (defknown append (&rest t) t (flushable))
799 (defknown sb!impl::append2 (list t) t (flushable))
801 (defknown copy-list (list) list (flushable))
802 (defknown copy-alist (list) list (flushable))
803 (defknown copy-tree (t) t (flushable recursive))
804 (defknown revappend (list t) t (flushable))
806 ;;; All but last must be of type LIST, but there seems to be no way to
807 ;;; express that in this syntax. The result must be LIST, but we do
808 ;;; not check it now :-).
809 (defknown nconc (&rest t) t ()
810 :destroyed-constant-args (remove-non-constants-and-nils #'butlast))
812 (defknown nreconc (list t) t (important-result)
813 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
814 (defknown butlast (list &optional unsigned-byte) list (flushable))
815 (defknown nbutlast (list &optional unsigned-byte) list ()
816 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
818 (defknown ldiff (list t) list (flushable))
819 (defknown (rplaca rplacd) (cons t) cons ()
820 :destroyed-constant-args (nth-constant-args 1))
822 (defknown subst (t t t &key (:key (callable 1)) (:test (callable 2))
823 (:test-not (callable 2)))
824 t (flushable call))
825 (defknown nsubst (t t t &key (:key (callable 1)) (:test (callable 2))
826 (:test-not (callable 2)))
827 t (call)
828 :destroyed-constant-args (nth-constant-nonempty-sequence-args 3))
830 (defknown (subst-if subst-if-not)
831 (t (callable 1) t &key (:key (callable 1)))
832 t (flushable call))
833 (defknown (nsubst-if nsubst-if-not)
834 (t (callable 1) t &key (:key (callable 1)))
835 t (call)
836 :destroyed-constant-args (nth-constant-nonempty-sequence-args 3))
838 (defknown sublis (list t &key (:key (callable 1)) (:test (callable 2))
839 (:test-not (callable 2)))
840 t (flushable call))
841 (defknown nsublis (list t &key (:key (callable 1)) (:test (callable 2))
842 (:test-not (callable 2)))
843 t (flushable call)
844 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2))
846 (defknown member (t list &key (:key (callable 1)) (:test (callable 2))
847 (:test-not (callable 2)))
848 list (foldable flushable call))
849 (defknown (member-if member-if-not) ((callable 1) list &key (:key (callable 1)))
850 list (foldable flushable call))
852 (defknown tailp (t list) boolean (foldable flushable))
854 (defknown adjoin (t list &key (:key (callable 1)) (:test (callable 2))
855 (:test-not (callable 2)))
856 cons (flushable call))
858 (defknown (union intersection set-difference set-exclusive-or)
859 (list list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
860 list
861 (foldable flushable call))
863 (defknown (nunion nintersection nset-difference nset-exclusive-or)
864 (list list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
865 list
866 (foldable flushable call important-result)
867 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1 2))
869 (defknown subsetp
870 (list list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
871 boolean
872 (foldable flushable call))
874 (defknown acons (t t t) cons (movable flushable))
875 (defknown pairlis (t t &optional t) list (flushable))
877 (defknown (rassoc assoc)
878 (t list &key (:key (callable 1)) (:test (callable 2)) (:test-not (callable 2)))
879 list (foldable flushable call))
880 (defknown (assoc-if-not assoc-if rassoc-if rassoc-if-not)
881 ((callable 1) list &key (:key (callable 1))) list (foldable flushable call))
883 (defknown (memq assq) (t list) list (foldable flushable))
884 (defknown delq (t list) list (flushable)
885 :destroyed-constant-args (nth-constant-nonempty-sequence-args 2))
887 ;;;; from the "Hash Tables" chapter:
889 (defknown make-hash-table
890 (&key (:test callable) (:size unsigned-byte)
891 (:rehash-size (or (integer 1) (float (1.0))))
892 (:rehash-threshold (real 0 1))
893 (:hash-function (or null callable))
894 (:weakness (member nil :key :value :key-and-value :key-or-value))
895 (:synchronized t))
896 hash-table
897 (flushable))
898 (defknown hash-table-p (t) boolean (movable foldable flushable))
899 (defknown gethash (t hash-table &optional t) (values t boolean)
900 (flushable)) ; not FOLDABLE, since hash table contents can change
901 (defknown sb!impl::gethash3 (t hash-table t) (values t boolean)
902 (flushable)) ; not FOLDABLE, since hash table contents can change
903 (defknown %puthash (t hash-table t) t ()
904 :destroyed-constant-args (nth-constant-args 2)
905 :derive-type #'result-type-last-arg)
906 (defknown remhash (t hash-table) boolean ()
907 :destroyed-constant-args (nth-constant-args 2))
908 (defknown maphash ((callable 2) hash-table) null (flushable call))
909 (defknown clrhash (hash-table) hash-table ()
910 :destroyed-constant-args (nth-constant-args 2))
911 (defknown hash-table-count (hash-table) index (flushable))
912 (defknown hash-table-rehash-size (hash-table) (or index (single-float (1.0)))
913 (foldable flushable))
914 (defknown hash-table-rehash-threshold (hash-table) (single-float (0.0) 1.0)
915 (foldable flushable))
916 (defknown hash-table-size (hash-table) index (flushable))
917 (defknown hash-table-test (hash-table) symbol (foldable flushable))
918 (defknown sxhash (t) hash (#-sb-xc-host foldable flushable))
919 (defknown psxhash (t &optional t) hash (#-sb-xc-host foldable flushable))
920 (defknown hash-table-equalp (hash-table hash-table) boolean (foldable flushable))
922 ;;;; from the "Arrays" chapter
924 (defknown make-array ((or index list)
925 &key
926 (:element-type type-specifier)
927 (:initial-element t)
928 (:initial-contents t)
929 (:adjustable t)
930 (:fill-pointer (or index boolean))
931 (:displaced-to (or array null))
932 (:displaced-index-offset index))
933 array (flushable))
935 (defknown %make-array ((or index list)
936 (unsigned-byte #.sb!vm:n-widetag-bits)
937 (unsigned-byte 16)
938 &key
939 (:element-type type-specifier)
940 (:initial-element t)
941 (:initial-contents t)
942 (:adjustable t)
943 (:fill-pointer (or index boolean))
944 (:displaced-to (or array null))
945 (:displaced-index-offset index))
946 array (flushable))
948 (defknown sb!impl::fill-data-vector (vector list sequence) t ())
950 (defknown vector (&rest t) simple-vector (flushable))
952 (defknown aref (array &rest index) t (foldable))
953 (defknown row-major-aref (array index) t (foldable))
955 (defknown array-element-type (array) (or list symbol)
956 (foldable flushable))
957 (defknown array-rank (array) array-rank (foldable flushable))
958 ;; FIXME: there's a fencepost bug, but for all practical purposes our
959 ;; ARRAY-RANK-LIMIT is infinite, thus masking the bug. e.g. if the
960 ;; exclusive limit on rank were 8, then your dimension numbers can
961 ;; be in the range 0 through 6, not 0 through 7.
962 (defknown array-dimension (array array-rank) index (foldable flushable))
963 (defknown array-dimensions (array) list (foldable flushable))
964 (defknown array-in-bounds-p (array &rest integer) boolean (foldable flushable))
965 (defknown array-row-major-index (array &rest index) array-total-size
966 (foldable flushable))
967 (defknown array-total-size (array) array-total-size (foldable flushable))
968 (defknown adjustable-array-p (array) boolean (movable foldable flushable))
970 (defknown svref (simple-vector index) t (foldable flushable))
971 (defknown bit ((array bit) &rest index) bit (foldable flushable))
972 (defknown sbit ((simple-array bit) &rest index) bit (foldable flushable))
974 ;;; FIXME: :DESTROYED-CONSTANT-ARGS for these is complicated.
975 (defknown (bit-and bit-ior bit-xor bit-eqv bit-nand bit-nor bit-andc1 bit-andc2
976 bit-orc1 bit-orc2)
977 ((array bit) (array bit) &optional (or (array bit) (member t nil)))
978 (array bit)
980 #|:derive-type #'result-type-last-arg|#)
982 (defknown bit-not ((array bit) &optional (or (array bit) (member t nil)))
983 (array bit)
985 #|:derive-type #'result-type-last-arg|#)
987 (defknown bit-vector-= (bit-vector bit-vector) boolean
988 (movable foldable flushable))
990 (defknown array-has-fill-pointer-p (array) boolean
991 (movable foldable flushable))
992 (defknown fill-pointer (complex-vector) index
993 (unsafely-flushable))
994 (defknown sb!impl::fill-pointer-error (t &optional t) nil)
996 (defknown vector-push (t complex-vector) (or index null) ()
997 :destroyed-constant-args (nth-constant-args 2))
998 (defknown vector-push-extend (t complex-vector &optional (and index (integer 1))) index
1000 :destroyed-constant-args (nth-constant-args 2))
1001 (defknown vector-pop (complex-vector) t ()
1002 :destroyed-constant-args (nth-constant-args 1))
1004 ;;; FIXME: complicated :DESTROYED-CONSTANT-ARGS
1005 ;;; Also, an important-result warning could be provided if the array
1006 ;;; is known to be not expressly adjustable.
1007 (defknown adjust-array
1008 (array (or index list) &key (:element-type type-specifier)
1009 (:initial-element t) (:initial-contents t)
1010 (:fill-pointer (or index boolean))
1011 (:displaced-to (or array null))
1012 (:displaced-index-offset index))
1013 array ())
1014 ; :derive-type 'result-type-arg1) Not even close...
1016 ;;;; from the "Strings" chapter:
1018 (defknown char (string index) character (foldable flushable))
1019 (defknown schar (simple-string index) character (foldable flushable))
1021 (defknown (string= string-equal)
1022 (string-designator string-designator &key (:start1 index) (:end1 sequence-end)
1023 (:start2 index) (:end2 sequence-end))
1024 boolean
1025 (foldable flushable))
1027 (defknown (string< string> string<= string>= string/= string-lessp
1028 string-greaterp string-not-lessp string-not-greaterp
1029 string-not-equal)
1030 (string-designator string-designator &key (:start1 index) (:end1 sequence-end)
1031 (:start2 index) (:end2 sequence-end))
1032 (or index null)
1033 (foldable flushable))
1035 (defknown make-string (index &key (:element-type type-specifier)
1036 (:initial-element character))
1037 simple-string (flushable))
1039 (defknown (string-trim string-left-trim string-right-trim)
1040 (sequence string-designator) string (flushable))
1042 (defknown (string-upcase string-downcase string-capitalize)
1043 (string-designator &key (:start index) (:end sequence-end))
1044 simple-string (flushable))
1046 (defknown (nstring-upcase nstring-downcase nstring-capitalize)
1047 (string &key (:start index) (:end sequence-end))
1048 string ()
1049 :destroyed-constant-args (nth-constant-nonempty-sequence-args 1))
1051 (defknown string (string-designator) string (flushable))
1053 ;;;; internal non-keyword versions of string predicates:
1055 (defknown (string<* string>* string<=* string>=* string/=*)
1056 (string-designator string-designator index sequence-end index sequence-end)
1057 (or index null)
1058 (foldable flushable))
1060 (defknown string=*
1061 (string-designator string-designator index sequence-end index sequence-end)
1062 boolean
1063 (foldable flushable))
1065 ;;;; from the "Eval" chapter:
1067 (defknown eval (t) * (recursive))
1068 (defknown constantp (t &optional lexenv-designator) boolean
1069 (foldable flushable))
1071 ;;;; from the "Streams" chapter:
1073 (defknown make-synonym-stream (symbol) stream (flushable))
1074 (defknown make-broadcast-stream (&rest stream) stream (unsafely-flushable))
1075 (defknown make-concatenated-stream (&rest stream) stream (unsafely-flushable))
1076 (defknown make-two-way-stream (stream stream) stream (unsafely-flushable))
1077 (defknown make-echo-stream (stream stream) stream (flushable))
1078 (defknown make-string-input-stream (string &optional index sequence-end)
1079 stream
1080 (flushable))
1081 (defknown make-string-output-stream
1082 (&key (:element-type type-specifier)) sb!impl::string-output-stream
1083 (flushable))
1084 (defknown get-output-stream-string (stream) simple-string ())
1085 (defknown streamp (t) boolean (movable foldable flushable))
1086 (defknown stream-element-type (stream) type-specifier ; can it return a CLASS?
1087 (movable foldable flushable))
1088 (defknown stream-external-format (stream) t (flushable))
1089 (defknown (output-stream-p input-stream-p) (stream) boolean
1090 (movable foldable flushable))
1091 (defknown open-stream-p (stream) boolean (flushable))
1092 (defknown close (stream &key (:abort t)) (eql t) ())
1093 (defknown file-string-length (ansi-stream (or string character))
1094 (or unsigned-byte null)
1095 (flushable))
1097 ;;;; from the "Input/Output" chapter:
1099 ;;; (The I/O functions are given effects ANY under the theory that
1100 ;;; code motion over I/O operations is particularly confusing and not
1101 ;;; very important for efficiency.)
1103 (defknown copy-readtable (&optional (or readtable null) (or readtable null))
1104 readtable
1106 (defknown readtablep (t) boolean (movable foldable flushable))
1108 (defknown set-syntax-from-char
1109 (character character &optional readtable (or readtable null)) (eql t)
1112 (defknown set-macro-character (character (callable 2) &optional t (or readtable null))
1113 (eql t)
1114 (call))
1115 (defknown get-macro-character (character &optional (or readtable null))
1116 (values callable boolean) (flushable))
1118 (defknown make-dispatch-macro-character (character &optional t readtable)
1119 (eql t) ())
1120 (defknown set-dispatch-macro-character
1121 (character character callable &optional (or readtable null)) (eql t)
1123 (defknown get-dispatch-macro-character
1124 (character character &optional (or readtable null)) (or callable null)
1127 (defknown copy-pprint-dispatch
1128 (&optional (or sb!pretty:pprint-dispatch-table null))
1129 sb!pretty:pprint-dispatch-table
1131 (defknown pprint-dispatch
1132 (t &optional (or sb!pretty:pprint-dispatch-table null))
1133 (values callable boolean)
1135 (defknown (pprint-fill pprint-linear)
1136 (stream-designator t &optional t t)
1137 null
1139 (defknown pprint-tabular
1140 (stream-designator t &optional t t unsigned-byte)
1141 null
1143 (defknown pprint-indent
1144 ((member :block :current) real &optional stream-designator)
1145 null
1147 (defknown pprint-newline
1148 ((member :linear :fill :miser :mandatory) &optional stream-designator)
1149 null
1151 (defknown pprint-tab
1152 ((member :line :section :line-relative :section-relative)
1153 unsigned-byte unsigned-byte &optional stream-designator)
1154 null
1156 (defknown set-pprint-dispatch
1157 (type-specifier (or null callable)
1158 &optional real sb!pretty:pprint-dispatch-table)
1159 null
1162 ;;; may return any type due to eof-value...
1163 ;;; and because READ generally returns anything.
1164 (defknown (read read-preserving-whitespace)
1165 (&optional stream-designator t t t) t ())
1167 (defknown read-char (&optional stream-designator t t t) t ()
1168 :derive-type (read-elt-type-deriver nil 'character nil))
1169 (defknown read-char-no-hang (&optional stream-designator t t t) t ()
1170 :derive-type (read-elt-type-deriver nil 'character t))
1172 (defknown read-delimited-list (character &optional stream-designator t) list ())
1173 ;; FIXME: add a type-deriver => (values (or string eof-value) boolean)
1174 (defknown read-line (&optional stream-designator t t t) (values t boolean) ())
1175 (defknown unread-char (character &optional stream-designator) t ())
1176 (defknown peek-char (&optional (or character (member nil t))
1177 stream-designator t t t) t
1179 :derive-type (read-elt-type-deriver t 'character nil))
1181 (defknown listen (&optional stream-designator) boolean (flushable))
1183 (defknown clear-input (&optional stream-designator) null ())
1185 (defknown read-from-string
1186 (string &optional t t
1187 &key
1188 (:start index)
1189 (:end sequence-end)
1190 (:preserve-whitespace t))
1191 (values t index))
1192 (defknown parse-integer
1193 (string &key
1194 (:start index)
1195 (:end sequence-end)
1196 (:radix (integer 2 36))
1197 (:junk-allowed t))
1198 (values (or integer null ()) index))
1200 (defknown read-byte (stream &optional t t) t ()
1201 :derive-type (read-elt-type-deriver nil 'integer nil))
1203 (defknown (prin1 print princ) (t &optional stream-designator)
1205 (any)
1206 :derive-type #'result-type-first-arg)
1208 (defknown output-object (t stream) null (any))
1209 (defknown %write (t stream-designator) t (any))
1211 (defknown (pprint) (t &optional stream-designator) (values)
1214 (macrolet
1215 ((deffrob (name keys returns attributes &rest more)
1216 `(defknown ,name
1217 (t &key ,@keys
1218 (:escape t)
1219 (:radix t)
1220 (:base (integer 2 36))
1221 (:circle t)
1222 (:pretty t)
1223 (:readably t)
1224 (:level (or unsigned-byte null))
1225 (:length (or unsigned-byte null))
1226 (:case t)
1227 (:array t)
1228 (:gensym t)
1229 (:lines (or unsigned-byte null))
1230 (:right-margin (or unsigned-byte null))
1231 (:miser-width (or unsigned-byte null))
1232 (:pprint-dispatch t)
1233 (:suppress-errors t))
1234 ,returns ,attributes ,@more)))
1235 (deffrob write ((:stream stream-designator)) t (any)
1236 :derive-type #'result-type-first-arg)
1237 ;;; xxx-TO-STRING functions are not foldable because they depend on
1238 ;;; the dynamic environment, the state of the pretty printer dispatch
1239 ;;; table, and probably other run-time factors.
1240 (deffrob write-to-string () simple-string
1241 (unsafely-flushable)))
1243 (defknown (prin1-to-string princ-to-string) (t) simple-string (flushable))
1244 (defknown sb!impl::stringify-object (t) simple-string)
1246 (defknown write-char (character &optional stream-designator) character ()
1247 :derive-type #'result-type-first-arg)
1249 (defknown (write-string write-line)
1250 (string &optional stream-designator &key (:start index) (:end sequence-end))
1251 string
1253 :derive-type #'result-type-first-arg)
1255 (defknown (terpri finish-output force-output clear-output)
1256 (&optional stream-designator) null
1259 (defknown fresh-line (&optional stream-designator) boolean ())
1261 (defknown write-byte (integer stream) integer ()
1262 :derive-type #'result-type-first-arg)
1264 ;;; FIXME: complicated :DESTROYED-CONSTANT-ARGS
1265 (defknown format ((or (member nil t) stream string)
1266 (or string function) &rest t)
1267 (or string null)
1269 (defknown sb!format::args-exhausted (string integer) nil)
1271 (defknown (y-or-n-p yes-or-no-p) (&optional string &rest t) boolean
1274 ;;;; from the "File System Interface" chapter:
1276 ;;; (No pathname functions are FOLDABLE because they all potentially
1277 ;;; depend on *DEFAULT-PATHNAME-DEFAULTS*, e.g. to provide a default
1278 ;;; host when parsing a namestring. They are not FLUSHABLE because
1279 ;;; parsing of a PATHNAME-DESIGNATOR might signal an error.)
1281 (defknown wild-pathname-p (pathname-designator
1282 &optional
1283 (member nil :host :device
1284 :directory :name
1285 :type :version))
1286 generalized-boolean
1287 (recursive))
1289 (defknown pathname-match-p (pathname-designator pathname-designator)
1290 generalized-boolean
1293 (defknown translate-pathname (pathname-designator
1294 pathname-designator
1295 pathname-designator &key)
1296 pathname
1299 (defknown logical-pathname (pathname-designator) logical-pathname ())
1300 (defknown translate-logical-pathname (pathname-designator &key) pathname
1301 (recursive))
1302 (defknown load-logical-pathname-translations (string) t ())
1303 (defknown logical-pathname-translations (logical-host-designator) list ())
1305 (defknown pathname (pathname-designator) pathname ())
1306 (defknown truename (pathname-designator) pathname ())
1308 (defknown parse-namestring
1309 (pathname-designator &optional
1310 (or list host string (member :unspecific))
1311 pathname-designator
1312 &key
1313 (:start index)
1314 (:end sequence-end)
1315 (:junk-allowed t))
1316 (values (or pathname null) sequence-end)
1317 (recursive))
1319 (defknown merge-pathnames
1320 (pathname-designator &optional pathname-designator pathname-version)
1321 pathname
1324 (defknown make-pathname
1325 (&key (:defaults pathname-designator)
1326 (:host (or string pathname-host))
1327 (:device (or string pathname-device))
1328 (:directory (or pathname-directory string (member :wild)))
1329 (:name (or pathname-name string (member :wild)))
1330 (:type (or pathname-type string (member :wild)))
1331 (:version pathname-version) (:case (member :local :common)))
1332 pathname (unsafely-flushable))
1334 (defknown pathnamep (t) boolean (movable flushable))
1336 (defknown pathname-host (pathname-designator
1337 &key (:case (member :local :common)))
1338 pathname-host (flushable))
1339 (defknown pathname-device (pathname-designator
1340 &key (:case (member :local :common)))
1341 pathname-device (flushable))
1342 (defknown pathname-directory (pathname-designator
1343 &key (:case (member :local :common)))
1344 pathname-directory (flushable))
1345 (defknown pathname-name (pathname-designator
1346 &key (:case (member :local :common)))
1347 pathname-name (flushable))
1348 (defknown pathname-type (pathname-designator
1349 &key (:case (member :local :common)))
1350 pathname-type (flushable))
1351 (defknown pathname-version (pathname-designator)
1352 pathname-version (flushable))
1354 (defknown pathname= (pathname pathname) boolean (movable foldable flushable))
1356 (defknown (namestring file-namestring directory-namestring host-namestring)
1357 (pathname-designator) (or simple-string null)
1358 (unsafely-flushable))
1360 (defknown enough-namestring (pathname-designator &optional pathname-designator)
1361 simple-string
1362 (unsafely-flushable))
1364 (defknown user-homedir-pathname (&optional t) pathname (flushable))
1366 (defknown open
1367 (pathname-designator &key
1368 (:class symbol)
1369 (:direction (member :input :output :io :probe))
1370 (:element-type type-specifier)
1371 (:if-exists (member :error :new-version :rename
1372 :rename-and-delete :overwrite
1373 :append :supersede nil))
1374 (:if-does-not-exist (member :error :create nil))
1375 (:external-format external-format-designator))
1376 (or stream null))
1378 (defknown rename-file (pathname-designator filename)
1379 (values pathname pathname pathname))
1380 (defknown delete-file (pathname-designator) (eql t))
1381 (defknown probe-file (pathname-designator) (or pathname null) ())
1382 (defknown file-write-date (pathname-designator) (or unsigned-byte null)
1384 (defknown file-author (pathname-designator) (or simple-string null)
1387 (defknown file-position (stream &optional
1388 (or unsigned-byte (member :start :end)))
1389 (or unsigned-byte (member t nil)))
1390 (defknown file-length (stream) (or unsigned-byte null) (unsafely-flushable))
1392 (defknown load
1393 ((or filename stream)
1394 &key
1395 (:verbose t)
1396 (:print t)
1397 (:if-does-not-exist t)
1398 (:external-format external-format-designator))
1399 boolean)
1401 (defknown directory (pathname-designator &key (:resolve-symlinks t))
1402 list ())
1404 ;;;; from the "Conditions" chapter:
1406 (defknown error (t &rest t) nil)
1407 (defknown cerror (format-control t &rest t) null)
1408 (defknown invalid-method-error (t format-control &rest t) *) ; FIXME: first arg is METHOD
1409 (defknown method-combination-error (format-control &rest t) *)
1410 (defknown signal (t &rest t) null)
1411 (defknown warn (t &rest t) null)
1412 (defknown invoke-debugger (condition) nil)
1413 (defknown break (&optional format-control &rest t) null)
1414 (defknown make-condition (type-specifier &rest t) condition ())
1415 (defknown compute-restarts (&optional (or condition null)) list)
1416 (defknown find-restart (restart-designator &optional (or condition null))
1417 (or restart null))
1418 (defknown invoke-restart (restart-designator &rest t) *)
1419 (defknown invoke-restart-interactively (restart-designator) *)
1420 (defknown restart-name (restart) symbol)
1421 (defknown (abort muffle-warning) (&optional (or condition null)) nil)
1422 (defknown continue (&optional (or condition null)) null)
1423 (defknown (store-value use-value) (t &optional (or condition null))
1424 null)
1426 ;;; and analogous SBCL extension:
1427 (defknown sb!impl::%failed-aver (t) nil)
1428 (defknown bug (t &rest t) nil) ; never returns
1429 (defknown sb!int:simple-reader-error (stream string &rest t) nil)
1430 (defknown sb!kernel:reader-eof-error (stream string) nil)
1433 ;;;; from the "Miscellaneous" Chapter:
1435 (defknown compile ((or symbol cons) &optional (or list function null))
1436 (values (or function symbol cons) boolean boolean))
1438 (defknown compile-file
1439 (pathname-designator
1440 &key
1442 ;; ANSI options
1443 (:output-file (or pathname-designator
1444 null
1445 ;; FIXME: This last case is a non-ANSI hack.
1446 (member t)))
1447 (:verbose t)
1448 (:print t)
1449 (:external-format external-format-designator)
1451 ;; extensions
1452 (:trace-file t)
1453 (:block-compile t)
1454 (:emit-cfasl t))
1455 (values (or pathname null) boolean boolean))
1457 (defknown (compile-file-pathname)
1458 (pathname-designator &key (:output-file (or pathname-designator
1459 null
1460 (member t)))
1461 &allow-other-keys)
1462 pathname)
1464 ;; FIXME: consider making (OR CALLABLE CONS) something like
1465 ;; EXTENDED-FUNCTION-DESIGNATOR
1466 (defknown disassemble ((or callable cons) &key
1467 (:stream stream) (:use-labels t))
1468 null)
1470 (defknown describe (t &optional (or stream (member t nil))) (values))
1471 (defknown function-lambda-expression (function) (values t boolean t))
1472 (defknown inspect (t) (values))
1473 (defknown room (&optional (member t nil :default)) (values))
1474 (defknown ed (&optional (or symbol cons filename))
1476 (defknown dribble (&optional filename &key (:if-exists t)) (values))
1478 (defknown apropos (string-designator &optional package-designator t) (values))
1479 (defknown apropos-list (string-designator &optional package-designator t) list
1480 (flushable recursive))
1482 (defknown get-decoded-time ()
1483 (values (integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1484 (integer 1 12) unsigned-byte (integer 0 6) boolean (rational -24 24))
1485 (flushable))
1487 (defknown get-universal-time () unsigned-byte (flushable))
1489 (defknown decode-universal-time
1490 (unsigned-byte &optional (or null (rational -24 24)))
1491 (values (integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1492 (integer 1 12) unsigned-byte (integer 0 6) boolean (rational -24 24))
1493 (flushable))
1495 (defknown encode-universal-time
1496 ((integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1497 (integer 1 12) unsigned-byte &optional (or null (rational -24 24)))
1498 unsigned-byte
1499 (flushable))
1501 (defknown (get-internal-run-time get-internal-real-time)
1502 () internal-time (flushable))
1504 (defknown sleep ((real 0)) null ())
1506 (defknown call-with-timing (callable callable &rest t) *
1507 (call))
1509 ;;; Even though ANSI defines LISP-IMPLEMENTATION-TYPE and
1510 ;;; LISP-IMPLEMENTATION-VERSION to possibly punt and return NIL, we
1511 ;;; know that there's no valid reason for our implementations to ever
1512 ;;; do so, so we can safely guarantee that they'll return strings.
1513 (defknown (lisp-implementation-type lisp-implementation-version)
1514 () simple-string (flushable))
1516 ;;; For any of these functions, meaningful information might not be
1517 ;;; available, so -- unlike the related LISP-IMPLEMENTATION-FOO
1518 ;;; functions -- these really can return NIL.
1519 (defknown (machine-type machine-version machine-instance
1520 software-type software-version
1521 short-site-name long-site-name)
1522 () (or simple-string null) (flushable))
1524 (defknown identity (t) t (movable foldable flushable)
1525 :derive-type #'result-type-first-arg)
1527 (defknown constantly (t) function (movable flushable))
1528 (defknown complement (function) function (movable flushable))
1530 ;;;; miscellaneous extensions
1532 (defknown symbol-global-value (symbol) t ())
1533 (defknown set-symbol-global-value (symbol t) t ()
1534 :derive-type #'result-type-last-arg)
1536 (defknown get-bytes-consed () unsigned-byte (flushable))
1537 (defknown mask-signed-field ((integer 0 *) integer) integer
1538 (movable flushable foldable))
1540 (defknown array-storage-vector (array) (simple-array * (*))
1541 (any))
1543 ;;;; magical compiler frobs
1545 (defknown %rest-values (t t t) * (always-translatable))
1546 (defknown %rest-ref (t t t t &optional boolean) * (always-translatable))
1547 (defknown %rest-length (t t t) * (always-translatable))
1548 (defknown %rest-null (t t t t) * (always-translatable))
1549 (defknown %rest-true (t t t) * (always-translatable))
1551 (defknown %unary-truncate/single-float (single-float) integer (movable foldable flushable))
1552 (defknown %unary-truncate/double-float (double-float) integer (movable foldable flushable))
1554 ;;; We can't fold this in general because of SATISFIES. There is a
1555 ;;; special optimizer anyway.
1556 (defknown %typep (t (or type-specifier ctype)) boolean (movable flushable))
1557 (defknown %instance-typep (t (or type-specifier ctype)) boolean
1558 (movable flushable always-translatable))
1559 ;;; We should never emit a call to %typep-wrapper
1560 (defknown %typep-wrapper (t t (or type-specifier ctype)) t
1561 (movable flushable always-translatable))
1563 (defknown %cleanup-point () t)
1564 (defknown %special-bind (t t) t)
1565 (defknown %special-unbind (t) t)
1566 (defknown %listify-rest-args (t index) list (flushable))
1567 (defknown %more-arg-context (t t) (values t index) (flushable))
1568 (defknown %more-arg (t index) t)
1569 #!+stack-grows-downward-not-upward
1570 ;;; FIXME: The second argument here should really be NEGATIVE-INDEX, but doing that
1571 ;;; breaks the build, and I cannot seem to figure out why. --NS 2006-06-29
1572 (defknown %more-kw-arg (t fixnum) (values t t))
1573 (defknown %more-arg-values (t index index) * (flushable))
1575 #!-precise-arg-count-error
1576 (defknown %verify-arg-count (index index) (values))
1578 (defknown %arg-count-error (t t) nil)
1579 (defknown %unknown-values () *)
1580 (defknown %catch (t t) t)
1581 (defknown %unwind-protect (t t) t)
1582 (defknown (%catch-breakup %unwind-protect-breakup) () t)
1583 (defknown %lexical-exit-breakup (t) t)
1584 (defknown %continue-unwind (t t t) nil)
1585 (defknown %throw (t &rest t) nil) ; This is MV-called.
1586 (defknown %nlx-entry (t) *)
1587 (defknown %%primitive (t t &rest t) *)
1588 (defknown %pop-values (t) t)
1589 (defknown %nip-values (t t &rest t) (values))
1590 (defknown %dummy-dx-alloc (t t) t)
1591 (defknown %allocate-closures (t) *)
1592 (defknown %type-check-error (t t) nil)
1593 (defknown %type-check-error/c (t t) nil)
1595 ;; FIXME: This function does not return, but due to the implementation
1596 ;; of FILTER-LVAR we cannot write it here.
1597 (defknown %compile-time-type-error (t t t t t) *)
1598 (defknown (etypecase-failure ecase-failure) (t t) nil)
1600 (defknown %odd-key-args-error () nil)
1601 (defknown %unknown-key-arg-error (t) nil)
1602 (defknown (%ldb %mask-field) (bit-index bit-index integer) unsigned-byte
1603 (movable foldable flushable))
1604 (defknown (%dpb %deposit-field) (integer bit-index bit-index integer) integer
1605 (movable foldable flushable))
1606 (defknown %negate (number) number (movable foldable flushable))
1607 (defknown (%check-bound check-bound) (array index t) index
1608 (dx-safe))
1609 (defknown data-vector-ref (simple-array index) t
1610 (foldable unsafely-flushable always-translatable))
1611 (defknown data-vector-ref-with-offset (simple-array fixnum fixnum) t
1612 (foldable unsafely-flushable always-translatable))
1613 (defknown data-nil-vector-ref (simple-array index) nil
1614 (always-translatable))
1615 (defknown data-vector-set (array index t) t
1616 (always-translatable))
1617 (defknown data-vector-set-with-offset (array fixnum fixnum t) t
1618 (always-translatable))
1619 (defknown hairy-data-vector-ref (array index) t (foldable))
1620 (defknown hairy-data-vector-set (array index t) t ())
1621 (defknown hairy-data-vector-ref/check-bounds (array index) t (foldable))
1622 (defknown hairy-data-vector-set/check-bounds (array index t) t ())
1623 (defknown %caller-frame () t (flushable))
1624 (defknown %caller-pc () system-area-pointer (flushable))
1625 (defknown %with-array-data (array index (or index null))
1626 (values (simple-array * (*)) index index index)
1627 (foldable flushable))
1628 (defknown %with-array-data/fp (array index (or index null))
1629 (values (simple-array * (*)) index index index)
1630 (foldable flushable))
1631 (defknown %set-symbol-package (symbol t) t ())
1632 (defknown %coerce-callable-to-fun (callable) function (flushable))
1633 (defknown array-bounding-indices-bad-error (t t t) nil)
1634 (defknown sequence-bounding-indices-bad-error (t t t) nil)
1635 (defknown %find-position
1636 (t sequence t index sequence-end function function)
1637 (values t (or index null))
1638 (flushable call))
1639 (defknown (%find-position-if %find-position-if-not)
1640 (function sequence t index sequence-end function)
1641 (values t (or index null))
1642 (call))
1643 (defknown effective-find-position-test (callable callable)
1644 function
1645 (flushable foldable))
1646 (defknown effective-find-position-key (callable)
1647 function
1648 (flushable foldable))
1650 (defknown (%adjoin %adjoin-eq)
1651 (t list)
1652 list
1653 (flushable))
1655 (defknown (%member %member-eq
1656 %assoc %assoc-eq %rassoc %rassoc-eq)
1657 (t list)
1658 list
1659 (foldable flushable))
1661 (defknown (%adjoin-key %adjoin-key-eq)
1662 (t list function)
1663 list
1664 (flushable call))
1666 (defknown (%member-key %member-key-eq
1667 %assoc-key %assoc-key-eq %rassoc-key %rassoc-key-eq)
1668 (t list function)
1669 list
1670 (foldable flushable call))
1672 (defknown (%assoc-if %assoc-if-not %rassoc-if %rassoc-if-not
1673 %member-if %member-if-not)
1674 (function list)
1675 list
1676 (foldable flushable call))
1678 (defknown (%assoc-if-key %assoc-if-not-key %rassoc-if-key %rassoc-if-not-key
1679 %member-if-key %member-if-not-key)
1680 (function list function)
1681 list
1682 (foldable flushable call))
1684 (defknown (%adjoin-test %adjoin-test-not)
1685 (t list function)
1686 list
1687 (flushable call))
1689 (defknown (%member-test %member-test-not
1690 %assoc-test %assoc-test-not
1691 %rassoc-test %rassoc-test-not)
1692 (t list function)
1693 list
1694 (foldable flushable call))
1696 (defknown (%adjoin-key-test %adjoin-key-test-not)
1697 (t list function function)
1698 list
1699 (flushable call))
1701 (defknown (%member-key-test %member-key-test-not
1702 %assoc-key-test %assoc-key-test-not
1703 %rassoc-key-test %rassoc-key-test-not)
1704 (t list function function)
1705 list
1706 (foldable flushable call))
1708 (defknown %check-vector-sequence-bounds (vector index sequence-end)
1709 index
1710 (unwind))
1712 ;;;; SETF inverses
1714 (defknown (setf aref) (t array &rest index) t ()
1715 :destroyed-constant-args (nth-constant-args 2)
1716 :derive-type #'result-type-first-arg)
1717 (defknown %set-row-major-aref (array index t) t ()
1718 :destroyed-constant-args (nth-constant-args 1))
1719 (defknown (%rplaca %rplacd) (cons t) t ()
1720 :destroyed-constant-args (nth-constant-args 1)
1721 :derive-type #'result-type-last-arg)
1722 (defknown %put (symbol t t) t ())
1723 (defknown %setelt (sequence index t) t ()
1724 :destroyed-constant-args (nth-constant-args 1)
1725 :derive-type #'result-type-last-arg)
1726 (defknown %svset (simple-vector index t) t ()
1727 :destroyed-constant-args (nth-constant-args 1))
1728 (defknown (setf bit) (bit (array bit) &rest index) bit ()
1729 :destroyed-constant-args (nth-constant-args 2))
1730 (defknown (setf sbit) (bit (simple-array bit) &rest index) bit ()
1731 :destroyed-constant-args (nth-constant-args 2))
1732 (defknown %charset (string index character) character ()
1733 :destroyed-constant-args (nth-constant-args 1))
1734 (defknown %scharset (simple-string index character) character ()
1735 :destroyed-constant-args (nth-constant-args 1))
1736 (defknown %set-symbol-value (symbol t) t ())
1737 (defknown (setf symbol-function) (function symbol) function ())
1738 (defknown %set-symbol-plist (symbol list) list ()
1739 :derive-type #'result-type-last-arg)
1740 (defknown %setnth (unsigned-byte list t) t ()
1741 :destroyed-constant-args (nth-constant-args 2)
1742 :derive-type #'result-type-last-arg)
1743 (defknown %set-fill-pointer (complex-vector index) index ()
1744 :destroyed-constant-args (nth-constant-args 1)
1745 :derive-type #'result-type-last-arg)
1747 ;;;; ALIEN and call-out-to-C stuff
1749 ;; Used by WITH-PINNED-OBJECTS
1750 #!+(or x86 x86-64)
1751 (defknown sb!vm::touch-object (t) (values)
1752 (always-translatable))
1754 #!+linkage-table
1755 (defknown foreign-symbol-dataref-sap (simple-string)
1756 system-area-pointer
1757 (movable flushable))
1759 (defknown foreign-symbol-sap (simple-string &optional boolean)
1760 system-area-pointer
1761 (movable flushable))
1763 (defknown foreign-symbol-address (simple-string &optional boolean)
1764 (values integer boolean)
1765 (movable flushable))
1767 ;;;; miscellaneous internal utilities
1769 (defknown %fun-name (function) t (flushable))
1770 (defknown (setf %fun-name) (t function) t ())
1772 (defknown policy-quality (policy symbol) policy-quality
1773 (flushable))
1775 (defknown compiler-error (t &rest t) nil ())
1776 (defknown (compiler-warn compiler-style-warn) (t &rest t) (values) ())
1777 (defknown (compiler-notify maybe-compiler-notify) ((or string symbol) &rest t)
1778 (values)
1780 (defknown style-warn (t &rest t) null ())
1782 (defknown coerce-to-condition ((or condition symbol string function)
1783 list type-specifier symbol)
1784 condition
1787 (defknown coerce-symbol-to-fun (symbol)
1788 function
1791 (defknown sc-number-or-lose (symbol) sc-number
1792 (foldable))
1794 (defknown set-info-value (t info-number t) t ()
1795 :derive-type #'result-type-last-arg)
1797 ;;;; memory barriers
1799 (defknown sb!vm:%compiler-barrier () (values) ())
1800 (defknown sb!vm:%memory-barrier () (values) ())
1801 (defknown sb!vm:%read-barrier () (values) ())
1802 (defknown sb!vm:%write-barrier () (values) ())
1803 (defknown sb!vm:%data-dependency-barrier () (values) ())
1805 #!+sb-safepoint
1806 ;;; Note: This known function does not have an out-of-line definition;
1807 ;;; and if such a definition were needed, it would not need to "call"
1808 ;;; itself inline, but could be a no-op, because the compiler inserts a
1809 ;;; use of the VOP in the function prologue anyway.
1810 (defknown sb!kernel::gc-safepoint () (values) ())
1812 ;;;; atomic ops
1813 (defknown %compare-and-swap-svref (simple-vector index t t) t
1815 (defknown %compare-and-swap-symbol-value (symbol t t) t
1816 (unwind))
1817 (defknown (%atomic-dec-symbol-global-value %atomic-inc-symbol-global-value)
1818 (symbol fixnum) fixnum)
1819 (defknown (%atomic-dec-car %atomic-inc-car %atomic-dec-cdr %atomic-inc-cdr)
1820 (cons fixnum) fixnum)
1821 (defknown spin-loop-hint () (values)
1822 (always-translatable))
1824 ;;;; Stream methods
1826 ;;; Avoid a ton of FBOUNDP checks in the string stream constructors etc,
1827 ;;; by wiring in the needed functions instead of dereferencing their fdefns.
1828 (defknown (ill-in ill-bin ill-out ill-bout
1829 sb!impl::string-inch sb!impl::string-in-misc
1830 sb!impl::string-ouch sb!impl::string-sout sb!impl::string-out-misc
1831 sb!impl::fill-pointer-ouch sb!impl::fill-pointer-sout
1832 sb!impl::fill-pointer-misc
1833 sb!impl::case-frob-upcase-out sb!impl::case-frob-upcase-sout
1834 sb!impl::case-frob-downcase-out sb!impl::case-frob-downcase-sout
1835 sb!impl::case-frob-capitalize-out sb!impl::case-frob-capitalize-sout
1836 sb!impl::case-frob-capitalize-first-out sb!impl::case-frob-capitalize-first-sout
1837 sb!impl::case-frob-capitalize-aux-out sb!impl::case-frob-capitalize-aux-sout
1838 sb!impl::case-frob-misc
1839 sb!pretty::pretty-out sb!pretty::pretty-misc) * *)
1840 (defknown sb!pretty::pretty-sout * * (recursive))
1842 ;;;; PCL
1844 (defknown sb!pcl::pcl-instance-p (t) boolean
1845 (movable foldable flushable))
1847 ;; FIXME: should T be be (OR INSTANCE FUNCALLABLE-INSTANCE) etc?
1848 (defknown slot-value (t symbol) t (any))
1849 (defknown (slot-boundp slot-exists-p) (t symbol) boolean)
1850 (defknown sb!pcl::set-slot-value (t symbol t) t (any))
1852 (defknown find-class (symbol &optional t lexenv-designator) (or class null) ())
1853 (defknown class-of (t) class (flushable))
1854 (defknown class-name (class) symbol (flushable))