Make type caches perform better.
[sbcl.git] / src / code / primordial-type.lisp
blob0696c07a17783507896de35ded720c8863661321
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB!KERNEL")
12 ;;; Has the type system been properly initialized? (I.e. is it OK to
13 ;;; use it?)
14 (!defglobal *type-system-initialized* nil)
16 ;; These are set by cold-init-forms in 'late-type' (look for "macrolet frob").
17 ;; It is a requirement of the type machinery that there be
18 ;; exactly one instance of each of these, which is to say,
19 ;; any type named T is exactly EQ to *UNIVERSAL-TYPE*, etc.
20 (defglobal *wild-type* -1)
21 (defglobal *empty-type* -1)
22 (defglobal *universal-type* -1)
23 (defglobal *instance-type* -1)
24 (defglobal *funcallable-instance-type* -1)
25 (defglobal *extended-sequence-type* -1)
27 ;; Unlike the above, this one is not a NAMED-TYPE, and as such
28 ;; does not have to be a singleton, but it improves efficiency.
29 ;; (Except that we never really need it for anything)
30 (defglobal *universal-fun-type* -1)
32 ;; These need not be singletons, but again it is more efficient
33 ;; when there is only a single instance of each.
34 (defglobal *cons-t-t-type* -1)
35 (defglobal *null-type* -1)
36 (defglobal *boolean-type* -1)
38 ;; This one is used when parsing (SATISFIES KEYWORDP)
39 ;; so that simplifications can be made whe computing intersections,
40 ;; without which we would see this kind of "empty-type in disguise"
41 ;; (AND (SATISFIES KEYWORDP) CONS)
42 ;; This isn't *keyword-type* because KEYWORD is implemented
43 ;; as the intersection of SYMBOL and (SATISFIES KEYWORDP)
44 ;; We could also intern the KEYWORD type but that would require
45 ;; hacking the INTERSECTION logic.
46 (defglobal *satisfies-keywordp-type* -1)
48 ;; Here too I discovered more than 1000 instances in a particular
49 ;; Lisp image, when really this is *EMPTY-TYPE*.
50 ;; (AND (SATISFIES LEGAL-FUN-NAME-P) (SIMPLE-ARRAY CHARACTER (*)))
51 (defglobal *fun-name-type* -1)
53 ;;; a vector that maps type codes to layouts, used for quickly finding
54 ;;; the layouts of built-in classes
55 (defglobal **built-in-class-codes** #()) ; initialized in cold load
56 (declaim (type simple-vector **built-in-class-codes**))