X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fvop.lisp;h=fca025a9e327d48abd54ded8e1097b984f9f9be1;hb=a7c2a16d0c2be6709becc962be1cb5e0aeda68c6;hp=0a232616420239036a834f2d1c06a38b14cede6a;hpb=4eb1a6d3ad2b7dcc19ac0ec979a1eb1eb049659a;p=sbcl.git diff --git a/src/compiler/vop.lisp b/src/compiler/vop.lisp index 0a23261..fca025a 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)) @@ -59,46 +59,46 @@ ;;;; IR1 annotations used for IR2 conversion -;;; 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 +;;; 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 -;;; Holds the IR2-Component structure. +;;; COMPONENT-INFO +;;; Holds the IR2-COMPONENT structure. ;;; -;;; Continuation-Info -;;; Holds the IR2-Continuation structure. Continuations whose +;;; CONTINUATION-INFO +;;; Holds the IR2-CONTINUATION structure. Continuations whose ;;; values aren't used won't have any. ;;; -;;; 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. @@ -108,7 +108,7 @@ (defstruct (ir2-block (:include block-annotation) (:constructor make-ir2-block (block)) (:copier nil)) - ;; the IR2-Block's number, which differs from Block's Block-Number + ;; 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 @@ -117,7 +117,7 @@ ;; 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 + ;; 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 @@ -146,12 +146,12 @@ ;; assign all the more args one LTN number, and all the more results ;; another LTN number. We can do this, since more operands are ;; referenced simultaneously as far as conflict analysis is - ;; concerned. Note that all these :More TNs will be global TNs. + ;; concerned. Note that all these :MORE TNs will be global TNs. (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) @@ -159,9 +159,8 @@ :type local-tn-bit-vector) ;; This is similar to the above, but is updated by lifetime flow ;; analysis to have a 1 for LTN numbers of TNs live at the end of - ;; the block. This takes into account all TNs that aren't :Live. - (live-in (make-array local-tn-limit :element-type 'bit - :initial-element 0) + ;; the block. This takes into account all TNs that aren't :LIVE. + (live-in (make-array local-tn-limit :element-type 'bit :initial-element 0) :type local-tn-bit-vector) ;; a thread running through the global-conflicts structures for this ;; block, sorted by TN number @@ -169,7 +168,7 @@ ;; the assembler label that points to the beginning of the code for ;; this block, or NIL when we haven't assigned a label yet (%label nil) - ;; list of Location-Info structures describing all the interesting + ;; list of LOCATION-INFO structures describing all the interesting ;; (to the debugger) locations in this block (locations nil :type list)) @@ -243,6 +242,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)) @@ -285,12 +286,12 @@ ;; overhead that is eventually stuffed in somehow. (constants (make-array 10 :fill-pointer 0 :adjustable t) :type vector) ;; some kind of info about the component's run-time representation. - ;; This is filled in by the VM supplied Select-Component-Format function. + ;; This is filled in by the VM supplied SELECT-COMPONENT-FORMAT function. format ;; a list of the ENTRY-INFO structures describing all of the entries ;; into this component. Filled in by entry analysis. (entries nil :type list) - ;; Head of the list of :ALIAS TNs in this component, threaded by TN-NEXT. + ;; head of the list of :ALIAS TNs in this component, threaded by TN-NEXT (alias-tns nil :type (or tn null)) ;; SPILLED-VOPS is a hashtable translating from "interesting" VOPs ;; to a list of the TNs spilled at that VOP. This is used when @@ -312,7 +313,7 @@ ;;; 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)) - ;; true if this function has a non-null closure environment + ;; Does this function have a non-null closure environment? (closure-p nil :type boolean) ;; a label pointing to the entry vector for this function, or NIL ;; before ENTRY-ANALYZE runs @@ -321,9 +322,8 @@ ;; of the function, a symbol or (SETF ). Otherwise, this is ;; some string that is intended to be informative. (name "" :type (or simple-string list symbol)) - ;; a string representing the argument list that the function was - ;; defined with - (arguments nil :type (or simple-string null)) + ;; the argument list that the function was defined with. + (arguments nil :type list) ;; a function type specifier representing the arguments and results ;; of this function (type 'function :type (or list (member function)))) @@ -331,14 +331,14 @@ ;;; An IR2-PHYSENV is used to annotate non-LET LAMBDAs with their ;;; passing locations. It is stored in the PHYSENV-INFO. (defstruct (ir2-physenv (:copier nil)) - ;; the TNs that hold the passed environment within the function. - ;; This is an alist translating from the NLX-INFO or LAMBDA-VAR to - ;; the TN that holds the corresponding value within this function. - ;; - ;; The elements of this list correspond to the elements of the list - ;; in the CLOSURE slot of the ENVIRONMENT object that links to us: - ;; essentially this list is related to the CLOSURE list by MAPCAR. - (environment (missing-arg) :type list :read-only t) + ;; TN info for closed-over things within the function: an alist + ;; mapping from NLX-INFOs and LAMBDA-VARs to TNs holding the + ;; corresponding thing within this function + ;; + ;; Elements of this list have a one-to-one correspondence with + ;; elements of the PHYSENV-CLOSURE list of the PHYSENV object that + ;; links to us. + (closure (missing-arg) :type list :read-only t) ;; the TNs that hold the OLD-FP and RETURN-PC within the function. ;; We always save these so that the debugger can do a backtrace, ;; even if the function has no return (and thus never uses them). @@ -368,7 +368,7 @@ ;; function as far as the debugger is concerned. (environment-start nil :type (or label null))) (defprinter (ir2-physenv) - environment + closure old-fp return-pc return-pc-pass) @@ -422,24 +422,24 @@ ;;; operands to the operation. (defstruct (vop (:constructor make-vop (block node info args results)) (:copier nil)) - ;; VOP-Info structure containing static info about the operation + ;; 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 ;; translation. (next nil :type (or vop null)) (prev nil :type (or vop null)) - ;; heads of the TN-Ref lists for operand TNs, linked using the - ;; Across slot + ;; heads of the TN-REF lists for operand TNs, linked using the + ;; ACROSS slot (args nil :type (or tn-ref null)) (results nil :type (or tn-ref null)) ;; head of the list of write refs for each explicitly allocated - ;; temporary, linked together using the Across slot + ;; temporary, linked together using the ACROSS slot (temps nil :type (or tn-ref null)) - ;; head of the list of all TN-refs for references in this VOP, - ;; linked by the Next-Ref slot. There will be one entry for each + ;; head of the list of all TN-REFs for references in this VOP, + ;; linked by the NEXT-REF slot. There will be one entry for each ;; operand and two (a read and a write) for each temporary. (refs nil :type (or tn-ref null)) ;; stuff that is passed uninterpreted from IR2 conversion to @@ -447,7 +447,7 @@ codegen-info ;; the node that generated this VOP, for keeping track of debug info (node nil :type (or node null)) - ;; Local-TN bit vector representing the set of TNs live after args + ;; LOCAL-TN-BIT-VECTOR representing the set of TNs live after args ;; are read and before results are written. This is only filled in ;; when VOP-INFO-SAVE-P is non-null. (save-set nil :type (or local-tn-bit-vector null))) @@ -466,20 +466,20 @@ (tn (missing-arg) :type tn) ;; Is this is a write reference? (as opposed to a read reference) (write-p nil :type boolean) - ;; the link for a list running through all TN-Refs for this TN of + ;; the link for a list running through all TN-REFs for this TN of ;; the same kind (read or write) (next nil :type (or tn-ref null)) ;; the VOP where the reference happens, or NIL temporarily (vop nil :type (or vop null)) - ;; the link for a list of all TN-Refs in VOP, in reverse order of + ;; the link for a list of all TN-REFs in VOP, in reverse order of ;; reference (next-ref nil :type (or tn-ref null)) - ;; the link for a list of the TN-Refs in VOP of the same kind + ;; the link for a list of the TN-REFs in VOP of the same kind ;; (argument, result, temp) (across nil :type (or tn-ref null)) - ;; If true, this is a TN-Ref also in VOP whose TN we would like + ;; If true, this is a TN-REF also in VOP whose TN we would like ;; packed in the same location as our TN. Read and write refs are - ;; always paired: Target in the read points to the write, and + ;; always paired: TARGET in the read points to the write, and ;; vice-versa. (target nil :type (or null tn-ref)) ;; the load TN allocated for this operand, if any @@ -515,7 +515,7 @@ ;; the type constraint as a Lisp function type. ;; ;; If RESULT-TYPES is :CONDITIONAL, then this is an IF-FOO style - ;; conditional that yeilds its result as a control transfer. The + ;; conditional that yields its result as a control transfer. The ;; emit function takes two info arguments: the target label and a ;; boolean flag indicating whether to negate the sense of the test. (arg-types nil :type list) @@ -548,11 +548,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 @@ -576,7 +576,7 @@ (def!struct (vop-info (:include template) (:make-load-form-fun ignore-it)) - ;; side-effects of this VOP and side-effects that affect the value + ;; side effects of this VOP and side effects that affect the value ;; of this VOP (effects (missing-arg) :type attributes) (affected (missing-arg) :type attributes) @@ -586,19 +586,19 @@ ;; save-sc will be saved in a TN in the save SC before the VOP ;; and restored after the VOP. This is used by call VOPs. A bit ;; vector representing the live TNs is stored in the VOP-SAVE-SET. - ;; -- If :Force-To-Stack, all such TNs will made into :Environment TNs + ;; -- If :FORCE-TO-STACK, all such TNs will made into :ENVIRONMENT TNs ;; and forced to be allocated in SCs without any save-sc. This is ;; used by NLX entry vops. - ;; -- If :Compute-Only, just compute the save set, don't do any saving. + ;; -- If :COMPUTE-ONLY, just compute the save set, don't do any saving. ;; This is used to get the live variables for debug info. (save-p nil :type (member t nil :force-to-stack :compute-only)) ;; info for automatic emission of move-arg VOPs by representation ;; selection. If NIL, then do nothing special. If non-null, then ;; there must be a more arg. Each more arg is moved to its passing - ;; location using the appropriate representation-specific - ;; move-argument VOP. The first (fixed) argument must be the - ;; control-stack frame pointer for the frame to move into. The first - ;; info arg is the list of passing locations. + ;; location using the appropriate representation-specific MOVE-ARG + ;; VOP. The first (fixed) argument must be the control-stack frame + ;; pointer for the frame to move into. The first info arg is the + ;; list of passing locations. ;; ;; Additional constraints depend on the value: ;; @@ -631,7 +631,7 @@ ;; if true, a function that is called with the VOP to do operand ;; targeting. This is done by modifying the TN-REF-TARGET slots in ;; the TN-REFS so that they point to other TN-REFS in the same VOP. - (target-function nil :type (or null function)) + (target-fun nil :type (or null function)) ;; a function that emits assembly code for a use of this VOP when it ;; is called with the VOP structure. This is null if this VOP has no ;; specified generator (i.e. if it exists only to be inherited by @@ -650,11 +650,12 @@ (temps nil :type (or null (specializable-vector (unsigned-byte 16)))) ;; the order all the refs for this vop should be put in. Each ;; operand is assigned a number in the following ordering: args, - ;; more-args, results, more-results, temps This vector represents + ;; more-args, results, more-results, temps. This vector represents ;; the order the operands should be put into in the next-ref link. (ref-ordering nil :type (or null (specializable-vector (unsigned-byte 8)))) ;; a vector of the various targets that should be done. Each element - ;; encodes the source ref (shifted 8) and the dest ref index. + ;; encodes the source ref (shifted 8, it is also encoded in + ;; MAX-VOP-TN-REFS) and the dest ref index. (targets nil :type (or null (specializable-vector (unsigned-byte 16))))) ;;;; SBs and SCs @@ -692,7 +693,7 @@ ;;; Boxed-Reg: any boxed register (any boxed object) ;;; Unboxed-Reg: any unboxed register (any unboxed object) ;;; Float-Reg, Double-Float-Reg: float in FP register. -;;; Stack: boxed object on the stack (on cstack) +;;; Stack: boxed object on the stack (on control stack) ;;; Word: any 32bit unboxed object on nstack. ;;; Double: any 64bit unboxed object on nstack. @@ -760,13 +761,13 @@ ;; true if the values in this SC needs to be saved across calls (save-p nil :type boolean) ;; vectors mapping from SC numbers to information about how to load - ;; from the index SC to this one. Move-Functions holds the names of - ;; the functions used to do loading, and Load-Costs holds the cost - ;; of the corresponding Move-Functions. If loading is impossible, - ;; then the entries are NIL. Load-Costs is initialized to have a 0 + ;; from the index SC to this one. MOVE-FUNS holds the names of + ;; the functions used to do loading, and LOAD-COSTS holds the cost + ;; of the corresponding move functions. If loading is impossible, + ;; then the entries are NIL. LOAD-COSTS is initialized to have a 0 ;; for this SC. - (move-functions (make-array sc-number-limit :initial-element nil) - :type sc-vector) + (move-funs (make-array sc-number-limit :initial-element nil) + :type sc-vector) (load-costs (make-array sc-number-limit :initial-element nil) :type sc-vector) ;; a vector mapping from SC numbers to possibly @@ -880,27 +881,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. @@ -908,8 +910,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 @@ -930,7 +932,7 @@ (print-unreadable-object (tn stream :type t) ;; KLUDGE: The distinction between PRINT-TN and PRINT-OBJECT on TN is ;; not very mnemonic. -- WHN 20000124 - (print-tn tn stream))) + (print-tn-guts tn stream))) ;;; The GLOBAL-CONFLICTS structure represents the conflicts for global ;;; TNs. Each global TN has a list of these structures, one for each @@ -941,43 +943,43 @@ (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 - ;; with in this block is 1. To find the full conflict set, the :Live - ;; TNs for Block must also be included. This slot is not meaningful - ;; when Kind is :Live. + ;; BLOCK. The index for the local TN number of each TN we conflict + ;; with in this block is 1. To find the full conflict set, the :LIVE + ;; TNs for BLOCK must also be included. This slot is not meaningful + ;; when KIND is :LIVE. (conflicts (make-array local-tn-limit :element-type 'bit :initial-element 0) :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)) - ;; TN's local TN number in Block. :Live TNs don't have local numbers. + ;; 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) tn