X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fnode.lisp;h=14c344491a99d779aea3c2c7edbb3a86263ef948;hb=b63c4fb9b98fa8188e17ba926e150ba417a74635;hp=392bea63ade36cdfbb03692879bac13dc113d69b;hpb=ea12c1295d511ba5242f3ce64c44e1e445f72cc8;p=sbcl.git diff --git a/src/compiler/node.lisp b/src/compiler/node.lisp index 392bea6..14c3444 100644 --- a/src/compiler/node.lisp +++ b/src/compiler/node.lisp @@ -53,7 +53,7 @@ (def!method print-object ((x ctran) stream) (print-unreadable-object (x stream :type t :identity t) - (format stream " #~D" (cont-num x)))) + (format stream "~D" (cont-num x)))) ;;; Linear VARiable. Multiple-value (possibly of unknown number) ;;; temporal storage. @@ -83,10 +83,10 @@ (def!method print-object ((x lvar) stream) (print-unreadable-object (x stream :type t :identity t) - (format stream " #~D" (cont-num x)))) + (format stream "~D" (cont-num x)))) (def!struct (node (:constructor nil) - (:copier nil)) + (:copier nil)) ;; unique ID for debugging #!+sb-show (id (new-object-id) :read-only t) ;; True if this node needs to be optimized. This is set to true @@ -137,9 +137,9 @@ (tail-p nil :type boolean)) (def!struct (valued-node (:conc-name node-) - (:include node) - (:constructor nil) - (:copier nil)) + (:include node) + (:constructor nil) + (:copier nil)) ;; the bottom-up derived type for this node. (derived-type *wild-type* :type ctype) ;; Lvar, receiving the values, produced by this node. May be NIL if @@ -192,10 +192,10 @@ ;;; numbering in the debug-info (though that is relative to the start ;;; of the function.) (def!struct (cblock (:include sset-element) - (:constructor make-block (start)) - (:constructor make-block-key) - (:conc-name block-) - (:predicate block-p)) + (:constructor make-block (start)) + (:constructor make-block-key) + (:conc-name block-) + (:predicate block-p)) ;; a list of all the blocks that are predecessors/successors of this ;; block. In well-formed IR1, most blocks will have one successor. ;; The only exceptions are: @@ -260,7 +260,7 @@ ;;; different BLOCK-INFO annotation structures so that code ;;; (specifically control analysis) can be shared. (def!struct (block-annotation (:constructor nil) - (:copier nil)) + (:copier nil)) ;; 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 @@ -283,7 +283,11 @@ ;;; component. (def!struct (component (:copier nil) (:constructor - make-component (head tail &aux (last-block tail)))) + make-component + (head + tail &aux + (last-block tail) + (outer-loop (make-loop :kind :outer :head head))))) ;; unique ID for debugging #!+sb-show (id (new-object-id) :read-only t) ;; the kind of component @@ -388,7 +392,7 @@ ;; this is filled by physical environment analysis (dx-lvars nil :type list) ;; The default LOOP in the component. - (outer-loop (make-loop :kind :outer :head head) :type cloop)) + (outer-loop (missing-arg) :type cloop)) (defprinter (component :identity t) name #!+sb-show id @@ -451,7 +455,9 @@ ;; For :DYNAMIC-EXTENT: a list of all DX LVARs, preserved by this ;; cleanup. This is filled when the cleanup is created (now by ;; locall call analysis) and is rechecked by physical environment - ;; analysis. + ;; analysis. (For closures this is a list of the allocating node - + ;; during IR1, and a list of the argument LVAR of the allocator - + ;; after physical environment analysis.) (info nil :type list)) (defprinter (cleanup :identity t) kind @@ -534,37 +540,42 @@ ;;; 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 (:constructor make-nlx-info - (cleanup exit &aux (lvar (node-lvar exit)))) - (:make-load-form-fun ignore-it)) +(def!struct (nlx-info + (:constructor make-nlx-info (cleanup + exit + &aux + (block (first (block-succ + (node-block exit)))))) + (: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 (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 - ;; physical environment analysis deletes the escape function and - ;; instead has the %NLX-ENTRY use this continuation. + ;; the ``continuation'' exited to (the block, succeeding the EXIT + ;; nodes). If this exit is from an escape function (CATCH or + ;; UNWIND-PROTECT), then 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 - ;; 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. - (exit (missing-arg) :type exit) - (lvar (missing-arg) :type (or lvar null)) + ;; This slot is 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, since exits to different + ;; places may deliver their result to the same continuation. + (block (missing-arg) :type cblock) ;; 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)) + ;; for a lexical exit it determines whether tag existence check is + ;; needed + (safe-p nil :type boolean) ;; some kind of info used by the back end info) (defprinter (nlx-info :identity t) - exit + block target info) @@ -851,6 +862,9 @@ ;; the original function or macro lambda list, or :UNSPECIFIED if ;; this is a compiler created function (arg-documentation nil :type (or list (member :unspecified))) + ;; Node, allocating closure for this lambda. May be NIL when we are + ;; sure that no closure is needed. + (allocator nil :type (or null combination)) ;; various rare miscellaneous info that drives code generation & stuff (plist () :type list)) (defprinter (functional :identity t) @@ -1118,12 +1132,12 @@ ;;; initially (and forever) NIL, since REFs don't receive any values ;;; and don't have any IR1 optimizer. (def!struct (ref (:include valued-node (reoptimize nil)) - (:constructor make-ref - (leaf - &aux (leaf-type (leaf-type leaf)) - (derived-type - (make-single-value-type leaf-type)))) - (:copier nil)) + (:constructor make-ref + (leaf + &aux (leaf-type (leaf-type leaf)) + (derived-type + (make-single-value-type leaf-type)))) + (:copier nil)) ;; The leaf referenced. (leaf nil :type leaf)) (defprinter (ref :identity t) @@ -1132,10 +1146,10 @@ ;;; Naturally, the IF node always appears at the end of a block. (def!struct (cif (:include node) - (:conc-name if-) - (:predicate if-p) - (:constructor make-if) - (:copier copy-if)) + (:conc-name if-) + (:predicate if-p) + (:constructor make-if) + (:copier copy-if)) ;; LVAR for the predicate (test (missing-arg) :type lvar) ;; the blocks that we execute next in true and false case, @@ -1150,10 +1164,10 @@ (def!struct (cset (:include valued-node (derived-type (make-single-value-type *universal-type*))) - (:conc-name set-) - (:predicate set-p) - (:constructor make-set) - (:copier copy-set)) + (:conc-name set-) + (:predicate set-p) + (:constructor make-set) + (:copier copy-set)) ;; descriptor for the variable set (var (missing-arg) :type basic-var) ;; LVAR for the value form @@ -1167,8 +1181,8 @@ ;;; node appears at the end of its block and the body of the called ;;; function appears as the successor; the NODE-LVAR is null. (def!struct (basic-combination (:include valued-node) - (:constructor nil) - (:copier nil)) + (:constructor nil) + (:copier nil)) ;; LVAR for the function (fun (missing-arg) :type lvar) ;; list of LVARs for the args. In a local call, an argument lvar may @@ -1194,8 +1208,8 @@ ;;; including FUNCALL. This is distinct from BASIC-COMBINATION so that ;;; an MV-COMBINATION isn't COMBINATION-P. (def!struct (combination (:include basic-combination) - (:constructor make-combination (fun)) - (:copier nil))) + (:constructor make-combination (fun)) + (:copier nil))) (defprinter (combination :identity t) #!+sb-show id (fun :prin1 (lvar-uses fun)) @@ -1209,8 +1223,8 @@ ;;; FUNCALL. This is used to implement all the multiple-value ;;; receiving forms. (def!struct (mv-combination (:include basic-combination) - (:constructor make-mv-combination (fun)) - (:copier nil))) + (:constructor make-mv-combination (fun)) + (:copier nil))) (defprinter (mv-combination) (fun :prin1 (lvar-uses fun)) (args :prin1 (mapcar #'lvar-uses args))) @@ -1218,7 +1232,7 @@ ;;; The BIND node marks the beginning of a lambda body and represents ;;; the creation and initialization of the variables. (def!struct (bind (:include node) - (:copier nil)) + (:copier nil)) ;; the lambda we are binding variables for. Null when we are ;; creating the LAMBDA during IR1 translation. (lambda nil :type (or clambda null))) @@ -1230,10 +1244,10 @@ ;;; is also where we stick information used for TAIL-SET type ;;; inference. (def!struct (creturn (:include node) - (:conc-name return-) - (:predicate return-p) - (:constructor make-return) - (:copier copy-return)) + (:conc-name return-) + (:predicate return-p) + (:constructor make-return) + (:copier copy-return)) ;; the lambda we are returning from. Null temporarily during ;; ir1tran. (lambda nil :type (or clambda null)) @@ -1252,7 +1266,7 @@ ;;; TYPE-TO-CHECK is performed and then the VALUE is declared to be of ;;; type ASSERTED-TYPE. (def!struct (cast (:include valued-node) - (:constructor %make-cast)) + (:constructor %make-cast)) (asserted-type (missing-arg) :type ctype) (type-to-check (missing-arg) :type ctype) ;; an indication of what we have proven about how this type @@ -1284,7 +1298,7 @@ ;;; lexical exit. It is the mess-up node for the corresponding :ENTRY ;;; cleanup. (def!struct (entry (:include node) - (:copier nil)) + (:copier nil)) ;; 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. @@ -1300,7 +1314,7 @@ ;;; lvar is the exit node's LVAR; physenv analysis also makes it the ;;; lvar of %NLX-ENTRY call. (def!struct (exit (:include valued-node) - (:copier nil)) + (:copier nil)) ;; 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 @@ -1308,7 +1322,8 @@ (entry nil :type (or entry null)) ;; the lvar yielding the value we are to exit with. If NIL, then no ;; value is desired (as in GO). - (value nil :type (or lvar null))) + (value nil :type (or lvar null)) + (nlx-info nil :type (or nlx-info null))) (defprinter (exit :identity t) #!+sb-show id (entry :test entry)