X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fvop.lisp;h=4570b36c8a6eafd77673bd6275d73ddf2443964c;hb=8902b8b6bd2e9285749dd39d313b33b6c69c5213;hp=4f3b7d39800a00c3c8a54710c02ed526bc6fb1d9;hpb=fc6400512d98021430dcd7d95c4e5535c6fe9b86;p=sbcl.git diff --git a/src/compiler/vop.lisp b/src/compiler/vop.lisp index 4f3b7d3..4570b36 100644 --- a/src/compiler/vop.lisp +++ b/src/compiler/vop.lisp @@ -14,7 +14,7 @@ ;;; the largest number of TNs whose liveness changes that we can have ;;; in any block -(defconstant local-tn-limit 64) +(def!constant local-tn-limit 64) (deftype local-tn-number () `(integer 0 (,local-tn-limit))) (deftype local-tn-count () `(integer 0 ,local-tn-limit)) @@ -47,7 +47,7 @@ (scs nil :type list) ;; the Lisp type equivalent to this type. If this type could never be ;; returned by PRIMITIVE-TYPE, then this is the NIL (or empty) type - (type (missing-arg) :type ctype) + (specifier (missing-arg) :type type-specifier) ;; the template used to check that an object is of this type. This is a ;; template of one argument and one result, both of primitive-type T. If ;; the argument is of the correct type, then it is delivered into the @@ -59,46 +59,46 @@ ;;;; IR1 annotations used for IR2 conversion -;;; Block-Info +;;; BLOCK-INFO ;;; Holds the IR2-BLOCK structure. If there are overflow blocks, ;;; then this points to the first IR2-BLOCK. The BLOCK-INFO of the ;;; dummy component head and tail are dummy IR2 blocks that begin ;;; and end the emission order thread. ;;; -;;; Component-Info +;;; COMPONENT-INFO ;;; Holds the IR2-COMPONENT structure. ;;; -;;; Continuation-Info -;;; Holds the IR2-Continuation structure. Continuations whose -;;; values aren't used won't have any. +;;; LVAR-INFO +;;; Holds the IR2-LVAR structure. LVARs whose values aren't used +;;; won't have any. XXX ;;; -;;; Cleanup-Info +;;; CLEANUP-INFO ;;; If non-null, then a TN in which the affected dynamic ;;; environment pointer should be saved after the binding is ;;; instantiated. ;;; -;;; Physenv-Info -;;; Holds the Ir2-Physenv structure. +;;; PHYSENV-INFO +;;; Holds the IR2-PHYSENV structure. ;;; -;;; Tail-Set-Info -;;; Holds the Return-Info structure. +;;; TAIL-SET-INFO +;;; Holds the RETURN-INFO structure. ;;; -;;; NLX-Info-Info -;;; Holds the IR2-NLX-Info structure. +;;; NLX-INFO-INFO +;;; Holds the IR2-NLX-INFO structure. ;;; -;;; Leaf-Info +;;; LEAF-INFO ;;; If a non-set lexical variable, the TN that holds the value in ;;; the home environment. If a constant, then the corresponding ;;; constant TN. If an XEP lambda, then the corresponding ;;; Entry-Info structure. ;;; -;;; Basic-Combination-Info +;;; BASIC-COMBINATION-INFO ;;; The template chosen by LTN, or ;;; :FULL if this is definitely a full call. ;;; :FUNNY if this is an oddball thing with IR2-convert. ;;; :LOCAL if this is a local call. ;;; -;;; Node-Tail-P +;;; NODE-TAIL-P ;;; After LTN analysis, this is true only in combination nodes that are ;;; truly tail recursive. @@ -111,22 +111,21 @@ ;; the IR2-BLOCK's number, which differs from BLOCK's BLOCK-NUMBER ;; if any blocks are split. This is assigned by lifetime analysis. (number nil :type (or index null)) - ;; information about unknown-values continuations that is used by - ;; stack analysis to do stack simulation. An UNKNOWN-VALUES - ;; continuation is PUSHED if its DEST is in another block. - ;; Similarly, a continuation is POPPED if its DEST is in this block - ;; but has its uses elsewhere. The continuations are in the order - ;; that are pushed/popped in the block. Note that the args to a - ;; single MV-Combination appear reversed in POPPED, since we must - ;; effectively pop the last argument first. All pops must come - ;; before all pushes (although internal MV uses may be interleaved.) - ;; POPPED is computed by LTN, and PUSHED is computed by stack - ;; analysis. + ;; information about unknown-values LVARs that is used by stack + ;; analysis to do stack simulation. An UNKNOWN-VALUES LVAR is PUSHED + ;; if its DEST is in another block. Similarly, a LVAR is POPPED if + ;; its DEST is in this block but has its uses elsewhere. The LVARs + ;; are in the order that are pushed/popped in the block. Note that + ;; the args to a single MV-COMBINATION appear reversed in POPPED, + ;; since we must effectively pop the last argument first. All pops + ;; must come before all pushes (although internal MV uses may be + ;; interleaved.) POPPED is computed by LTN, and PUSHED is computed + ;; by stack analysis. (pushed () :type list) (popped () :type list) ;; the result of stack analysis: lists of all the unknown-values - ;; continuations on the stack at the block start and end, topmost - ;; continuation first. + ;; LVARs on the stack at the block start and end, topmost LVAR + ;; first. (start-stack () :type list) (end-stack () :type list) ;; the first and last VOP in this block. If there are none, both @@ -150,8 +149,8 @@ (local-tns (make-array local-tn-limit) :type local-tn-vector) ;; Bit-vectors used during lifetime analysis to keep track of ;; references to local TNs. When indexed by the LTN number, the - ;; index for a TN is non-zero in Written if it is ever written in - ;; the block, and in Live-Out if the first reference is a read. + ;; index for a TN is non-zero in WRITTEN if it is ever written in + ;; the block, and in LIVE-OUT if the first reference is a read. (written (make-array local-tn-limit :element-type 'bit :initial-element 0) :type local-tn-bit-vector) @@ -180,45 +179,51 @@ (local-tn-count :test (not (zerop local-tn-count))) (%label :test %label)) -;;; An IR2-CONTINUATION structure is used to annotate continuations -;;; that are used as a function result continuation or that receive MVs. -(defstruct (ir2-continuation - (:constructor make-ir2-continuation (primitive-type)) +;;; An IR2-LVAR structure is used to annotate LVARs that are used as a +;;; function result LVARs or that receive MVs. +(defstruct (ir2-lvar + (:constructor make-ir2-lvar (primitive-type)) (:copier nil)) - ;; If this is :DELAYED, then this is a single value continuation for - ;; which the evaluation of the use is to be postponed until the - ;; evaluation of destination. This can be done for ref nodes or - ;; predicates whose destination is an IF. + ;; If this is :DELAYED, then this is a single value LVAR for which + ;; the evaluation of the use is to be postponed until the evaluation + ;; of destination. This can be done for ref nodes or predicates + ;; whose destination is an IF. ;; - ;; If this is :FIXED, then this continuation has a fixed number of - ;; values, with the TNs in LOCS. + ;; If this is :FIXED, then this LVAR has a fixed number of values, + ;; with the TNs in LOCS. ;; - ;; If this is :UNKNOWN, then this is an unknown-values continuation, - ;; using the passing locations in LOCS. + ;; If this is :UNKNOWN, then this is an unknown-values LVAR, using + ;; the passing locations in LOCS. ;; - ;; If this is :UNUSED, then this continuation should never actually - ;; be used as the destination of a value: it is only used - ;; tail-recursively. + ;; If this is :UNUSED, then this LVAR should never actually be used + ;; as the destination of a value: it is only used tail-recursively. (kind :fixed :type (member :delayed :fixed :unknown :unused)) - ;; The primitive-type of the first value of this continuation. This - ;; is primarily for internal use during LTN, but it also records the + ;; The primitive-type of the first value of this LVAR. This is + ;; primarily for internal use during LTN, but it also records the ;; type restriction on delayed references. In multiple-value ;; contexts, this is null to indicate that it is meaningless. This - ;; is always (primitive-type (continuation-type cont)), which may be - ;; more restrictive than the tn-primitive-type of the value TN. This - ;; is becase the value TN must hold any possible type that could be - ;; computed (before type checking.) + ;; is always (primitive-type (lvar-type cont)), which may be more + ;; restrictive than the tn-primitive-type of the value TN. This is + ;; becase the value TN must hold any possible type that could be + ;; computed (before type checking.) XXX (primitive-type nil :type (or primitive-type null)) - ;; Locations used to hold the values of the continuation. If the - ;; number of values if fixed, then there is one TN per value. If the - ;; number of values is unknown, then this is a two-list of TNs - ;; holding the start of the values glob and the number of values. - ;; Note that since type checking is the responsibility of the values - ;; receiver, these TNs primitive type is only based on the proven - ;; type information. - (locs nil :type list)) + ;; Locations used to hold the values of the LVAR. If the number of + ;; values if fixed, then there is one TN per value. If the number of + ;; values is unknown, then this is a two-list of TNs holding the + ;; start of the values glob and the number of values. Note that + ;; since type checking is the responsibility of the values receiver, + ;; these TNs primitive type is only based on the proven type + ;; information. + (locs nil :type list) + #!+stack-grows-downward-not-upward + (stack-pointer nil :type (or tn null))) +;; For upward growing stack start of stack block and start of object +;; differ only by lowtag. +#!-stack-grows-downward-not-upward +(defmacro ir2-lvar-stack-pointer (2lvar) + `(first (ir2-lvar-locs ,2lvar))) -(defprinter (ir2-continuation) +(defprinter (ir2-lvar) kind primitive-type locs) @@ -242,6 +247,8 @@ ;; CONSTANT-TNs are non-packed TNs that represent constants. ;; :CONSTANT TNs may eventually be converted to :CACHED-CONSTANT ;; normal TNs. + ;; + ;; FIXME: What is :CACHED-CONSTANT? (normal-tns nil :type (or tn null)) (restricted-tns nil :type (or tn null)) (wired-tns nil :type (or tn null)) @@ -307,9 +314,10 @@ ;;; An ENTRY-INFO condenses all the information that the dumper needs ;;; to create each XEP's function entry data structure. ENTRY-INFO -;;; structures are somtimes created before they are initialized, since -;;; IR2 conversion may need to compile a forward reference. In this -;;; case the slots aren't actually initialized until entry analysis runs. +;;; structures are sometimes created before they are initialized, +;;; since IR2 conversion may need to compile a forward reference. In +;;; this case the slots aren't actually initialized until entry +;;; analysis runs. (defstruct (entry-info (:copier nil)) ;; Does this function have a non-null closure environment? (closure-p nil :type boolean) @@ -418,11 +426,11 @@ ;;; A VOP is a Virtual Operation. It represents an operation and the ;;; operands to the operation. -(defstruct (vop (:constructor make-vop (block node info args results)) - (:copier nil)) +(def!struct (vop (:constructor make-vop (block node info args results)) + (:copier nil)) ;; VOP-INFO structure containing static info about the operation (info nil :type (or vop-info null)) - ;; the IR2-Block this VOP is in + ;; the IR2-BLOCK this VOP is in (block (missing-arg) :type ir2-block) ;; VOPs evaluated after and before this one. Null at the ;; beginning/end of the block, and temporarily during IR2 @@ -458,8 +466,8 @@ ;;; A TN-REF object contains information about a particular reference ;;; to a TN. The information in TN-REFs largely determines how TNs are ;;; packed. -(defstruct (tn-ref (:constructor make-tn-ref (tn write-p)) - (:copier nil)) +(def!struct (tn-ref (:constructor make-tn-ref (tn write-p)) + (:copier nil)) ;; the TN referenced (tn (missing-arg) :type tn) ;; Is this is a write reference? (as opposed to a read reference) @@ -498,7 +506,7 @@ ;; the arg/result type restrictions. We compute this from the ;; PRIMITIVE-TYPE restrictions to make life easier for IR1 phases ;; that need to anticipate LTN's template selection. - (type (missing-arg) :type fun-type) + (type (missing-arg) :type ctype) ;; lists of restrictions on the argument and result types. A ;; restriction may take several forms: ;; -- The restriction * is no restriction at all. @@ -546,11 +554,11 @@ (info-arg-count 0 :type index) ;; a function that emits the VOPs for this template. Arguments: ;; 1] Node for source context. - ;; 2] IR2-Block that we place the VOP in. + ;; 2] IR2-BLOCK that we place the VOP in. ;; 3] This structure. - ;; 4] Head of argument TN-Ref list. - ;; 5] Head of result TN-Ref list. - ;; 6] If Info-Arg-Count is non-zero, then a list of the magic + ;; 4] Head of argument TN-REF list. + ;; 5] Head of result TN-REF list. + ;; 6] If INFO-ARG-COUNT is non-zero, then a list of the magic ;; arguments. ;; ;; Two values are returned: the first and last VOP emitted. This vop @@ -741,7 +749,7 @@ ;;; the SC structure holds the storage base that storage is allocated ;;; in and information used to select locations within the SB -(defstruct (sc (:copier nil)) +(def!struct (sc (:copier nil)) ;; name, for printing and reference (name nil :type symbol) ;; the number used to index SC cost vectors @@ -813,7 +821,7 @@ ;;;; TNs -(defstruct (tn (:include sset-element) +(def!struct (tn (:include sset-element) (:constructor make-random-tn) (:constructor make-tn (number kind primitive-type sc)) (:copier nil)) @@ -879,27 +887,28 @@ ;; wired TNs. (primitive-type nil :type (or primitive-type null)) ;; If this TN represents a variable or constant, then this is the - ;; corresponding Leaf. + ;; corresponding LEAF. (leaf nil :type (or leaf null)) ;; thread that links TNs together so that we can find them (next nil :type (or tn null)) - ;; head of TN-Ref lists for reads and writes of this TN + ;; head of TN-REF lists for reads and writes of this TN (reads nil :type (or tn-ref null)) (writes nil :type (or tn-ref null)) ;; a link we use when building various temporary TN lists (next* nil :type (or tn null)) - ;; some block that contains a reference to this TN, or Nil if we + ;; some block that contains a reference to this TN, or NIL if we ;; haven't seen any reference yet. If the TN is local, then this is ;; the block it is local to. (local nil :type (or ir2-block null)) ;; If a local TN, the block relative number for this TN. Global TNs ;; whose liveness changes within a block are also assigned a local ;; number during the conflicts analysis of that block. If the TN has - ;; no local number within the block, then this is Nil. + ;; no local number within the block, then this is NIL. (local-number nil :type (or local-tn-number null)) ;; If this object is a local TN, this slot is a bit-vector with 1 ;; for the local-number of every TN that we conflict with. - (local-conflicts (make-array local-tn-limit :element-type 'bit + (local-conflicts (make-array local-tn-limit + :element-type 'bit :initial-element 0) :type local-tn-bit-vector) ;; head of the list of GLOBAL-CONFLICTS structures for a global TN. @@ -907,8 +916,8 @@ ;; the intersection between the lifetimes for two global TNs to be ;; easily found. If null, then this TN is a local TN. (global-conflicts nil :type (or global-conflicts null)) - ;; during lifetime analysis, this is used as a pointer into the - ;; conflicts chain, for scanning through blocks in reverse DFO + ;; During lifetime analysis, this is used as a pointer into the + ;; conflicts chain, for scanning through blocks in reverse DFO. (current-conflict nil) ;; In a :SAVE TN, this is the TN saved. In a :NORMAL or :ENVIRONMENT ;; TN, this is the associated save TN. In TNs with no save TN, this @@ -940,28 +949,28 @@ (defstruct (global-conflicts (:constructor make-global-conflicts (kind tn block number)) (:copier nil)) - ;; the IR2-Block that this structure represents the conflicts for + ;; the IR2-BLOCK that this structure represents the conflicts for (block (missing-arg) :type ir2-block) - ;; thread running through all the Global-Conflict for Block. This + ;; thread running through all the GLOBAL-CONFLICTSs for BLOCK. This ;; thread is sorted by TN number - (next nil :type (or global-conflicts null)) - ;; the way that TN is used by Block + (next-blockwise nil :type (or global-conflicts null)) + ;; the way that TN is used by BLOCK ;; - ;; :READ - ;; The TN is read before it is written. It starts the block live, - ;; but is written within the block. + ;; :READ + ;; The TN is read before it is written. It starts the block live, + ;; but is written within the block. ;; - ;; :WRITE - ;; The TN is written before any read. It starts the block dead, - ;; and need not have a read within the block. + ;; :WRITE + ;; The TN is written before any read. It starts the block dead, + ;; and need not have a read within the block. ;; - ;; :READ-ONLY - ;; The TN is read, but never written. It starts the block live, - ;; and is not killed by the block. Lifetime analysis will promote - ;; :READ-ONLY TNs to :LIVE if they are live at the block end. + ;; :READ-ONLY + ;; The TN is read, but never written. It starts the block live, + ;; and is not killed by the block. Lifetime analysis will promote + ;; :READ-ONLY TNs to :LIVE if they are live at the block end. ;; - ;; :LIVE - ;; The TN is not referenced. It is live everywhere in the block. + ;; :LIVE + ;; The TN is not referenced. It is live everywhere in the block. (kind :read-only :type (member :read :write :read-only :live)) ;; a local conflicts vector representing conflicts with TNs live in ;; BLOCK. The index for the local TN number of each TN we conflict @@ -974,8 +983,8 @@ :type local-tn-bit-vector) ;; the TN we are recording conflicts for. (tn (missing-arg) :type tn) - ;; thread through all the Global-Conflicts for TN - (tn-next nil :type (or global-conflicts null)) + ;; thread through all the GLOBAL-CONFLICTSs for TN + (next-tnwise nil :type (or global-conflicts null)) ;; TN's local TN number in BLOCK. :LIVE TNs don't have local numbers. (number nil :type (or local-tn-number null))) (defprinter (global-conflicts)