0.pre7.125:
[sbcl.git] / src / compiler / node.lisp
index 484ba63..0774feb 100644 (file)
 
 (defstruct (node (:constructor nil)
                 (:copier nil))
+  ;; unique ID for debugging
+  #!+sb-show (id (new-object-id) :read-only t)
   ;; the bottom-up derived type for this node. This does not take into
   ;; consideration output type assertions on this node (actually on its CONT).
   (derived-type *wild-type* :type ctype)
 ;;;    checking blocks we have already checked.
 ;;; -- DELETE-P is true when this block is used to indicate that this block
 ;;;    has been determined to be unreachable and should be deleted. IR1
-;;;    phases should not attempt to  examine or modify blocks with DELETE-P
+;;;    phases should not attempt to examine or modify blocks with DELETE-P
 ;;;    set, since they may:
 ;;;     - be in the process of being deleted, or
 ;;;     - have no successors, or
 (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
+;;; findable by grep for 'def.*block-delete-p'.
 (macrolet ((frob (slot)
             `(defmacro ,(symbolicate "BLOCK-" slot) (block)
                `(block-attributep (block-flags ,block) ,',slot))))
   (out nil)
   ;; the component this block is in, or NIL temporarily during IR1
   ;; conversion and in deleted blocks
-  (component *current-component* :type (or component null))
+  (component (progn
+              (aver-live-component *current-component*)
+              *current-component*)
+            :type (or component null))
   ;; a flag used by various graph-walking code to determine whether
   ;; this block has been processed already or what. We make this
   ;; initially NIL so that FIND-INITIAL-DFO doesn't have to scan the
   (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~D" (cont-num (block-start cblock)))))
+    (format stream ":START c~W" (cont-num (block-start cblock)))))
 
 ;;; The BLOCK-ANNOTATION class is inherited (via :INCLUDE) by
 ;;; different BLOCK-INFO annotation structures so that code
   ;; The IR1 block that this block is in the INFO for.
   (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
-  ;; in lifetime analysis.
+  ;; determines which block we drop though to, and is also used to
+  ;; chain together overflow blocks that result from splitting of IR2
+  ;; blocks in lifetime analysis.
   (next nil :type (or block-annotation null))
   (prev nil :type (or block-annotation null)))
 
 ;;;   structures to be reclaimed after the compilation of each
 ;;;   component.
 (defstruct (component (:copier nil))
+  ;; unique ID for debugging
+  #!+sb-show (id (new-object-id) :read-only t)
   ;; the kind of component
   ;;
   ;; (The terminology here is left over from before
   (reanalyze nil :type boolean)
   ;; some sort of name for the code in this component
   (name "<unknown>" :type simple-string)
-  ;; some kind of info used by the back end
-  (info nil)
+  ;; When I am a child, this is :NO-IR2-YET.
+  ;; In my adulthood, IR2 stores notes to itself here.
+  ;; 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).
+  (info :no-ir2-yet :type (or ir2-component (member :no-ir2-yet :dead)))
   ;; the SOURCE-INFO structure describing where this component was
   ;; compiled from
   (source-info *source-info* :type source-info)
   (reanalyze-funs nil :type list))
 (defprinter (component :identity t)
   name
+  #!+sb-show id
   (reanalyze :test reanalyze))
 
+;;; Check that COMPONENT is suitable for roles which involve adding
+;;; new code. (gotta love imperative programming with lotso in-place
+;;; 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
+  ;; (certainly stricter, possibly also correct...) to assert that
+  ;; IR1-FINALIZE hasn't happened yet?
+  (aver (not (eql (component-info component) :dead))))
+
 ;;; Before sbcl-0.7.0, there were :TOPLEVEL things which were magical
 ;;; in multiple ways. That's since been refactored into the orthogonal
 ;;; properties "optimized for locall with no arguments" and "externally
 ;;; hacking the flow graph.
 (def!struct (leaf (:make-load-form-fun ignore-it)
                  (:constructor nil))
+  ;; unique ID for debugging
+  #!+sb-show (id (new-object-id) :read-only t)
   ;; (For public access to this slot, use LEAF-SOURCE-NAME.)
   ;;
   ;; the name of LEAF as it appears in the source, e.g. 'FOO or '(SETF
        :type (member :special :global-function :global)))
 (defprinter (global-var :identity t)
   %source-name
+  #!+sb-show id
   (type :test (not (eq type *universal-type*)))
   (where-from :test (not (eq where-from :assumed)))
   kind)
   (functional nil :type (or functional null)))
 (defprinter (defined-fun :identity t)
   %source-name
+  #!+sb-show id
   inlinep
   (functional :test functional))
 \f
   (plist () :type list))
 (defprinter (functional :identity t)
   %source-name
-  %debug-name)
+  %debug-name
+  #!+sb-show id)
 
 ;;; FUNCTIONAL name operations
 (defun functional-debug-name (functional)
 (defprinter (clambda :conc-name lambda- :identity t)
   %source-name
   %debug-name
+  #!+sb-show id
   (type :test (not (eq type *universal-type*)))
   (where-from :test (not (eq where-from :assumed)))
   (vars :prin1 (mapcar #'leaf-source-name vars)))
 (defprinter (optional-dispatch :identity t)
   %source-name
   %debug-name
+  #!+sb-show id
   (type :test (not (eq type *universal-type*)))
   (where-from :test (not (eq where-from :assumed)))
   arglist
   (constraints nil :type (or sset null)))
 (defprinter (lambda-var :identity t)
   %source-name
+  #!+sb-show id
   (type :test (not (eq type *universal-type*)))
   (where-from :test (not (eq where-from :assumed)))
   (ignorep :test ignorep)
   ;; The leaf referenced.
   (leaf nil :type leaf))
 (defprinter (ref :identity t)
+  #!+sb-show id
   leaf)
 
 ;;; Naturally, the IF node always appears at the end of a block.
                        (:constructor make-combination (fun))
                        (:copier nil)))
 (defprinter (combination :identity t)
+  #!+sb-show id
   (fun :prin1 (continuation-use fun))
   (args :prin1 (mapcar (lambda (x)
                         (if x
 ;;; cleanup.
 (defstruct (entry (:include node)
                  (:copier nil))
-  ;; All of the Exit nodes for potential non-local exits to this point.
+  ;; All of the EXIT nodes for potential non-local exits to this point.
   (exits nil :type list)
   ;; The cleanup for this entry. NULL only temporarily.
   (cleanup nil :type (or cleanup null)))
-(defprinter (entry :identity t))
+(defprinter (entry :identity t)
+  #!+sb-show id)
 
 ;;; The EXIT node marks the place at which exit code would be emitted,
 ;;; if necessary. This is interposed between the uses of the exit
 ;;; original exit continuation is the exit node's CONT.
 (defstruct (exit (:include node)
                 (:copier nil))
-  ;; The Entry node that this is an exit for. If null, this is a
+  ;; the ENTRY node that this is an exit for. If null, this is a
   ;; degenerate exit. A degenerate exit is used to "fill" an empty
   ;; block (which isn't allowed in IR1.) In a degenerate exit, Value
   ;; is always also null.
   (entry nil :type (or entry null))
-  ;; The continuation yeilding the value we are to exit with. If NIL,
+  ;; the continuation yielding 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 :identity t)
+  #!+sb-show id
   (entry :test entry)
   (value :test value))
 \f