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))
50 ;; the byte function that we call
51 (function (required-argument) :type byte-function)
52 ;; the closure data vector
53 (data (required-argument) :type simple-vector))
55 ;;; any non-closure byte function (including the hidden function
56 ;;; object for a closure)
57 (defstruct (byte-function (:include byte-function-or-closure)
58 (:type funcallable-structure)
60 ;; The component that this XEP is an entry point into. NIL until
61 ;; LOAD or MAKE-CORE-BYTE-COMPONENT fills it in. They count on this
62 ;; being the first slot.
63 (component nil :type (or null code-component))
64 ;; Debug name of this function.
66 (def!method print-object ((x byte-function) stream)
67 ;; FIXME: I think functions should probably print either as
68 ;; #<FUNCTION ..> or as #<COMPILED-FUNCTION ..>, since those are
69 ;; their user-visible types. (And this should be true for
70 ;; BYTE-CLOSURE objects too.)
71 (print-unreadable-object (x stream :identity t)
72 (format stream "byte function ~S" (byte-function-name x))))
74 ;;; fixed-argument byte function
75 (defstruct (simple-byte-function (:include byte-function)
76 (:type funcallable-structure))
77 ;; The number of arguments expected.
78 (num-args 0 :type (integer 0 #.call-arguments-limit))
79 ;; The start of the function.
80 (entry-point 0 :type index))
82 ;;; variable-arg-count byte function
83 (defstruct (hairy-byte-function (:include byte-function)
84 (:type funcallable-structure))
85 ;; The minimum and maximum number of args, ignoring &REST and &KEY.
86 (min-args 0 :type (integer 0 #.call-arguments-limit))
87 (max-args 0 :type (integer 0 #.call-arguments-limit))
88 ;; List of the entry points for min-args, min-args+1, ... max-args.
89 (entry-points nil :type list)
90 ;; The entry point to use when there are more than max-args. Only
91 ;; filled in where okay. In other words, only when &REST or &KEY is
93 (more-args-entry-point nil :type (or null (unsigned-byte 24)))
94 ;; The number of ``more-arg'' args.
95 (num-more-args 0 :type (integer 0 #.call-arguments-limit))
96 ;; True if there is a rest-arg.
97 (rest-arg-p nil :type (member t nil))
98 ;; True if there are keywords. Note: keywords might still be NIL
99 ;; because having &KEY with no keywords is valid and should result
100 ;; in allow-other-keys processing. If :allow-others, then allow
102 (keywords-p nil :type (member t nil :allow-others))
103 ;; List of keyword arguments. Each element is a list of:
104 ;; key, default, supplied-p.
105 (keywords nil :type list))
107 #!-sb-fluid (declaim (freeze-type byte-function-or-closure))