1 ;;;; types which are needed to implement byte-compiled functions
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
16 (deftype stack-pointer ()
17 `(integer 0 ,(1- sb!vm:*target-most-positive-fixnum*)))
19 ;;; KLUDGE: bare numbers, no documentation, ick.. -- WHN 19990701
20 (eval-when (:compile-toplevel :load-toplevel :execute)
21 (defconstant max-pc (1- (ash 1 24))))
27 `(integer ,(- max-pc) ,max-pc))
31 ;;; This abstract class represents any type of byte-compiled function.
32 (defstruct (byte-function-or-closure
33 (:alternate-metaclass funcallable-instance
34 funcallable-structure-class
35 make-funcallable-structure-class)
36 (:type funcallable-structure)
40 ;;; a byte-compiled closure
41 (defstruct (byte-closure
42 (:include byte-function-or-closure)
43 (:constructor make-byte-closure (function data))
44 (:type funcallable-structure)
47 (print-unreadable-object (x stream :type t :identity t)
48 (prin1 (byte-function-name (byte-closure-function x))
51 ;; the byte function that we call
52 (function (required-argument) :type byte-function)
53 ;; the closure data vector
54 (data (required-argument) :type simple-vector))
56 ;;; any non-closure byte function (including the hidden function
57 ;;; object for a closure)
58 (defstruct (byte-function (:include byte-function-or-closure)
59 (:type funcallable-structure)
62 ;; The component that this XEP is an entry point into. NIL until
63 ;; LOAD or MAKE-CORE-BYTE-COMPONENT fills it in. They count on this
64 ;; being the first slot.
65 (component nil :type (or null code-component))
66 ;; Debug name of this function.
68 (def!method print-object ((x byte-function) stream)
69 ;; FIXME: I think functions should probably print either as
70 ;; #<FUNCTION ..> or as #<COMPILED-FUNCTION ..>, since those are
71 ;; their user-visible types. (And this should be true for
72 ;; BYTE-CLOSURE objects too.)
73 (print-unreadable-object (x stream :identity t)
74 (format stream "byte function ~S" (byte-function-name x))))
76 ;;; fixed-argument byte function
77 (defstruct (simple-byte-function (:include byte-function)
78 (:type funcallable-structure)
80 ;; The number of arguments expected.
81 (num-args 0 :type (integer 0 #.call-arguments-limit))
82 ;; The start of the function.
83 (entry-point 0 :type index))
85 ;;; variable-arg-count byte function
86 (defstruct (hairy-byte-function (:include byte-function)
87 (:type funcallable-structure)
89 ;; The minimum and maximum number of args, ignoring &REST and &KEY.
90 (min-args 0 :type (integer 0 #.call-arguments-limit))
91 (max-args 0 :type (integer 0 #.call-arguments-limit))
92 ;; List of the entry points for min-args, min-args+1, ... max-args.
93 (entry-points nil :type list)
94 ;; The entry point to use when there are more than max-args. Only
95 ;; filled in where okay. In other words, only when &REST or &KEY is
97 (more-args-entry-point nil :type (or null (unsigned-byte 24)))
98 ;; The number of ``more-arg'' args.
99 (num-more-args 0 :type (integer 0 #.call-arguments-limit))
100 ;; True if there is a rest-arg.
101 (rest-arg-p nil :type (member t nil))
102 ;; True if there are keywords. Note: keywords might still be NIL
103 ;; because having &KEY with no keywords is valid and should result
104 ;; in &ALLOW-OTHER-KEYS processing. If :ALLOW-OTHERS, then allow
106 (keywords-p nil :type (member t nil :allow-others))
107 ;; list of &KEY arguments. Each element is a list of:
108 ;; key, default, supplied-p.
109 (keywords nil :type list))
111 #!-sb-fluid (declaim (freeze-type byte-function-or-closure))