;; until it is assigned a block, and may be also be temporarily
;; unused during later manipulations of IR1. In a consistent
;; state there should never be any mention of :UNUSED
- ;; continuations. Next can have a non-null value if the next node
+ ;; continuations. NEXT can have a non-null value if the next node
;; has already been determined.
;;
;; :DELETED
;; the node where this continuation is used, if unique. This is always
;; null in :DELETED and :UNUSED continuations, and is never null in
;; :INSIDE-BLOCK continuations. In a :BLOCK-START continuation, the
- ;; Block's START-USES indicate whether NIL means no uses or more
+ ;; BLOCK's START-USES indicate whether NIL means no uses or more
;; than one use.
(use nil :type (or node null))
;; the basic block this continuation is in. This is null only in
;; will be used. In the latter case, LTN must ensure that a safe
;; implementation *is* used.
;;
- ;; :ERROR
- ;; There is a compile-time type error in some use of this
- ;; continuation. A type check should still be generated, but be
- ;; careful.
- ;;
;; This is computed lazily by CONTINUATION-DERIVED-TYPE, so use
;; CONTINUATION-TYPE-CHECK instead of the %'ed slot accessor.
- (%type-check t :type (member t nil :deleted :no-check :error))
+ (%type-check t :type (member t nil :deleted :no-check))
+ ;; Asserted type, weakend according to policies
+ (type-to-check *wild-type* :type ctype)
+ ;; Cached type which is checked by DEST. If NIL, then this must be
+ ;; recomputed: see CONTINUATION-EXTERNALLY-CHECKABLE-TYPE.
+ (%externally-checkable-type nil :type (or null ctype))
;; something or other that the back end annotates this continuation with
(info nil)
;; uses of this continuation in the lexical environment. They are
;;; Flags that are used to indicate various things about a block, such
;;; as what optimizations need to be done on it:
;;; -- REOPTIMIZE is set when something interesting happens the uses of a
-;;; continuation whose Dest is in this block. This indicates that the
+;;; continuation whose DEST is in this block. This indicates that the
;;; value-driven (forward) IR1 optimizations should be done on this block.
;;; -- FLUSH-P is set when code in this block becomes potentially flushable,
;;; usually due to a continuation's DEST becoming null.
;;; is set when a continuation type assertion is strengthened.
;;; TEST-MODIFIED is set whenever the test for the ending IF has
;;; changed (may be true when there is no IF.)
-(def-boolean-attribute block
+(!def-boolean-attribute block
reoptimize flush-p type-check delete-p type-asserted test-modified)
;;; FIXME: Tweak so that definitions of e.g. BLOCK-DELETE-P is
(flags (block-attributes reoptimize flush-p type-check type-asserted
test-modified)
:type attributes)
- ;; 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))
+ ;; in constraint propagation: list of LAMBDA-VARs killed in this block
+ ;; in copy propagation: list of killed TNs
+ (kill nil)
;; other sets used in constraint propagation and/or copy propagation
(gen nil)
(in nil)
(flag nil)
;; 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.
+ ;; constraints that hold in this block and its successors by merit
+ ;; of being tested by its IF predecessors.
(test-constraint nil :type (or sset null)))
(def!method print-object ((cblock cblock) stream)
(print-unreadable-object (cblock stream :type t :identity t)
- (format stream ":START c~W" (cont-num (block-start cblock)))))
+ (format stream "~W :START c~W"
+ (block-number cblock)
+ (cont-num (block-start cblock)))))
;;; The BLOCK-ANNOTATION class is inherited (via :INCLUDE) by
;;; different BLOCK-INFO annotation structures so that code
;;; size of flow analysis problems, this allows back-end data
;;; structures to be reclaimed after the compilation of each
;;; component.
-(defstruct (component (:copier nil))
+(defstruct (component (:copier nil)
+ (:constructor
+ make-component (head tail &aux (last-block tail))))
;; unique ID for debugging
#!+sb-show (id (new-object-id) :read-only t)
;; the kind of component
;; 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 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))
+ ;; predecessors/successors. The start and return from each
+ ;; non-deleted function is linked to the component head 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 (missing-arg) :type cblock)
+ (tail (missing-arg) :type cblock)
+ ;; New blocks are inserted before this.
+ (last-block (missing-arg) :type cblock)
;; 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
;;
;; Note that logical associations between CLAMBDAs and COMPONENTs
;; seem to exist for a while before this is initialized. See e.g.
- ;; the NEW-FUNS slot. In particular, I got burned by writing some
- ;; code to use this value to decide which components need
+ ;; the NEW-FUNCTIONALS slot. In particular, I got burned by writing
+ ;; some code to use this value to decide which components need
;; LOCALL-ANALYZE-COMPONENT, when it turns out that
;; LOCALL-ANALYZE-COMPONENT had a role in initializing this value
;; (and DFO stuff does too, maybe). Also, even after it's
;; (possibly as LETs, or implicitly as XEPs if an OPTIONAL-DISPATCH.)
;; Between runs of local call analysis there may be some debris of
;; converted or even deleted functions in this list.
- (new-funs () :type list)
+ (new-functionals () :type list)
;; If this is true, then there is stuff in this component that could
;; benefit from further IR1 optimization.
(reoptimize t :type boolean)
;; After I have left the great wheel and am staring into the GC, this
;; is set to :DEAD to indicate that it's a gruesome error to operate
;; on me (e.g. by using me as *CURRENT-COMPONENT*, or by pushing
- ;; LAMBDAs onto my NEW-FUNS, as in sbcl-0.pre7.115).
+ ;; LAMBDAs onto my NEW-FUNCTIONALS, as in sbcl-0.pre7.115).
(info :no-ir2-yet :type (or ir2-component (member :no-ir2-yet :dead)))
;; the SOURCE-INFO structure describing where this component was
;; compiled from
;; 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-FUNS, but is used when a function has
- ;; already been analyzed, but new references have been added by
- ;; inline expansion. Unlike NEW-FUNS, this is not disjoint from
- ;; COMPONENT-LAMBDAS.
- (reanalyze-funs nil :type list))
+ ;; This is similar to NEW-FUNCTIONALS, but is used when a function
+ ;; has already been analyzed, but new references have been added by
+ ;; inline expansion. Unlike NEW-FUNCTIONALS, this is not disjoint
+ ;; from COMPONENT-LAMBDAS.
+ (reanalyze-functionals nil :type list))
(defprinter (component :identity t)
name
#!+sb-show id
;;; Check that COMPONENT is suitable for roles which involve adding
;;; new code. (gotta love imperative programming with lotso in-place
-;;; side-effects...)
+;;; side effects...)
(defun aver-live-component (component)
;; FIXME: As of sbcl-0.pre7.115, we're asserting that
;; COMPILE-COMPONENT hasn't happened yet. Might it be even better
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
+;;; An 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
;;; PHYSENV-NLX-INFO.
(def!struct (nlx-info (:make-load-form-fun ignore-it))
;;
;; 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
- ;; allow us to find the NLX-Info that corresponds to a given exit.
- ;; For this purpose, the Entry must also be used to disambiguate,
+ ;; allow us to find the NLX-INFO that corresponds to a given exit.
+ ;; 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 (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
+ ;; 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))
;; skewed enough (e.g. for macro functions or method functions) that
;; we don't want to have that name affect compilation
;;
+ ;; (We use .ANONYMOUS. here more or less the way we'd ordinarily use
+ ;; NIL, but we're afraid to use NIL because it's a symbol which could
+ ;; be the name of a leaf, if only the constant named NIL.)
+ ;;
;; The value of this slot in can affect ordinary runtime behavior,
;; e.g. of special variables and known functions, not just debugging.
;;
(sets () :type list))
;;; The GLOBAL-VAR structure represents a value hung off of the symbol
-;;; NAME. We use a :CONSTANT VAR when we know that the thing is a
-;;; constant, but don't know what the value is at compile time.
+;;; NAME.
(def!struct (global-var (:include basic-var))
;; kind of variable described
(kind (missing-arg)
(where-from :test (not (eq where-from :assumed)))
kind)
-;;; The SLOT-ACCESSOR structure represents slot accessor functions. It
-;;; is a subtype of GLOBAL-VAR to make it look more like a normal
-;;; function.
-(def!struct (slot-accessor (:include global-var
- (where-from :defined)
- (kind :global-function)))
- ;; The description of the structure that this is an accessor for.
- (for (missing-arg) :type sb!xc:class)
- ;; The slot description of the slot.
- (slot (missing-arg)))
-(defprinter (slot-accessor :identity t)
- %source-name
- for
- slot)
-
;;; 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.
;; Unlike the SOURCE-NAME slot, this slot's value should never
;; affect ordinary code behavior, only debugging/diagnostic behavior.
;;
+ ;; Ha. Ah, the starry-eyed idealism of the writer of the above
+ ;; paragraph. FUNCTION-LAMBDA-EXPRESSION's behaviour, as of
+ ;; sbcl-0.7.11.x, differs if the name of the a function is a string
+ ;; or not, as if it is a valid function name then it can look for an
+ ;; inline expansion.
+ ;;
;; The value of this slot can be anything, except that it shouldn't
;; be a legal function name, since otherwise debugging gets
;; confusing. (If a legal function name is a good name for the
;; continuation for the call.
;;
;; :MV-LET
- ;; Similar to :LET, but the call is an MV-CALL.
+ ;; Similar to :LET (as per FUNCTIONAL-LETLIKE-P), but the call
+ ;; is an MV-CALL.
;;
;; :ASSIGNMENT
- ;; similar to a LET, but can have other than one call as long as
- ;; there is at most one non-tail call.
+ ;; similar to a LET (as per FUNCTIONAL-SOMEWHAT-LETLIKE-P), but
+ ;; can have other than one call as long as there is at most
+ ;; one non-tail call.
;;
;; :OPTIONAL
- ;; a lambda that is an entry-point for an optional-dispatch.
+ ;; a lambda that is an entry point for an OPTIONAL-DISPATCH.
;; 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
;;
;; With all other kinds, this is null.
(entry-fun nil :type (or functional null))
- ;; the value of any inline/notinline declaration for a local function
+ ;; the value of any inline/notinline declaration for a local
+ ;; function (or NIL in any case if no inline expansion is available)
(inlinep nil :type inlinep)
;; If we have a lambda that can be used as in inline expansion for
;; this function, then this is it. If there is no source-level
- ;; lambda corresponding to this function then this is Null (but then
+ ;; lambda corresponding to this function then this is null (but then
;; INLINEP will always be NIL as well.)
(inline-expansion nil :type list)
- ;; the lexical environment that the inline-expansion should be converted in
+ ;; the lexical environment that the INLINE-EXPANSION should be converted in
(lexenv *lexenv* :type lexenv)
;; the original function or macro lambda list, or :UNSPECIFIED if
;; this is a compiler created function
%debug-name
#!+sb-show id)
+;;; Is FUNCTIONAL LET-converted? (where we're indifferent to whether
+;;; it returns one value or multiple values)
+(defun functional-letlike-p (functional)
+ (member (functional-kind functional)
+ '(:let :mv-let)))
+
+;;; Is FUNCTIONAL sorta LET-converted? (where even an :ASSIGNMENT counts)
+;;;
+;;; FIXME: I (WHN) don't understand this one well enough to give a good
+;;; definition or even a good function name, it's just a literal copy
+;;; of a CMU CL idiom. Does anyone have a better name or explanation?
+(defun functional-somewhat-letlike-p (functional)
+ (or (functional-letlike-p functional)
+ (eql (functional-kind functional) :assignment)))
+
;;; FUNCTIONAL name operations
(defun functional-debug-name (functional)
;; FUNCTIONAL-%DEBUG-NAME takes precedence over FUNCTIONAL-SOURCE-NAME
;;; A REF represents a reference to a LEAF. REF-REOPTIMIZE is
;;; initially (and forever) NIL, since REFs don't receive any values
;;; and don't have any IR1 optimizer.
-(defstruct (ref (:include node (:reoptimize nil))
+(defstruct (ref (:include node (reoptimize nil))
(:constructor make-ref (derived-type leaf))
(:copier nil))
;; The leaf referenced.
;;;; lexical exits.
;;; The ENTRY node serves to mark the start of the dynamic extent of a
-;;; lexical exit. It is the mess-up node for the corresponding :Entry
+;;; lexical exit. It is the mess-up node for the corresponding :ENTRY
;;; cleanup.
(defstruct (entry (:include node)
(:copier nil))