0.pre7.85:
[sbcl.git] / src / compiler / node.lisp
index 41d2953..d3e7d5f 100644 (file)
   ;; 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.
 (defstruct (block-annotation (:constructor nil)
                             (:copier nil))
   ;; The IR1 block that this block is in the INFO for.
-  (block (required-argument) :type cblock)
+  (block (missing-arg) :type cblock)
   ;; the next and previous block in emission order (not DFO). This
   ;; determines which block we drop though to, and also used to chain
   ;; together overflow blocks that result from splitting of IR2 blocks
   ;; 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))
   ;; This becomes a list of the CLAMBDA structures for all functions
   ;; 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
+  ;; arguments for the note, or the FUN-TYPE that would have
   ;; enabled the transformation but failed to match.
   (failed-optimizations (make-hash-table :test 'eq) :type hash-table)
   ;; This is similar to NEW-FUNCTIONS, but is used when a function has
 ;;; change.
 (defstruct (cleanup (:copier nil))
   ;; the kind of thing that has to be cleaned up
-  (kind (required-argument)
+  (kind (missing-arg)
        :type (member :special-bind :catch :unwind-protect :block :tagbody))
   ;; 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.
+  ;; this cleanup. This is filled in by physical environment analysis.
   (nlx-info nil :type list))
 (defprinter (cleanup :identity t)
   kind
   mess-up
   (nlx-info :test nlx-info))
 
-;;; original CMU CL comment:
-;;;   An ENVIRONMENT structure represents the result of environment
-;;;   analysis.
+;;; 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
 ;;; 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-ENVIRONMENT
+;;; 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 (environment (:copier nil))
-  ;; the function that allocates this environment
-  (function (required-argument) :type clambda)
-  ;; a list of all the lambdas that allocate variables in this environment
+(defstruct (physenv (:copier nil))
+  ;; the function that allocates this physical environment
+  (function (missing-arg) :type clambda)
+  #| ; 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)
+  |#
   ;; This ultimately converges to a list of all the LAMBDA-VARs and
   ;; NLX-INFOs needed from enclosing environments by code in this
-  ;; environment. In the meantime, it may be
+  ;; 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
+  ;; into this physical environment
   (nlx-info nil :type list)
   ;; some kind of info used by the back end
   (info nil))
-(defprinter (environment :identity t)
+(defprinter (physenv :identity t)
   function
   (closure :test closure)
   (nlx-info :test nlx-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,
   ;; and not the cleanup for the escape block. The CLEANUP-KIND of
   ;; this thus provides a good indication of what kind of exit is
   ;; being done.
-  (cleanup (required-argument) :type cleanup)
+  (cleanup (missing-arg) :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
   ;; For this purpose, the Entry must also be used to disambiguate,
   ;; 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
+  (continuation (missing-arg) :type continuation)
+  ;; 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
   ;; GLOBAL-VAR, this is the symbol name of the variable. In a
   ;; functional that is from a DEFUN, this is the defined name. In
   ;; other functionals, this is a descriptive string.
+  ;;
+  ;; KLUDGE: Note that at least for LAMBDA-VARs, this is important not
+  ;; just for debugging but for ordinary compilation as well. In
+  ;; particular, in RECOGNIZE-KNOWN-CALL function calls are compiled
+  ;; differently based on the LEAF-NAME.
   (name nil :type t)
   ;; the type which values of this leaf must have
   (type *universal-type* :type ctype)
 ;;; constant, but don't know what the value is at compile time.
 (def!struct (global-var (:include basic-var))
   ;; kind of variable described
-  (kind (required-argument)
-       :type (member :special :global-function :constant :global)))
+  (kind (missing-arg)
+       :type (member :special :global-function :global)))
 (defprinter (global-var :identity t)
   name
   (type :test (not (eq type *universal-type*)))
                                     (where-from :defined)
                                     (kind :global-function)))
   ;; The description of the structure that this is an accessor for.
-  (for (required-argument) :type sb!xc:class)
+  (for (missing-arg) :type sb!xc:class)
   ;; The slot description of the slot.
-  (slot (required-argument)))
+  (slot (missing-arg)))
 (defprinter (slot-accessor :identity t)
   name
   for
   slot)
 
-;;; The DEFINED-FUNCTION structure represents functions that are
-;;; 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.
-(def!struct (defined-function (:include global-var
-                                       (where-from :defined)
-                                       (kind :global-function)))
+;;; A DEFINED-FUN represents a function that is defined in the same
+;;; compilation block, or that has an inline expansion, or that has 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.
+(def!struct (defined-fun (:include global-var
+                                  (where-from :defined)
+                                  (kind :global-function)))
   ;; The values of INLINEP and INLINE-EXPANSION initialized from the
   ;; global environment.
   (inlinep nil :type inlinep)
   (inline-expansion nil :type (or cons null))
-  ;; The block-local definition of this function (either because it
-  ;; was semi-inline, or because it was defined in this block.) If
+  ;; the block-local definition of this function (either because it
+  ;; was semi-inline, or because it was defined in this block). If
   ;; this function is not an entry point, then this may be deleted or
-  ;; let-converted. Null if we haven't converted the expansion yet.
+  ;; LET-converted. Null if we haven't converted the expansion yet.
   (functional nil :type (or functional null)))
-(defprinter (defined-function :identity t)
+(defprinter (defined-fun :identity t)
   name
   inlinep
   (functional :test functional))
 (def!struct (functional (:include leaf
                                  (where-from :defined)
                                  (type (specifier-type 'function))))
-  ;; Some information about how this function is used. These values are
-  ;; meaningful:
+  ;; some information about how this function is used. These values
+  ;; are meaningful:
   ;;
   ;;    NIL
   ;;   an ordinary function, callable using local call
   ;; (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
+  ;; the structure which represents the phsical 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))
+  ;; 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),
   ;; we will still have caller's lexenv to figure out which cleanup is
   (specialp nil :type boolean)
   ;; the kind of argument being described. Required args only have arg
   ;; info structures if they are special.
-  (kind (required-argument) :type (member :required :optional :keyword :rest
-                                         :more-context :more-count))
+  (kind (missing-arg)
+       :type (member :required :optional :keyword :rest
+                     :more-context :more-count))
   ;; If true, this is the VAR for SUPPLIED-P variable of a keyword or
   ;; optional arg. This is true for keywords with non-constant
   ;; defaults even when there is no user-specified supplied-p var.
 ;;; 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:
                (:constructor make-if)
                (:copier copy-if))
   ;; CONTINUATION for the predicate
-  (test (required-argument) :type continuation)
+  (test (missing-arg) :type continuation)
   ;; the blocks that we execute next in true and false case,
   ;; respectively (may be the same)
-  (consequent (required-argument) :type cblock)
-  (alternative (required-argument) :type cblock))
+  (consequent (missing-arg) :type cblock)
+  (alternative (missing-arg) :type cblock))
 (defprinter (cif :conc-name if- :identity t)
   (test :prin1 (continuation-use test))
   consequent
                 (:constructor make-set)
                 (:copier copy-set))
   ;; descriptor for the variable set
-  (var (required-argument) :type basic-var)
+  (var (missing-arg) :type basic-var)
   ;; continuation for the value form
-  (value (required-argument) :type continuation))
+  (value (missing-arg) :type continuation))
 (defprinter (cset :conc-name set- :identity t)
   var
   (value :prin1 (continuation-use value)))
                              (:constructor nil)
                              (:copier nil))
   ;; continuation for the function
-  (fun (required-argument) :type continuation)
+  (fun (missing-arg) :type continuation)
   ;; list of CONTINUATIONs for the args. In a local call, an argument
   ;; continuation may be replaced with NIL to indicate that the
   ;; corresponding variable is unreferenced, and thus no argument
   ;; ir1tran.
   (lambda nil :type (or clambda null))
   ;; the continuation which yields the value of the lambda
-  (result (required-argument) :type continuation)
+  (result (missing-arg) :type continuation)
   ;; the union of the node-derived-type of all uses of the result
   ;; other than by a local call, intersected with the result's
   ;; asserted-type. If there are no non-call uses, this is
   ;; the name of the unknown thing
   (name nil :type (or symbol list))
   ;; the kind of reference to NAME
-  (kind (required-argument) :type (member :function :type :variable))
+  (kind (missing-arg) :type (member :function :type :variable))
   ;; the number of times this thing was used
   (count 0 :type unsigned-byte)
   ;; a list of COMPILER-ERROR-CONTEXT structures describing places
 
 #!-sb-fluid
 (declaim (freeze-type node leaf lexenv continuation cblock component cleanup
-                     environment tail-set nlx-info))
+                     physenv tail-set nlx-info))