(def!struct (continuation
(:make-load-form-fun ignore-it)
(:constructor make-continuation (&optional dest)))
- ;; An indication of the way that this continuation is currently used:
+ ;; an indication of the way that this continuation is currently used
;;
;; :UNUSED
;; A continuation for which all control-related slots have the
;; A continuation that is the CONT of some node in BLOCK.
(kind :unused :type (member :unused :deleted :inside-block :block-start
:deleted-block-start))
- ;; The node which receives this value, if any. In a deleted continuation,
- ;; this is null even though the node that receives this continuation may not
- ;; yet be deleted.
+ ;; The node which receives this value, if any. In a deleted
+ ;; continuation, this is null even though the node that receives
+ ;; this continuation may not yet be deleted.
(dest nil :type (or node null))
;; If this is a NODE, then it is the node which is to be evaluated
;; next. This is always null in :DELETED and :UNUSED continuations,
;; Following the introduced forms is a representation of the
;; location of the enclosing original source form. This transition
;; is indicated by the magic ORIGINAL-SOURCE-START marker. The first
- ;; element of the orignal source is the "form number", which is the
+ ;; element of the original source is the "form number", which is the
;; ordinal number of this form in a depth-first, left-to-right walk
;; of the truly top-level form in which this appears.
;;
;;
;; The last element in the list is the top-level form number, which
;; is the ordinal number (in this call to the compiler) of the truly
- ;; top-level form containing the orignal source.
+ ;; top-level form containing the original source.
(source-path *current-path* :type list)
;; If this node is in a tail-recursive position, then this is set to
- ;; T. At the end of IR1 (in environment analysis) this is computed
- ;; for all nodes (after cleanup code has been emitted). Before then,
- ;; a non-null value indicates that IR1 optimization has converted a
- ;; tail local call to a direct transfer.
+ ;; T. At the end of IR1 (in physical environment analysis) this is
+ ;; computed for all nodes (after cleanup code has been emitted).
+ ;; Before then, a non-null value indicates that IR1 optimization has
+ ;; converted a tail local call to a direct transfer.
;;
;; If the back-end breaks tail-recursion for some reason, then it
;; can null out this slot.
(flags (block-attributes reoptimize flush-p type-check type-asserted
test-modified)
:type attributes)
- ;; Some sets used by constraint propagation.
- (kill nil)
+ ;; CMU CL had a KILL slot here, documented as "set used by
+ ;; constraint propagation", which was used in constraint propagation
+ ;; as a list of LAMBDA-VARs killed, and in copy propagation as an
+ ;; SSET, representing I dunno what. I (WHN) found this confusing,
+ ;; and furthermore it caused type errors when I was trying to make
+ ;; the compiler produce fully general LAMBDA functions directly
+ ;; (instead of doing as CMU CL always did, producing extra little
+ ;; functions which return the LAMDBA you need) and therefore taking
+ ;; a new path through the compiler. So I split this into two:
+ ;; KILL-LIST = list of LAMBDA-VARs killed, used in constraint propagation
+ ;; KILL-SSET = an SSET value, used in copy propagation
+ (kill-list nil :type list)
+ (kill-sset nil :type (or sset null))
+ ;; other sets used in constraint propagation and/or copy propagation
(gen nil)
(in nil)
(out nil)
;; initially NIL so that FIND-INITIAL-DFO doesn't have to scan the
;; entire initial component just to clear the flags.
(flag nil)
- ;; Some kind of info used by the back end.
+ ;; some kind of info used by the back end
(info nil)
;; If true, then constraints that hold in this block and its
;; successors by merit of being tested by its IF predecessor.
(print-unreadable-object (cblock stream :type t :identity t)
(format stream ":START c~D" (cont-num (block-start cblock)))))
-;;; The Block-Annotation structure is shared (via :INCLUDE) by
-;;; different block-info annotation structures so that code
+;;; The BLOCK-ANNOTATION class is inherited (via :INCLUDE) by
+;;; different BLOCK-INFO annotation structures so that code
;;; (specifically control analysis) can be shared.
(defstruct (block-annotation (:constructor nil)
(:copier nil))
(next nil :type (or block-annotation null))
(prev nil :type (or block-annotation null)))
-;;; The Component structure provides a handle on a connected piece of
+;;; A COMPONENT structure provides a handle on a connected piece of
;;; the flow graph. Most of the passes in the compiler operate on
-;;; components rather than on the entire flow graph.
+;;; COMPONENTs rather than on the entire flow graph.
(defstruct (component (:copier nil))
- ;; The kind of component:
- ;;
- ;; NIL
- ;; An ordinary component, containing non-top-level code.
+ ;; the kind of component
;;
- ;; :Top-Level
- ;; A component containing only load-time code.
+ ;; (The terminology here is left over from before
+ ;; sbcl-0.pre7.34.flaky5.2, when there was no such thing as
+ ;; FUNCTIONAL-HAS-EXTERNAL-REFERENCES-P, so that Python was
+ ;; incapable of building standalone :EXTERNAL functions, but instead
+ ;; had to implement things like #'CL:COMPILE as FUNCALL of a little
+ ;; toplevel stub whose sole purpose was to return an :EXTERNAL
+ ;; function.)
;;
- ;; :Complex-Top-Level
- ;; A component containing both top-level and run-time code.
+ ;; The possibilities are:
+ ;; NIL
+ ;; an ordinary component, containing non-top-level code
+ ;; :TOP-LEVEL
+ ;; a component containing only load-time code
+ ;; :COMPLEX-TOP-LEVEL
+ ;; In the old system, before FUNCTIONAL-HAS-EXTERNAL-REFERENCES-P
+ ;; was defined, this was necessarily a component containing both
+ ;; top-level and run-time code. Now this state is also used for
+ ;; a component with HAS-EXTERNAL-REFERENCES-P functionals in it.
+ ;; :INITIAL
+ ;; the result of initial IR1 conversion, on which component
+ ;; analysis has not been done
+ ;; :DELETED
+ ;; debris left over from component analysis
;;
- ;; :Initial
- ;; The result of initial IR1 conversion, on which component
- ;; analysis has not been done.
- ;;
- ;; :Deleted
- ;; Debris left over from component analysis.
+ ;; See also COMPONENT-TOP-LEVELISH-P.
(kind nil :type (member nil :top-level :complex-top-level :initial :deleted))
- ;; The blocks that are the dummy head and tail of the DFO.
+ ;; the blocks that are the dummy head and tail of the DFO
+ ;;
;; Entry/exit points have these blocks as their
;; predecessors/successors. Null temporarily. The start and return
;; from each non-deleted function is linked to the component head
- ;; and tail. Until environment analysis links NLX entry stubs to the
- ;; component head, every successor of the head is a function start
- ;; (i.e. begins with a Bind node.)
+ ;; and tail. Until physical environment analysis links NLX entry
+ ;; stubs to the component head, every successor of the head is a
+ ;; function start (i.e. begins with a BIND node.)
(head nil :type (or null cblock))
(tail nil :type (or null cblock))
- ;; A list of the CLambda structures for all functions in this
- ;; component. Optional-Dispatches are represented only by their XEP
- ;; and other associated lambdas. This doesn't contain any deleted or
- ;; let lambdas.
+ ;; This becomes a list of the CLAMBDA structures for all functions
+ ;; in this component. OPTIONAL-DISPATCHes are represented only by
+ ;; their XEP and other associated lambdas. This doesn't contain any
+ ;; deleted or LET lambdas.
+ ;;
+ ;; Note that logical associations between CLAMBDAs and COMPONENTs
+ ;; seem to exist for a while before this is initialized. In
+ ;; particular, I got burned by writing some code to use this value
+ ;; to decide which components need LOCAL-CALL-ANALYZE, when it turns
+ ;; out that LOCAL-CALL-ANALYZE had a role in initializing this value
+ ;; (and DFO stuff does too, maybe). Also, even after it's
+ ;; initialized, it might change as CLAMBDAs are deleted or merged.
+ ;; -- WHN 2001-09-30
(lambdas () :type list)
- ;; A list of Functional structures for functions that are newly
+ ;; a list of FUNCTIONAL structures for functions that are newly
;; converted, and haven't been local-call analyzed yet. Initially
- ;; functions are not in the Lambdas list. LOCAL-CALL-ANALYZE moves
+ ;; functions are not in the LAMBDAS list. LOCAL-CALL-ANALYZE moves
;; them there (possibly as LETs, or implicitly as XEPs if an
;; OPTIONAL-DISPATCH.) Between runs of LOCAL-CALL-ANALYZE there may
;; be some debris of converted or even deleted functions in this
;; list.
(new-functions () :type list)
- ;; If true, then there is stuff in this component that could benefit
- ;; from further IR1 optimization.
+ ;; If this is true, then there is stuff in this component that could
+ ;; benefit from further IR1 optimization.
(reoptimize t :type boolean)
- ;; If true, then the control flow in this component was messed up by
- ;; IR1 optimizations. The DFO should be recomputed.
+ ;; If this is true, then the control flow in this component was
+ ;; messed up by IR1 optimizations, so the DFO should be recomputed.
(reanalyze nil :type boolean)
- ;; String that is some sort of name for the code in this component.
+ ;; some sort of name for the code in this component
(name "<unknown>" :type simple-string)
- ;; Some kind of info used by the back end.
+ ;; some kind of info used by the back end
(info nil)
- ;; The Source-Info structure describing where this component was
- ;; compiled from.
+ ;; the SOURCE-INFO structure describing where this component was
+ ;; compiled from
(source-info *source-info* :type source-info)
- ;; Count of the number of inline expansions we have done while
+ ;; count of the number of inline expansions we have done while
;; compiling this component, to detect infinite or exponential
- ;; blowups.
+ ;; blowups
(inline-expansions 0 :type index)
- ;; A hashtable from combination nodes to things describing how an
- ;; optimization of the node failed. The value is an alist (Transform
- ;; . Args), where Transform is the structure describing the
- ;; transform that failed, and Args is either a list of format
+ ;; a map from combination nodes to things describing how an
+ ;; optimization of the node failed. The description is an alist
+ ;; (TRANSFORM . ARGS), where TRANSFORM is the structure describing
+ ;; the transform that failed, and ARGS is either a list of format
;; arguments for the note, or the FUNCTION-TYPE that would have
;; enabled the transformation but failed to match.
(failed-optimizations (make-hash-table :test 'eq) :type hash-table)
- ;; Similar to NEW-FUNCTIONS, but is used when a function has already
- ;; been analyzed, but new references have been added by inline
- ;; expansion. Unlike NEW-FUNCTIONS, this is not disjoint from
+ ;; This is similar to NEW-FUNCTIONS, but is used when a function has
+ ;; already been analyzed, but new references have been added by
+ ;; inline expansion. Unlike NEW-FUNCTIONS, this is not disjoint from
;; COMPONENT-LAMBDAS.
(reanalyze-functions nil :type list))
-(defprinter (component)
+(defprinter (component :identity t)
name
(reanalyze :test reanalyze))
-;;; The CLEANUP structure represents some dynamic binding action.
-;;; Blocks are annotated with the current cleanup so that dynamic
-;;; bindings can be removed when control is transferred out of the
-;;; binding environment. We arrange for changes in dynamic bindings to
-;;; happen at block boundaries, so that cleanup code may easily be
-;;; inserted. The "mess-up" action is explicitly represented by a
-;;; funny function call or Entry node.
+;;; Before sbcl-0.7.0, there were :TOP-LEVEL things which were magical
+;;; in multiple ways. That's since been refactored into the orthogonal
+;;; properties "optimized for locall with no arguments" and "externally
+;;; visible/referenced (so don't delete it)". The code <0.7.0 did a lot
+;;; of tests a la (EQ KIND :TOP_LEVEL) in the "don't delete it?" sense;
+;;; this function is a sort of literal translation of those tests into
+;;; the new world.
+;;;
+;;; FIXME: After things settle down, bare :TOP-LEVEL might go away, at
+;;; which time it might be possible to replace the COMPONENT-KIND
+;;; :TOP-LEVEL mess with a flag COMPONENT-HAS-EXTERNAL-REFERENCES-P
+;;; along the lines of FUNCTIONAL-HAS-EXTERNAL-REFERENCES-P.
+(defun lambda-top-levelish-p (clambda)
+ (or (eql (lambda-kind clambda) :top-level)
+ (lambda-has-external-references-p clambda)))
+(defun component-top-levelish-p (component)
+ (member (component-kind component)
+ '(:top-level :complex-top-level)))
+
+;;; A CLEANUP structure represents some dynamic binding action. Blocks
+;;; are annotated with the current CLEANUP so that dynamic bindings
+;;; can be removed when control is transferred out of the binding
+;;; environment. We arrange for changes in dynamic bindings to happen
+;;; at block boundaries, so that cleanup code may easily be inserted.
+;;; The "mess-up" action is explicitly represented by a funny function
+;;; call or ENTRY node.
;;;
-;;; We guarantee that cleanups only need to be done at block boundaries
+;;; We guarantee that CLEANUPs only need to be done at block boundaries
;;; by requiring that the exit continuations initially head their
;;; blocks, and then by not merging blocks when there is a cleanup
;;; change.
(defstruct (cleanup (:copier nil))
- ;; The kind of thing that has to be cleaned up.
+ ;; the kind of thing that has to be cleaned up
(kind (required-argument)
:type (member :special-bind :catch :unwind-protect :block :tagbody))
- ;; The node that messes things up. This is the last node in the
+ ;; the node that messes things up. This is the last node in the
;; non-messed-up environment. Null only temporarily. This could be
;; deleted due to unreachability.
(mess-up nil :type (or node null))
- ;; A list of all the NLX-Info structures whose NLX-Info-Cleanup is
- ;; this cleanup. This is filled in by environment analysis.
+ ;; a list of all the NLX-INFO structures whose NLX-INFO-CLEANUP is
+ ;; this cleanup. This is filled in by physical environment analysis.
(nlx-info nil :type list))
-(defprinter (cleanup)
+(defprinter (cleanup :identity t)
kind
mess-up
(nlx-info :test nlx-info))
-;;; The ENVIRONMENT structure represents the result of environment analysis.
-(defstruct (environment (:copier nil))
- ;; the function that allocates this environment
+;;; A PHYSENV represents the result of physical environment analysis.
+;;;
+;;; As far as I can tell from reverse engineering, this IR1 structure
+;;; represents the physical environment (which is probably not the
+;;; standard Lispy term for this concept, but I dunno what is the
+;;; standard term): those things in the lexical environment which a
+;;; LAMBDA actually interacts with. Thus in
+;;; (DEFUN FROB-THINGS (THINGS)
+;;; (DOLIST (THING THINGS)
+;;; (BLOCK FROBBING-ONE-THING
+;;; (MAPCAR (LAMBDA (PATTERN)
+;;; (WHEN (FITS-P THING PATTERN)
+;;; (RETURN-FROM FROB-THINGS (LIST :FIT THING PATTERN))))
+;;; *PATTERNS*))))
+;;; the variables THINGS, THING, and PATTERN and the block names
+;;; FROB-THINGS and FROBBING-ONE-THING are all in the inner LAMBDA's
+;;; lexical environment, but of those only THING, PATTERN, and
+;;; FROB-THINGS are in its physical environment. In IR1, we largely
+;;; just collect the names of these things; in IR2 an IR2-PHYSENV
+;;; structure is attached to INFO and used to keep track of
+;;; associations between these names and less-abstract things (like
+;;; TNs, or eventually stack slots and registers). -- WHN 2001-09-29
+(defstruct (physenv (:copier nil))
+ ;; the function that allocates this physical environment
(function (required-argument) :type clambda)
- ;; a list of all the lambdas that allocate variables in this environment
+ #| ; seems not to be used as of sbcl-0.pre7.51
+ ;; a list of all the lambdas that allocate variables in this
+ ;; physical environment
(lambdas nil :type list)
- ;; a list of all the lambda-vars and NLX-Infos needed from enclosing
- ;; environments by code in this environment
+ |#
+ ;; This ultimately converges to a list of all the LAMBDA-VARs and
+ ;; NLX-INFOs needed from enclosing environments by code in this
+ ;; physical environment. In the meantime, it may be
+ ;; * NIL at object creation time
+ ;; * a superset of the correct result, generated somewhat later
+ ;; * smaller and smaller sets converging to the correct result as
+ ;; we notice and delete unused elements in the superset
(closure nil :type list)
- ;; a list of NLX-Info structures describing all the non-local exits
- ;; into this environment
+ ;; a list of NLX-INFO structures describing all the non-local exits
+ ;; into this physical environment
(nlx-info nil :type list)
;; some kind of info used by the back end
(info nil))
-(defprinter (environment)
+(defprinter (physenv :identity t)
function
(closure :test closure)
(nlx-info :test nlx-info))
-;;; The TAIL-SET structure is used to accumulate information about
+;;; An TAIL-SET structure is used to accumulate information about
;;; tail-recursive local calls. The "tail set" is effectively the
;;; transitive closure of the "is called tail-recursively by"
;;; relation.
;;; sets of the called function and the calling function.
;;;
;;; The tail set is somewhat approximate, because it is too early to
-;;; be sure which calls will be TR. Any call that *might* end up TR
-;;; causes tail-set merging.
-(defstruct (tail-set (:copier nil))
- ;; a list of all the lambdas in this tail set
+;;; be sure which calls will be tail-recursive. Any call that *might*
+;;; end up tail-recursive causes TAIL-SET merging.
+(defstruct (tail-set)
+ ;; a list of all the LAMBDAs in this tail set
(functions nil :type list)
;; our current best guess of the type returned by these functions.
;; This is the union across all the functions of the return node's
- ;; RESULT-TYPE. excluding local calls.
+ ;; RESULT-TYPE, excluding local calls.
(type *wild-type* :type ctype)
;; some info used by the back end
(info nil))
-(defprinter (tail-set)
+(defprinter (tail-set :identity t)
functions
type
(info :test info))
;;; The NLX-Info structure is used to collect various information
;;; about non-local exits. This is effectively an annotation on the
;;; CONTINUATION, although it is accessed by searching in the
-;;; ENVIRONMENT-NLX-INFO.
+;;; PHYSENV-NLX-INFO.
(def!struct (nlx-info (:make-load-form-fun ignore-it))
;; the cleanup associated with this exit. In a catch or
;; unwind-protect, this is the :CATCH or :UNWIND-PROTECT cleanup,
(cleanup (required-argument) :type cleanup)
;; the continuation exited to (the CONT of the EXIT nodes). If this
;; exit is from an escape function (CATCH or UNWIND-PROTECT), then
- ;; environment analysis deletes the escape function and instead has
- ;; the %NLX-ENTRY use this continuation.
+ ;; physical environment analysis deletes the escape function and
+ ;; instead has the %NLX-ENTRY use this continuation.
;;
;; This slot is primarily an indication of where this exit delivers
;; its values to (if any), but it is also used as a sort of name to
;; since exits to different places may deliver their result to the
;; same continuation.
(continuation (required-argument) :type continuation)
- ;; the entry stub inserted by environment analysis. This is a block
- ;; containing a call to the %NLX-Entry funny function that has the
- ;; original exit destination as its successor. Null only
+ ;; the entry stub inserted by physical environment analysis. This is
+ ;; a block containing a call to the %NLX-Entry funny function that
+ ;; has the original exit destination as its successor. Null only
;; temporarily.
(target nil :type (or cblock null))
;; some kind of info used by the back end
info)
-(defprinter (nlx-info)
+(defprinter (nlx-info :identity t)
continuation
target
info)
;; :DECLARED, from a declaration.
;; :ASSUMED, from uses of the object.
;; :DEFINED, from examination of the definition.
- ;; FIXME: This should be a named type. (LEAF-WHERE-FROM?)
+ ;; FIXME: This should be a named type. (LEAF-WHERE-FROM? Or
+ ;; perhaps just WHERE-FROM, since it's not just used in LEAF,
+ ;; but also in various DEFINE-INFO-TYPEs in globaldb.lisp,
+ ;; and very likely elsewhere too.)
(where-from :assumed :type (member :declared :assumed :defined))
;; list of the REF nodes for this leaf
(refs () :type list)
(def!struct (constant (:include leaf))
;; the value of the constant
(value nil :type t))
-(defprinter (constant)
+(defprinter (constant :identity t)
(name :test name)
value)
;; kind of variable described
(kind (required-argument)
:type (member :special :global-function :constant :global)))
-(defprinter (global-var)
+(defprinter (global-var :identity t)
name
(type :test (not (eq type *universal-type*)))
(where-from :test (not (eq where-from :assumed)))
(for (required-argument) :type sb!xc:class)
;; The slot description of the slot.
(slot (required-argument)))
-(defprinter (slot-accessor)
+(defprinter (slot-accessor :identity t)
name
for
slot)
;;; defined in the same compilation block, or that have inline
;;; expansions, or have a non-NIL INLINEP value. Whenever we change
;;; the INLINEP state (i.e. an inline proclamation) we copy the
-;;; structure so that former inlinep values are preserved.
+;;; structure so that former INLINEP values are preserved.
(def!struct (defined-function (:include global-var
(where-from :defined)
(kind :global-function)))
;; this function is not an entry point, then this may be deleted or
;; let-converted. Null if we haven't converted the expansion yet.
(functional nil :type (or functional null)))
-(defprinter (defined-function)
+(defprinter (defined-function :identity t)
name
inlinep
(functional :test functional))
;; Similar to NIL, but requires greater caution, since local call
;; analysis may create new references to this function. Also, the
;; function cannot be deleted even if it has *no* references. The
- ;; Optional-Dispatch is in the LAMDBA-OPTIONAL-DISPATCH.
+ ;; OPTIONAL-DISPATCH is in the LAMDBA-OPTIONAL-DISPATCH.
;;
;; :EXTERNAL
;; an external entry point lambda. The function it is an entry
- ;; for is in the Entry-Function.
+ ;; for is in the ENTRY-FUNCTION slot.
;;
;; :TOP-LEVEL
;; a top-level lambda, holding a compiled top-level form.
;; :DELETED
;; This function has been found to be uncallable, and has been
;; marked for deletion.
- (kind nil :type (member nil :optional :deleted :external :top-level :escape
- :cleanup :let :mv-let :assignment
+ (kind nil :type (member nil :optional :deleted :external :top-level
+ :escape :cleanup :let :mv-let :assignment
:top-level-xep))
+ ;; Is this a function that some external entity (e.g. the fasl dumper)
+ ;; refers to, so that even when it appears to have no references, it
+ ;; shouldn't be deleted? In the old days (before
+ ;; sbcl-0.pre7.37.flaky5.2) this was sort of implicitly true when
+ ;; KIND was :TOP-LEVEL. Now it must be set explicitly, both for
+ ;; :TOP-LEVEL functions and for any other kind of functions that we
+ ;; want to dump or return from #'CL:COMPILE or whatever.
+ (has-external-references-p nil)
;; In a normal function, this is the external entry point (XEP)
;; lambda for this function, if any. Each function that is used
;; other than in a local call has an XEP, and all of the
;; non-local-call references are replaced with references to the
;; XEP.
;;
- ;; In an XEP lambda (indicated by the :External kind), this is the
+ ;; In an XEP lambda (indicated by the :EXTERNAL kind), this is the
;; function that the XEP is an entry-point for. The body contains
;; local calls to all the actual entry points in the function. In a
- ;; :Top-Level lambda (which is its own XEP) this is a self-pointer.
+ ;; :TOP-LEVEL lambda (which is its own XEP) this is a self-pointer.
;;
;; With all other kinds, this is null.
(entry-function nil :type (or functional null))
(arg-documentation nil :type (or list (member :unspecified)))
;; various rare miscellaneous info that drives code generation & stuff
(plist () :type list))
-(defprinter (functional)
+(defprinter (functional :identity t)
name)
;;; The CLAMBDA only deals with required lexical arguments. Special,
(:predicate lambda-p)
(:constructor make-lambda)
(:copier copy-lambda))
- ;; List of lambda-var descriptors for args.
+ ;; list of LAMBDA-VAR descriptors for args
(vars nil :type list)
;; If this function was ever a :OPTIONAL function (an entry-point
- ;; for an optional-dispatch), then this is that optional-dispatch.
+ ;; for an OPTIONAL-DISPATCH), then this is that OPTIONAL-DISPATCH.
;; The optional dispatch will be :DELETED if this function is no
;; longer :OPTIONAL.
(optional-dispatch nil :type (or optional-dispatch null))
- ;; The Bind node for this Lambda. This node marks the beginning of
+ ;; the BIND node for this LAMBDA. This node marks the beginning of
;; the lambda, and serves to explicitly represent the lambda binding
- ;; semantics within the flow graph representation. Null in deleted
- ;; functions, and also in LETs where we deleted the call & bind
- ;; (because there are no variables left), but have not yet actually
- ;; deleted the lambda yet.
+ ;; semantics within the flow graph representation. This is null in
+ ;; deleted functions, and also in LETs where we deleted the call and
+ ;; bind (because there are no variables left), but have not yet
+ ;; actually deleted the LAMBDA yet.
(bind nil :type (or bind null))
- ;; The Return node for this Lambda, or NIL if it has been deleted.
+ ;; the RETURN node for this LAMBDA, or NIL if it has been deleted.
;; This marks the end of the lambda, receiving the result of the
- ;; body. In a let, the return node is deleted, and the body delivers
+ ;; body. In a LET, the return node is deleted, and the body delivers
;; the value to the actual continuation. The return may also be
;; deleted if it is unreachable.
(return nil :type (or creturn null))
- ;; If this is a let, then the Lambda whose Lets list we are in,
- ;; otherwise this is a self-pointer.
+ ;; If this CLAMBDA is a LET, then this slot holds the LAMBDA whose
+ ;; LETS list we are in, otherwise it is a self-pointer.
(home nil :type (or clambda null))
- ;; A list of all the all the lambdas that have been let-substituted
+ ;; a list of all the all the lambdas that have been LET-substituted
;; in this lambda. This is only non-null in lambdas that aren't
- ;; lets.
+ ;; LETs.
(lets () :type list)
- ;; A list of all the Entry nodes in this function and its lets. Null
- ;; an a let.
+ ;; a list of all the ENTRY nodes in this function and its LETs, or
+ ;; null in a LET
(entries () :type list)
- ;; A list of all the functions directly called from this function
- ;; (or one of its lets) using a non-let local call. May include
+ ;; a list of all the functions directly called from this function
+ ;; (or one of its LETs) using a non-LET local call. This may include
;; deleted functions because nobody bothers to clear them out.
(calls () :type list)
- ;; The Tail-Set that this lambda is in. Null during creation and in
- ;; let lambdas.
+ ;; the TAIL-SET that this LAMBDA is in. This is null during creation.
+ ;;
+ ;; In CMU CL, and old SBCL, this was also NILed out when LET
+ ;; conversion happened. That caused some problems, so as of
+ ;; sbcl-0.pre7.37.flaky5.2 when I was trying to get the compiler to
+ ;; emit :EXTERNAL functions directly, and so now the value
+ ;; is no longer NILed out in LET conversion, but instead copied
+ ;; (so that any further optimizations on the rest of the tail
+ ;; set won't modify the value) if necessary.
(tail-set nil :type (or tail-set null))
- ;; The structure which represents the environment that this
- ;; Function's variables are allocated in. This is filled in by
- ;; environment analysis. In a let, this is EQ to our home's
- ;; environment.
- (environment nil :type (or environment null))
+ ;; the structure which represents the phsical environment that this
+ ;; function's variables are allocated in. This is filled in by
+ ;; physical environment analysis. In a LET, this is EQ to our home's
+ ;; physical environment.
+ (physenv nil :type (or physenv null))
;; In a LET, this is the NODE-LEXENV of the combination node. We
- ;; retain it so that if the let is deleted (due to a lack of vars),
+ ;; retain it so that if the LET is deleted (due to a lack of vars),
;; we will still have caller's lexenv to figure out which cleanup is
;; in effect.
(call-lexenv nil :type (or lexenv null)))
-(defprinter (clambda :conc-name lambda-)
+(defprinter (clambda :conc-name lambda- :identity t)
name
(type :test (not (eq type *universal-type*)))
(where-from :test (not (eq where-from :assumed)))
;;; point tail-recursively, passing all the arguments passed in and
;;; the default for the argument the entry point is for. The last
;;; entry point calls the real body of the function. In the presence
-;;; of supplied-p args and other hair, things are more complicated. In
+;;; of SUPPLIED-P args and other hair, things are more complicated. In
;;; general, there is a distinct internal function that takes the
-;;; supplied-p args as parameters. The preceding entry point calls
-;;; this function with NIL filled in for the supplied-p args, while
-;;; the current entry point calls it with T in the supplied-p
+;;; SUPPLIED-P args as parameters. The preceding entry point calls
+;;; this function with NIL filled in for the SUPPLIED-P args, while
+;;; the current entry point calls it with T in the SUPPLIED-P
;;; positions.
;;;
;;; Note that it is easy to turn a call with a known number of
;; second, ... MAX-ARGS last. The last entry-point always calls the
;; main entry; in simple cases it may be the main entry.
(entry-points nil :type list)
- ;; An entry point which takes MAX-ARGS fixed arguments followed by
+ ;; an entry point which takes MAX-ARGS fixed arguments followed by
;; an argument context pointer and an argument count. This entry
;; point deals with listifying rest args and parsing keywords. This
;; is null when extra arguments aren't legal.
(more-entry nil :type (or clambda null))
- ;; The main entry-point into the function, which takes all arguments
+ ;; the main entry-point into the function, which takes all arguments
;; including keywords as fixed arguments. The format of the
;; arguments must be determined by examining the arglist. This may
- ;; be used by callers that supply at least Max-Args arguments and
+ ;; be used by callers that supply at least MAX-ARGS arguments and
;; know what they are doing.
(main-entry nil :type (or clambda null)))
-(defprinter (optional-dispatch)
+(defprinter (optional-dispatch :identity t)
name
(type :test (not (eq type *universal-type*)))
(where-from :test (not (eq where-from :assumed)))
;; the actual key for a &KEY argument. Note that in ANSI CL this is not
;; necessarily a keyword: (DEFUN FOO (&KEY ((BAR BAR))) ..).
(key nil :type symbol))
-(defprinter (arg-info)
+(defprinter (arg-info :identity t)
(specialp :test specialp)
kind
(supplied-p :test supplied-p)
;;; lambda arguments which may ultimately turn out not to be simple
;;; and lexical.
;;;
-;;; LAMBDA-VARs with no REFs are considered to be deleted; environment
-;;; analysis isn't done on these variables, so the back end must check
-;;; for and ignore unreferenced variables. Note that a deleted
-;;; lambda-var may have sets; in this case the back end is still
-;;; responsible for propagating the Set-Value to the set's Cont.
+;;; LAMBDA-VARs with no REFs are considered to be deleted; physical
+;;; environment analysis isn't done on these variables, so the back
+;;; end must check for and ignore unreferenced variables. Note that a
+;;; deleted lambda-var may have sets; in this case the back end is
+;;; still responsible for propagating the Set-Value to the set's Cont.
(def!struct (lambda-var (:include basic-var))
;; true if this variable has been declared IGNORE
(ignorep nil :type boolean)
;; the CLAMBDA that this var belongs to. This may be null when we are
;; building a lambda during IR1 conversion.
(home nil :type (or null clambda))
- ;; This is set by environment analysis if it chooses an indirect
- ;; (value cell) representation for this variable because it is both
- ;; set and closed over.
+ ;; This is set by physical environment analysis if it chooses an
+ ;; indirect (value cell) representation for this variable because it
+ ;; is both set and closed over.
(indirect nil :type boolean)
;; The following two slots are only meaningful during IR1 conversion
;; of hairy lambda vars:
;; determine that this is a set closure variable, and is thus not a
;; good subject for flow analysis.
(constraints nil :type (or sset null)))
-(defprinter (lambda-var)
+(defprinter (lambda-var :identity t)
name
(type :test (not (eq type *universal-type*)))
(where-from :test (not (eq where-from :assumed)))
(:copier nil))
;; The leaf referenced.
(leaf nil :type leaf))
-(defprinter (ref)
+(defprinter (ref :identity t)
leaf)
;;; Naturally, the IF node always appears at the end of a block.
;; respectively (may be the same)
(consequent (required-argument) :type cblock)
(alternative (required-argument) :type cblock))
-(defprinter (cif :conc-name if-)
+(defprinter (cif :conc-name if- :identity t)
(test :prin1 (continuation-use test))
consequent
alternative)
(var (required-argument) :type basic-var)
;; continuation for the value form
(value (required-argument) :type continuation))
-(defprinter (cset :conc-name set-)
+(defprinter (cset :conc-name set- :identity t)
var
(value :prin1 (continuation-use value)))
(defstruct (combination (:include basic-combination)
(:constructor make-combination (fun))
(:copier nil)))
-(defprinter (combination)
+(defprinter (combination :identity t)
(fun :prin1 (continuation-use fun))
(args :prin1 (mapcar (lambda (x)
(if x
;; asserted-type. If there are no non-call uses, this is
;; *EMPTY-TYPE*
(result-type *wild-type* :type ctype))
-(defprinter (creturn :conc-name return-)
+(defprinter (creturn :conc-name return- :identity t)
lambda
result-type)
\f
(exits nil :type list)
;; The cleanup for this entry. NULL only temporarily.
(cleanup nil :type (or cleanup null)))
-(defprinter (entry))
+(defprinter (entry :identity t))
;;; The EXIT node marks the place at which exit code would be emitted,
;;; if necessary. This is interposed between the uses of the exit
;; The continuation yeilding the value we are to exit with. If NIL,
;; then no value is desired (as in GO).
(value nil :type (or continuation null)))
-(defprinter (exit)
+(defprinter (exit :identity t)
(entry :test entry)
(value :test value))
\f
;; *UNDEFINED-WARNING-LIMIT* calls.
(warnings () :type list))
\f
+;;; a helper for the POLICY macro, defined late here so that the
+;;; various type tests can be inlined
+(declaim (ftype (function ((or list lexenv node functional)) list)
+ %coerce-to-policy))
+(defun %coerce-to-policy (thing)
+ (let ((result (etypecase thing
+ (list thing)
+ (lexenv (lexenv-policy thing))
+ (node (lexenv-policy (node-lexenv thing)))
+ (functional (lexenv-policy (functional-lexenv thing))))))
+ ;; Test the first element of the list as a rudimentary sanity
+ ;; that it really does look like a valid policy.
+ (aver (or (null result) (policy-quality-name-p (caar result))))
+ ;; Voila.
+ result))
+\f
;;;; Freeze some structure types to speed type testing.
#!-sb-fluid
(declaim (freeze-type node leaf lexenv continuation cblock component cleanup
- environment tail-set nlx-info))
+ physenv tail-set nlx-info))