home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / docs.lha / internals / middle.tex < prev    next >
LaTeX Document  |  1992-05-30  |  32.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: LaTeX Document (document/latex).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document, ASCII text default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 2d 2a 2d 20 44 69 | 63 74 69 6f 6e 61 72 79 |% -*- Di|ctionary|
|00000010| 3a 20 64 65 73 69 67 6e | 20 2d 2a 2d 0a 0a 0c 0a |: design| -*-....|
|00000020| 5c 63 68 61 70 74 65 72 | 7b 56 69 72 74 75 61 6c |\chapter|{Virtual|
|00000030| 20 4d 61 63 68 69 6e 65 | 20 52 65 70 72 65 73 65 | Machine| Represe|
|00000040| 6e 74 61 74 69 6f 6e 20 | 49 6e 74 72 6f 64 75 63 |ntation |Introduc|
|00000050| 74 69 6f 6e 7d 0a 0a 0c | 0a 5c 63 68 61 70 74 65 |tion}...|.\chapte|
|00000060| 72 7b 47 6c 6f 62 61 6c | 20 54 4e 20 61 73 73 69 |r{Global| TN assi|
|00000070| 67 6e 6d 65 6e 74 7d 0a | 0a 5b 5c 23 5c 23 5c 23 |gnment}.|.[\#\#\#|
|00000080| 20 52 65 6e 61 6d 65 20 | 74 68 69 73 20 70 68 61 | Rename |this pha|
|00000090| 73 65 20 73 6f 20 61 73 | 20 6e 6f 74 20 74 6f 20 |se so as| not to |
|000000a0| 62 65 20 63 6f 6e 66 75 | 73 65 64 20 77 69 74 68 |be confu|sed with|
|000000b0| 20 74 68 65 20 6c 6f 63 | 61 6c 2f 67 6c 6f 62 61 | the loc|al/globa|
|000000c0| 6c 20 54 4e 0a 72 65 70 | 72 65 73 65 6e 74 61 74 |l TN.rep|resentat|
|000000d0| 69 6f 6e 2e 5d 0a 0a 54 | 68 65 20 62 61 73 69 63 |ion.]..T|he basic|
|000000e0| 20 6d 65 63 68 61 6e 69 | 73 6d 20 66 6f 72 20 63 | mechani|sm for c|
|000000f0| 6c 6f 73 69 6e 67 20 6f | 76 65 72 20 76 61 6c 75 |losing o|ver valu|
|00000100| 65 73 20 69 73 20 74 6f | 20 70 61 73 73 20 74 68 |es is to| pass th|
|00000110| 65 20 76 61 6c 75 65 73 | 20 61 73 20 61 64 64 69 |e values| as addi|
|00000120| 74 69 6f 6e 61 6c 0a 69 | 6d 70 6c 69 63 69 74 20 |tional.i|mplicit |
|00000130| 61 72 67 75 6d 65 6e 74 | 73 20 69 6e 20 74 68 65 |argument|s in the|
|00000140| 20 66 75 6e 63 74 69 6f | 6e 20 63 61 6c 6c 2e 20 | functio|n call. |
|00000150| 20 54 68 69 73 20 74 65 | 63 68 6e 69 71 75 65 20 | This te|chnique |
|00000160| 69 73 20 6f 6e 6c 79 20 | 61 70 70 6c 69 63 61 62 |is only |applicab|
|00000170| 6c 65 0a 77 68 65 6e 3a | 0a 20 2d 2d 20 74 68 65 |le.when:|. -- the|
|00000180| 20 63 61 6c 6c 69 6e 67 | 20 66 75 6e 63 74 69 6f | calling| functio|
|00000190| 6e 20 6b 6e 6f 77 73 20 | 77 68 69 63 68 20 76 61 |n knows |which va|
|000001a0| 6c 75 65 73 20 74 68 65 | 20 63 61 6c 6c 65 64 20 |lues the| called |
|000001b0| 66 75 6e 63 74 69 6f 6e | 20 77 61 6e 74 73 20 74 |function| wants t|
|000001c0| 6f 20 63 6c 6f 73 65 0a | 20 20 20 20 6f 76 65 72 |o close.| over|
|000001d0| 2c 20 61 6e 64 0a 20 2d | 2d 20 74 68 65 20 76 61 |, and. -|- the va|
|000001e0| 6c 75 65 73 20 74 6f 20 | 62 65 20 63 6c 6f 73 65 |lues to |be close|
|000001f0| 64 20 6f 76 65 72 20 61 | 72 65 20 61 76 61 69 6c |d over a|re avail|
|00000200| 61 62 6c 65 20 69 6e 20 | 74 68 65 20 63 61 6c 6c |able in |the call|
|00000210| 69 6e 67 20 65 6e 76 69 | 72 6f 6e 6d 65 6e 74 2e |ing envi|ronment.|
|00000220| 0a 0a 54 68 65 20 66 69 | 72 73 74 20 63 6f 6e 64 |..The fi|rst cond|
|00000230| 69 74 69 6f 6e 20 69 73 | 20 61 6c 77 61 79 73 20 |ition is| always |
|00000240| 74 72 75 65 20 6f 66 20 | 6c 6f 63 61 6c 20 66 75 |true of |local fu|
|00000250| 6e 63 74 69 6f 6e 20 63 | 61 6c 6c 73 2e 20 20 45 |nction c|alls. E|
|00000260| 6e 76 69 72 6f 6e 6d 65 | 6e 74 0a 61 6e 61 6c 79 |nvironme|nt.analy|
|00000270| 73 69 73 20 63 61 6e 20 | 67 75 61 72 61 6e 74 65 |sis can |guarante|
|00000280| 65 20 74 68 61 74 20 74 | 68 65 20 73 65 63 6f 6e |e that t|he secon|
|00000290| 64 20 63 6f 6e 64 69 74 | 69 6f 6e 20 68 6f 6c 64 |d condit|ion hold|
|000002a0| 73 20 62 79 20 63 6c 6f | 73 69 6e 67 20 6f 76 65 |s by clo|sing ove|
|000002b0| 72 20 61 6e 79 0a 6e 65 | 65 64 65 64 20 76 61 6c |r any.ne|eded val|
|000002c0| 75 65 73 20 69 6e 20 74 | 68 65 20 63 61 6c 6c 69 |ues in t|he calli|
|000002d0| 6e 67 20 65 6e 76 69 72 | 6f 6e 6d 65 6e 74 2e 0a |ng envir|onment..|
|000002e0| 0a 49 66 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e |.If the |function|
|000002f0| 20 74 68 61 74 20 63 6c | 6f 73 65 73 20 6f 76 65 | that cl|oses ove|
|00000300| 72 20 76 61 6c 75 65 73 | 20 6d 61 79 20 62 65 20 |r values| may be |
|00000310| 63 61 6c 6c 65 64 20 69 | 6e 20 61 6e 20 65 6e 76 |called i|n an env|
|00000320| 69 72 6f 6e 6d 65 6e 74 | 20 77 68 65 72 65 0a 74 |ironment| where.t|
|00000330| 68 65 20 63 6c 6f 73 65 | 64 20 6f 76 65 72 20 76 |he close|d over v|
|00000340| 61 6c 75 65 73 20 61 72 | 65 20 6e 6f 74 20 61 76 |alues ar|e not av|
|00000350| 61 69 6c 61 62 6c 65 2c | 20 74 68 65 6e 20 77 65 |ailable,| then we|
|00000360| 20 6d 75 73 74 20 73 74 | 6f 72 65 20 74 68 65 20 | must st|ore the |
|00000370| 76 61 6c 75 65 73 20 69 | 6e 20 61 0a 22 63 6c 6f |values i|n a."clo|
|00000380| 73 75 72 65 22 20 73 6f | 20 74 68 61 74 20 74 68 |sure" so| that th|
|00000390| 65 79 20 61 72 65 20 61 | 6c 77 61 79 73 20 61 63 |ey are a|lways ac|
|000003a0| 63 65 73 73 69 62 6c 65 | 2e 20 20 43 6c 6f 73 75 |cessible|. Closu|
|000003b0| 72 65 73 20 61 72 65 20 | 63 61 6c 6c 65 64 20 75 |res are |called u|
|000003c0| 73 69 6e 67 20 74 68 65 | 0a 22 66 75 6c 6c 20 63 |sing the|."full c|
|000003d0| 61 6c 6c 22 20 63 6f 6e | 76 65 6e 74 69 6f 6e 2e |all" con|vention.|
|000003e0| 20 20 57 68 65 6e 20 61 | 20 63 6c 6f 73 75 72 65 | When a| closure|
|000003f0| 20 69 73 20 63 61 6c 6c | 65 64 2c 20 63 6f 6e 74 | is call|ed, cont|
|00000400| 72 6f 6c 20 69 73 20 74 | 72 61 6e 73 66 65 72 72 |rol is t|ransferr|
|00000410| 65 64 20 74 6f 0a 74 68 | 65 20 22 65 78 74 65 72 |ed to.th|e "exter|
|00000420| 6e 61 6c 20 65 6e 74 72 | 79 20 70 6f 69 6e 74 22 |nal entr|y point"|
|00000430| 2c 20 77 68 69 63 68 20 | 66 65 74 63 68 65 73 20 |, which |fetches |
|00000440| 74 68 65 20 76 61 6c 75 | 65 73 20 6f 75 74 20 6f |the valu|es out o|
|00000450| 66 20 74 68 65 20 63 6c | 6f 73 75 72 65 20 61 6e |f the cl|osure an|
|00000460| 64 0a 74 68 65 6e 20 64 | 6f 65 73 20 61 20 6c 6f |d.then d|oes a lo|
|00000470| 63 61 6c 20 63 61 6c 6c | 20 74 6f 20 74 68 65 20 |cal call| to the |
|00000480| 72 65 61 6c 20 66 75 6e | 63 74 69 6f 6e 2c 20 70 |real fun|ction, p|
|00000490| 61 73 73 69 6e 67 20 74 | 68 65 20 63 6c 6f 73 75 |assing t|he closu|
|000004a0| 72 65 20 76 61 6c 75 65 | 73 20 61 73 0a 69 6d 70 |re value|s as.imp|
|000004b0| 6c 69 63 69 74 20 61 72 | 67 75 6d 65 6e 74 73 2e |licit ar|guments.|
|000004c0| 0a 0a 49 6e 20 74 68 69 | 73 20 73 63 68 65 6d 65 |..In thi|s scheme|
|000004d0| 20 74 68 65 72 65 20 69 | 73 20 6e 6f 20 73 75 63 | there i|s no suc|
|000004e0| 68 20 74 68 69 6e 67 20 | 61 73 20 61 20 22 68 65 |h thing |as a "he|
|000004f0| 61 70 20 63 6c 6f 73 75 | 72 65 20 76 61 72 69 61 |ap closu|re varia|
|00000500| 62 6c 65 22 20 69 6e 20 | 63 6f 64 65 2c 0a 73 69 |ble" in |code,.si|
|00000510| 6e 63 65 20 74 68 65 20 | 63 6c 6f 73 75 72 65 20 |nce the |closure |
|00000520| 76 61 6c 75 65 73 20 61 | 72 65 20 6d 6f 76 65 64 |values a|re moved|
|00000530| 20 69 6e 74 6f 20 54 4e | 73 20 62 79 20 74 68 65 | into TN|s by the|
|00000540| 20 65 78 74 65 72 6e 61 | 6c 20 65 6e 74 72 79 20 | externa|l entry |
|00000550| 70 6f 69 6e 74 2e 20 20 | 54 68 65 72 65 0a 69 73 |point. |There.is|
|00000560| 20 73 6f 6d 65 20 70 6f | 74 65 6e 74 69 61 6c 20 | some po|tential |
|00000570| 66 6f 72 20 70 65 73 73 | 69 6d 69 7a 61 74 69 6f |for pess|imizatio|
|00000580| 6e 20 68 65 72 65 2c 20 | 73 69 6e 63 65 20 77 65 |n here, |since we|
|00000590| 20 6d 61 79 20 65 6e 64 | 20 75 70 20 6d 6f 76 69 | may end| up movi|
|000005a0| 6e 67 20 74 68 65 20 76 | 61 6c 75 65 73 0a 66 72 |ng the v|alues.fr|
|000005b0| 6f 6d 20 74 68 65 20 63 | 6c 6f 73 75 72 65 20 69 |om the c|losure i|
|000005c0| 6e 74 6f 20 61 20 73 74 | 61 63 6b 20 6d 65 6d 6f |nto a st|ack memo|
|000005d0| 72 79 20 6c 6f 63 61 74 | 69 6f 6e 2c 20 62 75 74 |ry locat|ion, but|
|000005e0| 20 74 68 65 20 61 64 76 | 61 6e 74 61 67 65 73 20 | the adv|antages |
|000005f0| 61 72 65 20 61 6c 73 6f | 0a 73 75 62 73 74 61 6e |are also|.substan|
|00000600| 74 69 61 6c 2e 20 20 53 | 69 6d 70 6c 69 63 69 74 |tial. S|implicit|
|00000610| 79 20 69 73 20 67 61 69 | 6e 65 64 20 62 79 20 61 |y is gai|ned by a|
|00000620| 6c 77 61 79 73 20 72 65 | 70 72 65 73 65 6e 74 69 |lways re|presenti|
|00000630| 6e 67 20 63 6c 6f 73 75 | 72 65 20 76 61 6c 75 65 |ng closu|re value|
|00000640| 73 20 74 68 65 0a 73 61 | 6d 65 20 77 61 79 2c 20 |s the.sa|me way, |
|00000650| 61 6e 64 20 66 75 6e 63 | 74 69 6f 6e 73 20 77 69 |and func|tions wi|
|00000660| 74 68 20 63 6c 6f 73 75 | 72 65 20 72 65 66 65 72 |th closu|re refer|
|00000670| 65 6e 63 65 73 20 6d 61 | 79 20 73 74 69 6c 6c 20 |ences ma|y still |
|00000680| 62 65 20 63 61 6c 6c 65 | 64 20 6c 6f 63 61 6c 6c |be calle|d locall|
|00000690| 79 0a 77 69 74 68 6f 75 | 74 20 61 6c 6c 6f 63 61 |y.withou|t alloca|
|000006a0| 74 69 6e 67 20 61 20 63 | 6c 6f 73 75 72 65 2e 20 |ting a c|losure. |
|000006b0| 20 41 6c 6c 20 74 68 65 | 20 54 4e 20 62 61 73 65 | All the| TN base|
|000006c0| 64 20 56 4d 52 20 6f 70 | 74 69 6d 69 7a 61 74 69 |d VMR op|timizati|
|000006d0| 6f 6e 73 20 77 69 6c 6c | 20 61 70 70 6c 79 0a 74 |ons will| apply.t|
|000006e0| 6f 20 63 6c 6f 73 75 72 | 65 20 76 61 72 69 61 62 |o closur|e variab|
|000006f0| 6c 65 73 2c 20 73 69 6e | 63 65 20 63 6c 6f 73 75 |les, sin|ce closu|
|00000700| 72 65 20 76 61 72 69 61 | 62 6c 65 73 20 61 72 65 |re varia|bles are|
|00000710| 20 72 65 70 72 65 73 65 | 6e 74 65 64 20 69 6e 20 | represe|nted in |
|00000720| 74 68 65 20 73 61 6d 65 | 20 77 61 79 0a 61 73 20 |the same| way.as |
|00000730| 61 6c 6c 20 6f 74 68 65 | 72 20 76 61 72 69 61 62 |all othe|r variab|
|00000740| 6c 65 73 20 69 6e 20 56 | 4d 52 2e 20 20 43 6c 6f |les in V|MR. Clo|
|00000750| 73 75 72 65 20 76 61 6c | 75 65 73 20 77 69 6c 6c |sure val|ues will|
|00000760| 20 62 65 20 61 6c 6c 6f | 63 61 74 65 64 20 69 6e | be allo|cated in|
|00000770| 20 72 65 67 69 73 74 65 | 72 73 0a 77 68 65 72 65 | registe|rs.where|
|00000780| 20 61 70 70 72 6f 70 72 | 69 61 74 65 2e 0a 0a 43 | appropr|iate...C|
|00000790| 6c 6f 73 75 72 65 73 20 | 61 72 65 20 63 72 65 61 |losures |are crea|
|000007a0| 74 65 64 20 61 74 20 74 | 68 65 20 70 6f 69 6e 74 |ted at t|he point|
|000007b0| 20 77 68 65 72 65 20 74 | 68 65 20 66 75 6e 63 74 | where t|he funct|
|000007c0| 69 6f 6e 20 69 73 20 72 | 65 66 65 72 65 6e 63 65 |ion is r|eference|
|000007d0| 64 2c 20 65 6c 69 6d 69 | 6e 61 74 69 6e 67 0a 74 |d, elimi|nating.t|
|000007e0| 68 65 20 6e 65 65 64 20 | 74 6f 20 62 65 20 61 62 |he need |to be ab|
|000007f0| 6c 65 20 74 6f 20 63 6c | 6f 73 65 20 6f 76 65 72 |le to cl|ose over|
|00000800| 20 63 6c 6f 73 75 72 65 | 73 2e 20 20 54 68 69 73 | closure|s. This|
|00000810| 20 6c 61 7a 79 20 63 72 | 65 61 74 69 6f 6e 20 6f | lazy cr|eation o|
|00000820| 66 20 63 6c 6f 73 75 72 | 65 73 20 68 61 73 0a 74 |f closur|es has.t|
|00000830| 68 65 20 61 64 64 69 74 | 69 6f 6e 61 6c 20 61 64 |he addit|ional ad|
|00000840| 76 61 6e 74 61 67 65 20 | 74 68 61 74 20 77 68 65 |vantage |that whe|
|00000850| 6e 20 61 20 63 6c 6f 73 | 75 72 65 20 72 65 66 65 |n a clos|ure refe|
|00000860| 72 65 6e 63 65 20 69 73 | 20 63 6f 6e 64 69 74 69 |rence is| conditi|
|00000870| 6f 6e 61 6c 6c 79 20 6e | 6f 74 0a 64 6f 6e 65 2c |onally n|ot.done,|
|00000880| 20 74 68 65 6e 20 74 68 | 65 20 63 6c 6f 73 75 72 | then th|e closur|
|00000890| 65 20 63 6f 6e 73 69 6e | 67 20 77 69 6c 6c 20 6e |e consin|g will n|
|000008a0| 65 76 65 72 20 62 65 20 | 64 6f 6e 65 20 61 74 20 |ever be |done at |
|000008b0| 61 6c 6c 2e 20 20 54 68 | 65 20 63 6f 72 72 65 73 |all. Th|e corres|
|000008c0| 70 6f 6e 64 69 6e 67 0a | 64 69 73 61 64 76 61 6e |ponding.|disadvan|
|000008d0| 74 61 67 65 20 69 73 20 | 74 68 61 74 20 61 20 63 |tage is |that a c|
|000008e0| 6c 6f 73 75 72 65 20 6f | 76 65 72 20 74 68 65 20 |losure o|ver the |
|000008f0| 73 61 6d 65 20 76 61 6c | 75 65 73 20 6d 61 79 20 |same val|ues may |
|00000900| 62 65 20 63 72 65 61 74 | 65 64 20 6d 75 6c 74 69 |be creat|ed multi|
|00000910| 70 6c 65 0a 74 69 6d 65 | 73 20 69 66 20 74 68 65 |ple.time|s if the|
|00000920| 72 65 20 61 72 65 20 6d | 75 6c 74 69 70 6c 65 20 |re are m|ultiple |
|00000930| 72 65 66 65 72 65 6e 63 | 65 73 2e 20 20 4e 6f 74 |referenc|es. Not|
|00000940| 65 20 68 6f 77 65 76 65 | 72 2c 20 74 68 61 74 20 |e howeve|r, that |
|00000950| 56 4d 52 20 6c 6f 6f 70 | 20 61 6e 64 20 63 6f 6d |VMR loop| and com|
|00000960| 6d 6f 6e 0a 73 75 62 65 | 78 70 72 65 73 73 69 6f |mon.sube|xpressio|
|00000970| 6e 20 6f 70 74 69 6d 69 | 7a 61 74 69 6f 6e 73 20 |n optimi|zations |
|00000980| 63 61 6e 20 65 6c 69 6d | 69 6e 61 74 65 20 72 65 |can elim|inate re|
|00000990| 64 75 6e 64 61 6e 74 20 | 63 6c 6f 73 75 72 65 20 |dundant |closure |
|000009a0| 63 6f 6e 73 69 6e 67 2e | 20 20 49 6e 20 61 6e 79 |consing.| In any|
|000009b0| 0a 63 61 73 65 2c 20 6d | 75 6c 74 69 70 6c 65 20 |.case, m|ultiple |
|000009c0| 63 6c 6f 73 75 72 65 73 | 20 6f 76 65 72 20 74 68 |closures| over th|
|000009d0| 65 20 73 61 6d 65 20 76 | 61 72 69 61 62 6c 65 73 |e same v|ariables|
|000009e0| 20 64 6f 65 73 6e 27 74 | 20 73 65 65 6d 20 74 6f | doesn't| seem to|
|000009f0| 20 62 65 20 74 68 61 74 | 20 63 6f 6d 6d 6f 6e 2e | be that| common.|
|00000a00| 0a 0a 5c 23 7c 0a 48 61 | 76 69 6e 67 20 74 68 65 |..\#|.Ha|ving the|
|00000a10| 20 54 61 69 6c 2d 49 6e | 66 6f 20 77 6f 75 6c 64 | Tail-In|fo would|
|00000a20| 20 61 6c 73 6f 20 6d 61 | 6b 65 20 72 65 74 75 72 | also ma|ke retur|
|00000a30| 6e 20 63 6f 6e 76 65 6e | 74 69 6f 6e 20 64 65 74 |n conven|tion det|
|00000a40| 65 72 6d 69 6e 61 74 69 | 6f 6e 20 74 72 69 76 69 |erminati|on trivi|
|00000a50| 61 6c 2e 0a 57 65 20 63 | 6f 75 6c 64 20 6a 75 73 |al..We c|ould jus|
|00000a60| 74 20 6c 6f 6f 6b 20 61 | 74 20 74 68 65 20 74 79 |t look a|t the ty|
|00000a70| 70 65 2c 20 63 68 65 63 | 6b 69 6e 67 20 74 6f 20 |pe, chec|king to |
|00000a80| 73 65 65 20 69 66 20 69 | 74 20 72 65 70 72 65 73 |see if i|t repres|
|00000a90| 65 6e 74 73 20 61 20 66 | 69 78 65 64 20 6e 75 6d |ents a f|ixed num|
|00000aa0| 62 65 72 0a 6f 66 20 76 | 61 6c 75 65 73 2e 20 20 |ber.of v|alues. |
|00000ab0| 54 6f 20 64 65 74 65 72 | 6d 69 6e 65 20 69 66 20 |To deter|mine if |
|00000ac0| 74 68 65 20 73 74 61 6e | 64 61 72 64 20 72 65 74 |the stan|dard ret|
|00000ad0| 75 72 6e 20 63 6f 6e 76 | 65 6e 74 69 6f 6e 20 69 |urn conv|ention i|
|00000ae0| 73 20 6e 65 63 65 73 73 | 61 72 79 20 74 6f 0a 70 |s necess|ary to.p|
|00000af0| 72 65 73 65 72 76 65 20 | 74 61 69 6c 2d 72 65 63 |reserve |tail-rec|
|00000b00| 75 72 73 69 6f 6e 2c 20 | 77 65 20 6a 75 73 74 20 |ursion, |we just |
|00000b10| 69 74 65 72 61 74 65 20 | 6f 76 65 72 20 74 68 65 |iterate |over the|
|00000b20| 20 65 71 75 69 76 61 6c | 65 6e 74 20 66 75 6e 63 | equival|ent func|
|00000b30| 74 69 6f 6e 73 2c 20 6c | 6f 6f 6b 69 6e 67 0a 66 |tions, l|ooking.f|
|00000b40| 6f 72 20 58 45 50 73 20 | 61 6e 64 20 75 73 65 73 |or XEPs |and uses|
|00000b50| 20 69 6e 20 66 75 6c 6c | 20 63 61 6c 6c 73 2e 0a | in full| calls..|
|00000b60| 7c 5c 23 0a 0a 54 68 65 | 20 47 6c 6f 62 61 6c 20 ||\#..The| Global |
|00000b70| 54 4e 20 41 73 73 69 67 | 6e 6d 65 6e 74 20 70 61 |TN Assig|nment pa|
|00000b80| 73 73 20 28 47 54 4e 29 | 20 63 61 6e 20 62 65 20 |ss (GTN)| can be |
|00000b90| 63 6f 6e 73 69 64 65 72 | 65 64 20 61 20 70 6f 73 |consider|ed a pos|
|00000ba0| 74 2d 70 61 73 73 20 74 | 6f 0a 65 6e 76 69 72 6f |t-pass t|o.enviro|
|00000bb0| 6e 6d 65 6e 74 20 61 6e | 61 6c 79 73 69 73 2e 20 |nment an|alysis. |
|00000bc0| 20 54 68 69 73 20 70 68 | 61 73 65 20 61 73 73 69 | This ph|ase assi|
|00000bd0| 67 6e 73 20 74 68 65 20 | 54 4e 73 20 75 73 65 64 |gns the |TNs used|
|00000be0| 20 74 6f 20 68 6f 6c 64 | 20 6c 6f 63 61 6c 20 6c | to hold| local l|
|00000bf0| 65 78 69 63 61 6c 0a 76 | 61 72 69 61 62 6c 65 73 |exical.v|ariables|
|00000c00| 20 61 6e 64 20 70 61 73 | 73 20 61 72 67 75 6d 65 | and pas|s argume|
|00000c10| 6e 74 73 20 61 6e 64 20 | 72 65 74 75 72 6e 20 76 |nts and |return v|
|00000c20| 61 6c 75 65 73 20 61 6e | 64 20 64 65 74 65 72 6d |alues an|d determ|
|00000c30| 69 6e 65 73 20 74 68 65 | 20 76 61 6c 75 65 2d 70 |ines the| value-p|
|00000c40| 61 73 73 69 6e 67 0a 73 | 74 72 61 74 65 67 79 20 |assing.s|trategy |
|00000c50| 75 73 65 64 20 69 6e 20 | 6c 6f 63 61 6c 20 63 61 |used in |local ca|
|00000c60| 6c 6c 73 2e 0a 0a 54 6f | 20 61 73 73 69 67 6e 20 |lls...To| assign |
|00000c70| 72 65 74 75 72 6e 20 6c | 6f 63 61 74 69 6f 6e 73 |return l|ocations|
|00000c80| 2c 20 77 65 20 6c 6f 6f | 6b 20 61 74 20 74 68 65 |, we loo|k at the|
|00000c90| 20 66 75 6e 63 74 69 6f | 6e 27 73 20 74 61 69 6c | functio|n's tail|
|00000ca0| 2d 73 65 74 2e 0a 0a 49 | 66 20 74 68 65 20 72 65 |-set...I|f the re|
|00000cb0| 73 75 6c 74 20 63 6f 6e | 74 69 6e 75 61 74 69 6f |sult con|tinuatio|
|00000cc0| 6e 20 66 6f 72 20 61 6e | 20 65 6e 74 72 79 20 70 |n for an| entry p|
|00000cd0| 6f 69 6e 74 20 69 73 20 | 75 73 65 64 20 61 73 20 |oint is |used as |
|00000ce0| 74 68 65 20 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |the cont|inuation|
|00000cf0| 20 66 6f 72 20 61 0a 66 | 75 6c 6c 20 63 61 6c 6c | for a.f|ull call|
|00000d00| 2c 20 74 68 65 6e 20 77 | 65 20 6d 61 79 20 6e 65 |, then w|e may ne|
|00000d10| 65 64 20 74 6f 20 63 6f | 6e 73 74 72 61 69 6e 20 |ed to co|nstrain |
|00000d20| 74 68 65 20 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |the cont|inuation|
|00000d30| 27 73 20 76 61 6c 75 65 | 73 20 70 61 73 73 69 6e |'s value|s passin|
|00000d40| 67 0a 63 6f 6e 76 65 6e | 74 69 6f 6e 20 74 6f 20 |g.conven|tion to |
|00000d50| 74 68 65 20 73 74 61 6e | 64 61 72 64 20 6f 6e 65 |the stan|dard one|
|00000d60| 2e 20 20 54 68 69 73 20 | 69 73 20 6e 6f 74 20 6e |. This |is not n|
|00000d70| 65 63 65 73 73 61 72 79 | 20 77 68 65 6e 20 74 68 |ecessary| when th|
|00000d80| 65 20 63 61 6c 6c 20 69 | 73 20 6b 6e 6f 77 6e 0a |e call i|s known.|
|00000d90| 6e 6f 74 20 74 6f 20 62 | 65 20 70 61 72 74 20 6f |not to b|e part o|
|00000da0| 66 20 61 20 74 61 69 6c | 2d 72 65 63 75 72 73 69 |f a tail|-recursi|
|00000db0| 76 65 20 6c 6f 6f 70 20 | 28 64 75 65 20 74 6f 20 |ve loop |(due to |
|00000dc0| 62 65 69 6e 67 20 61 20 | 6b 6e 6f 77 6e 20 66 75 |being a |known fu|
|00000dd0| 6e 63 74 69 6f 6e 29 2e | 0a 0a 4f 6e 63 65 20 77 |nction).|..Once w|
|00000de0| 65 20 68 61 76 65 20 66 | 69 67 75 72 65 64 20 6f |e have f|igured o|
|00000df0| 75 74 20 77 68 65 72 65 | 20 77 65 20 6d 75 73 74 |ut where| we must|
|00000e00| 20 75 73 65 20 74 68 65 | 20 73 74 61 6e 64 61 72 | use the| standar|
|00000e10| 64 20 76 61 6c 75 65 20 | 70 61 73 73 69 6e 67 20 |d value |passing |
|00000e20| 73 74 72 61 74 65 67 79 | 2c 0a 77 65 20 63 61 6e |strategy|,.we can|
|00000e30| 20 75 73 65 20 61 20 6d | 6f 72 65 20 66 6c 65 78 | use a m|ore flex|
|00000e40| 69 62 6c 65 20 73 74 72 | 61 74 65 67 79 20 74 6f |ible str|ategy to|
|00000e50| 20 64 65 74 65 72 6d 69 | 6e 65 20 74 68 65 20 72 | determi|ne the r|
|00000e60| 65 74 75 72 6e 20 6c 6f | 63 61 74 69 6f 6e 73 20 |eturn lo|cations |
|00000e70| 66 6f 72 20 6c 6f 63 61 | 6c 0a 66 75 6e 63 74 69 |for loca|l.functi|
|00000e80| 6f 6e 73 2e 20 20 57 65 | 20 64 65 74 65 72 6d 69 |ons. We| determi|
|00000e90| 6e 65 20 74 68 65 20 70 | 6f 73 73 69 62 6c 65 20 |ne the p|ossible |
|00000ea0| 6e 75 6d 62 65 72 73 20 | 6f 66 20 72 65 74 75 72 |numbers |of retur|
|00000eb0| 6e 20 76 61 6c 75 65 73 | 20 66 72 6f 6d 20 65 61 |n values| from ea|
|00000ec0| 63 68 0a 66 75 6e 63 74 | 69 6f 6e 20 62 79 20 65 |ch.funct|ion by e|
|00000ed0| 78 61 6d 69 6e 69 6e 67 | 20 74 68 65 20 75 73 65 |xamining| the use|
|00000ee0| 73 20 6f 66 20 61 6c 6c | 20 74 68 65 20 72 65 73 |s of all| the res|
|00000ef0| 75 6c 74 20 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |ult cont|inuation|
|00000f00| 73 20 69 6e 20 74 68 65 | 0a 65 71 75 69 76 61 6c |s in the|.equival|
|00000f10| 65 6e 63 65 20 63 6c 61 | 73 73 20 6f 66 20 74 68 |ence cla|ss of th|
|00000f20| 65 20 72 65 73 75 6c 74 | 20 63 6f 6e 74 69 6e 75 |e result| continu|
|00000f30| 61 74 69 6f 6e 2e 0a 0a | 49 66 20 74 68 65 20 74 |ation...|If the t|
|00000f40| 61 69 6c 2d 73 65 74 20 | 74 79 70 65 20 69 73 20 |ail-set |type is |
|00000f50| 66 6f 72 20 61 20 66 69 | 78 65 64 20 6e 75 6d 62 |for a fi|xed numb|
|00000f60| 65 72 20 6f 66 0a 76 61 | 6c 75 65 73 2c 20 74 68 |er of.va|lues, th|
|00000f70| 65 6e 20 77 65 20 72 65 | 74 75 72 6e 20 74 68 61 |en we re|turn tha|
|00000f80| 74 20 66 69 78 65 64 20 | 6e 75 6d 62 65 72 20 6f |t fixed |number o|
|00000f90| 66 20 76 61 6c 75 65 73 | 20 66 72 6f 6d 20 61 6c |f values| from al|
|00000fa0| 6c 20 74 68 65 20 66 75 | 6e 63 74 69 6f 6e 73 20 |l the fu|nctions |
|00000fb0| 77 68 6f 73 65 0a 72 65 | 73 75 6c 74 20 63 6f 6e |whose.re|sult con|
|00000fc0| 74 69 6e 75 61 74 69 6f | 6e 73 20 61 72 65 20 65 |tinuatio|ns are e|
|00000fd0| 71 75 61 74 65 64 2e 20 | 20 49 66 20 74 68 65 20 |quated. | If the |
|00000fe0| 6e 75 6d 62 65 72 20 6f | 66 20 76 61 6c 75 65 73 |number o|f values|
|00000ff0| 20 69 73 20 6e 6f 74 20 | 66 69 78 65 64 2c 20 74 | is not |fixed, t|
|00001000| 68 65 6e 0a 77 65 20 6d | 75 73 74 20 75 73 65 20 |hen.we m|ust use |
|00001010| 74 68 65 20 75 6e 6b 6e | 6f 77 6e 2d 76 61 6c 75 |the unkn|own-valu|
|00001020| 65 73 20 63 6f 6e 76 65 | 6e 74 69 6f 6e 2c 20 61 |es conve|ntion, a|
|00001030| 6c 74 68 6f 75 67 68 20 | 77 65 20 61 72 65 20 6e |lthough |we are n|
|00001040| 6f 74 20 66 6f 72 63 65 | 64 20 74 6f 20 75 73 65 |ot force|d to use|
|00001050| 0a 74 68 65 20 73 74 61 | 6e 64 61 72 64 20 6c 6f |.the sta|ndard lo|
|00001060| 63 61 74 69 6f 6e 73 2e | 20 20 57 65 20 61 73 73 |cations.| We ass|
|00001070| 69 67 6e 20 74 68 65 20 | 72 65 73 75 6c 74 20 54 |ign the |result T|
|00001080| 4e 73 20 61 74 20 74 68 | 69 73 20 74 69 6d 65 2e |Ns at th|is time.|
|00001090| 0a 0a 57 65 20 61 6c 73 | 6f 20 75 73 65 20 74 68 |..We als|o use th|
|000010a0| 65 20 74 61 69 6c 2d 73 | 65 74 73 20 74 6f 20 73 |e tail-s|ets to s|
|000010b0| 65 65 20 77 68 61 74 20 | 63 6f 6e 76 65 6e 74 69 |ee what |conventi|
|000010c0| 6f 6e 20 77 65 20 77 61 | 6e 74 20 74 6f 20 75 73 |on we wa|nt to us|
|000010d0| 65 2e 20 20 57 68 61 74 | 20 77 65 20 64 6f 20 69 |e. What| we do i|
|000010e0| 73 0a 75 73 65 20 74 68 | 65 20 66 75 6c 6c 20 63 |s.use th|e full c|
|000010f0| 6f 6e 76 65 6e 74 69 6f | 6e 20 66 6f 72 20 61 6e |onventio|n for an|
|00001100| 79 20 66 75 6e 63 74 69 | 6f 6e 20 74 68 61 74 20 |y functi|on that |
|00001110| 68 61 73 20 61 20 58 45 | 50 20 69 74 73 20 74 61 |has a XE|P its ta|
|00001120| 69 6c 2d 73 65 74 2c 20 | 65 76 65 6e 20 69 66 0a |il-set, |even if.|
|00001130| 77 65 20 61 72 65 6e 27 | 74 20 72 65 71 75 69 72 |we aren'|t requir|
|00001140| 65 64 20 74 6f 20 64 6f | 20 73 6f 20 62 79 20 61 |ed to do| so by a|
|00001150| 20 74 61 69 6c 2d 72 65 | 63 75 72 73 69 76 65 20 | tail-re|cursive |
|00001160| 66 75 6c 6c 20 63 61 6c | 6c 2c 20 61 73 20 6c 6f |full cal|l, as lo|
|00001170| 6e 67 20 61 73 20 74 68 | 65 72 65 20 61 72 65 0a |ng as th|ere are.|
|00001180| 6e 6f 20 6e 6f 6e 2d 74 | 61 69 6c 2d 72 65 63 75 |no non-t|ail-recu|
|00001190| 72 73 69 76 65 20 6c 6f | 63 61 6c 20 63 61 6c 6c |rsive lo|cal call|
|000011a0| 73 20 69 6e 20 74 68 65 | 20 73 65 74 2e 20 20 54 |s in the| set. T|
|000011b0| 68 69 73 20 70 72 65 76 | 65 6e 74 73 20 75 73 20 |his prev|ents us |
|000011c0| 66 72 6f 6d 0a 67 72 61 | 74 75 69 74 6f 75 73 6c |from.gra|tuitousl|
|000011d0| 79 20 75 73 69 6e 67 20 | 61 20 6e 6f 6e 2d 73 74 |y using |a non-st|
|000011e0| 61 6e 64 61 72 64 20 63 | 6f 6e 76 65 6e 74 69 6f |andard c|onventio|
|000011f0| 6e 20 77 68 65 6e 20 74 | 68 65 72 65 20 69 73 20 |n when t|here is |
|00001200| 6e 6f 20 72 65 61 73 6f | 6e 20 74 6f 2e 0a 0a 0c |no reaso|n to....|
|00001210| 0a 5c 63 68 61 70 74 65 | 72 7b 4c 6f 63 61 6c 20 |.\chapte|r{Local |
|00001220| 54 4e 20 61 73 73 69 67 | 6e 6d 65 6e 74 7d 0a 0a |TN assig|nment}..|
|00001230| 5b 57 61 6e 74 20 61 20 | 64 69 66 66 65 72 65 6e |[Want a |differen|
|00001240| 74 20 6e 61 6d 65 20 66 | 6f 72 20 74 68 69 73 20 |t name f|or this |
|00001250| 73 6f 20 61 73 20 6e 6f | 74 20 74 6f 20 62 65 20 |so as no|t to be |
|00001260| 63 6f 6e 66 75 73 65 64 | 20 77 69 74 68 20 74 68 |confused| with th|
|00001270| 65 20 64 69 66 66 65 72 | 65 6e 74 0a 6c 6f 63 61 |e differ|ent.loca|
|00001280| 6c 2f 67 6c 6f 62 61 6c | 20 54 4e 20 72 65 70 72 |l/global| TN repr|
|00001290| 65 73 65 6e 74 61 74 69 | 6f 6e 73 2e 20 20 54 68 |esentati|ons. Th|
|000012a0| 65 20 72 65 61 6c 6c 79 | 20 69 6e 74 65 72 65 73 |e really| interes|
|000012b0| 74 69 6e 67 20 73 74 75 | 66 66 20 69 6e 20 74 68 |ting stu|ff in th|
|000012c0| 69 73 20 70 68 61 73 65 | 20 69 73 0a 6f 70 65 72 |is phase| is.oper|
|000012d0| 61 74 69 6f 6e 20 73 65 | 6c 65 63 74 69 6f 6e 2c |ation se|lection,|
|000012e0| 20 76 61 6c 75 65 73 20 | 72 65 70 72 65 73 65 6e | values |represen|
|000012f0| 74 61 74 69 6f 6e 20 73 | 65 6c 65 63 74 69 6f 6e |tation s|election|
|00001300| 2c 20 72 65 74 75 72 6e | 20 73 74 72 61 74 65 67 |, return| strateg|
|00001310| 79 2c 20 65 74 63 2e 0a | 4d 61 79 62 65 20 74 68 |y, etc..|Maybe th|
|00001320| 69 73 20 70 68 61 73 65 | 20 73 68 6f 75 6c 64 20 |is phase| should |
|00001330| 62 65 20 63 6f 6e 63 65 | 70 74 75 61 6c 6c 79 20 |be conce|ptually |
|00001340| 6c 75 6d 70 65 64 20 77 | 69 74 68 20 47 54 4e 20 |lumped w|ith GTN |
|00001350| 61 73 20 22 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |as "impl|ementati|
|00001360| 6f 6e 0a 73 65 6c 65 63 | 74 69 6f 6e 22 2c 20 73 |on.selec|tion", s|
|00001370| 69 6e 63 65 20 47 54 4e | 20 64 65 74 65 72 6d 69 |ince GTN| determi|
|00001380| 6e 65 73 20 63 61 6c 6c | 20 73 74 72 61 74 65 67 |nes call| strateg|
|00001390| 69 65 73 20 61 6e 64 20 | 6c 6f 63 61 74 69 6f 6e |ies and |location|
|000013a0| 73 2e 5d 0a 0a 5c 23 7c | 0a 0a 5b 5c 23 5c 23 5c |s.]..\#||..[\#\#\|
|000013b0| 23 20 49 20 67 75 65 73 | 73 20 49 20 62 65 6c 69 |# I gues|s I beli|
|000013c0| 65 76 65 20 74 68 61 74 | 20 69 74 20 69 73 20 4f |eve that| it is O|
|000013d0| 4b 20 66 6f 72 20 56 4d | 52 20 63 6f 6e 76 65 72 |K for VM|R conver|
|000013e0| 73 69 6f 6e 20 74 6f 20 | 64 69 63 6b 20 74 68 65 |sion to |dick the|
|000013f0| 20 49 43 52 20 66 6c 6f | 77 0a 67 72 61 70 68 2e | ICR flo|w.graph.|
|00001400| 20 20 41 6e 20 61 6c 74 | 65 72 6e 61 74 69 76 65 | An alt|ernative|
|00001410| 20 77 6f 75 6c 64 20 62 | 65 20 74 6f 20 67 69 76 | would b|e to giv|
|00001420| 65 20 56 4d 52 20 69 74 | 73 20 76 65 72 79 20 6f |e VMR it|s very o|
|00001430| 77 6e 20 66 6c 6f 77 20 | 67 72 61 70 68 2c 20 62 |wn flow |graph, b|
|00001440| 75 74 20 74 68 61 74 0a | 73 65 65 6d 73 20 6c 69 |ut that.|seems li|
|00001450| 6b 65 20 6f 76 65 72 6b | 69 6c 6c 2e 0a 0a 49 6e |ke overk|ill...In|
|00001460| 20 70 61 72 74 69 63 75 | 6c 61 72 2c 20 69 74 20 | particu|lar, it |
|00001470| 77 6f 75 6c 64 20 62 65 | 20 76 65 72 79 20 6e 69 |would be| very ni|
|00001480| 63 65 20 69 66 20 61 20 | 54 52 20 6c 6f 63 61 6c |ce if a |TR local|
|00001490| 20 63 61 6c 6c 20 6c 6f | 6f 6b 65 64 20 65 78 61 | call lo|oked exa|
|000014a0| 63 74 6c 79 20 6c 69 6b | 65 20 61 0a 6a 75 6d 70 |ctly lik|e a.jump|
|000014b0| 20 69 6e 20 56 4d 52 2e | 20 20 54 68 69 73 20 77 | in VMR.| This w|
|000014c0| 6f 75 6c 64 20 61 6c 6c | 6f 77 20 6c 6f 6f 70 20 |ould all|ow loop |
|000014d0| 6f 70 74 69 6d 69 7a 61 | 74 69 6f 6e 73 20 74 6f |optimiza|tions to|
|000014e0| 20 62 65 20 64 6f 6e 65 | 20 6f 6e 20 6c 6f 6f 70 | be done| on loop|
|000014f0| 73 20 77 72 69 74 74 65 | 6e 0a 61 73 20 72 65 63 |s writte|n.as rec|
|00001500| 75 72 73 69 6f 6e 73 2e | 20 20 49 6e 20 61 64 64 |ursions.| In add|
|00001510| 69 74 69 6f 6e 20 74 6f | 20 6d 61 6b 69 6e 67 20 |ition to| making |
|00001520| 74 68 65 20 63 61 6c 6c | 20 62 6c 6f 63 6b 20 74 |the call| block t|
|00001530| 72 61 6e 73 66 65 72 20 | 74 6f 20 74 68 65 20 68 |ransfer |to the h|
|00001540| 65 61 64 20 6f 66 0a 74 | 68 65 20 66 75 6e 63 74 |ead of.t|he funct|
|00001550| 69 6f 6e 20 72 61 74 68 | 65 72 20 74 68 61 6e 20 |ion rath|er than |
|00001560| 74 6f 20 74 68 65 20 72 | 65 74 75 72 6e 2c 20 77 |to the r|eturn, w|
|00001570| 65 20 77 6f 75 6c 64 20 | 61 6c 73 6f 20 68 61 76 |e would |also hav|
|00001580| 65 20 74 6f 20 64 6f 20 | 73 6f 6d 65 74 68 69 6e |e to do |somethin|
|00001590| 67 0a 61 62 6f 75 74 20 | 73 6b 69 70 70 69 6e 67 |g.about |skipping|
|000015a0| 20 74 68 65 20 70 61 72 | 74 20 6f 66 20 74 68 65 | the par|t of the|
|000015b0| 20 66 75 6e 63 74 69 6f | 6e 20 70 72 6f 6c 6f 67 | functio|n prolog|
|000015c0| 20 74 68 61 74 20 6d 6f | 76 65 73 20 61 72 67 75 | that mo|ves argu|
|000015d0| 6d 65 6e 74 73 20 66 72 | 6f 6d 20 74 68 65 0a 70 |ments fr|om the.p|
|000015e0| 61 73 73 69 6e 67 20 6c | 6f 63 61 74 69 6f 6e 73 |assing l|ocations|
|000015f0| 2c 20 73 69 6e 63 65 20 | 69 6e 20 61 20 54 52 20 |, since |in a TR |
|00001600| 63 61 6c 6c 20 74 68 65 | 79 20 61 72 65 20 61 6c |call the|y are al|
|00001610| 72 65 61 64 79 20 69 6e | 20 74 68 65 20 72 69 67 |ready in| the rig|
|00001620| 68 74 20 66 72 61 6d 65 | 2e 0a 0a 0a 49 6e 20 61 |ht frame|....In a|
|00001630| 64 64 69 74 69 6f 6e 20 | 74 6f 20 64 69 72 65 63 |ddition |to direc|
|00001640| 74 6c 79 20 69 6e 64 69 | 63 61 74 69 6e 67 20 77 |tly indi|cating w|
|00001650| 68 65 74 68 65 72 20 61 | 20 63 61 6c 6c 20 73 68 |hether a| call sh|
|00001660| 6f 75 6c 64 20 62 65 20 | 63 6f 64 65 64 20 77 69 |ould be |coded wi|
|00001670| 74 68 20 61 20 54 52 0a | 76 61 72 69 61 6e 74 2c |th a TR.|variant,|
|00001680| 20 74 68 65 20 54 61 69 | 6c 2d 50 20 61 6e 6e 6f | the Tai|l-P anno|
|00001690| 74 61 74 69 6f 6e 20 66 | 6c 61 67 73 20 6e 6f 6e |tation f|lags non|
|000016a0| 2d 63 61 6c 6c 20 6e 6f | 64 65 73 20 74 68 61 74 |-call no|des that|
|000016b0| 20 63 61 6e 20 64 69 72 | 65 63 74 6c 79 20 72 65 | can dir|ectly re|
|000016c0| 74 75 72 6e 0a 74 68 65 | 20 76 61 6c 75 65 20 28 |turn.the| value (|
|000016d0| 61 6e 20 22 61 64 76 61 | 6e 63 65 64 20 72 65 74 |an "adva|nced ret|
|000016e0| 75 72 6e 22 29 2c 20 72 | 61 74 68 65 72 20 74 68 |urn"), r|ather th|
|000016f0| 61 6e 20 6d 6f 76 69 6e | 67 20 74 68 65 20 76 61 |an movin|g the va|
|00001700| 6c 75 65 20 74 6f 20 74 | 68 65 20 72 65 73 75 6c |lue to t|he resul|
|00001710| 74 0a 63 6f 6e 74 69 6e | 75 61 74 69 6f 6e 20 61 |t.contin|uation a|
|00001720| 6e 64 20 6a 75 6d 70 69 | 6e 67 20 74 6f 20 74 68 |nd jumpi|ng to th|
|00001730| 65 20 72 65 74 75 72 6e | 20 63 6f 64 65 2e 20 20 |e return| code. |
|00001740| 54 68 65 6e 20 28 61 63 | 63 6f 72 64 69 6e 67 20 |Then (ac|cording |
|00001750| 74 6f 20 70 6f 6c 69 63 | 79 29 2c 20 77 65 0a 63 |to polic|y), we.c|
|00001760| 61 6e 20 64 65 63 69 64 | 65 20 74 6f 20 61 64 76 |an decid|e to adv|
|00001770| 61 6e 63 65 20 61 6c 6c | 20 70 6f 73 73 69 62 6c |ance all| possibl|
|00001780| 65 20 72 65 74 75 72 6e | 73 2e 20 20 49 66 20 61 |e return|s. If a|
|00001790| 6c 6c 20 75 73 65 73 20 | 6f 66 20 74 68 65 20 72 |ll uses |of the r|
|000017a0| 65 73 75 6c 74 20 61 72 | 65 0a 54 61 69 6c 2d 50 |esult ar|e.Tail-P|
|000017b0| 2c 20 74 68 65 6e 20 4c | 54 4e 20 63 61 6e 20 61 |, then L|TN can a|
|000017c0| 6e 6e 6f 74 61 74 65 20 | 74 68 65 20 72 65 73 75 |nnotate |the resu|
|000017d0| 6c 74 20 63 6f 6e 74 69 | 6e 75 61 74 69 6f 6e 20 |lt conti|nuation |
|000017e0| 61 73 20 3a 55 6e 75 73 | 65 64 2c 20 69 6e 68 69 |as :Unus|ed, inhi|
|000017f0| 62 69 74 69 6e 67 0a 65 | 6d 69 73 73 69 6f 6e 20 |biting.e|mission |
|00001800| 6f 66 20 74 68 65 20 64 | 65 66 61 75 6c 74 20 72 |of the d|efault r|
|00001810| 65 74 75 72 6e 20 63 6f | 64 65 2e 0a 0a 5b 5c 23 |eturn co|de...[\#|
|00001820| 5c 23 5c 23 20 42 75 74 | 20 6e 6f 74 20 72 65 61 |\#\# But| not rea|
|00001830| 6c 6c 79 2e 20 20 4e 6f | 77 20 74 68 65 72 65 20 |lly. No|w there |
|00001840| 69 73 20 61 20 73 69 6e | 67 6c 65 20 6c 69 73 74 |is a sin|gle list|
|00001850| 20 6f 66 20 74 65 6d 70 | 6c 61 74 65 73 2c 20 61 | of temp|lates, a|
|00001860| 6e 64 20 61 20 67 69 76 | 65 6e 0a 74 65 6d 70 6c |nd a giv|en.templ|
|00001870| 61 74 65 20 68 61 73 20 | 6f 6e 6c 79 20 6f 6e 65 |ate has |only one|
|00001880| 20 70 6f 6c 69 63 79 2e | 5d 0a 0a 49 6e 20 4c 54 | policy.|]..In LT|
|00001890| 4e 2c 20 77 65 20 75 73 | 65 20 74 68 65 20 3a 53 |N, we us|e the :S|
|000018a0| 61 66 65 20 74 65 6d 70 | 6c 61 74 65 20 61 73 20 |afe temp|late as |
|000018b0| 61 20 6c 61 73 74 20 72 | 65 73 6f 72 74 20 65 76 |a last r|esort ev|
|000018c0| 65 6e 20 77 68 65 6e 20 | 74 68 65 20 70 6f 6c 69 |en when |the poli|
|000018d0| 63 79 20 69 73 0a 75 6e | 73 61 66 65 2e 20 20 4e |cy is.un|safe. N|
|000018e0| 6f 74 65 20 74 68 61 74 | 20 77 65 20 64 6f 6e 27 |ote that| we don'|
|000018f0| 74 20 74 72 79 20 3a 46 | 61 73 74 2d 53 61 66 65 |t try :F|ast-Safe|
|00001900| 3b 20 69 66 20 74 68 69 | 73 20 69 73 20 61 6c 73 |; if thi|s is als|
|00001910| 6f 20 61 20 67 6f 6f 64 | 20 75 6e 73 61 66 65 0a |o a good| unsafe.|
|00001920| 74 65 6d 70 6c 61 74 65 | 2c 20 74 68 65 6e 20 69 |template|, then i|
|00001930| 74 20 73 68 6f 75 6c 64 | 20 68 61 76 65 20 74 68 |t should| have th|
|00001940| 65 20 75 6e 73 61 66 65 | 20 70 6f 6c 69 63 69 65 |e unsafe| policie|
|00001950| 73 20 65 78 70 6c 69 63 | 69 74 6c 79 20 73 70 65 |s explic|itly spe|
|00001960| 63 69 66 69 65 64 2e 0a | 0a 57 69 74 68 20 61 20 |cified..|.With a |
|00001970| 3a 46 61 73 74 2d 53 61 | 66 65 20 74 65 6d 70 6c |:Fast-Sa|fe templ|
|00001980| 61 74 65 2c 20 74 68 65 | 20 72 65 73 75 6c 74 20 |ate, the| result |
|00001990| 74 79 70 65 20 6d 75 73 | 74 20 62 65 20 70 72 6f |type mus|t be pro|
|000019a0| 76 65 6e 20 74 6f 20 73 | 61 74 69 73 66 79 20 74 |ven to s|atisfy t|
|000019b0| 68 65 0a 6f 75 74 70 75 | 74 20 74 79 70 65 20 61 |he.outpu|t type a|
|000019c0| 73 73 65 72 74 69 6f 6e | 2e 20 20 54 68 69 73 20 |ssertion|. This |
|000019d0| 6d 65 61 6e 73 20 74 68 | 61 74 20 61 20 66 61 73 |means th|at a fas|
|000019e0| 74 2d 73 61 66 65 20 74 | 65 6d 70 6c 61 74 65 20 |t-safe t|emplate |
|000019f0| 77 69 74 68 20 61 20 66 | 69 78 6e 75 6d 0a 6f 75 |with a f|ixnum.ou|
|00001a00| 74 70 75 74 20 74 79 70 | 65 20 64 6f 65 73 6e 27 |tput typ|e doesn'|
|00001a10| 74 20 6e 65 65 64 20 74 | 6f 20 64 6f 20 66 69 78 |t need t|o do fix|
|00001a20| 6e 75 6d 20 6f 76 65 72 | 66 6c 6f 77 20 63 68 65 |num over|flow che|
|00001a30| 63 6b 69 6e 67 2e 20 20 | 5b 5c 23 5c 23 5c 23 20 |cking. |[\#\#\# |
|00001a40| 4e 6f 74 20 72 69 67 68 | 74 20 74 6f 0a 6a 75 73 |Not righ|t to.jus|
|00001a50| 74 20 63 68 65 63 6b 20 | 61 67 61 69 6e 73 74 20 |t check |against |
|00001a60| 74 68 65 20 4e 6f 64 65 | 2d 44 65 72 69 76 65 64 |the Node|-Derived|
|00001a70| 2d 54 79 70 65 2c 20 73 | 69 6e 63 65 20 74 79 70 |-Type, s|ince typ|
|00001a80| 65 2d 63 68 65 63 6b 20 | 69 6e 74 65 72 73 65 63 |e-check |intersec|
|00001a90| 74 73 20 77 69 74 68 0a | 74 68 69 73 2e 5d 0a 0a |ts with.|this.]..|
|00001aa0| 49 74 20 73 65 65 6d 73 | 20 74 68 61 74 20 69 74 |It seems| that it|
|00001ab0| 20 77 6f 75 6c 64 20 62 | 65 20 75 73 65 66 75 6c | would b|e useful|
|00001ac0| 20 74 6f 20 68 61 76 65 | 20 61 20 6b 69 6e 64 20 | to have| a kind |
|00001ad0| 6f 66 20 74 65 6d 70 6c | 61 74 65 20 77 68 65 72 |of templ|ate wher|
|00001ae0| 65 20 74 68 65 20 61 72 | 67 73 20 6d 75 73 74 0a |e the ar|gs must.|
|00001af0| 62 65 20 63 68 65 63 6b | 65 64 20 74 6f 20 62 65 |be check|ed to be|
|00001b00| 20 66 69 78 6e 75 6d 2c | 20 62 75 74 20 74 68 65 | fixnum,| but the|
|00001b10| 20 74 65 6d 70 6c 61 74 | 65 20 63 68 65 63 6b 73 | templat|e checks|
|00001b20| 20 66 6f 72 20 6f 76 65 | 72 66 6c 6f 77 20 61 6e | for ove|rflow an|
|00001b30| 64 20 73 69 67 6e 61 6c | 73 20 61 6e 0a 65 72 72 |d signal|s an.err|
|00001b40| 6f 72 2e 20 20 49 6e 20 | 74 68 65 20 63 61 73 65 |or. In |the case|
|00001b50| 20 77 68 65 72 65 20 61 | 6e 20 6f 75 74 70 75 74 | where a|n output|
|00001b60| 20 61 73 73 65 72 74 69 | 6f 6e 20 69 73 20 70 72 | asserti|on is pr|
|00001b70| 65 73 65 6e 74 2c 20 74 | 68 69 73 20 77 6f 75 6c |esent, t|his woul|
|00001b80| 64 20 67 65 6e 65 72 61 | 74 65 0a 62 65 74 74 65 |d genera|te.bette|
|00001b90| 72 20 63 6f 64 65 20 74 | 68 61 6e 20 63 6f 6e 64 |r code t|han cond|
|00001ba0| 69 74 69 6f 6e 61 6c 6c | 79 20 62 72 61 6e 63 68 |itionall|y branch|
|00001bb0| 69 6e 67 20 6f 66 66 20 | 74 6f 20 6d 61 6b 65 20 |ing off |to make |
|00001bc0| 61 20 62 69 67 6e 75 6d | 2c 20 61 6e 64 20 74 68 |a bignum|, and th|
|00001bd0| 65 6e 20 64 6f 69 6e 67 | 20 61 0a 74 79 70 65 20 |en doing| a.type |
|00001be0| 63 68 65 63 6b 20 6f 6e | 20 74 68 65 20 72 65 73 |check on| the res|
|00001bf0| 75 6c 74 2e 0a 0a 20 20 | 20 20 48 6f 77 20 64 6f |ult... | How do|
|00001c00| 20 77 65 20 64 65 61 6c | 20 77 69 74 68 20 64 65 | we deal| with de|
|00001c10| 63 69 64 69 6e 67 20 77 | 68 65 74 68 65 72 20 74 |ciding w|hether t|
|00001c20| 6f 20 64 6f 20 61 20 66 | 69 78 6e 75 6d 20 6f 76 |o do a f|ixnum ov|
|00001c30| 65 72 66 6c 6f 77 20 63 | 68 65 63 6b 3f 20 20 54 |erflow c|heck? T|
|00001c40| 68 69 73 0a 20 20 20 20 | 69 73 20 70 65 72 68 61 |his. |is perha|
|00001c50| 70 73 20 61 20 6d 6f 72 | 65 20 67 65 6e 65 72 61 |ps a mor|e genera|
|00001c60| 6c 20 70 72 6f 62 6c 65 | 6d 20 77 69 74 68 20 74 |l proble|m with t|
|00001c70| 68 65 20 69 6e 74 65 72 | 70 72 65 74 61 74 69 6f |he inter|pretatio|
|00001c80| 6e 20 6f 66 20 72 65 73 | 75 6c 74 20 74 79 70 65 |n of res|ult type|
|00001c90| 0a 20 20 20 20 72 65 73 | 74 72 69 63 74 69 6f 6e |. res|triction|
|00001ca0| 73 20 69 6e 20 74 65 6d | 70 6c 61 74 65 73 2e 20 |s in tem|plates. |
|00001cb0| 20 49 74 20 77 6f 75 6c | 64 20 62 65 20 75 73 65 | It woul|d be use|
|00001cc0| 66 75 6c 20 74 6f 20 62 | 65 20 61 62 6c 65 20 74 |ful to b|e able t|
|00001cd0| 6f 20 64 69 73 63 72 69 | 6d 69 6e 61 74 65 0a 20 |o discri|minate. |
|00001ce0| 20 20 20 62 65 74 77 65 | 65 6e 20 74 68 65 20 63 | betwe|en the c|
|00001cf0| 61 73 65 20 77 68 65 72 | 65 20 74 68 65 20 72 65 |ase wher|e the re|
|00001d00| 73 75 6c 74 20 68 61 73 | 20 62 65 65 6e 20 70 72 |sult has| been pr|
|00001d10| 6f 76 65 6e 20 74 6f 20 | 62 65 20 61 20 66 69 78 |oven to |be a fix|
|00001d20| 6e 75 6d 20 61 6e 64 20 | 77 68 65 72 65 0a 20 20 |num and |where. |
|00001d30| 20 20 69 74 20 68 61 73 | 20 73 69 6d 70 6c 79 20 | it has| simply |
|00001d40| 62 65 65 6e 20 61 73 73 | 65 72 74 65 64 20 74 6f |been ass|erted to|
|00001d50| 20 62 65 20 73 6f 2e 0a | 0a 20 20 20 20 54 68 65 | be so..|. The|
|00001d60| 20 73 65 6d 61 6e 74 69 | 63 73 20 6f 66 20 72 65 | semanti|cs of re|
|00001d70| 73 75 6c 74 20 74 79 70 | 65 20 72 65 73 74 72 69 |sult typ|e restri|
|00001d80| 63 74 69 6f 6e 20 69 73 | 20 74 68 61 74 20 74 68 |ction is| that th|
|00001d90| 65 20 72 65 73 75 6c 74 | 20 6d 75 73 74 20 62 65 |e result| must be|
|00001da0| 20 70 72 6f 76 65 6e 0a | 20 20 20 20 74 6f 20 62 | proven.| to b|
|00001db0| 65 20 6f 66 20 74 68 61 | 74 20 74 79 70 65 20 2a |e of tha|t type *|
|00001dc0| 65 78 63 65 70 74 2a 20 | 66 6f 72 20 73 61 66 65 |except* |for safe|
|00001dd0| 20 67 65 6e 65 72 61 74 | 6f 72 73 2c 20 77 68 69 | generat|ors, whi|
|00001de0| 63 68 20 61 72 65 20 61 | 73 73 75 6d 65 64 20 74 |ch are a|ssumed t|
|00001df0| 6f 0a 20 20 20 20 76 65 | 72 69 66 79 20 74 68 65 |o. ve|rify the|
|00001e00| 20 61 73 73 65 72 74 69 | 6f 6e 2e 20 20 54 68 61 | asserti|on. Tha|
|00001e10| 74 20 77 61 79 20 22 69 | 73 2d 66 69 78 6e 75 6d |t way "i|s-fixnum|
|00001e20| 22 20 63 61 73 65 20 63 | 61 6e 20 62 65 20 61 20 |" case c|an be a |
|00001e30| 66 61 73 74 2d 73 61 66 | 65 0a 20 20 20 20 67 65 |fast-saf|e. ge|
|00001e40| 6e 65 72 61 74 6f 72 20 | 61 6e 64 20 74 68 65 20 |nerator |and the |
|00001e50| 22 73 68 6f 75 6c 64 2d | 62 65 2d 66 69 78 6e 75 |"should-|be-fixnu|
|00001e60| 6d 22 20 63 61 73 65 20 | 69 73 20 61 20 73 61 66 |m" case |is a saf|
|00001e70| 65 20 67 65 6e 65 72 61 | 74 6f 72 2e 20 20 57 65 |e genera|tor. We|
|00001e80| 20 63 6f 75 6c 64 0a 20 | 20 20 20 63 68 6f 6f 73 | could. | choos|
|00001e90| 65 20 6e 6f 74 20 74 6f | 20 68 61 76 65 20 61 20 |e not to| have a |
|00001ea0| 73 61 66 65 20 22 73 68 | 6f 75 6c 64 2d 62 65 2d |safe "sh|ould-be-|
|00001eb0| 66 69 78 6e 75 6d 22 20 | 67 65 6e 65 72 61 74 6f |fixnum" |generato|
|00001ec0| 72 2c 20 61 6e 64 20 6c | 65 74 20 74 68 65 0a 20 |r, and l|et the. |
|00001ed0| 20 20 20 75 6e 72 65 73 | 74 72 69 63 74 65 64 20 | unres|tricted |
|00001ee0| 73 61 66 65 20 67 65 6e | 65 72 61 74 6f 72 20 68 |safe gen|erator h|
|00001ef0| 61 6e 64 6c 65 20 69 74 | 2e 20 20 57 65 20 77 6f |andle it|. We wo|
|00001f00| 75 6c 64 20 74 68 65 6e | 20 68 61 76 65 20 74 6f |uld then| have to|
|00001f10| 20 64 6f 20 61 6e 0a 20 | 20 20 20 65 78 70 6c 69 | do an. | expli|
|00001f20| 63 69 74 20 74 79 70 65 | 20 63 68 65 63 6b 20 6f |cit type| check o|
|00001f30| 6e 20 74 68 65 20 72 65 | 73 75 6c 74 2e 0a 0a 20 |n the re|sult... |
|00001f40| 20 20 20 49 6e 20 6f 74 | 68 65 72 20 77 6f 72 64 | In ot|her word|
|00001f50| 73 2c 20 66 6f 72 20 61 | 6c 6c 20 74 65 6d 70 6c |s, for a|ll templ|
|00001f60| 61 74 65 20 65 78 63 65 | 70 74 20 53 61 66 65 2c |ate exce|pt Safe,|
|00001f70| 20 61 20 74 79 70 65 20 | 72 65 73 74 72 69 63 74 | a type |restrict|
|00001f80| 69 6f 6e 20 6f 6e 20 65 | 69 74 68 65 72 0a 20 20 |ion on e|ither. |
|00001f90| 20 20 61 6e 20 61 72 67 | 75 6d 65 6e 74 20 6f 72 | an arg|ument or|
|00001fa0| 20 72 65 73 75 6c 74 20 | 6d 65 61 6e 73 20 22 74 | result |means "t|
|00001fb0| 68 69 73 20 6d 75 73 74 | 20 62 65 20 74 72 75 65 |his must| be true|
|00001fc0| 3b 20 69 66 20 69 74 20 | 69 73 20 6e 6f 74 20 74 |; if it |is not t|
|00001fd0| 68 65 20 73 79 73 74 65 | 6d 20 6d 61 79 0a 20 20 |he syste|m may. |
|00001fe0| 20 20 62 72 65 61 6b 2e | 22 20 20 49 6e 20 63 6f | break.|" In co|
|00001ff0| 6e 74 72 61 73 74 2c 20 | 69 6e 20 61 20 53 61 66 |ntrast, |in a Saf|
|00002000| 65 20 74 65 6d 70 6c 61 | 74 65 2c 20 74 68 65 20 |e templa|te, the |
|00002010| 72 65 73 74 72 69 63 74 | 69 6f 6e 20 6d 65 61 6e |restrict|ion mean|
|00002020| 73 20 22 49 66 20 74 68 | 69 73 20 69 73 0a 20 20 |s "If th|is is. |
|00002030| 20 20 6e 6f 74 20 74 72 | 75 65 2c 20 49 20 77 69 | not tr|ue, I wi|
|00002040| 6c 6c 20 73 69 67 6e 61 | 6c 20 61 6e 20 65 72 72 |ll signa|l an err|
|00002050| 6f 72 2e 22 0a 0a 20 20 | 20 20 53 69 6e 63 65 20 |or.".. | Since |
|00002060| 74 68 65 20 6e 6f 64 65 | 2d 64 65 72 69 76 65 64 |the node|-derived|
|00002070| 2d 74 79 70 65 20 6f 6e | 6c 79 20 74 61 6b 65 73 |-type on|ly takes|
|00002080| 20 69 6e 74 6f 20 63 6f | 6e 73 69 64 65 72 61 74 | into co|nsiderat|
|00002090| 69 6f 6e 20 73 74 75 66 | 66 20 74 68 61 74 20 63 |ion stuf|f that c|
|000020a0| 61 6e 20 62 65 0a 20 20 | 20 20 70 72 6f 76 65 64 |an be. | proved|
|000020b0| 20 66 72 6f 6d 20 74 68 | 65 20 61 72 67 75 6d 65 | from th|e argume|
|000020c0| 6e 74 73 2c 20 77 65 20 | 63 61 6e 20 75 73 65 20 |nts, we |can use |
|000020d0| 74 68 65 20 6e 6f 64 65 | 2d 64 65 72 69 76 65 64 |the node|-derived|
|000020e0| 2d 74 79 70 65 20 74 6f | 20 73 65 6c 65 63 74 0a |-type to| select.|
|000020f0| 20 20 20 20 66 61 73 74 | 2d 73 61 66 65 20 74 65 | fast|-safe te|
|00002100| 6d 70 6c 61 74 65 73 2e | 20 20 57 69 74 68 20 75 |mplates.| With u|
|00002110| 6e 73 61 66 65 20 70 6f | 6c 69 63 69 65 73 2c 20 |nsafe po|licies, |
|00002120| 77 65 20 64 6f 6e 27 74 | 20 63 61 72 65 2c 20 73 |we don't| care, s|
|00002130| 69 6e 63 65 20 74 68 65 | 20 63 6f 64 65 0a 20 20 |ince the| code. |
|00002140| 20 20 69 73 20 73 75 70 | 70 6f 73 65 64 20 74 6f | is sup|posed to|
|00002150| 20 62 65 20 75 6e 73 61 | 66 65 2e 0a 0a 7c 5c 23 | be unsa|fe...|\#|
|00002160| 0a 0a 4c 6f 63 61 6c 20 | 54 4e 20 61 73 73 69 67 |..Local |TN assig|
|00002170| 6e 6d 65 6e 74 20 28 4c | 54 4e 29 20 61 73 73 69 |nment (L|TN) assi|
|00002180| 67 6e 73 20 61 6c 6c 20 | 74 68 65 20 54 4e 73 20 |gns all |the TNs |
|00002190| 6e 65 65 64 65 64 20 74 | 6f 20 72 65 70 72 65 73 |needed t|o repres|
|000021a0| 65 6e 74 20 74 68 65 20 | 76 61 6c 75 65 73 20 6f |ent the |values o|
|000021b0| 66 0a 63 6f 6e 74 69 6e | 75 61 74 69 6f 6e 73 2e |f.contin|uations.|
|000021c0| 20 20 54 68 69 73 20 70 | 61 73 73 20 73 63 61 6e | This p|ass scan|
|000021d0| 73 20 6f 76 65 72 20 74 | 68 65 20 63 6f 64 65 20 |s over t|he code |
|000021e0| 66 6f 72 20 74 68 65 20 | 63 6f 6d 70 6f 6e 65 6e |for the |componen|
|000021f0| 74 2c 20 65 78 61 6d 69 | 6e 69 6e 67 20 65 61 63 |t, exami|ning eac|
|00002200| 68 0a 63 6f 6e 74 69 6e | 75 61 74 69 6f 6e 20 61 |h.contin|uation a|
|00002210| 6e 64 20 69 74 73 20 64 | 65 73 74 69 6e 61 74 69 |nd its d|estinati|
|00002220| 6f 6e 2e 20 20 41 20 6e | 75 6d 62 65 72 20 6f 66 |on. A n|umber of|
|00002230| 20 73 6f 6d 65 77 68 61 | 74 20 75 6e 72 65 6c 61 | somewha|t unrela|
|00002240| 74 65 64 20 74 68 69 6e | 67 73 20 61 72 65 0a 61 |ted thin|gs are.a|
|00002250| 6c 73 6f 20 64 6f 6e 65 | 20 61 74 20 74 68 65 20 |lso done| at the |
|00002260| 73 61 6d 65 20 74 69 6d | 65 20 73 6f 20 74 68 61 |same tim|e so tha|
|00002270| 74 20 6d 75 6c 74 69 70 | 6c 65 20 70 61 73 73 65 |t multip|le passe|
|00002280| 73 20 61 72 65 6e 27 74 | 20 6e 65 63 65 73 73 61 |s aren't| necessa|
|00002290| 72 79 2e 0a 20 2d 2d 20 | 44 65 74 65 72 6d 69 6e |ry.. -- |Determin|
|000022a0| 65 20 74 68 65 20 50 72 | 69 6d 69 74 69 76 65 2d |e the Pr|imitive-|
|000022b0| 54 79 70 65 20 66 6f 72 | 20 65 61 63 68 20 63 6f |Type for| each co|
|000022c0| 6e 74 69 6e 75 61 74 69 | 6f 6e 20 76 61 6c 75 65 |ntinuati|on value|
|000022d0| 20 61 6e 64 20 61 73 73 | 69 67 6e 73 20 54 4e 73 | and ass|igns TNs|
|000022e0| 0a 20 20 20 20 74 6f 20 | 68 6f 6c 64 20 74 68 65 |. to |hold the|
|000022f0| 20 76 61 6c 75 65 73 2e | 0a 20 2d 2d 20 55 73 65 | values.|. -- Use|
|00002300| 20 70 6f 6c 69 63 79 20 | 69 6e 66 6f 72 6d 61 74 | policy |informat|
|00002310| 69 6f 6e 20 74 6f 20 64 | 65 74 65 72 6d 69 6e 65 |ion to d|etermine|
|00002320| 20 74 68 65 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 | the imp|lementat|
|00002330| 69 6f 6e 20 73 74 72 61 | 74 65 67 79 20 66 6f 72 |ion stra|tegy for|
|00002340| 20 65 61 63 68 0a 20 20 | 20 20 63 61 6c 6c 20 74 | each. | call t|
|00002350| 6f 20 61 20 6b 6e 6f 77 | 6e 20 66 75 6e 63 74 69 |o a know|n functi|
|00002360| 6f 6e 2e 0a 20 2d 2d 20 | 43 6c 65 61 72 20 74 68 |on.. -- |Clear th|
|00002370| 65 20 74 79 70 65 2d 63 | 68 65 63 6b 20 66 6c 61 |e type-c|heck fla|
|00002380| 67 73 20 69 6e 20 63 6f | 6e 74 69 6e 75 61 74 69 |gs in co|ntinuati|
|00002390| 6f 6e 73 20 77 68 6f 73 | 65 20 64 65 73 74 69 6e |ons whos|e destin|
|000023a0| 61 74 69 6f 6e 73 20 68 | 61 76 65 20 73 61 66 65 |ations h|ave safe|
|000023b0| 0a 20 20 20 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |. imp|lementat|
|000023c0| 69 6f 6e 73 2e 0a 20 2d | 2d 20 44 65 74 65 72 6d |ions.. -|- Determ|
|000023d0| 69 6e 65 20 74 68 65 20 | 76 61 6c 75 65 2d 70 61 |ine the |value-pa|
|000023e0| 73 73 69 6e 67 20 73 74 | 72 61 74 65 67 79 20 66 |ssing st|rategy f|
|000023f0| 6f 72 20 65 61 63 68 20 | 63 6f 6e 74 69 6e 75 61 |or each |continua|
|00002400| 74 69 6f 6e 3a 20 6b 6e | 6f 77 6e 20 6f 72 0a 20 |tion: kn|own or. |
|00002410| 20 20 20 75 6e 6b 6e 6f | 77 6e 2e 0a 20 2d 2d 20 | unkno|wn.. -- |
|00002420| 4e 6f 74 65 20 75 73 61 | 67 65 20 6f 66 20 75 6e |Note usa|ge of un|
|00002430| 6b 6e 6f 77 6e 2d 76 61 | 6c 75 65 73 20 63 6f 6e |known-va|lues con|
|00002440| 74 69 6e 75 61 74 69 6f | 6e 73 20 73 6f 20 74 68 |tinuatio|ns so th|
|00002450| 61 74 20 73 74 61 63 6b | 20 61 6e 61 6c 79 73 69 |at stack| analysi|
|00002460| 73 20 63 61 6e 20 74 65 | 6c 6c 0a 20 20 20 20 77 |s can te|ll. w|
|00002470| 68 65 6e 20 73 74 61 63 | 6b 20 76 61 6c 75 65 73 |hen stac|k values|
|00002480| 20 6d 75 73 74 20 62 65 | 20 64 69 73 63 61 72 64 | must be| discard|
|00002490| 65 64 2e 0a 20 0a 49 66 | 20 73 61 66 65 74 79 20 |ed.. .If| safety |
|000024a0| 69 73 20 6d 6f 72 65 20 | 69 6d 70 6f 72 74 61 6e |is more |importan|
|000024b0| 74 20 74 68 61 74 20 73 | 70 65 65 64 20 61 6e 64 |t that s|peed and|
|000024c0| 20 73 70 61 63 65 2c 20 | 74 68 65 6e 20 77 65 20 | space, |then we |
|000024d0| 63 6f 6e 73 69 64 65 72 | 20 67 65 6e 65 72 61 74 |consider| generat|
|000024e0| 69 6e 67 0a 74 79 70 65 | 20 63 68 65 63 6b 73 20 |ing.type| checks |
|000024f0| 6f 6e 20 74 68 65 20 76 | 61 6c 75 65 73 20 6f 66 |on the v|alues of|
|00002500| 20 6e 6f 64 65 73 20 77 | 68 6f 73 65 20 43 4f 4e | nodes w|hose CON|
|00002510| 54 20 68 61 73 20 74 68 | 65 20 54 79 70 65 2d 43 |T has th|e Type-C|
|00002520| 68 65 63 6b 20 66 6c 61 | 67 20 73 65 74 2e 20 20 |heck fla|g set. |
|00002530| 49 66 0a 74 68 65 20 64 | 65 73 74 69 6e 61 74 61 |If.the d|estinata|
|00002540| 74 69 6f 6e 20 66 6f 72 | 20 74 68 65 20 63 6f 6e |tion for| the con|
|00002550| 74 69 6e 75 61 74 69 6f | 6e 20 76 61 6c 75 65 20 |tinuatio|n value |
|00002560| 69 73 20 73 61 66 65 2c | 20 74 68 65 6e 20 77 65 |is safe,| then we|
|00002570| 20 64 6f 6e 27 74 20 6e | 65 65 64 20 74 6f 20 64 | don't n|eed to d|
|00002580| 6f 0a 61 20 63 68 65 63 | 6b 2e 20 20 57 65 20 61 |o.a chec|k. We a|
|00002590| 73 73 75 6d 65 20 74 68 | 61 74 20 61 6c 6c 20 66 |ssume th|at all f|
|000025a0| 75 6c 6c 20 63 61 6c 6c | 73 20 61 72 65 20 73 61 |ull call|s are sa|
|000025b0| 66 65 2c 20 61 6e 64 20 | 75 73 65 20 74 68 65 20 |fe, and |use the |
|000025c0| 74 65 6d 70 6c 61 74 65 | 0a 69 6e 66 6f 72 6d 61 |template|.informa|
|000025d0| 74 69 6f 6e 20 74 6f 20 | 64 65 74 65 72 6d 69 6e |tion to |determin|
|000025e0| 65 20 77 68 65 74 68 65 | 72 20 69 6e 6c 69 6e 65 |e whethe|r inline|
|000025f0| 20 6f 70 65 72 61 74 69 | 6f 6e 73 20 61 72 65 20 | operati|ons are |
|00002600| 73 61 66 65 2e 0a 0a 54 | 68 69 73 20 70 68 61 73 |safe...T|his phas|
|00002610| 65 20 69 73 20 77 68 65 | 72 65 20 63 6f 6d 70 69 |e is whe|re compi|
|00002620| 6c 65 72 20 70 6f 6c 69 | 63 79 20 73 77 69 74 63 |ler poli|cy switc|
|00002630| 68 65 73 20 68 61 76 65 | 20 6d 6f 73 74 20 6f 66 |hes have| most of|
|00002640| 20 74 68 65 69 72 20 65 | 66 66 65 63 74 2e 20 20 | their e|ffect. |
|00002650| 54 68 65 0a 73 70 65 65 | 64 2f 73 70 61 63 65 2f |The.spee|d/space/|
|00002660| 73 61 66 65 74 79 20 74 | 72 61 64 65 6f 66 66 20 |safety t|radeoff |
|00002670| 63 61 6e 20 64 65 74 65 | 72 6d 69 6e 65 20 77 68 |can dete|rmine wh|
|00002680| 69 63 68 20 6f 66 20 61 | 20 6e 75 6d 62 65 72 20 |ich of a| number |
|00002690| 6f 66 20 63 6f 64 69 6e | 67 0a 73 74 72 61 74 65 |of codin|g.strate|
|000026a0| 67 69 65 73 20 61 72 65 | 20 75 73 65 64 2e 20 20 |gies are| used. |
|000026b0| 49 74 20 69 73 20 69 6d | 70 6f 72 74 61 6e 74 20 |It is im|portant |
|000026c0| 74 6f 20 6d 61 6b 65 20 | 74 68 65 20 70 6f 6c 69 |to make |the poli|
|000026d0| 63 79 20 63 68 6f 69 63 | 65 20 69 6e 20 56 4d 52 |cy choic|e in VMR|
|000026e0| 0a 63 6f 6e 76 65 72 73 | 69 6f 6e 20 72 61 74 68 |.convers|ion rath|
|000026f0| 65 72 20 74 68 61 6e 20 | 69 6e 20 63 6f 64 65 20 |er than |in code |
|00002700| 67 65 6e 65 72 61 74 69 | 6f 6e 20 62 65 63 61 75 |generati|on becau|
|00002710| 73 65 20 74 68 65 20 63 | 6f 73 74 20 61 6e 64 20 |se the c|ost and |
|00002720| 73 74 6f 72 61 67 65 0a | 72 65 71 75 69 72 65 6d |storage.|requirem|
|00002730| 65 6e 74 20 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |ent info|rmation |
|00002740| 77 68 69 63 68 20 64 72 | 69 76 65 73 20 54 4e 42 |which dr|ives TNB|
|00002750| 49 4e 44 20 77 69 6c 6c | 20 64 65 70 65 6e 64 20 |IND will| depend |
|00002760| 73 74 72 6f 6e 67 6c 79 | 20 6f 6e 20 77 68 61 74 |strongly| on what|
|00002770| 20 61 63 74 75 61 6c 0a | 56 4f 50 20 69 73 20 63 | actual.|VOP is c|
|00002780| 68 6f 73 65 6e 2e 20 20 | 49 6e 20 74 68 65 20 63 |hosen. |In the c|
|00002790| 61 73 65 20 6f 66 20 2b | 2f 46 49 58 4e 55 4d 2c |ase of +|/FIXNUM,|
|000027a0| 20 74 68 65 72 65 20 6d | 69 67 68 74 20 62 65 20 | there m|ight be |
|000027b0| 74 68 72 65 65 20 6f 72 | 20 6d 6f 72 65 0a 69 6d |three or| more.im|
|000027c0| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 73 2c 20 73 |plementa|tions, s|
|000027d0| 6f 6d 65 20 6f 70 74 69 | 6d 69 7a 65 64 20 66 6f |ome opti|mized fo|
|000027e0| 72 20 73 70 65 65 64 2c | 20 73 6f 6d 65 20 66 6f |r speed,| some fo|
|000027f0| 72 20 73 70 61 63 65 2c | 20 65 74 63 2e 20 20 53 |r space,| etc. S|
|00002800| 6f 6d 65 20 6f 66 20 74 | 68 65 73 65 0a 56 4f 50 |ome of t|hese.VOP|
|00002810| 53 20 6d 69 67 68 74 20 | 62 65 20 6f 70 65 6e 2d |S might |be open-|
|00002820| 63 6f 64 65 64 20 61 6e | 64 20 73 6f 6d 65 20 6e |coded an|d some n|
|00002830| 6f 74 2e 0a 0a 57 65 20 | 72 65 70 72 65 73 65 6e |ot...We |represen|
|00002840| 74 20 74 68 65 20 69 6d | 70 6c 65 6d 65 6e 74 61 |t the im|plementa|
|00002850| 74 69 6f 6e 20 73 74 72 | 61 74 65 67 79 20 66 6f |tion str|ategy fo|
|00002860| 72 20 61 20 63 61 6c 6c | 20 62 79 20 65 69 74 68 |r a call| by eith|
|00002870| 65 72 20 6d 61 72 6b 69 | 6e 67 20 69 74 20 61 73 |er marki|ng it as|
|00002880| 20 61 0a 66 75 6c 6c 20 | 63 61 6c 6c 20 6f 72 20 | a.full |call or |
|00002890| 61 6e 6e 6f 74 61 74 69 | 6e 67 20 69 74 20 77 69 |annotati|ng it wi|
|000028a0| 74 68 20 61 20 22 74 65 | 6d 70 6c 61 74 65 22 20 |th a "te|mplate" |
|000028b0| 72 65 70 72 65 73 65 6e | 74 69 6e 67 20 74 68 65 |represen|ting the|
|000028c0| 20 6f 70 65 6e 2d 63 6f | 64 69 6e 67 0a 73 74 72 | open-co|ding.str|
|000028d0| 61 74 65 67 79 2e 20 20 | 54 65 6d 70 6c 61 74 65 |ategy. |Template|
|000028e0| 73 20 61 72 65 20 73 65 | 6c 65 63 74 65 64 20 75 |s are se|lected u|
|000028f0| 73 69 6e 67 20 61 20 74 | 77 6f 2d 77 61 79 20 64 |sing a t|wo-way d|
|00002900| 69 73 70 61 74 63 68 20 | 6f 66 66 20 6f 66 20 6f |ispatch |off of o|
|00002910| 70 65 72 61 6e 64 0a 70 | 72 69 6d 69 74 69 76 65 |perand.p|rimitive|
|00002920| 2d 74 79 70 65 73 20 61 | 6e 64 20 70 6f 6c 69 63 |-types a|nd polic|
|00002930| 79 2e 20 20 54 68 65 20 | 67 65 6e 65 72 61 6c 20 |y. The |general |
|00002940| 63 61 73 65 20 6f 66 20 | 4c 54 4e 20 69 73 20 68 |case of |LTN is h|
|00002950| 61 6e 64 6c 65 64 20 62 | 79 20 74 68 65 0a 4c 54 |andled b|y the.LT|
|00002960| 4e 2d 41 6e 6e 6f 74 61 | 74 65 20 66 75 6e 63 74 |N-Annota|te funct|
|00002970| 69 6f 6e 20 69 6e 20 74 | 68 65 20 66 75 6e 63 74 |ion in t|he funct|
|00002980| 69 6f 6e 2d 69 6e 66 6f | 2c 20 62 75 74 20 6d 6f |ion-info|, but mo|
|00002990| 73 74 20 66 75 6e 63 74 | 69 6f 6e 73 20 61 72 65 |st funct|ions are|
|000029a0| 20 68 61 6e 64 6c 65 64 | 20 62 79 20 61 0a 74 61 | handled| by a.ta|
|000029b0| 62 6c 65 2d 64 72 69 76 | 65 6e 20 6d 65 63 68 61 |ble-driv|en mecha|
|000029c0| 6e 69 73 6d 2e 20 20 54 | 68 65 72 65 20 61 72 65 |nism. T|here are|
|000029d0| 20 66 6f 75 72 20 64 69 | 66 66 65 72 65 6e 74 20 | four di|fferent |
|000029e0| 74 72 61 6e 73 6c 61 74 | 69 6f 6e 20 70 6f 6c 69 |translat|ion poli|
|000029f0| 63 69 65 73 20 74 68 61 | 74 20 61 0a 74 65 6d 70 |cies tha|t a.temp|
|00002a00| 6c 61 74 65 20 6d 61 79 | 20 68 61 76 65 3a 0a 5c |late may| have:.\|
|00002a10| 62 65 67 69 6e 7b 64 65 | 73 63 72 69 70 74 69 6f |begin{de|scriptio|
|00002a20| 6e 7d 0a 5c 69 74 65 6d | 5b 53 61 66 65 5d 0a 20 |n}.\item|[Safe]. |
|00002a30| 20 20 20 20 20 20 20 54 | 68 65 20 73 61 66 65 73 | T|he safes|
|00002a40| 74 20 69 6d 70 6c 65 6d | 65 6e 74 61 74 69 6f 6e |t implem|entation|
|00002a50| 3b 20 6d 75 73 74 20 64 | 6f 20 61 72 67 75 6d 65 |; must d|o argume|
|00002a60| 6e 74 20 74 79 70 65 20 | 63 68 65 63 6b 69 6e 67 |nt type |checking|
|00002a70| 2e 0a 0a 5c 69 74 65 6d | 5b 53 6d 61 6c 6c 5d 0a |...\item|[Small].|
|00002a80| 20 20 20 20 20 20 20 20 | 54 68 65 20 28 75 6e 73 | |The (uns|
|00002a90| 61 66 65 29 20 73 6d 61 | 6c 6c 65 73 74 20 69 6d |afe) sma|llest im|
|00002aa0| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 2e 0a 0a 5c |plementa|tion...\|
|00002ab0| 69 74 65 6d 5b 46 61 73 | 74 5d 0a 20 20 20 20 20 |item[Fas|t]. |
|00002ac0| 20 20 20 54 68 65 20 28 | 75 6e 73 61 66 65 29 20 | The (|unsafe) |
|00002ad0| 66 61 73 74 65 73 74 20 | 69 6d 70 6c 65 6d 65 6e |fastest |implemen|
|00002ae0| 74 61 74 69 6f 6e 2e 0a | 0a 5c 69 74 65 6d 5b 46 |tation..|.\item[F|
|00002af0| 61 73 74 2d 53 61 66 65 | 5d 0a 20 20 20 20 20 20 |ast-Safe|]. |
|00002b00| 20 20 41 6e 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 | An imp|lementat|
|00002b10| 69 6f 6e 20 6f 70 74 69 | 6d 69 7a 65 64 20 66 6f |ion opti|mized fo|
|00002b20| 72 20 73 70 65 65 64 2c | 20 62 75 74 20 77 68 69 |r speed,| but whi|
|00002b30| 63 68 20 64 6f 65 73 20 | 61 6e 79 20 6e 65 63 65 |ch does |any nece|
|00002b40| 73 73 61 72 79 0a 20 20 | 20 20 20 20 20 20 63 68 |ssary. | ch|
|00002b50| 65 63 6b 73 20 65 78 63 | 6c 75 73 69 76 65 20 6f |ecks exc|lusive o|
|00002b60| 66 20 61 72 67 75 6d 65 | 6e 74 20 74 79 70 65 20 |f argume|nt type |
|00002b70| 63 68 65 63 6b 69 6e 67 | 2e 20 20 45 78 61 6d 70 |checking|. Examp|
|00002b80| 6c 65 73 20 61 72 65 20 | 61 72 72 61 79 20 62 6f |les are |array bo|
|00002b90| 75 6e 64 73 0a 20 20 20 | 20 20 20 20 20 63 68 65 |unds. | che|
|00002ba0| 63 6b 73 20 61 6e 64 20 | 66 69 78 6e 75 6d 20 6f |cks and |fixnum o|
|00002bb0| 76 65 72 66 6c 6f 77 20 | 63 68 65 63 6b 73 2e 0a |verflow |checks..|
|00002bc0| 5c 65 6e 64 7b 64 65 73 | 63 72 69 70 74 69 6f 6e |\end{des|cription|
|00002bd0| 7d 0a 0a 55 73 75 61 6c | 6c 79 20 61 20 66 75 6e |}..Usual|ly a fun|
|00002be0| 63 74 69 6f 6e 20 77 69 | 6c 6c 20 68 61 76 65 20 |ction wi|ll have |
|00002bf0| 6f 6e 6c 79 20 6f 6e 65 | 20 6f 72 20 74 77 6f 20 |only one| or two |
|00002c00| 64 69 73 74 69 6e 63 74 | 20 74 65 6d 70 6c 61 74 |distinct| templat|
|00002c10| 65 73 2e 20 20 45 69 74 | 68 65 72 20 6f 72 0a 62 |es. Eit|her or.b|
|00002c20| 6f 74 68 20 6f 66 20 74 | 68 65 20 73 61 66 65 20 |oth of t|he safe |
|00002c30| 61 6e 64 20 66 61 73 74 | 2d 73 61 66 65 20 74 65 |and fast|-safe te|
|00002c40| 6d 70 6c 61 74 65 73 20 | 6d 61 79 20 62 65 20 6f |mplates |may be o|
|00002c50| 6d 69 74 74 65 64 3b 20 | 69 66 20 62 6f 74 68 20 |mitted; |if both |
|00002c60| 61 72 65 20 73 70 65 63 | 69 66 69 65 64 2c 0a 74 |are spec|ified,.t|
|00002c70| 68 65 6e 20 74 68 65 79 | 20 73 68 6f 75 6c 64 20 |hen they| should |
|00002c80| 62 65 20 64 69 73 74 69 | 6e 63 74 2e 20 20 49 66 |be disti|nct. If|
|00002c90| 20 74 68 65 72 65 20 69 | 73 20 6e 6f 20 73 61 66 | there i|s no saf|
|00002ca0| 65 20 74 65 6d 70 6c 61 | 74 65 20 61 6e 64 20 6f |e templa|te and o|
|00002cb0| 75 72 20 70 6f 6c 69 63 | 79 20 69 73 0a 73 61 66 |ur polic|y is.saf|
|00002cc0| 65 2c 20 74 68 65 6e 20 | 77 65 20 64 6f 20 61 20 |e, then |we do a |
|00002cd0| 66 75 6c 6c 20 63 61 6c | 6c 2e 0a 0a 57 65 20 75 |full cal|l...We u|
|00002ce0| 73 65 20 66 6f 75 72 20 | 64 69 66 66 65 72 65 6e |se four |differen|
|00002cf0| 74 20 63 6f 64 69 6e 67 | 20 73 74 72 61 74 65 67 |t coding| strateg|
|00002d00| 69 65 73 2c 20 64 65 70 | 65 6e 64 69 6e 67 20 6f |ies, dep|ending o|
|00002d10| 6e 20 74 68 65 20 70 6f | 6c 69 63 79 3a 0a 5c 62 |n the po|licy:.\b|
|00002d20| 65 67 69 6e 7b 64 65 73 | 63 72 69 70 74 69 6f 6e |egin{des|cription|
|00002d30| 7d 0a 5c 69 74 65 6d 5b | 53 61 66 65 3a 5d 20 20 |}.\item[|Safe:] |
|00002d40| 73 61 66 65 74 79 20 24 | 3e 24 20 73 70 61 63 65 |safety $|>$ space|
|00002d50| 20 24 3e 24 20 73 70 65 | 65 64 2c 20 6f 72 0a 77 | $>$ spe|ed, or.w|
|00002d60| 65 20 77 61 6e 74 20 74 | 6f 20 75 73 65 20 74 68 |e want t|o use th|
|00002d70| 65 20 66 61 73 74 2d 73 | 61 66 65 20 74 65 6d 70 |e fast-s|afe temp|
|00002d80| 6c 61 74 65 2c 20 62 75 | 74 20 74 68 65 72 65 20 |late, bu|t there |
|00002d90| 69 73 6e 27 74 20 6f 6e | 65 2e 0a 0a 5c 69 74 65 |isn't on|e...\ite|
|00002da0| 6d 5b 53 6d 61 6c 6c 3a | 5d 20 73 70 61 63 65 20 |m[Small:|] space |
|00002db0| 24 3e 24 20 28 6d 61 78 | 20 73 70 65 65 64 20 73 |$>$ (max| speed s|
|00002dc0| 61 66 65 74 79 29 0a 0a | 5c 69 74 65 6d 5b 46 61 |afety)..|\item[Fa|
|00002dd0| 73 74 3a 5d 20 73 70 65 | 65 64 20 24 3e 24 20 28 |st:] spe|ed $>$ (|
|00002de0| 6d 61 78 20 73 70 61 63 | 65 20 73 61 66 65 74 79 |max spac|e safety|
|00002df0| 29 0a 0a 5c 69 74 65 6d | 5b 46 61 73 74 2d 53 61 |)..\item|[Fast-Sa|
|00002e00| 66 65 20 28 61 6e 64 20 | 74 79 70 65 20 63 68 65 |fe (and |type che|
|00002e10| 63 6b 29 3a 5d 20 73 61 | 66 65 74 79 20 24 3e 24 |ck):] sa|fety $>$|
|00002e20| 20 73 70 65 65 64 20 24 | 3e 24 20 73 70 61 63 65 | speed $|>$ space|
|00002e30| 2c 20 6f 72 20 77 65 20 | 77 61 6e 74 20 74 6f 20 |, or we |want to |
|00002e40| 75 73 65 0a 74 68 65 20 | 73 61 66 65 20 74 65 6d |use.the |safe tem|
|00002e50| 70 6c 61 74 65 2c 20 62 | 75 74 20 74 68 65 72 65 |plate, b|ut there|
|00002e60| 20 69 73 6e 27 74 20 6f | 6e 65 2e 0a 5c 65 6e 64 | isn't o|ne..\end|
|00002e70| 7b 64 65 73 63 72 69 70 | 74 69 6f 6e 7d 0a 0a 60 |{descrip|tion}..`|
|00002e80| 60 53 70 61 63 65 27 27 | 20 61 62 6f 76 65 20 69 |`Space''| above i|
|00002e90| 73 20 61 63 74 75 61 6c | 6c 79 20 74 68 65 20 6d |s actual|ly the m|
|00002ea0| 61 78 69 6d 75 6d 20 6f | 66 20 73 70 61 63 65 20 |aximum o|f space |
|00002eb0| 61 6e 64 20 63 73 70 65 | 65 64 2c 20 75 6e 64 65 |and cspe|ed, unde|
|00002ec0| 72 20 74 68 65 20 74 68 | 65 6f 72 79 0a 74 68 61 |r the th|eory.tha|
|00002ed0| 74 20 6c 65 73 73 20 63 | 6f 64 65 20 77 69 6c 6c |t less c|ode will|
|00002ee0| 20 74 61 6b 65 20 6c 65 | 73 73 20 74 69 6d 65 20 | take le|ss time |
|00002ef0| 74 6f 20 67 65 6e 65 72 | 61 74 65 20 61 6e 64 20 |to gener|ate and |
|00002f00| 61 73 73 65 6d 62 6c 65 | 2e 20 20 5b 5c 23 5c 23 |assemble|. [\#\#|
|00002f10| 5c 23 20 54 68 69 73 20 | 63 6f 75 6c 64 0a 6c 6f |\# This |could.lo|
|00002f20| 73 65 20 69 66 20 74 68 | 65 20 73 6d 61 6c 6c 65 |se if th|e smalle|
|00002f30| 73 74 20 63 61 73 65 20 | 69 73 20 6f 75 74 2d 6f |st case |is out-o|
|00002f40| 66 2d 6c 69 6e 65 2c 20 | 61 6e 64 20 6d 75 73 74 |f-line, |and must|
|00002f50| 20 61 6c 6c 6f 63 61 74 | 65 20 6d 61 6e 79 20 6c | allocat|e many l|
|00002f60| 69 6e 6b 61 67 65 0a 72 | 65 67 69 73 74 65 72 73 |inkage.r|egisters|
|00002f70| 2e 5d 0a 0a 0c 0a 5c 63 | 68 61 70 74 65 72 7b 43 |.]....\c|hapter{C|
|00002f80| 6f 6e 74 72 6f 6c 20 6f | 70 74 69 6d 69 7a 61 74 |ontrol o|ptimizat|
|00002f90| 69 6f 6e 7d 0a 0a 49 6e | 20 74 68 69 73 20 70 68 |ion}..In| this ph|
|00002fa0| 61 73 65 20 77 65 20 61 | 6e 6e 6f 74 61 74 65 20 |ase we a|nnotate |
|00002fb0| 62 6c 6f 63 6b 73 20 77 | 69 74 68 20 64 72 6f 70 |blocks w|ith drop|
|00002fc0| 2d 74 68 72 6f 75 67 68 | 73 2e 20 20 54 68 69 73 |-through|s. This|
|00002fd0| 20 63 6f 6e 74 72 6f 6c | 73 20 68 6f 77 20 63 6f | control|s how co|
|00002fe0| 64 65 0a 67 65 6e 65 72 | 61 74 69 6f 6e 20 6c 69 |de.gener|ation li|
|00002ff0| 6e 65 61 72 69 7a 65 73 | 20 63 6f 64 65 20 73 6f |nearizes| code so|
|00003000| 20 74 68 61 74 20 64 72 | 6f 70 2d 74 68 72 6f 75 | that dr|op-throu|
|00003010| 67 68 73 20 61 72 65 20 | 75 73 65 64 20 6d 6f 73 |ghs are |used mos|
|00003020| 74 20 65 66 66 65 63 74 | 69 76 65 6c 79 2e 20 20 |t effect|ively. |
|00003030| 57 65 0a 74 6f 74 61 6c | 6c 79 20 6c 69 6e 65 61 |We.total|ly linea|
|00003040| 72 69 7a 65 20 74 68 65 | 20 63 6f 64 65 20 68 65 |rize the| code he|
|00003050| 72 65 2c 20 61 6c 6c 6f | 77 69 6e 67 20 63 6f 64 |re, allo|wing cod|
|00003060| 65 20 67 65 6e 65 72 61 | 74 69 6f 6e 20 74 6f 20 |e genera|tion to |
|00003070| 73 63 61 6e 20 74 68 65 | 20 62 6c 6f 63 6b 73 0a |scan the| blocks.|
|00003080| 69 6e 20 74 68 65 20 65 | 6d 69 74 20 6f 72 64 65 |in the e|mit orde|
|00003090| 72 2e 0a 0a 54 68 65 72 | 65 20 61 72 65 20 62 61 |r...Ther|e are ba|
|000030a0| 73 69 63 61 6c 6c 79 20 | 74 77 6f 20 61 73 70 65 |sically |two aspe|
|000030b0| 63 74 73 20 74 6f 20 74 | 68 69 73 20 6f 70 74 69 |cts to t|his opti|
|000030c0| 6d 69 7a 61 74 69 6f 6e | 3a 0a 20 31 5d 20 44 79 |mization|:. 1] Dy|
|000030d0| 6e 61 6d 69 63 61 6c 6c | 79 20 72 65 64 75 63 69 |namicall|y reduci|
|000030e0| 6e 67 20 74 68 65 20 6e | 75 6d 62 65 72 20 6f 66 |ng the n|umber of|
|000030f0| 20 62 72 61 6e 63 68 65 | 73 20 74 61 6b 65 6e 20 | branche|s taken |
|00003100| 76 2e 73 2e 20 62 72 61 | 6e 63 68 65 73 20 6e 6f |v.s. bra|nches no|
|00003110| 74 0a 20 20 20 20 74 61 | 6b 65 6e 20 75 6e 64 65 |t. ta|ken unde|
|00003120| 72 20 74 68 65 20 61 73 | 73 75 6d 70 74 69 6f 6e |r the as|sumption|
|00003130| 20 74 68 61 74 20 62 72 | 61 6e 63 68 65 73 20 6e | that br|anches n|
|00003140| 6f 74 20 74 61 6b 65 6e | 20 61 72 65 20 63 68 65 |ot taken| are che|
|00003150| 61 70 65 72 2e 0a 20 32 | 5d 20 53 74 61 74 69 63 |aper.. 2|] Static|
|00003160| 61 6c 6c 79 20 6d 69 6e | 69 6d 69 7a 69 6e 67 20 |ally min|imizing |
|00003170| 74 68 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 75 6e |the numb|er of un|
|00003180| 63 6f 6e 64 69 74 69 6f | 6e 61 6c 20 62 72 61 6e |conditio|nal bran|
|00003190| 63 68 65 73 2c 20 73 61 | 76 69 6e 67 20 73 70 61 |ches, sa|ving spa|
|000031a0| 63 65 0a 20 20 20 20 61 | 6e 64 20 70 72 65 73 75 |ce. a|nd presu|
|000031b0| 6d 61 62 6c 79 20 74 69 | 6d 65 2e 0a 0a 54 68 65 |mably ti|me...The|
|000031c0| 73 65 20 74 77 6f 20 67 | 6f 61 6c 73 20 63 61 6e |se two g|oals can|
|000031d0| 20 63 6f 6e 66 6c 69 63 | 74 2c 20 62 75 74 20 69 | conflic|t, but i|
|000031e0| 66 20 74 68 65 79 20 64 | 6f 20 69 74 20 73 65 65 |f they d|o it see|
|000031f0| 6d 73 20 70 72 65 74 74 | 79 20 63 6c 65 61 72 20 |ms prett|y clear |
|00003200| 74 68 61 74 20 74 68 65 | 0a 64 79 6e 61 6d 69 63 |that the|.dynamic|
|00003210| 20 6f 70 74 69 6d 69 7a | 61 74 69 6f 6e 20 73 68 | optimiz|ation sh|
|00003220| 6f 75 6c 64 20 67 65 74 | 20 70 72 65 66 65 72 65 |ould get| prefere|
|00003230| 6e 63 65 2e 20 20 54 68 | 65 20 6d 61 69 6e 20 64 |nce. Th|e main d|
|00003240| 79 6e 61 6d 69 63 20 6f | 70 74 69 6d 69 7a 61 74 |ynamic o|ptimizat|
|00003250| 69 6f 6e 20 69 73 0a 63 | 68 61 6e 67 69 6e 67 20 |ion is.c|hanging |
|00003260| 74 68 65 20 73 65 6e 73 | 65 20 6f 66 20 61 20 63 |the sens|e of a c|
|00003270| 6f 6e 64 69 74 69 6f 6e | 61 6c 20 74 65 73 74 20 |ondition|al test |
|00003280| 73 6f 20 74 68 61 74 20 | 74 68 65 20 6d 6f 72 65 |so that |the more|
|00003290| 20 63 6f 6d 6d 6f 6e 6c | 79 20 74 61 6b 65 6e 20 | commonl|y taken |
|000032a0| 62 72 61 6e 63 68 0a 69 | 73 20 74 68 65 20 66 61 |branch.i|s the fa|
|000032b0| 6c 6c 2d 74 68 72 6f 75 | 67 68 20 63 61 73 65 2e |ll-throu|gh case.|
|000032c0| 20 20 54 68 65 20 70 72 | 6f 62 6c 65 6d 20 69 73 | The pr|oblem is|
|000032d0| 20 64 65 74 65 72 6d 69 | 6e 69 6e 67 20 77 68 69 | determi|ning whi|
|000032e0| 63 68 20 62 72 61 6e 63 | 68 20 69 73 20 6d 6f 72 |ch branc|h is mor|
|000032f0| 65 0a 63 6f 6d 6d 6f 6e | 6c 79 20 74 61 6b 65 6e |e.common|ly taken|
|00003300| 2e 0a 0a 54 68 65 20 6d | 6f 73 74 20 63 6c 65 61 |...The m|ost clea|
|00003310| 72 2d 63 75 74 20 63 61 | 73 65 20 69 73 20 77 68 |r-cut ca|se is wh|
|00003320| 65 72 65 20 6f 6e 65 20 | 62 72 61 6e 63 68 20 6c |ere one |branch l|
|00003330| 65 61 64 73 20 6f 75 74 | 20 6f 66 20 61 20 6c 6f |eads out| of a lo|
|00003340| 6f 70 20 61 6e 64 20 74 | 68 65 20 6f 74 68 65 72 |op and t|he other|
|00003350| 0a 69 73 20 77 69 74 68 | 69 6e 2e 20 20 49 6e 20 |.is with|in. In |
|00003360| 74 68 69 73 20 63 61 73 | 65 2c 20 63 6c 65 61 72 |this cas|e, clear|
|00003370| 6c 79 20 74 68 65 20 62 | 72 61 6e 63 68 20 77 69 |ly the b|ranch wi|
|00003380| 74 68 69 6e 20 74 68 65 | 20 6c 6f 6f 70 20 73 68 |thin the| loop sh|
|00003390| 6f 75 6c 64 20 62 65 0a | 70 72 65 66 65 72 72 65 |ould be.|preferre|
|000033a0| 64 2e 20 20 54 68 65 20 | 6f 6e 6c 79 20 61 64 64 |d. The |only add|
|000033b0| 65 64 20 63 6f 6d 70 6c | 69 63 61 74 69 6f 6e 20 |ed compl|ication |
|000033c0| 69 73 20 74 68 61 74 20 | 61 74 20 73 6f 6d 65 20 |is that |at some |
|000033d0| 70 6f 69 6e 74 20 69 6e | 20 74 68 65 20 6c 6f 6f |point in| the loo|
|000033e0| 70 20 74 68 65 72 65 0a | 68 61 73 20 74 6f 20 62 |p there.|has to b|
|000033f0| 65 20 61 20 62 61 63 6b | 77 61 72 64 20 62 72 61 |e a back|ward bra|
|00003400| 6e 63 68 2c 20 61 6e 64 | 20 69 74 20 69 73 20 70 |nch, and| it is p|
|00003410| 72 65 66 65 72 61 62 6c | 65 20 66 6f 72 20 74 68 |referabl|e for th|
|00003420| 69 73 20 62 72 61 6e 63 | 68 20 74 6f 20 62 65 0a |is branc|h to be.|
|00003430| 63 6f 6e 64 69 74 69 6f | 6e 61 6c 2c 20 73 69 6e |conditio|nal, sin|
|00003440| 63 65 20 61 6e 20 75 6e | 63 6f 6e 64 69 74 69 6f |ce an un|conditio|
|00003450| 6e 61 6c 20 62 72 61 6e | 63 68 20 69 73 20 6a 75 |nal bran|ch is ju|
|00003460| 73 74 20 61 20 77 61 73 | 74 65 20 6f 66 20 74 69 |st a was|te of ti|
|00003470| 6d 65 2e 0a 0a 49 6e 20 | 74 68 65 20 61 62 73 65 |me...In |the abse|
|00003480| 6e 63 65 20 6f 66 20 73 | 75 63 68 20 67 6f 6f 64 |nce of s|uch good|
|00003490| 20 69 6e 66 6f 72 6d 61 | 74 69 6f 6e 2c 20 77 65 | informa|tion, we|
|000034a0| 20 63 61 6e 20 61 74 74 | 65 6d 70 74 20 74 6f 20 | can att|empt to |
|000034b0| 67 75 65 73 73 20 77 68 | 69 63 68 20 62 72 61 6e |guess wh|ich bran|
|000034c0| 63 68 0a 69 73 20 6d 6f | 72 65 20 70 6f 70 75 6c |ch.is mo|re popul|
|000034d0| 61 72 20 6f 6e 20 74 68 | 65 20 62 61 73 69 73 20 |ar on th|e basis |
|000034e0| 6f 66 20 64 69 66 66 65 | 72 65 6e 63 65 20 69 6e |of diffe|rence in|
|000034f0| 20 74 68 65 20 63 6f 73 | 74 20 62 65 74 77 65 65 | the cos|t betwee|
|00003500| 6e 20 74 68 65 20 74 77 | 6f 20 63 61 73 65 73 2e |n the tw|o cases.|
|00003510| 0a 4d 69 6e 2d 6d 61 78 | 20 73 74 72 61 74 65 67 |.Min-max| strateg|
|00003520| 79 20 73 75 67 67 65 73 | 74 73 20 74 68 61 74 20 |y sugges|ts that |
|00003530| 77 65 20 73 68 6f 75 6c | 64 20 63 68 6f 6f 73 65 |we shoul|d choose|
|00003540| 20 74 68 65 20 63 68 65 | 61 70 65 72 20 61 6c 74 | the che|aper alt|
|00003550| 65 72 6e 61 74 69 76 65 | 2c 20 73 69 6e 63 65 0a |ernative|, since.|
|00003560| 74 68 65 20 70 65 72 63 | 65 6e 74 61 67 65 77 69 |the perc|entagewi|
|00003570| 73 65 20 69 6d 70 72 6f | 76 65 6d 65 6e 74 20 69 |se impro|vement i|
|00003580| 73 20 67 72 65 61 74 65 | 72 20 77 68 65 6e 20 74 |s greate|r when t|
|00003590| 68 65 20 62 72 61 6e 63 | 68 20 6f 76 65 72 68 65 |he branc|h overhe|
|000035a0| 61 64 20 69 73 0a 73 69 | 67 6e 69 66 69 63 61 6e |ad is.si|gnifican|
|000035b0| 74 20 77 69 74 68 20 72 | 65 73 70 65 63 74 20 74 |t with r|espect t|
|000035c0| 6f 20 74 68 65 20 63 6f | 73 74 20 6f 66 20 74 68 |o the co|st of th|
|000035d0| 65 20 63 6f 64 65 20 62 | 72 61 6e 63 68 65 64 20 |e code b|ranched |
|000035e0| 74 6f 2e 20 20 41 20 74 | 72 61 63 74 61 62 6c 65 |to. A t|ractable|
|000035f0| 0a 61 70 70 72 6f 78 69 | 6d 61 74 69 6f 6e 20 6f |.approxi|mation o|
|00003600| 66 20 74 68 69 73 20 69 | 73 20 74 6f 20 63 6f 6d |f this i|s to com|
|00003610| 70 61 72 65 20 6f 6e 6c | 79 20 74 68 65 20 63 6f |pare onl|y the co|
|00003620| 73 74 73 20 6f 66 20 74 | 68 65 20 74 77 6f 20 62 |sts of t|he two b|
|00003630| 6c 6f 63 6b 73 0a 69 6d | 6d 65 64 69 61 74 65 6c |locks.im|mediatel|
|00003640| 79 20 62 72 61 6e 63 68 | 65 64 20 74 6f 2c 20 73 |y branch|ed to, s|
|00003650| 69 6e 63 65 20 74 68 69 | 73 20 77 6f 75 6c 64 20 |ince thi|s would |
|00003660| 61 76 6f 69 64 20 68 61 | 76 69 6e 67 20 74 6f 20 |avoid ha|ving to |
|00003670| 64 6f 20 61 6e 79 20 68 | 61 69 72 79 20 67 72 61 |do any h|airy gra|
|00003680| 70 68 0a 77 61 6c 6b 69 | 6e 67 20 74 6f 20 66 69 |ph.walki|ng to fi|
|00003690| 6e 64 20 61 6c 6c 20 74 | 68 65 20 63 6f 64 65 20 |nd all t|he code |
|000036a0| 66 6f 72 20 74 68 65 20 | 63 6f 6e 73 65 71 75 65 |for the |conseque|
|000036b0| 6e 74 20 61 6e 64 20 74 | 68 65 20 61 6c 74 65 72 |nt and t|he alter|
|000036c0| 6e 61 74 69 76 65 2e 20 | 20 49 74 20 6d 69 67 68 |native. | It migh|
|000036d0| 74 0a 62 65 20 77 6f 72 | 74 68 77 68 69 6c 65 20 |t.be wor|thwhile |
|000036e0| 64 69 73 63 72 69 6d 69 | 6e 61 74 69 6e 67 20 61 |discrimi|nating a|
|000036f0| 67 61 69 6e 73 74 20 75 | 6c 74 72 61 2d 65 78 70 |gainst u|ltra-exp|
|00003700| 65 6e 73 69 76 65 20 66 | 75 6e 63 74 69 6f 6e 73 |ensive f|unctions|
|00003710| 20 73 75 63 68 20 61 73 | 20 45 52 52 4f 52 2e 0a | such as| ERROR..|
|00003720| 0a 46 6f 72 20 74 68 69 | 73 20 74 6f 20 77 6f 72 |.For thi|s to wor|
|00003730| 6b 2c 20 77 65 20 68 61 | 76 65 20 74 6f 20 64 65 |k, we ha|ve to de|
|00003740| 74 65 63 74 20 77 68 65 | 6e 20 6f 6e 65 20 6f 66 |tect whe|n one of|
|00003750| 20 74 68 65 20 6f 70 74 | 69 6f 6e 73 20 69 73 20 | the opt|ions is |
|00003760| 65 6d 70 74 79 2e 20 20 | 49 6e 20 74 68 69 73 0a |empty. |In this.|
|00003770| 63 61 73 65 2c 20 74 68 | 65 20 6e 65 78 74 20 66 |case, th|e next f|
|00003780| 6f 72 20 6f 6e 65 20 62 | 72 61 6e 63 68 20 69 73 |or one b|ranch is|
|00003790| 20 61 20 73 75 63 63 65 | 73 73 6f 72 20 6f 66 20 | a succe|ssor of |
|000037a0| 74 68 65 20 6f 74 68 65 | 72 20 62 72 61 6e 63 68 |the othe|r branch|
|000037b0| 2c 20 6d 61 6b 69 6e 67 | 20 74 68 65 0a 63 6f 6d |, making| the.com|
|000037c0| 70 61 72 69 73 6f 6e 20 | 6d 65 61 6e 69 6e 67 6c |parison |meaningl|
|000037d0| 65 73 73 2e 20 20 57 65 | 20 75 73 65 20 64 6f 6d |ess. We| use dom|
|000037e0| 69 6e 61 74 6f 72 20 69 | 6e 66 6f 72 6d 61 74 69 |inator i|nformati|
|000037f0| 6f 6e 20 74 6f 20 64 65 | 74 65 63 74 20 74 68 69 |on to de|tect thi|
|00003800| 73 20 73 69 74 75 61 74 | 69 6f 6e 2e 0a 57 68 65 |s situat|ion..Whe|
|00003810| 6e 20 61 20 62 72 61 6e | 63 68 20 69 73 20 65 6d |n a bran|ch is em|
|00003820| 70 74 79 2c 20 6f 6e 65 | 20 6f 66 20 74 68 65 20 |pty, one| of the |
|00003830| 70 72 65 64 65 63 65 73 | 73 6f 72 73 20 6f 66 20 |predeces|sors of |
|00003840| 74 68 65 20 66 69 72 73 | 74 20 62 6c 6f 63 6b 20 |the firs|t block |
|00003850| 69 6e 20 74 68 65 20 65 | 6d 70 74 79 0a 62 72 61 |in the e|mpty.bra|
|00003860| 6e 63 68 20 77 69 6c 6c | 20 62 65 20 64 6f 6d 69 |nch will| be domi|
|00003870| 6e 61 74 65 64 20 62 79 | 20 74 68 65 20 66 69 72 |nated by| the fir|
|00003880| 73 74 20 62 6c 6f 63 6b | 20 69 6e 20 74 68 65 20 |st block| in the |
|00003890| 6f 74 68 65 72 20 62 72 | 61 6e 63 68 2e 20 20 49 |other br|anch. I|
|000038a0| 6e 20 73 75 63 68 20 61 | 0a 63 61 73 65 20 77 65 |n such a|.case we|
|000038b0| 20 66 61 76 6f 72 20 74 | 68 65 20 65 6d 70 74 79 | favor t|he empty|
|000038c0| 20 62 72 61 6e 63 68 2c | 20 73 69 6e 63 65 20 74 | branch,| since t|
|000038d0| 68 61 74 27 73 20 61 62 | 6f 75 74 20 61 73 20 63 |hat's ab|out as c|
|000038e0| 68 65 61 70 20 61 73 20 | 79 6f 75 20 63 61 6e 20 |heap as |you can |
|000038f0| 67 65 74 2e 0a 0a 53 74 | 61 74 69 63 61 6c 6c 79 |get...St|atically|
|00003900| 20 6d 69 6e 69 6d 69 7a | 69 6e 67 20 62 72 61 6e | minimiz|ing bran|
|00003910| 63 68 65 73 20 69 73 20 | 72 65 61 6c 6c 79 20 61 |ches is |really a|
|00003920| 20 6d 75 63 68 20 6d 6f | 72 65 20 74 72 61 63 74 | much mo|re tract|
|00003930| 61 62 6c 65 20 70 72 6f | 62 6c 65 6d 2c 20 62 75 |able pro|blem, bu|
|00003940| 74 0a 77 68 61 74 20 6c | 69 74 65 72 61 74 75 72 |t.what l|iteratur|
|00003950| 65 20 74 68 65 72 65 20 | 69 73 20 6d 61 6b 65 73 |e there |is makes|
|00003960| 20 69 74 20 6c 6f 6f 6b | 20 68 61 72 64 2e 20 20 | it look| hard. |
|00003970| 43 6c 65 61 72 6c 79 20 | 74 68 65 20 74 68 69 6e |Clearly |the thin|
|00003980| 67 20 74 6f 20 64 6f 20 | 69 73 20 74 6f 20 75 73 |g to do |is to us|
|00003990| 65 0a 61 20 6e 6f 6e 2d | 6f 70 74 69 6d 61 6c 20 |e.a non-|optimal |
|000039a0| 68 65 75 72 69 73 74 69 | 63 20 61 6c 67 6f 72 69 |heuristi|c algori|
|000039b0| 74 68 6d 2e 0a 0a 41 20 | 67 6f 6f 64 20 70 6f 73 |thm...A |good pos|
|000039c0| 73 69 62 69 6c 69 74 79 | 20 69 73 20 74 6f 20 75 |sibility| is to u|
|000039d0| 73 65 20 61 6e 20 61 6c | 67 6f 72 69 74 68 6d 20 |se an al|gorithm |
|000039e0| 62 61 73 65 64 20 6f 6e | 20 74 68 65 20 64 65 70 |based on| the dep|
|000039f0| 74 68 20 66 69 72 73 74 | 20 6f 72 64 65 72 69 6e |th first| orderin|
|00003a00| 67 2e 0a 57 65 20 63 61 | 6e 20 6d 6f 64 69 66 79 |g..We ca|n modify|
|00003a10| 20 74 68 65 20 62 61 73 | 69 63 20 44 46 4f 20 61 | the bas|ic DFO a|
|00003a20| 6c 67 6f 72 69 74 68 6d | 20 73 6f 20 74 68 61 74 |lgorithm| so that|
|00003a30| 20 69 74 20 63 68 6f 6f | 73 65 73 20 61 6e 20 6f | it choo|ses an o|
|00003a40| 72 64 65 72 69 6e 67 20 | 77 68 69 63 68 0a 66 61 |rdering |which.fa|
|00003a50| 76 6f 72 73 20 61 6e 79 | 20 64 72 6f 70 2d 74 68 |vors any| drop-th|
|00003a60| 72 75 73 20 74 68 61 74 | 20 77 65 20 6d 61 79 20 |rus that| we may |
|00003a70| 63 68 6f 6f 73 65 20 66 | 6f 72 20 64 79 6e 61 6d |choose f|or dynam|
|00003a80| 69 63 20 72 65 61 73 6f | 6e 73 2e 20 20 57 68 65 |ic reaso|ns. Whe|
|00003a90| 6e 20 77 65 20 61 72 65 | 0a 77 61 6c 6b 69 6e 67 |n we are|.walking|
|00003aa0| 20 74 68 65 20 67 72 61 | 70 68 2c 20 77 65 20 77 | the gra|ph, we w|
|00003ab0| 61 6c 6b 20 74 68 65 20 | 64 65 73 69 72 65 64 20 |alk the |desired |
|00003ac0| 64 72 6f 70 2d 74 68 72 | 75 20 61 72 63 20 6c 61 |drop-thr|u arc la|
|00003ad0| 73 74 2c 20 77 68 69 63 | 68 20 77 69 6c 6c 20 70 |st, whic|h will p|
|00003ae0| 6c 61 63 65 20 69 74 0a | 69 6d 6d 65 64 69 61 74 |lace it.|immediat|
|00003af0| 65 6c 79 20 61 66 74 65 | 72 20 75 73 20 69 6e 20 |ely afte|r us in |
|00003b00| 74 68 65 20 44 46 4f 20 | 75 6e 6c 65 73 73 20 74 |the DFO |unless t|
|00003b10| 68 65 20 61 72 63 20 69 | 73 20 61 20 72 65 74 72 |he arc i|s a retr|
|00003b20| 65 61 74 69 6e 67 20 61 | 72 63 2e 0a 0a 57 65 20 |eating a|rc...We |
|00003b30| 73 63 61 6e 20 74 68 72 | 6f 75 67 68 20 74 68 65 |scan thr|ough the|
|00003b40| 20 44 46 4f 20 61 6e 64 | 20 77 68 65 6e 65 76 65 | DFO and| wheneve|
|00003b50| 72 20 77 65 20 66 69 6e | 64 20 61 20 62 6c 6f 63 |r we fin|d a bloc|
|00003b60| 6b 20 74 68 61 74 20 68 | 61 73 6e 27 74 20 62 65 |k that h|asn't be|
|00003b70| 65 6e 20 64 6f 6e 65 20 | 79 65 74 2c 0a 77 65 20 |en done |yet,.we |
|00003b80| 62 75 69 6c 64 20 61 20 | 73 74 72 61 69 67 68 74 |build a |straight|
|00003b90| 2d 6c 69 6e 65 20 73 65 | 67 6d 65 6e 74 20 62 79 |-line se|gment by|
|00003ba0| 20 73 65 74 74 69 6e 67 | 20 74 68 65 20 64 72 6f | setting| the dro|
|00003bb0| 70 2d 74 68 72 75 20 74 | 6f 20 74 68 65 20 75 6e |p-thru t|o the un|
|00003bc0| 72 65 61 63 68 65 64 0a | 73 75 63 63 65 73 73 6f |reached.|successo|
|00003bd0| 72 20 62 6c 6f 63 6b 20 | 77 68 69 63 68 20 68 61 |r block |which ha|
|00003be0| 73 20 74 68 65 20 6c 6f | 77 65 73 74 20 44 46 4e |s the lo|west DFN|
|00003bf0| 20 67 72 65 61 74 65 72 | 20 74 68 61 6e 20 74 68 | greater| than th|
|00003c00| 61 74 20 66 6f 72 20 74 | 68 65 20 62 6c 6f 63 6b |at for t|he block|
|00003c10| 2e 20 20 57 65 0a 6d 6f | 76 65 20 74 6f 20 74 68 |. We.mo|ve to th|
|00003c20| 65 20 64 72 6f 70 2d 74 | 68 72 75 20 62 6c 6f 63 |e drop-t|hru bloc|
|00003c30| 6b 20 61 6e 64 20 72 65 | 70 65 61 74 20 74 68 65 |k and re|peat the|
|00003c40| 20 70 72 6f 63 65 73 73 | 20 75 6e 74 69 6c 20 74 | process| until t|
|00003c50| 68 65 72 65 20 69 73 20 | 6e 6f 20 73 75 63 68 0a |here is |no such.|
|00003c60| 62 6c 6f 63 6b 2e 20 20 | 57 65 20 74 68 65 6e 20 |block. |We then |
|00003c70| 67 6f 20 62 61 63 6b 20 | 74 6f 20 6f 75 72 20 6f |go back |to our o|
|00003c80| 72 69 67 69 6e 61 6c 20 | 73 63 61 6e 20 74 68 72 |riginal |scan thr|
|00003c90| 6f 75 67 68 20 74 68 65 | 20 44 46 4f 2c 20 6c 6f |ough the| DFO, lo|
|00003ca0| 6f 6b 69 6e 67 20 66 6f | 72 20 74 68 65 0a 68 65 |oking fo|r the.he|
|00003cb0| 61 64 20 6f 66 20 61 6e | 6f 74 68 65 72 20 73 74 |ad of an|other st|
|00003cc0| 72 61 69 67 68 74 2d 6c | 69 6e 65 20 73 65 67 6d |raight-l|ine segm|
|00003cd0| 65 6e 74 2e 0a 0a 54 68 | 69 73 20 70 72 6f 63 65 |ent...Th|is proce|
|00003ce0| 73 73 20 77 69 6c 6c 20 | 61 75 74 6f 6d 61 67 69 |ss will |automagi|
|00003cf0| 63 61 6c 6c 79 20 69 6d | 70 6c 65 6d 65 6e 74 20 |cally im|plement |
|00003d00| 61 6c 6c 20 6f 66 20 74 | 68 65 20 64 79 6e 61 6d |all of t|he dynam|
|00003d10| 69 63 20 6f 70 74 69 6d | 69 7a 61 74 69 6f 6e 73 |ic optim|izations|
|00003d20| 0a 64 65 73 63 72 69 62 | 65 64 20 61 62 6f 76 65 |.describ|ed above|
|00003d30| 20 61 73 20 6c 6f 6e 67 | 20 61 73 20 77 65 20 66 | as long| as we f|
|00003d40| 61 76 6f 72 20 74 68 65 | 20 61 70 70 72 6f 70 72 |avor the| appropr|
|00003d50| 69 61 74 65 20 49 46 20 | 62 72 61 6e 63 68 20 77 |iate IF |branch w|
|00003d60| 68 65 6e 20 63 72 65 61 | 74 69 6e 67 20 74 68 65 |hen crea|ting the|
|00003d70| 0a 44 46 4f 2e 20 20 55 | 73 69 6e 67 20 74 68 65 |.DFO. U|sing the|
|00003d80| 20 44 46 4f 20 77 69 6c | 6c 20 70 72 65 76 65 6e | DFO wil|l preven|
|00003d90| 74 20 75 73 20 66 72 6f | 6d 20 6d 61 6b 69 6e 67 |t us fro|m making|
|00003da0| 20 74 68 65 20 62 61 63 | 6b 20 62 72 61 6e 63 68 | the bac|k branch|
|00003db0| 20 69 6e 20 61 20 6c 6f | 6f 70 20 74 68 65 0a 64 | in a lo|op the.d|
|00003dc0| 72 6f 70 2d 74 68 72 75 | 2c 20 62 75 74 20 77 65 |rop-thru|, but we|
|00003dd0| 20 6e 65 65 64 20 74 6f | 20 62 65 20 63 6c 65 76 | need to| be clev|
|00003de0| 65 72 20 61 62 6f 75 74 | 20 66 61 76 6f 72 69 6e |er about| favorin|
|00003df0| 67 20 49 46 20 62 72 61 | 6e 63 68 65 73 20 77 69 |g IF bra|nches wi|
|00003e00| 74 68 69 6e 20 6c 6f 6f | 70 73 0a 77 68 69 6c 65 |thin loo|ps.while|
|00003e10| 20 63 6f 6d 70 75 74 69 | 6e 67 20 74 68 65 20 44 | computi|ng the D|
|00003e20| 46 4f 2e 20 20 54 68 65 | 20 49 46 20 6a 6f 69 6e |FO. The| IF join|
|00003e30| 20 77 69 6c 6c 20 62 65 | 20 66 61 76 6f 72 65 64 | will be| favored|
|00003e40| 20 77 69 74 68 6f 75 74 | 20 61 6e 79 20 73 70 65 | without| any spe|
|00003e50| 63 69 61 6c 0a 65 66 66 | 6f 72 74 2c 20 73 69 6e |cial.eff|ort, sin|
|00003e60| 63 65 20 77 65 20 66 6f | 6c 6c 6f 77 20 74 68 72 |ce we fo|llow thr|
|00003e70| 6f 75 67 68 20 74 68 65 | 20 6d 6f 73 74 20 66 61 |ough the| most fa|
|00003e80| 76 6f 72 65 64 20 70 61 | 74 68 20 75 6e 74 69 6c |vored pa|th until|
|00003e90| 20 77 65 20 72 65 61 63 | 68 20 74 68 65 20 65 6e | we reac|h the en|
|00003ea0| 64 2e 0a 0a 54 68 69 73 | 20 6e 65 65 64 73 20 73 |d...This| needs s|
|00003eb0| 6f 6d 65 20 6b 6e 6f 77 | 6c 65 64 67 65 20 61 62 |ome know|ledge ab|
|00003ec0| 6f 75 74 20 74 68 65 20 | 74 61 72 67 65 74 20 6d |out the |target m|
|00003ed0| 61 63 68 69 6e 65 2c 20 | 73 69 6e 63 65 20 6f 6e |achine, |since on|
|00003ee0| 20 6d 6f 73 74 20 6d 61 | 63 68 69 6e 65 73 0a 6e | most ma|chines.n|
|00003ef0| 6f 6e 2d 74 61 69 6c 2d | 72 65 63 75 72 73 69 76 |on-tail-|recursiv|
|00003f00| 65 20 63 61 6c 6c 73 20 | 77 69 6c 6c 20 75 73 65 |e calls |will use|
|00003f10| 20 73 6f 6d 65 20 73 6f | 72 74 20 6f 66 20 63 61 | some so|rt of ca|
|00003f20| 6c 6c 20 69 6e 73 74 72 | 75 63 74 69 6f 6e 2e 20 |ll instr|uction. |
|00003f30| 20 49 6e 20 74 68 69 73 | 20 63 61 73 65 2c 0a 74 | In this| case,.t|
|00003f40| 68 65 20 63 61 6c 6c 20 | 61 63 74 75 61 6c 6c 79 |he call |actually|
|00003f50| 20 77 61 6e 74 73 20 74 | 6f 20 64 72 6f 70 20 74 | wants t|o drop t|
|00003f60| 68 72 6f 75 67 68 20 74 | 6f 20 74 68 65 20 72 65 |hrough t|o the re|
|00003f70| 74 75 72 6e 20 70 6f 69 | 6e 74 2c 20 72 61 74 68 |turn poi|nt, rath|
|00003f80| 65 72 20 74 68 61 6e 0a | 64 72 6f 70 70 69 6e 67 |er than.|dropping|
|00003f90| 20 74 68 72 6f 75 67 68 | 20 74 6f 20 74 68 65 20 | through| to the |
|00003fa0| 62 65 67 69 6e 6e 69 6e | 67 20 6f 66 20 74 68 65 |beginnin|g of the|
|00003fb0| 20 63 61 6c 6c 65 64 20 | 66 75 6e 63 74 69 6f 6e | called |function|
|00003fc0| 2e 0a 0a 0c 0a 5c 63 68 | 61 70 74 65 72 7b 56 4d |.....\ch|apter{VM|
|00003fd0| 52 20 63 6f 6e 76 65 72 | 73 69 6f 6e 7d 0a 0a 5c |R conver|sion}..\|
|00003fe0| 23 7c 0a 53 69 6e 67 6c | 65 2d 75 73 65 20 6c 65 |#|.Singl|e-use le|
|00003ff0| 74 20 76 61 72 20 63 6f | 6e 74 69 6e 75 61 74 69 |t var co|ntinuati|
|00004000| 6f 6e 20 73 75 62 73 74 | 69 74 75 74 69 6f 6e 20 |on subst|itution |
|00004010| 6e 6f 74 20 72 65 61 6c | 6c 79 20 63 6f 72 72 65 |not real|ly corre|
|00004020| 63 74 2c 20 73 69 6e 63 | 65 20 69 74 20 63 61 6e |ct, sinc|e it can|
|00004030| 0a 63 61 75 73 65 20 61 | 20 73 70 75 72 69 6f 75 |.cause a| spuriou|
|00004040| 73 20 74 79 70 65 20 65 | 72 72 6f 72 2e 20 20 4d |s type e|rror. M|
|00004050| 61 79 62 65 20 77 65 20 | 64 6f 20 77 61 6e 74 20 |aybe we |do want |
|00004060| 73 74 75 66 66 20 74 6f | 20 70 72 6f 76 65 20 74 |stuff to| prove t|
|00004070| 68 61 74 20 61 6e 20 4e | 4c 58 20 63 61 6e 27 74 |hat an N|LX can't|
|00004080| 0a 68 61 70 70 65 6e 20 | 61 66 74 65 72 20 61 6c |.happen |after al|
|00004090| 6c 2e 20 20 4f 72 20 67 | 6f 20 62 61 63 6b 20 74 |l. Or g|o back t|
|000040a0| 6f 20 74 68 65 20 69 64 | 65 61 20 6f 66 20 6d 6f |o the id|ea of mo|
|000040b0| 76 69 6e 67 20 61 20 63 | 6f 6d 62 69 6e 61 74 69 |ving a c|ombinati|
|000040c0| 6f 6e 20 61 72 67 20 74 | 6f 20 74 68 65 0a 72 65 |on arg t|o the.re|
|000040d0| 66 20 6c 6f 63 61 74 69 | 6f 6e 2c 20 61 6e 64 20 |f locati|on, and |
|000040e0| 68 61 76 69 6e 67 20 74 | 68 61 74 20 75 73 65 20 |having t|hat use |
|000040f0| 74 68 65 20 72 65 66 20 | 63 6f 6e 74 20 28 77 69 |the ref |cont (wi|
|00004100| 74 68 20 69 74 73 20 6f | 75 74 70 75 74 20 61 73 |th its o|utput as|
|00004110| 73 65 72 74 69 6f 6e 2e | 29 0a 54 68 69 73 20 6c |sertion.|).This l|
|00004120| 6f 73 73 61 67 65 20 64 | 6f 65 73 6e 27 74 20 73 |ossage d|oesn't s|
|00004130| 65 65 6d 20 76 65 72 79 | 20 6c 69 6b 65 6c 79 20 |eem very| likely |
|00004140| 74 6f 20 61 63 74 75 61 | 6c 6c 79 20 68 61 70 70 |to actua|lly happ|
|00004150| 65 6e 2c 20 74 68 6f 75 | 67 68 2e 0a 5b 5c 23 5c |en, thou|gh..[\#\|
|00004160| 23 5c 23 20 6d 75 73 74 | 2d 72 65 61 63 68 20 73 |#\# must|-reach s|
|00004170| 74 75 66 66 20 77 6f 75 | 6c 64 6e 27 74 20 77 6f |tuff wou|ldn't wo|
|00004180| 72 6b 20 71 75 69 74 65 | 20 61 73 20 77 65 6c 6c |rk quite| as well|
|00004190| 20 61 73 20 63 6f 6d 62 | 69 6e 61 74 69 6f 6e 20 | as comb|ination |
|000041a0| 73 75 62 73 74 69 74 75 | 74 65 20 69 6e 0a 70 73 |substitu|te in.ps|
|000041b0| 65 74 71 2c 20 65 74 63 | 2e 2c 20 73 69 6e 63 65 |etq, etc|., since|
|000041c0| 20 69 74 20 77 6f 75 6c | 64 20 66 61 69 6c 20 77 | it woul|d fail w|
|000041d0| 68 65 6e 20 6f 6e 65 20 | 6f 66 20 74 68 65 20 6e |hen one |of the n|
|000041e0| 65 77 20 76 61 6c 75 65 | 73 20 69 73 20 72 61 6e |ew value|s is ran|
|000041f0| 64 6f 6d 20 63 6f 64 65 | 0a 28 6d 69 67 68 74 20 |dom code|.(might |
|00004200| 75 6e 77 69 6e 64 2e 29 | 5d 0a 0a 49 73 20 74 68 |unwind.)|]..Is th|
|00004210| 69 73 20 72 65 61 6c 6c | 79 20 61 20 67 65 6e 65 |is reall|y a gene|
|00004220| 72 61 6c 20 70 72 6f 62 | 6c 65 6d 20 77 69 74 68 |ral prob|lem with|
|00004230| 20 65 61 67 65 72 20 74 | 79 70 65 20 63 68 65 63 | eager t|ype chec|
|00004240| 6b 69 6e 67 3f 20 20 49 | 74 20 73 65 65 6d 73 20 |king? I|t seems |
|00004250| 79 6f 75 20 63 6f 75 6c | 64 0a 61 72 67 75 65 20 |you coul|d.argue |
|00004260| 74 68 61 74 20 74 68 65 | 72 65 20 77 61 73 20 6e |that the|re was n|
|00004270| 6f 20 74 79 70 65 20 65 | 72 72 6f 72 20 69 6e 20 |o type e|rror in |
|00004280| 74 68 69 73 20 63 6f 64 | 65 3a 0a 20 20 20 20 28 |this cod|e:. (|
|00004290| 2b 20 3a 66 6f 6f 20 28 | 74 68 72 6f 77 20 27 75 |+ :foo (|throw 'u|
|000042a0| 70 20 6e 69 6c 29 29 0a | 42 75 74 20 77 65 20 77 |p nil)).|But we w|
|000042b0| 6f 75 6c 64 20 73 69 67 | 6e 61 6c 20 61 6e 20 65 |ould sig|nal an e|
|000042c0| 72 72 6f 72 2e 0a 0a 0a | 45 6d 69 74 20 65 78 70 |rror....|Emit exp|
|000042d0| 6c 69 63 69 74 20 79 6f | 75 2d 6c 6f 73 65 20 6f |licit yo|u-lose o|
|000042e0| 70 65 72 61 74 69 6f 6e | 20 77 68 65 6e 20 77 65 |peration| when we|
|000042f0| 20 64 6f 20 61 20 6d 6f | 76 65 20 62 65 74 77 65 | do a mo|ve betwe|
|00004300| 65 6e 20 74 77 6f 20 6e | 6f 6e 2d 54 20 70 74 79 |en two n|on-T pty|
|00004310| 70 65 73 2c 0a 65 76 65 | 6e 20 77 68 65 6e 20 74 |pes,.eve|n when t|
|00004320| 79 70 65 20 63 68 65 63 | 6b 69 6e 67 20 69 73 6e |ype chec|king isn|
|00004330| 27 74 20 6f 6e 2e 20 20 | 43 61 6e 20 74 68 69 73 |'t on. |Can this|
|00004340| 20 72 65 61 6c 6c 79 20 | 68 61 70 70 65 6e 3f 20 | really |happen? |
|00004350| 20 53 65 65 6d 73 20 77 | 65 20 73 68 6f 75 6c 64 | Seems w|e should|
|00004360| 0a 74 72 65 61 74 20 63 | 6f 6e 74 69 6e 75 61 74 |.treat c|ontinuat|
|00004370| 69 6f 6e 73 20 6c 69 6b | 65 20 74 68 69 73 20 61 |ions lik|e this a|
|00004380| 73 20 74 68 6f 75 67 68 | 20 74 79 70 65 2d 63 68 |s though| type-ch|
|00004390| 65 63 6b 20 77 61 73 20 | 74 72 75 65 2e 20 20 4d |eck was |true. M|
|000043a0| 61 79 62 65 20 4c 54 4e | 20 73 68 6f 75 6c 64 0a |aybe LTN| should.|
|000043b0| 6c 65 61 76 65 20 74 79 | 70 65 2d 63 68 65 63 6b |leave ty|pe-check|
|000043c0| 20 74 72 75 65 20 69 6e | 20 74 68 69 73 20 63 61 | true in| this ca|
|000043d0| 73 65 2c 20 65 76 65 6e | 20 77 68 65 6e 20 74 68 |se, even| when th|
|000043e0| 65 20 70 6f 6c 69 63 79 | 20 69 73 20 75 6e 73 61 |e policy| is unsa|
|000043f0| 66 65 2e 20 20 28 44 6f | 20 61 20 74 79 70 65 0a |fe. (Do| a type.|
|00004400| 63 68 65 63 6b 20 61 67 | 61 69 6e 73 74 20 4e 49 |check ag|ainst NI|
|00004410| 4c 3f 29 0a 0a 41 74 20 | 63 6f 6e 74 69 6e 75 61 |L?)..At |continua|
|00004420| 74 69 6f 6e 20 75 73 65 | 20 74 69 6d 65 2c 20 77 |tion use| time, w|
|00004430| 65 20 6d 61 79 20 69 6e | 20 67 65 6e 65 72 61 6c |e may in| general|
|00004440| 20 68 61 76 65 20 74 6f | 20 64 6f 20 62 6f 74 68 | have to| do both|
|00004450| 20 61 20 63 6f 65 72 63 | 65 2d 74 6f 2d 74 20 61 | a coerc|e-to-t a|
|00004460| 6e 64 20 61 0a 74 79 70 | 65 20 63 68 65 63 6b 2c |nd a.typ|e check,|
|00004470| 20 61 6c 6c 6f 63 61 74 | 69 6e 67 20 74 77 6f 20 | allocat|ing two |
|00004480| 74 65 6d 70 6f 72 61 72 | 79 20 54 4e 73 20 74 6f |temporar|y TNs to|
|00004490| 20 68 6f 6c 64 20 74 68 | 65 20 69 6e 74 65 72 6d | hold th|e interm|
|000044a0| 65 64 69 61 74 65 20 72 | 65 73 75 6c 74 73 2e 0a |ediate r|esults..|
|000044b0| 0a 0a 56 4d 52 20 43 6f | 6e 74 72 6f 6c 20 72 65 |..VMR Co|ntrol re|
|000044c0| 70 72 65 73 65 6e 74 61 | 74 69 6f 6e 3a 0a 0a 57 |presenta|tion:..W|
|000044d0| 65 20 72 65 70 72 65 73 | 65 6e 74 20 61 6c 6c 20 |e repres|ent all |
|000044e0| 63 6f 6e 74 72 6f 6c 20 | 74 72 61 6e 73 66 65 72 |control |transfer|
|000044f0| 20 65 78 70 6c 69 63 69 | 74 6c 79 2e 20 20 49 6e | explici|tly. In|
|00004500| 20 70 61 72 74 69 63 75 | 6c 61 72 2c 20 3a 43 6f | particu|lar, :Co|
|00004510| 6e 64 69 74 69 6f 6e 61 | 6c 20 56 4f 50 73 0a 74 |nditiona|l VOPs.t|
|00004520| 61 6b 65 20 61 20 73 69 | 6e 67 6c 65 20 54 61 72 |ake a si|ngle Tar|
|00004530| 67 65 74 20 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |get cont|inuation|
|00004540| 20 61 6e 64 20 61 20 4e | 6f 74 2d 50 20 66 6c 61 | and a N|ot-P fla|
|00004550| 67 20 69 6e 64 69 63 61 | 74 69 6e 67 20 77 68 65 |g indica|ting whe|
|00004560| 74 68 65 72 20 74 68 65 | 20 73 65 6e 73 65 0a 6f |ther the| sense.o|
|00004570| 66 20 74 68 65 20 74 65 | 73 74 20 69 73 20 6e 65 |f the te|st is ne|
|00004580| 67 61 74 65 64 2e 20 20 | 54 68 65 6e 20 61 6e 20 |gated. |Then an |
|00004590| 75 6e 63 6f 6e 64 69 74 | 69 6f 6e 61 6c 20 42 72 |uncondit|ional Br|
|000045a0| 61 6e 63 68 20 56 4f 50 | 20 77 69 6c 6c 20 62 65 |anch VOP| will be|
|000045b0| 20 65 6d 69 74 74 65 64 | 0a 61 66 74 65 72 77 61 | emitted|.afterwa|
|000045c0| 72 64 20 69 66 20 74 68 | 65 20 6f 74 68 65 72 20 |rd if th|e other |
|000045d0| 70 61 74 68 20 69 73 6e | 27 74 20 61 20 64 72 6f |path isn|'t a dro|
|000045e0| 70 2d 74 68 72 6f 75 67 | 68 2e 0a 0a 53 6f 20 77 |p-throug|h...So w|
|000045f0| 65 20 6c 69 6e 65 61 72 | 69 7a 65 20 74 68 65 20 |e linear|ize the |
|00004600| 63 6f 64 65 20 62 65 66 | 6f 72 65 20 56 4d 52 2d |code bef|ore VMR-|
|00004610| 63 6f 6e 76 65 72 73 69 | 6f 6e 2e 20 20 54 68 69 |conversi|on. Thi|
|00004620| 73 20 69 73 6e 27 74 20 | 61 20 70 72 6f 62 6c 65 |s isn't |a proble|
|00004630| 6d 2c 0a 73 69 6e 63 65 | 20 74 68 65 72 65 20 69 |m,.since| there i|
|00004640| 73 6e 27 74 20 6d 75 63 | 68 20 63 68 61 6e 67 65 |sn't muc|h change|
|00004650| 20 69 6e 20 63 6f 6e 74 | 72 6f 6c 20 66 6c 6f 77 | in cont|rol flow|
|00004660| 20 61 66 74 65 72 20 56 | 4d 52 20 63 6f 6e 76 65 | after V|MR conve|
|00004670| 72 73 69 6f 6e 20 28 6e | 6f 6e 65 20 75 6e 74 69 |rsion (n|one unti|
|00004680| 6c 0a 6c 6f 6f 70 20 6f | 70 74 69 6d 69 7a 61 74 |l.loop o|ptimizat|
|00004690| 69 6f 6e 20 72 65 71 75 | 69 72 65 73 20 69 6e 74 |ion requ|ires int|
|000046a0| 72 6f 64 75 63 74 69 6f | 6e 20 6f 66 20 68 65 61 |roductio|n of hea|
|000046b0| 64 65 72 20 62 6c 6f 63 | 6b 73 2e 29 20 20 49 74 |der bloc|ks.) It|
|000046c0| 20 64 6f 65 73 20 6d 61 | 6b 65 0a 63 6f 73 74 2d | does ma|ke.cost-|
|000046d0| 62 61 73 65 64 20 62 72 | 61 6e 63 68 20 70 72 65 |based br|anch pre|
|000046e0| 64 69 63 74 69 6f 6e 20 | 61 20 62 69 74 20 75 63 |diction |a bit uc|
|000046f0| 6b 79 2c 20 74 68 6f 75 | 67 68 2c 20 73 69 6e 63 |ky, thou|gh, sinc|
|00004700| 65 20 77 65 20 64 6f 6e | 27 74 20 68 61 76 65 20 |e we don|'t have |
|00004710| 61 6e 79 20 63 6f 73 74 | 0a 69 6e 66 6f 72 6d 61 |any cost|.informa|
|00004720| 74 69 6f 6e 20 69 6e 20 | 49 43 52 2e 20 20 41 63 |tion in |ICR. Ac|
|00004730| 74 75 61 6c 6c 79 2c 20 | 49 20 67 75 65 73 73 20 |tually, |I guess |
|00004740| 77 65 20 64 6f 20 68 61 | 76 65 20 70 72 65 74 74 |we do ha|ve prett|
|00004750| 79 20 67 6f 6f 64 20 63 | 6f 73 74 20 69 6e 66 6f |y good c|ost info|
|00004760| 72 6d 61 74 69 6f 6e 0a | 61 66 74 65 72 20 4c 54 |rmation.|after LT|
|00004770| 4e 20 65 76 65 6e 20 62 | 65 66 6f 72 65 20 56 4d |N even b|efore VM|
|00004780| 52 20 63 6f 6e 76 65 72 | 73 69 6f 6e 2c 20 73 69 |R conver|sion, si|
|00004790| 6e 63 65 20 74 68 65 20 | 6d 6f 73 74 20 69 6d 70 |nce the |most imp|
|000047a0| 6f 72 74 61 6e 74 20 74 | 68 69 6e 67 20 74 6f 20 |ortant t|hing to |
|000047b0| 6b 6e 6f 77 20 69 73 0a | 77 68 69 63 68 20 66 75 |know is.|which fu|
|000047c0| 6e 63 74 69 6f 6e 73 20 | 61 72 65 20 6f 70 65 6e |nctions |are open|
|000047d0| 2d 63 6f 64 65 64 2e 0a | 0a 7c 5c 23 0a 0a 56 4d |-coded..|.|\#..VM|
|000047e0| 52 20 70 72 65 73 65 72 | 76 65 73 20 74 68 65 20 |R preser|ves the |
|000047f0| 62 6c 6f 63 6b 20 73 74 | 72 75 63 74 75 72 65 20 |block st|ructure |
|00004800| 6f 66 20 49 43 52 2c 20 | 62 75 74 20 72 65 70 6c |of ICR, |but repl|
|00004810| 61 63 65 73 20 74 68 65 | 20 6e 6f 64 65 73 20 77 |aces the| nodes w|
|00004820| 69 74 68 20 61 20 74 61 | 72 67 65 74 0a 64 65 70 |ith a ta|rget.dep|
|00004830| 65 6e 64 65 6e 74 20 76 | 69 72 74 75 61 6c 20 6d |endent v|irtual m|
|00004840| 61 63 68 69 6e 65 20 28 | 56 4d 29 20 72 65 70 72 |achine (|VM) repr|
|00004850| 65 73 65 6e 74 61 74 69 | 6f 6e 2e 20 20 44 69 66 |esentati|on. Dif|
|00004860| 66 65 72 65 6e 74 20 69 | 6d 70 6c 65 6d 65 6e 74 |ferent i|mplement|
|00004870| 61 74 69 6f 6e 73 20 6d | 61 79 0a 75 73 65 20 64 |ations m|ay.use d|
|00004880| 69 66 66 65 72 65 6e 74 | 20 56 4d 73 20 77 69 74 |ifferent| VMs wit|
|00004890| 68 6f 75 74 20 6d 61 6b | 69 6e 67 20 6d 61 6a 6f |hout mak|ing majo|
|000048a0| 72 20 63 68 61 6e 67 65 | 73 20 69 6e 20 74 68 65 |r change|s in the|
|000048b0| 20 62 61 63 6b 20 65 6e | 64 2e 20 20 54 68 65 20 | back en|d. The |
|000048c0| 74 77 6f 20 6d 61 69 6e | 0a 63 6f 6d 70 6f 6e 65 |two main|.compone|
|000048d0| 6e 74 73 20 6f 66 20 56 | 4d 52 20 61 72 65 20 54 |nts of V|MR are T|
|000048e0| 65 6d 70 6f 72 61 72 79 | 20 4e 61 6d 65 73 20 28 |emporary| Names (|
|000048f0| 54 4e 73 29 20 61 6e 64 | 20 56 69 72 74 75 61 6c |TNs) and| Virtual|
|00004900| 20 4f 50 65 72 61 74 69 | 6f 6e 73 20 28 56 4f 50 | OPerati|ons (VOP|
|00004910| 73 29 2e 20 20 54 4e 73 | 0a 72 65 70 72 65 73 65 |s). TNs|.represe|
|00004920| 6e 74 20 74 68 65 20 6c | 6f 63 61 74 69 6f 6e 73 |nt the l|ocations|
|00004930| 20 74 68 61 74 20 68 6f | 6c 64 20 76 61 6c 75 65 | that ho|ld value|
|00004940| 73 2c 20 61 6e 64 20 56 | 4f 50 73 20 72 65 70 72 |s, and V|OPs repr|
|00004950| 65 73 65 6e 74 20 74 68 | 65 20 6f 70 65 72 61 74 |esent th|e operat|
|00004960| 69 6f 6e 73 0a 70 65 72 | 66 6f 72 6d 65 64 20 6f |ions.per|formed o|
|00004970| 6e 20 74 68 65 20 76 61 | 6c 75 65 73 2e 0a 0a 41 |n the va|lues...A|
|00004980| 20 22 70 72 69 6d 69 74 | 69 76 65 20 74 79 70 65 | "primit|ive type|
|00004990| 22 20 69 73 20 61 20 74 | 79 70 65 20 6d 65 61 6e |" is a t|ype mean|
|000049a0| 69 6e 67 66 75 6c 20 61 | 74 20 74 68 65 20 56 4d |ingful a|t the VM|
|000049b0| 20 6c 65 76 65 6c 2e 20 | 20 45 78 61 6d 70 6c 65 | level. | Example|
|000049c0| 73 20 61 72 65 20 46 69 | 78 6e 75 6d 2c 0a 53 74 |s are Fi|xnum,.St|
|000049d0| 72 69 6e 67 2d 43 68 61 | 72 2c 20 53 68 6f 72 74 |ring-Cha|r, Short|
|000049e0| 2d 46 6c 6f 61 74 2e 20 | 20 44 75 72 69 6e 67 20 |-Float. | During |
|000049f0| 56 4d 52 20 63 6f 6e 76 | 65 72 73 69 6f 6e 20 77 |VMR conv|ersion w|
|00004a00| 65 20 75 73 65 20 74 68 | 65 20 70 72 69 6d 69 74 |e use th|e primit|
|00004a10| 69 76 65 20 74 79 70 65 | 20 6f 66 0a 61 6e 20 65 |ive type| of.an e|
|00004a20| 78 70 72 65 73 73 69 6f | 6e 20 74 6f 20 64 65 74 |xpressio|n to det|
|00004a30| 65 72 6d 69 6e 65 20 62 | 6f 74 68 20 77 68 65 72 |ermine b|oth wher|
|00004a40| 65 20 77 65 20 63 61 6e | 20 73 74 6f 72 65 20 74 |e we can| store t|
|00004a50| 68 65 20 72 65 73 75 6c | 74 20 6f 66 20 74 68 65 |he resul|t of the|
|00004a60| 20 65 78 70 72 65 73 73 | 69 6f 6e 0a 61 6e 64 20 | express|ion.and |
|00004a70| 77 68 69 63 68 20 74 79 | 70 65 2d 73 70 65 63 69 |which ty|pe-speci|
|00004a80| 66 69 63 20 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |fic impl|ementati|
|00004a90| 6f 6e 73 20 6f 66 20 61 | 6e 20 6f 70 65 72 61 74 |ons of a|n operat|
|00004aa0| 69 6f 6e 20 63 61 6e 20 | 62 65 20 61 70 70 6c 69 |ion can |be appli|
|00004ab0| 65 64 20 74 6f 20 74 68 | 65 0a 76 61 6c 75 65 2e |ed to th|e.value.|
|00004ac0| 20 20 5b 50 74 79 70 65 | 20 69 73 20 61 20 73 65 | [Ptype| is a se|
|00004ad0| 74 20 6f 66 20 53 43 73 | 20 3d 3d 20 72 65 70 72 |t of SCs| == repr|
|00004ae0| 65 73 65 6e 74 61 74 69 | 6f 6e 20 63 68 6f 69 63 |esentati|on choic|
|00004af0| 65 73 20 61 6e 64 20 72 | 65 70 72 65 73 65 6e 74 |es and r|epresent|
|00004b00| 61 74 69 6f 6e 0a 73 70 | 65 63 69 66 69 63 20 6f |ation.sp|ecific o|
|00004b10| 70 65 72 61 74 69 6f 6e | 73 5d 0a 0a 54 68 65 20 |peration|s]..The |
|00004b20| 56 4d 20 73 70 65 63 69 | 66 69 63 20 64 65 66 69 |VM speci|fic defi|
|00004b30| 6e 69 74 69 6f 6e 73 20 | 70 72 6f 76 69 64 65 20 |nitions |provide |
|00004b40| 66 75 6e 63 74 69 6f 6e | 73 20 74 68 61 74 20 64 |function|s that d|
|00004b50| 6f 20 73 74 75 66 66 20 | 6c 69 6b 65 20 66 69 6e |o stuff |like fin|
|00004b60| 64 20 74 68 65 0a 70 72 | 69 6d 69 74 69 76 65 20 |d the.pr|imitive |
|00004b70| 74 79 70 65 20 63 6f 72 | 72 65 73 70 6f 6e 64 69 |type cor|respondi|
|00004b80| 6e 67 20 74 6f 20 61 20 | 74 79 70 65 20 61 6e 64 |ng to a |type and|
|00004b90| 20 74 65 73 74 20 66 6f | 72 20 70 72 69 6d 69 74 | test fo|r primit|
|00004ba0| 69 76 65 20 74 79 70 65 | 20 73 75 62 74 79 70 65 |ive type| subtype|
|00004bb0| 70 2e 0a 55 73 75 61 6c | 6c 79 20 70 72 69 6d 69 |p..Usual|ly primi|
|00004bc0| 74 69 76 65 20 74 79 70 | 65 73 20 77 69 6c 6c 20 |tive typ|es will |
|00004bd0| 62 65 20 64 69 73 6a 6f | 69 6e 74 20 65 78 63 65 |be disjo|int exce|
|00004be0| 70 74 20 66 6f 72 20 54 | 2c 20 77 68 69 63 68 20 |pt for T|, which |
|00004bf0| 72 65 70 72 65 73 65 6e | 74 73 20 61 6c 6c 0a 74 |represen|ts all.t|
|00004c00| 79 70 65 73 2e 0a 0a 54 | 68 65 20 70 72 69 6d 69 |ypes...T|he primi|
|00004c10| 74 69 76 65 20 74 79 70 | 65 20 54 20 69 73 20 73 |tive typ|e T is s|
|00004c20| 70 65 63 69 61 6c 2d 63 | 61 73 65 64 2e 20 20 4e |pecial-c|ased. N|
|00004c30| 6f 74 20 6f 6e 6c 79 20 | 64 6f 65 73 20 69 74 20 |ot only |does it |
|00004c40| 6f 76 65 72 6c 61 70 20 | 77 69 74 68 20 61 6c 6c |overlap |with all|
|00004c50| 20 74 68 65 0a 6f 74 68 | 65 72 20 74 79 70 65 73 | the.oth|er types|
|00004c60| 2c 20 62 75 74 20 69 74 | 20 69 6d 70 6c 69 65 73 |, but it| implies|
|00004c70| 20 61 20 64 65 73 63 72 | 69 70 74 6f 72 20 28 22 | a descr|iptor ("|
|00004c80| 62 6f 78 65 64 22 20 6f | 72 20 22 70 6f 69 6e 74 |boxed" o|r "point|
|00004c90| 65 72 22 29 20 72 65 70 | 72 65 73 65 6e 74 61 74 |er") rep|resentat|
|00004ca0| 69 6f 6e 2e 0a 46 6f 72 | 20 65 66 66 69 63 69 65 |ion..For| efficie|
|00004cb0| 6e 63 79 20 72 65 61 73 | 6f 6e 73 2c 20 77 65 20 |ncy reas|ons, we |
|00004cc0| 73 6f 6d 65 74 69 6d 65 | 73 20 77 61 6e 74 20 74 |sometime|s want t|
|00004cd0| 6f 20 75 73 65 0a 61 6c | 74 65 72 6e 61 74 65 20 |o use.al|ternate |
|00004ce0| 72 65 70 72 65 73 65 6e | 74 61 74 69 6f 6e 73 20 |represen|tations |
|00004cf0| 66 6f 72 20 73 6f 6d 65 | 20 6f 62 6a 65 63 74 73 |for some| objects|
|00004d00| 20 73 75 63 68 20 61 73 | 20 6e 75 6d 62 65 72 73 | such as| numbers|
|00004d10| 2e 20 20 54 68 65 20 6d | 61 6a 6f 72 69 74 79 20 |. The m|ajority |
|00004d20| 6f 66 0a 6f 70 65 72 61 | 74 69 6f 6e 73 20 63 61 |of.opera|tions ca|
|00004d30| 6e 6e 6f 74 20 65 78 70 | 6c 6f 69 74 20 61 6c 74 |nnot exp|loit alt|
|00004d40| 65 72 6e 61 74 65 20 72 | 65 70 72 65 73 65 6e 74 |ernate r|epresent|
|00004d50| 61 74 69 6f 6e 73 2c 20 | 61 6e 64 20 77 6f 75 6c |ations, |and woul|
|00004d60| 64 20 6f 6e 6c 79 20 62 | 65 0a 63 6f 6d 70 6c 69 |d only b|e.compli|
|00004d70| 63 61 74 65 64 20 69 66 | 20 74 68 65 79 20 68 61 |cated if| they ha|
|00004d80| 64 20 74 6f 20 62 65 20 | 61 62 6c 65 20 74 6f 20 |d to be |able to |
|00004d90| 63 6f 6e 76 65 72 74 20 | 61 6c 74 65 72 6e 61 74 |convert |alternat|
|00004da0| 65 20 72 65 70 72 65 73 | 65 6e 74 61 74 69 6f 6e |e repres|entation|
|00004db0| 73 20 69 6e 74 6f 0a 64 | 65 73 63 72 69 70 74 6f |s into.d|escripto|
|00004dc0| 72 73 2e 20 20 41 20 74 | 65 6d 70 6c 61 74 65 20 |rs. A t|emplate |
|00004dd0| 63 61 6e 20 72 65 71 75 | 69 72 65 20 61 6e 20 6f |can requ|ire an o|
|00004de0| 70 65 72 61 6e 64 20 74 | 6f 20 62 65 20 61 20 64 |perand t|o be a d|
|00004df0| 65 73 63 72 69 70 74 6f | 72 20 62 79 0a 63 6f 6e |escripto|r by.con|
|00004e00| 73 74 72 61 69 6e 69 6e | 67 20 74 68 65 20 6f 70 |strainin|g the op|
|00004e10| 65 72 61 6e 64 20 74 6f | 20 62 65 20 6f 66 20 74 |erand to| be of t|
|00004e20| 79 70 65 20 54 2e 0a 0a | 41 20 54 4e 20 63 61 6e |ype T...|A TN can|
|00004e30| 20 6f 6e 6c 79 20 72 65 | 70 72 65 73 65 6e 74 20 | only re|present |
|00004e40| 61 20 73 69 6e 67 6c 65 | 20 76 61 6c 75 65 2c 20 |a single| value, |
|00004e50| 73 6f 20 77 65 20 62 61 | 72 65 20 74 68 65 20 69 |so we ba|re the i|
|00004e60| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 20 6f 66 |mplement|ation of|
|00004e70| 20 4d 56 73 20 61 74 0a | 74 68 69 73 20 70 6f 69 | MVs at.|this poi|
|00004e80| 6e 74 2e 20 20 57 68 65 | 6e 20 77 65 20 6b 6e 6f |nt. Whe|n we kno|
|00004e90| 77 20 74 68 65 20 6e 75 | 6d 62 65 72 20 6f 66 20 |w the nu|mber of |
|00004ea0| 6d 75 6c 74 69 70 6c 65 | 20 76 61 6c 75 65 73 20 |multiple| values |
|00004eb0| 62 65 69 6e 67 20 68 61 | 6e 64 6c 65 64 2c 20 77 |being ha|ndled, w|
|00004ec0| 65 20 75 73 65 0a 6d 75 | 6c 74 69 70 6c 65 20 54 |e use.mu|ltiple T|
|00004ed0| 4e 73 20 74 6f 20 68 6f | 6c 64 20 74 68 65 6d 2e |Ns to ho|ld them.|
|00004ee0| 20 20 57 68 65 6e 20 74 | 68 65 20 6e 75 6d 62 65 | When t|he numbe|
|00004ef0| 72 20 6f 66 20 76 61 6c | 75 65 73 20 69 73 20 61 |r of val|ues is a|
|00004f00| 63 74 75 61 6c 6c 79 20 | 75 6e 6b 6e 6f 77 6e 2c |ctually |unknown,|
|00004f10| 20 77 65 0a 75 73 65 20 | 61 20 63 6f 6e 76 65 6e | we.use |a conven|
|00004f20| 74 69 6f 6e 20 74 68 61 | 74 20 69 73 20 63 6f 6d |tion tha|t is com|
|00004f30| 70 61 74 69 62 6c 65 20 | 77 69 74 68 20 66 75 6c |patible |with ful|
|00004f40| 6c 20 66 75 6e 63 74 69 | 6f 6e 20 63 61 6c 6c 2e |l functi|on call.|
|00004f50| 0a 0a 45 76 65 72 79 74 | 68 69 6e 67 20 74 68 61 |..Everyt|hing tha|
|00004f60| 74 20 69 73 20 64 6f 6e | 65 20 69 73 20 64 6f 6e |t is don|e is don|
|00004f70| 65 20 62 79 20 61 20 56 | 4f 50 20 69 6e 20 56 4d |e by a V|OP in VM|
|00004f80| 52 2e 20 20 43 61 6c 6c | 73 20 74 6f 20 73 69 6d |R. Call|s to sim|
|00004f90| 70 6c 65 20 70 72 69 6d | 69 74 69 76 65 0a 66 75 |ple prim|itive.fu|
|00004fa0| 6e 63 74 69 6f 6e 73 20 | 73 75 63 68 20 61 73 20 |nctions |such as |
|00004fb0| 2b 20 61 6e 64 20 43 41 | 52 20 61 72 65 20 74 72 |+ and CA|R are tr|
|00004fc0| 61 6e 73 6c 61 74 65 64 | 20 74 6f 20 56 4f 50 20 |anslated| to VOP |
|00004fd0| 65 71 75 69 76 61 6c 65 | 6e 74 73 20 62 79 20 61 |equivale|nts by a|
|00004fe0| 20 74 61 62 6c 65 2d 64 | 72 69 76 65 6e 0a 6d 65 | table-d|riven.me|
|00004ff0| 63 68 61 6e 69 73 6d 2e | 20 20 54 68 69 73 20 74 |chanism.| This t|
|00005000| 72 61 6e 73 6c 61 74 69 | 6f 6e 20 69 73 20 73 70 |ranslati|on is sp|
|00005010| 65 63 69 66 69 65 64 20 | 62 79 20 74 68 65 20 70 |ecified |by the p|
|00005020| 61 72 74 69 63 75 6c 61 | 72 20 56 4d 20 64 65 66 |articula|r VM def|
|00005030| 69 6e 69 74 69 6f 6e 3b | 20 56 4d 52 0a 63 6f 6e |inition;| VMR.con|
|00005040| 76 65 72 73 69 6f 6e 20 | 6d 61 6b 65 73 20 6e 6f |version |makes no|
|00005050| 20 61 73 73 75 6d 70 74 | 69 6f 6e 73 20 61 62 6f | assumpt|ions abo|
|00005060| 75 74 20 77 68 69 63 68 | 20 6f 70 65 72 61 74 69 |ut which| operati|
|00005070| 6f 6e 73 20 61 72 65 20 | 70 72 69 6d 69 74 69 76 |ons are |primitiv|
|00005080| 65 20 6f 72 20 77 68 61 | 74 0a 6f 70 65 72 61 6e |e or wha|t.operan|
|00005090| 64 20 74 79 70 65 73 20 | 61 72 65 20 77 6f 72 74 |d types |are wort|
|000050a0| 68 20 73 70 65 63 69 61 | 6c 2d 63 61 73 69 6e 67 |h specia|l-casing|
|000050b0| 2e 20 20 54 68 65 20 64 | 65 66 61 75 6c 74 20 63 |. The d|efault c|
|000050c0| 61 6c 6c 69 6e 67 20 6d | 65 63 68 61 6e 69 73 6d |alling m|echanism|
|000050d0| 73 20 61 6e 64 0a 6f 74 | 68 65 72 20 6d 69 73 63 |s and.ot|her misc|
|000050e0| 65 6c 6c 61 6e 65 6f 75 | 73 20 62 75 69 6c 74 69 |ellaneou|s builti|
|000050f0| 6e 20 66 65 61 74 75 72 | 65 73 20 61 72 65 20 69 |n featur|es are i|
|00005100| 6d 70 6c 65 6d 65 6e 74 | 65 64 20 75 73 69 6e 67 |mplement|ed using|
|00005110| 20 73 74 61 6e 64 61 72 | 64 20 56 4f 50 73 20 74 | standar|d VOPs t|
|00005120| 68 61 74 0a 6d 75 73 74 | 20 69 6d 70 6c 65 6d 65 |hat.must| impleme|
|00005130| 6e 74 65 64 20 62 79 20 | 65 61 63 68 20 56 4d 2e |nted by |each VM.|
|00005140| 0a 0a 54 79 70 65 20 69 | 6e 66 6f 72 6d 61 74 69 |..Type i|nformati|
|00005150| 6f 6e 20 63 61 6e 20 62 | 65 20 66 6f 72 67 6f 74 |on can b|e forgot|
|00005160| 74 65 6e 20 61 66 74 65 | 72 20 56 4d 52 20 63 6f |ten afte|r VMR co|
|00005170| 6e 76 65 72 73 69 6f 6e | 2c 20 73 69 6e 63 65 20 |nversion|, since |
|00005180| 61 6c 6c 20 74 79 70 65 | 2d 73 70 65 63 69 66 69 |all type|-specifi|
|00005190| 63 0a 6f 70 65 72 61 74 | 69 6f 6e 20 73 65 6c 65 |c.operat|ion sele|
|000051a0| 63 74 69 6f 6e 73 20 68 | 61 76 65 20 62 65 65 6e |ctions h|ave been|
|000051b0| 20 6d 61 64 65 2e 0a 0a | 53 69 6d 70 6c 65 20 74 | made...|Simple t|
|000051c0| 79 70 65 20 63 68 65 63 | 6b 69 6e 67 20 69 73 20 |ype chec|king is |
|000051d0| 65 78 70 6c 69 63 69 74 | 6c 79 20 64 6f 6e 65 20 |explicit|ly done |
|000051e0| 75 73 69 6e 67 20 43 48 | 45 43 4b 2d 78 78 78 20 |using CH|ECK-xxx |
|000051f0| 56 4f 50 73 2e 20 20 54 | 68 65 79 20 61 63 74 20 |VOPs. T|hey act |
|00005200| 6c 69 6b 65 0a 69 6e 6e | 6f 63 75 6f 75 73 20 65 |like.inn|ocuous e|
|00005210| 66 66 65 63 74 6c 65 73 | 73 2f 75 6e 61 66 66 65 |ffectles|s/unaffe|
|00005220| 63 74 65 64 20 56 4f 50 | 73 20 77 68 69 63 68 20 |cted VOP|s which |
|00005230| 72 65 74 75 72 6e 20 74 | 68 65 20 63 68 65 63 6b |return t|he check|
|00005240| 65 64 20 74 68 69 6e 67 | 20 61 73 20 61 0a 72 65 |ed thing| as a.re|
|00005250| 73 75 6c 74 2e 20 20 54 | 68 69 73 20 61 6c 6c 6f |sult. T|his allo|
|00005260| 77 73 20 6c 6f 6f 70 2d | 69 6e 76 61 72 69 61 6e |ws loop-|invarian|
|00005270| 74 20 6f 70 74 69 6d 69 | 7a 61 74 69 6f 6e 20 61 |t optimi|zation a|
|00005280| 6e 64 20 63 6f 6d 6d 6f | 6e 20 73 75 62 65 78 70 |nd commo|n subexp|
|00005290| 72 65 73 73 69 6f 6e 0a | 65 6c 69 6d 69 6e 61 74 |ression.|eliminat|
|000052a0| 69 6f 6e 20 74 6f 20 72 | 65 6d 6f 76 65 20 72 65 |ion to r|emove re|
|000052b0| 64 75 6e 64 61 6e 74 20 | 63 68 65 63 6b 73 2e 20 |dundant |checks. |
|000052c0| 20 41 6c 6c 20 74 79 70 | 65 20 63 68 65 63 6b 69 | All typ|e checki|
|000052d0| 6e 67 20 69 73 20 64 6f | 6e 65 20 61 74 20 74 68 |ng is do|ne at th|
|000052e0| 65 20 74 69 6d 65 0a 74 | 68 65 20 63 6f 6e 74 69 |e time.t|he conti|
|000052f0| 6e 75 61 74 69 6f 6e 20 | 69 73 20 75 73 65 64 2e |nuation |is used.|
|00005300| 0a 0a 4e 6f 74 65 20 74 | 68 61 74 20 77 65 20 6e |..Note t|hat we n|
|00005310| 65 65 64 20 6f 6e 6c 79 | 20 63 68 65 63 6b 20 61 |eed only| check a|
|00005320| 73 73 65 72 74 65 64 20 | 74 79 70 65 73 2c 20 73 |sserted |types, s|
|00005330| 69 6e 63 65 20 69 66 20 | 74 79 70 65 20 69 6e 66 |ince if |type inf|
|00005340| 65 72 65 6e 63 65 20 77 | 6f 72 6b 73 2c 20 74 68 |erence w|orks, th|
|00005350| 65 0a 64 65 72 69 76 65 | 64 20 74 79 70 65 73 20 |e.derive|d types |
|00005360| 77 69 6c 6c 20 61 6c 73 | 6f 20 62 65 20 73 61 74 |will als|o be sat|
|00005370| 69 73 66 69 65 64 2e 20 | 20 57 65 20 63 61 6e 20 |isfied. | We can |
|00005380| 63 68 65 63 6b 20 77 68 | 69 63 68 65 76 65 72 20 |check wh|ichever |
|00005390| 69 73 20 6d 6f 72 65 0a | 63 6f 6e 76 65 6e 69 65 |is more.|convenie|
|000053a0| 6e 74 2c 20 73 69 6e 63 | 65 20 62 6f 74 68 20 73 |nt, sinc|e both s|
|000053b0| 68 6f 75 6c 64 20 62 65 | 20 74 72 75 65 2e 0a 0a |hould be| true...|
|000053c0| 43 6f 6e 73 74 61 6e 74 | 73 20 61 72 65 20 74 75 |Constant|s are tu|
|000053d0| 72 6e 65 64 20 69 6e 74 | 6f 20 73 70 65 63 69 61 |rned int|o specia|
|000053e0| 6c 20 43 6f 6e 73 74 61 | 6e 74 20 54 4e 73 2c 20 |l Consta|nt TNs, |
|000053f0| 77 68 69 63 68 20 61 72 | 65 20 77 69 72 65 64 20 |which ar|e wired |
|00005400| 64 6f 77 6e 20 69 6e 20 | 61 20 53 43 0a 74 68 61 |down in |a SC.tha|
|00005410| 74 20 69 73 20 64 65 74 | 65 72 6d 69 6e 65 64 20 |t is det|ermined |
|00005420| 62 79 20 74 68 65 69 72 | 20 74 79 70 65 2e 20 20 |by their| type. |
|00005430| 54 68 65 20 56 4d 20 64 | 65 66 69 6e 69 74 69 6f |The VM d|efinitio|
|00005440| 6e 20 70 72 6f 76 69 64 | 65 73 20 61 20 66 75 6e |n provid|es a fun|
|00005450| 63 74 69 6f 6e 20 74 68 | 61 74 0a 72 65 74 75 72 |ction th|at.retur|
|00005460| 6e 73 20 63 6f 6e 73 74 | 61 6e 74 20 61 20 54 4e |ns const|ant a TN|
|00005470| 20 74 6f 20 72 65 70 72 | 65 73 65 6e 74 20 61 20 | to repr|esent a |
|00005480| 43 6f 6e 73 74 61 6e 74 | 20 4c 65 61 66 2e 20 0a |Constant| Leaf. .|
|00005490| 0a 45 61 63 68 20 63 6f | 6d 70 6f 6e 65 6e 74 20 |.Each co|mponent |
|000054a0| 68 61 73 20 61 20 63 6f | 6e 73 74 61 6e 74 20 70 |has a co|nstant p|
|000054b0| 6f 6f 6c 2e 20 20 54 68 | 65 72 65 20 69 73 20 61 |ool. Th|ere is a|
|000054c0| 20 72 65 67 69 73 74 65 | 72 20 64 65 64 69 63 61 | registe|r dedica|
|000054d0| 74 65 64 20 74 6f 20 68 | 6f 6c 64 69 6e 67 0a 74 |ted to h|olding.t|
|000054e0| 68 65 20 63 6f 6e 73 74 | 61 6e 74 20 70 6f 6f 6c |he const|ant pool|
|000054f0| 20 66 6f 72 20 74 68 65 | 20 63 75 72 72 65 6e 74 | for the| current|
|00005500| 20 63 6f 6d 70 6f 6e 65 | 6e 74 2e 20 20 54 68 65 | compone|nt. The|
|00005510| 20 62 61 63 6b 20 65 6e | 64 20 61 6c 6c 6f 63 61 | back en|d alloca|
|00005520| 74 65 73 0a 6e 6f 6e 2d | 69 6d 6d 65 64 69 61 74 |tes.non-|immediat|
|00005530| 65 20 63 6f 6e 73 74 61 | 6e 74 73 20 69 6e 20 74 |e consta|nts in t|
|00005540| 68 65 20 63 6f 6e 73 74 | 61 6e 74 20 70 6f 6f 6c |he const|ant pool|
|00005550| 20 77 68 65 6e 20 69 74 | 20 64 69 73 63 6f 76 65 | when it| discove|
|00005560| 72 73 20 74 68 65 6d 20 | 64 75 72 69 6e 67 0a 74 |rs them |during.t|
|00005570| 72 61 6e 73 6c 61 74 69 | 6f 6e 20 66 72 6f 6d 20 |ranslati|on from |
|00005580| 49 43 52 2e 0a 0a 5b 5c | 23 5c 23 5c 23 20 43 68 |ICR...[\|#\#\# Ch|
|00005590| 65 63 6b 20 74 68 61 74 | 20 77 65 20 61 72 65 20 |eck that| we are |
|000055a0| 64 65 73 63 72 69 62 69 | 6e 67 20 77 68 61 74 20 |describi|ng what |
|000055b0| 69 73 20 61 63 74 75 61 | 6c 6c 79 20 69 6d 70 6c |is actua|lly impl|
|000055c0| 65 6d 65 6e 74 65 64 2e | 20 20 42 75 74 20 74 68 |emented.| But th|
|000055d0| 69 73 0a 72 65 61 6c 6c | 79 20 69 73 6e 27 74 20 |is.reall|y isn't |
|000055e0| 76 65 72 79 20 67 6f 6f | 64 20 69 6e 20 74 68 65 |very goo|d in the|
|000055f0| 20 70 72 65 73 65 6e 63 | 65 20 6f 66 20 69 6e 74 | presenc|e of int|
|00005600| 65 72 65 73 74 69 6e 67 | 20 75 6e 62 6f 78 65 64 |eresting| unboxed|
|00005610| 0a 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 73 |.represe|ntations|
|00005620| 2e 2e 2e 5d 20 0a 53 69 | 6e 63 65 20 4c 54 4e 20 |...] .Si|nce LTN |
|00005630| 6f 6e 6c 79 20 64 65 61 | 6c 73 20 77 69 74 68 20 |only dea|ls with |
|00005640| 76 61 6c 75 65 73 20 66 | 72 6f 6d 20 74 68 65 20 |values f|rom the |
|00005650| 76 69 65 77 70 6f 69 6e | 74 20 6f 66 20 74 68 65 |viewpoin|t of the|
|00005660| 20 72 65 63 65 69 76 65 | 72 2c 20 77 65 20 6d 75 | receive|r, we mu|
|00005670| 73 74 20 62 65 0a 70 72 | 65 70 61 72 65 64 20 64 |st be.pr|epared d|
|00005680| 75 72 69 6e 67 20 74 68 | 65 20 74 72 61 6e 73 6c |uring th|e transl|
|00005690| 61 74 69 6f 6e 20 70 61 | 73 73 20 74 6f 20 64 6f |ation pa|ss to do|
|000056a0| 20 73 74 75 66 66 20 74 | 6f 20 74 68 65 20 63 6f | stuff t|o the co|
|000056b0| 6e 74 69 6e 75 61 74 69 | 6f 6e 20 61 74 20 74 68 |ntinuati|on at th|
|000056c0| 65 0a 74 69 6d 65 20 69 | 74 20 69 73 20 75 73 65 |e.time i|t is use|
|000056d0| 64 2e 0a 20 2d 2d 20 49 | 66 20 61 20 56 4f 50 20 |d.. -- I|f a VOP |
|000056e0| 79 69 65 6c 64 73 20 6d | 6f 72 65 20 76 61 6c 75 |yields m|ore valu|
|000056f0| 65 73 20 74 68 61 6e 20 | 61 72 65 20 64 65 73 69 |es than |are desi|
|00005700| 72 65 64 2c 20 74 68 65 | 6e 20 77 65 20 6d 75 73 |red, the|n we mus|
|00005710| 74 20 63 72 65 61 74 65 | 20 54 4e 73 20 74 6f 0a |t create| TNs to.|
|00005720| 20 20 20 20 68 6f 6c 64 | 20 74 68 65 20 64 69 73 | hold| the dis|
|00005730| 63 61 72 64 65 64 20 72 | 65 73 75 6c 74 73 2e 20 |carded r|esults. |
|00005740| 20 41 6e 20 69 6d 70 6f | 72 74 61 6e 74 20 73 70 | An impo|rtant sp|
|00005750| 65 63 69 61 6c 2d 63 61 | 73 65 20 69 73 20 63 6f |ecial-ca|se is co|
|00005760| 6e 74 69 6e 75 61 74 69 | 6f 6e 73 0a 20 20 20 20 |ntinuati|ons. |
|00005770| 77 68 6f 73 65 20 76 61 | 6c 75 65 20 69 73 20 64 |whose va|lue is d|
|00005780| 69 73 63 61 72 64 65 64 | 2e 20 20 54 68 65 73 65 |iscarded|. These|
|00005790| 20 63 6f 6e 74 69 6e 75 | 61 74 69 6f 6e 73 20 77 | continu|ations w|
|000057a0| 6f 6e 27 74 20 62 65 20 | 61 6e 6e 6f 74 61 74 65 |on't be |annotate|
|000057b0| 64 20 61 74 20 61 6c 6c | 2e 0a 20 20 20 20 49 6e |d at all|.. In|
|000057c0| 20 74 68 65 20 63 61 73 | 65 20 6f 66 20 61 20 52 | the cas|e of a R|
|000057d0| 65 66 2c 20 77 65 20 63 | 61 6e 20 73 69 6d 70 6c |ef, we c|an simpl|
|000057e0| 79 20 73 6b 69 70 20 65 | 76 61 6c 75 61 74 69 6f |y skip e|valuatio|
|000057f0| 6e 20 6f 66 20 74 68 65 | 20 72 65 66 65 72 65 6e |n of the| referen|
|00005800| 63 65 20 77 68 65 6e 0a | 20 20 20 20 74 68 65 20 |ce when.| the |
|00005810| 63 6f 6e 74 69 6e 75 61 | 74 69 6f 6e 20 68 61 73 |continua|tion has|
|00005820| 6e 27 74 20 62 65 65 6e | 20 61 6e 6e 6f 74 61 74 |n't been| annotat|
|00005830| 65 64 2e 20 20 41 6c 74 | 68 6f 75 67 68 20 74 68 |ed. Alt|hough th|
|00005840| 69 73 20 77 69 6c 6c 20 | 65 6c 69 6d 69 6e 61 74 |is will |eliminat|
|00005850| 65 0a 20 20 20 20 62 6f | 67 75 73 20 72 65 66 65 |e. bo|gus refe|
|00005860| 72 65 6e 63 65 73 20 74 | 68 61 74 20 66 6f 72 20 |rences t|hat for |
|00005870| 73 6f 6d 65 20 72 65 61 | 73 6f 6e 20 77 65 72 65 |some rea|son were|
|00005880| 6e 27 74 20 6f 70 74 69 | 6d 69 7a 65 64 20 61 77 |n't opti|mized aw|
|00005890| 61 79 2c 20 74 68 65 20 | 72 65 61 6c 0a 20 20 20 |ay, the |real. |
|000058a0| 20 70 75 72 70 6f 73 65 | 20 69 73 20 74 6f 20 68 | purpose| is to h|
|000058b0| 61 6e 64 6c 65 20 64 65 | 66 65 72 72 65 64 20 72 |andle de|ferred r|
|000058c0| 65 66 65 72 65 6e 63 65 | 73 2e 0a 20 2d 2d 20 49 |eference|s.. -- I|
|000058d0| 66 20 61 20 56 4f 50 20 | 79 69 65 6c 64 73 20 66 |f a VOP |yields f|
|000058e0| 65 77 65 72 20 76 61 6c | 75 65 73 20 74 68 61 6e |ewer val|ues than|
|000058f0| 20 64 65 73 69 72 65 64 | 2c 20 74 68 65 6e 20 77 | desired|, then w|
|00005900| 65 20 6d 75 73 74 20 64 | 65 66 61 75 6c 74 20 74 |e must d|efault t|
|00005910| 68 65 20 65 78 74 72 61 | 0a 20 20 20 20 76 61 6c |he extra|. val|
|00005920| 75 65 73 20 74 6f 20 4e | 49 4c 2e 0a 20 2d 2d 20 |ues to N|IL.. -- |
|00005930| 49 66 20 61 20 63 6f 6e | 74 69 6e 75 61 74 69 6f |If a con|tinuatio|
|00005940| 6e 20 68 61 73 20 69 74 | 73 20 74 79 70 65 2d 63 |n has it|s type-c|
|00005950| 68 65 63 6b 20 66 6c 61 | 67 20 73 65 74 2c 20 74 |heck fla|g set, t|
|00005960| 68 65 6e 20 77 65 20 6d | 75 73 74 20 63 68 65 63 |hen we m|ust chec|
|00005970| 6b 20 74 68 65 20 74 79 | 70 65 0a 20 20 20 20 6f |k the ty|pe. o|
|00005980| 66 20 74 68 65 20 76 61 | 6c 75 65 20 62 65 66 6f |f the va|lue befo|
|00005990| 72 65 20 6d 6f 76 69 6e | 67 20 69 74 20 69 6e 74 |re movin|g it int|
|000059a0| 6f 20 74 68 65 20 72 65 | 73 75 6c 74 20 6c 6f 63 |o the re|sult loc|
|000059b0| 61 74 69 6f 6e 2e 20 20 | 49 6e 20 67 65 6e 65 72 |ation. |In gener|
|000059c0| 61 6c 2c 20 74 68 69 73 | 0a 20 20 20 20 72 65 71 |al, this|. req|
|000059d0| 75 69 72 65 73 20 63 6f | 6d 70 75 74 69 6e 67 20 |uires co|mputing |
|000059e0| 74 68 65 20 72 65 73 75 | 6c 74 20 69 6e 20 61 20 |the resu|lt in a |
|000059f0| 74 65 6d 70 6f 72 61 72 | 79 2c 20 61 6e 64 20 68 |temporar|y, and h|
|00005a00| 61 76 69 6e 67 20 74 68 | 65 20 74 79 70 65 2d 63 |aving th|e type-c|
|00005a10| 68 65 63 6b 0a 20 20 20 | 20 6f 70 65 72 61 74 69 |heck. | operati|
|00005a20| 6f 6e 20 64 65 6c 69 76 | 65 72 20 69 74 20 69 6e |on deliv|er it in|
|00005a30| 20 74 68 65 20 61 63 74 | 75 61 6c 20 72 65 73 75 | the act|ual resu|
|00005a40| 6c 74 20 6c 6f 63 61 74 | 69 6f 6e 2e 0a 20 2d 2d |lt locat|ion.. --|
|00005a50| 20 49 66 20 74 68 65 20 | 74 65 6d 70 6c 61 74 65 | If the |template|
|00005a60| 27 73 20 72 65 73 75 6c | 74 20 74 79 70 65 20 69 |'s resul|t type i|
|00005a70| 73 20 54 2c 20 74 68 65 | 6e 20 77 65 20 6d 75 73 |s T, the|n we mus|
|00005a80| 74 20 67 65 6e 65 72 61 | 74 65 20 61 20 62 6f 78 |t genera|te a box|
|00005a90| 65 64 0a 20 20 20 20 74 | 65 6d 70 6f 72 61 72 79 |ed. t|emporary|
|00005aa0| 20 74 6f 20 63 6f 6d 70 | 75 74 65 20 74 68 65 20 | to comp|ute the |
|00005ab0| 72 65 73 75 6c 74 20 69 | 6e 20 77 68 65 6e 20 74 |result i|n when t|
|00005ac0| 68 65 20 63 6f 6e 74 69 | 6e 75 61 74 69 6f 6e 27 |he conti|nuation'|
|00005ad0| 73 20 74 79 70 65 20 69 | 73 6e 27 74 20 54 2e 0a |s type i|sn't T..|
|00005ae0| 0a 0a 57 65 20 6d 61 79 | 20 61 6c 73 6f 20 6e 65 |..We may| also ne|
|00005af0| 65 64 20 74 6f 20 64 6f | 20 73 74 75 66 66 20 74 |ed to do| stuff t|
|00005b00| 6f 20 74 68 65 20 61 72 | 67 75 6d 65 6e 74 73 20 |o the ar|guments |
|00005b10| 77 68 65 6e 20 77 65 20 | 67 65 6e 65 72 61 74 65 |when we |generate|
|00005b20| 20 63 6f 64 65 20 66 6f | 72 20 61 0a 74 65 6d 70 | code fo|r a.temp|
|00005b30| 6c 61 74 65 2e 20 20 49 | 66 20 61 6e 20 61 72 67 |late. I|f an arg|
|00005b40| 75 6d 65 6e 74 20 63 6f | 6e 74 69 6e 75 61 74 69 |ument co|ntinuati|
|00005b50| 6f 6e 20 69 73 6e 27 74 | 20 61 6e 6e 6f 74 61 74 |on isn't| annotat|
|00005b60| 65 64 2c 20 74 68 65 6e | 20 69 74 20 6d 75 73 74 |ed, then| it must|
|00005b70| 20 62 65 20 61 0a 64 65 | 66 65 72 72 65 64 20 72 | be a.de|ferred r|
|00005b80| 65 66 65 72 65 6e 63 65 | 2e 20 20 57 65 20 75 73 |eference|. We us|
|00005b90| 65 20 74 68 65 20 6c 65 | 61 66 27 73 20 54 4e 20 |e the le|af's TN |
|00005ba0| 69 6e 73 74 65 61 64 2e | 20 20 57 65 20 6d 61 79 |instead.| We may|
|00005bb0| 20 68 61 76 65 20 74 6f | 20 64 6f 20 61 6e 79 20 | have to| do any |
|00005bc0| 6f 66 0a 74 68 65 20 61 | 62 6f 76 65 20 75 73 65 |of.the a|bove use|
|00005bd0| 2d 74 69 6d 65 20 61 63 | 74 69 6f 6e 73 20 61 6c |-time ac|tions al|
|00005be0| 73 6f 2e 20 20 41 6c 74 | 65 72 6e 61 74 69 76 65 |so. Alt|ernative|
|00005bf0| 6c 79 2c 20 77 65 20 63 | 6f 75 6c 64 20 61 76 6f |ly, we c|ould avo|
|00005c00| 69 64 20 68 61 69 72 20 | 62 79 20 6e 6f 74 0a 64 |id hair |by not.d|
|00005c10| 65 66 65 72 72 69 6e 67 | 20 72 65 66 65 72 65 6e |eferring| referen|
|00005c20| 63 65 73 20 74 68 61 74 | 20 6d 75 73 74 20 62 65 |ces that| must be|
|00005c30| 20 74 79 70 65 2d 63 68 | 65 63 6b 65 64 20 6f 72 | type-ch|ecked or|
|00005c40| 20 6d 61 79 20 6e 65 65 | 64 20 74 6f 20 62 65 20 | may nee|d to be |
|00005c50| 62 6f 78 65 64 2e 0a 0a | 0c 0a 5c 73 65 63 74 69 |boxed...|..\secti|
|00005c60| 6f 6e 7b 53 74 61 63 6b | 20 61 6e 61 6c 79 73 69 |on{Stack| analysi|
|00005c70| 73 7d 0a 0a 54 68 69 6e | 6b 20 6f 66 20 74 68 69 |s}..Thin|k of thi|
|00005c80| 73 20 61 73 20 61 20 6c | 69 66 65 74 69 6d 65 20 |s as a l|ifetime |
|00005c90| 70 72 6f 62 6c 65 6d 3a | 20 61 20 76 61 6c 75 65 |problem:| a value|
|00005ca0| 73 20 67 65 6e 65 72 61 | 74 6f 72 20 69 73 20 61 |s genera|tor is a|
|00005cb0| 20 77 72 69 74 65 20 61 | 6e 64 20 61 20 76 61 6c | write a|nd a val|
|00005cc0| 75 65 73 0a 72 65 63 65 | 69 76 65 72 20 69 73 20 |ues.rece|iver is |
|00005cd0| 61 20 72 65 61 64 2e 20 | 20 57 65 20 77 61 6e 74 |a read. | We want|
|00005ce0| 20 74 6f 20 61 6e 6e 6f | 74 61 74 65 20 65 61 63 | to anno|tate eac|
|00005cf0| 68 20 56 4d 52 2d 42 6c | 6f 63 6b 20 77 69 74 68 |h VMR-Bl|ock with|
|00005d00| 20 74 68 65 20 75 6e 6b | 6e 6f 77 6e 2d 76 61 6c | the unk|nown-val|
|00005d10| 75 65 73 0a 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |ues.cont|inuation|
|00005d20| 73 20 74 68 61 74 20 61 | 72 65 20 6c 69 76 65 20 |s that a|re live |
|00005d30| 61 74 20 74 68 61 74 20 | 70 6f 69 6e 74 2e 20 20 |at that |point. |
|00005d40| 49 66 20 77 65 20 64 6f | 20 61 20 63 6f 6e 74 72 |If we do| a contr|
|00005d50| 6f 6c 20 74 72 61 6e 73 | 66 65 72 20 74 6f 20 61 |ol trans|fer to a|
|00005d60| 0a 70 6c 61 63 65 20 77 | 68 65 72 65 20 66 65 77 |.place w|here few|
|00005d70| 65 72 20 63 6f 6e 74 69 | 6e 75 61 74 69 6f 6e 73 |er conti|nuations|
|00005d80| 20 61 72 65 20 6c 69 76 | 65 2c 20 74 68 65 6e 20 | are liv|e, then |
|00005d90| 77 65 20 6d 75 73 74 20 | 64 65 61 6c 6c 6f 63 61 |we must |dealloca|
|00005da0| 74 65 20 74 68 65 20 6e | 65 77 6c 79 0a 64 65 61 |te the n|ewly.dea|
|00005db0| 64 20 63 6f 6e 74 69 6e | 75 61 74 69 6f 6e 73 2e |d contin|uations.|
|00005dc0| 0a 0a 57 65 20 77 61 6e | 74 20 74 6f 20 63 6f 6e |..We wan|t to con|
|00005dd0| 76 69 6e 63 65 20 6f 75 | 72 73 65 6c 76 65 73 20 |vince ou|rselves |
|00005de0| 74 68 61 74 20 76 61 6c | 75 65 73 20 64 65 61 6c |that val|ues deal|
|00005df0| 6c 6f 63 61 74 69 6f 6e | 20 62 61 73 65 64 20 6f |location| based o|
|00005e00| 6e 20 6c 69 66 65 74 69 | 6d 65 0a 61 6e 61 6c 79 |n lifeti|me.analy|
|00005e10| 73 69 73 20 61 63 74 75 | 61 6c 6c 79 20 77 6f 72 |sis actu|ally wor|
|00005e20| 6b 73 2e 20 20 49 6e 20 | 70 61 72 74 69 63 75 6c |ks. In |particul|
|00005e30| 61 72 2c 20 77 65 20 6e | 65 65 64 20 74 6f 20 62 |ar, we n|eed to b|
|00005e40| 65 20 73 75 72 65 20 74 | 68 61 74 20 69 74 20 64 |e sure t|hat it d|
|00005e50| 6f 65 73 6e 27 74 0a 76 | 69 6f 6c 61 74 65 20 74 |oesn't.v|iolate t|
|00005e60| 68 65 20 72 65 71 75 69 | 72 65 64 20 73 74 61 63 |he requi|red stac|
|00005e70| 6b 20 64 69 73 63 69 70 | 6c 69 6e 65 2e 20 20 49 |k discip|line. I|
|00005e80| 74 20 69 73 20 63 6c 65 | 61 72 20 74 68 61 74 20 |t is cle|ar that |
|00005e90| 69 74 20 69 73 20 69 6d | 70 6f 73 73 69 62 6c 65 |it is im|possible|
|00005ea0| 20 74 6f 0a 64 65 61 6c | 6c 6f 63 61 74 65 20 74 | to.deal|locate t|
|00005eb0| 68 65 20 76 61 6c 75 65 | 73 20 62 65 66 6f 72 65 |he value|s before|
|00005ec0| 20 74 68 65 79 20 62 65 | 63 6f 6d 65 20 64 65 61 | they be|come dea|
|00005ed0| 64 2c 20 73 69 6e 63 65 | 20 6c 61 74 65 72 20 63 |d, since| later c|
|00005ee0| 6f 64 65 20 6d 61 79 20 | 64 65 63 69 64 65 20 74 |ode may |decide t|
|00005ef0| 6f 0a 75 73 65 20 74 68 | 65 6d 2e 20 20 53 6f 20 |o.use th|em. So |
|00005f00| 74 68 65 20 6f 6e 6c 79 | 20 74 68 69 6e 67 20 77 |the only| thing w|
|00005f10| 65 20 6e 65 65 64 20 74 | 6f 20 65 6e 73 75 72 65 |e need t|o ensure|
|00005f20| 20 69 73 20 74 68 61 74 | 20 74 68 65 20 22 72 69 | is that| the "ri|
|00005f30| 67 68 74 22 20 74 69 6d | 65 20 69 73 6e 27 74 0a |ght" tim|e isn't.|
|00005f40| 6c 61 74 65 72 20 74 68 | 61 6e 20 74 68 65 20 74 |later th|an the t|
|00005f50| 69 6d 65 20 74 68 61 74 | 20 74 68 65 20 63 6f 6e |ime that| the con|
|00005f60| 74 69 6e 75 61 74 69 6f | 6e 20 62 65 63 6f 6d 65 |tinuatio|n become|
|00005f70| 73 20 64 65 61 64 2e 0a | 0a 54 68 65 20 6f 6e 6c |s dead..|.The onl|
|00005f80| 79 20 72 65 61 73 6f 6e | 20 77 68 79 20 77 65 20 |y reason| why we |
|00005f90| 63 6f 75 6c 64 6e 27 74 | 20 64 65 61 6c 6c 6f 63 |couldn't| dealloc|
|00005fa0| 61 74 65 20 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |ate cont|inuation|
|00005fb0| 20 41 20 61 73 20 73 6f | 6f 6e 20 61 73 20 69 74 | A as so|on as it|
|00005fc0| 20 62 65 63 6f 6d 65 73 | 0a 64 65 61 64 20 77 6f | becomes|.dead wo|
|00005fd0| 75 6c 64 20 62 65 20 74 | 68 61 74 20 74 68 65 72 |uld be t|hat ther|
|00005fe0| 65 20 69 73 20 61 6e 6f | 74 68 65 72 20 63 6f 6e |e is ano|ther con|
|00005ff0| 74 69 6e 75 61 74 69 6f | 6e 20 42 20 6f 6e 20 74 |tinuatio|n B on t|
|00006000| 6f 70 20 6f 66 20 69 74 | 20 74 68 61 74 20 69 73 |op of it| that is|
|00006010| 6e 27 74 20 64 65 61 64 | 0a 28 73 69 6e 63 65 20 |n't dead|.(since |
|00006020| 77 65 20 63 61 6e 20 6f | 6e 6c 79 20 64 65 61 6c |we can o|nly deal|
|00006030| 6c 6f 63 61 74 65 20 74 | 68 65 20 74 6f 70 6d 6f |locate t|he topmo|
|00006040| 73 74 20 63 6f 6e 74 69 | 6e 75 61 74 69 6f 6e 29 |st conti|nuation)|
|00006050| 2e 0a 0a 54 68 65 20 6b | 65 79 20 74 6f 20 75 6e |...The k|ey to un|
|00006060| 64 65 72 73 74 61 6e 64 | 69 6e 67 20 77 68 79 20 |derstand|ing why |
|00006070| 74 68 69 73 20 63 61 6e | 27 74 20 68 61 70 70 65 |this can|'t happe|
|00006080| 6e 20 69 73 20 74 68 61 | 74 20 65 61 63 68 20 63 |n is tha|t each c|
|00006090| 6f 6e 74 69 6e 75 61 74 | 69 6f 6e 20 68 61 73 0a |ontinuat|ion has.|
|000060a0| 6f 6e 6c 79 20 6f 6e 65 | 20 72 65 61 64 20 28 72 |only one| read (r|
|000060b0| 65 63 65 69 76 65 72 29 | 2e 20 20 49 66 20 42 20 |eceiver)|. If B |
|000060c0| 69 73 20 6f 6e 20 74 6f | 70 20 6f 66 20 41 2c 20 |is on to|p of A, |
|000060d0| 74 68 65 6e 20 69 74 20 | 6d 75 73 74 20 62 65 20 |then it |must be |
|000060e0| 74 68 65 20 63 61 73 65 | 20 74 68 61 74 20 41 0a |the case| that A.|
|000060f0| 69 73 20 6c 69 76 65 20 | 61 74 20 74 68 65 20 72 |is live |at the r|
|00006100| 65 63 65 69 76 65 72 20 | 66 6f 72 20 42 2e 20 20 |eceiver |for B. |
|00006110| 54 68 69 73 20 6d 65 61 | 6e 73 20 74 68 61 74 20 |This mea|ns that |
|00006120| 69 74 20 69 73 20 69 6d | 70 6f 73 73 69 62 6c 65 |it is im|possible|
|00006130| 20 66 6f 72 20 42 20 74 | 6f 20 62 65 0a 6c 69 76 | for B t|o be.liv|
|00006140| 65 20 77 69 74 68 6f 75 | 74 20 41 20 62 65 69 6e |e withou|t A bein|
|00006150| 67 20 6c 69 76 65 2e 0a | 0a 0a 54 68 65 20 72 65 |g live..|..The re|
|00006160| 61 73 6f 6e 20 74 68 61 | 74 20 77 65 20 64 6f 6e |ason tha|t we don|
|00006170| 27 74 20 73 6f 6c 76 65 | 20 74 68 69 73 20 70 72 |'t solve| this pr|
|00006180| 6f 62 6c 65 6d 20 75 73 | 69 6e 67 20 61 20 6e 6f |oblem us|ing a no|
|00006190| 72 6d 61 6c 20 69 74 65 | 72 61 74 69 76 65 20 66 |rmal ite|rative f|
|000061a0| 6c 6f 77 0a 61 6e 61 6c | 79 73 69 73 20 69 73 20 |low.anal|ysis is |
|000061b0| 74 68 61 74 20 77 65 20 | 61 6c 73 6f 20 6e 65 65 |that we |also nee|
|000061c0| 64 20 74 6f 20 6b 6e 6f | 77 20 74 68 65 20 6f 72 |d to kno|w the or|
|000061d0| 64 65 72 69 6e 67 20 6f | 66 20 74 68 65 20 63 6f |dering o|f the co|
|000061e0| 6e 74 69 6e 75 61 74 69 | 6f 6e 73 20 6f 6e 20 74 |ntinuati|ons on t|
|000061f0| 68 65 0a 73 74 61 63 6b | 20 73 6f 20 74 68 61 74 |he.stack| so that|
|00006200| 20 77 65 20 63 61 6e 20 | 64 6f 20 64 65 61 6c 6c | we can |do deall|
|00006210| 6f 63 61 74 69 6f 6e 2e | 20 20 57 68 65 6e 20 69 |ocation.| When i|
|00006220| 74 20 63 6f 6d 65 73 20 | 74 69 6d 65 20 74 6f 20 |t comes |time to |
|00006230| 64 69 73 63 61 72 64 20 | 76 61 6c 75 65 73 2c 20 |discard |values, |
|00006240| 77 65 0a 77 61 6e 74 20 | 74 6f 20 6b 6e 6f 77 20 |we.want |to know |
|00006250| 77 68 69 63 68 20 64 69 | 73 63 61 72 64 65 64 20 |which di|scarded |
|00006260| 63 6f 6e 74 69 6e 75 61 | 74 69 6f 6e 20 69 73 20 |continua|tion is |
|00006270| 6f 6e 20 74 68 65 20 62 | 6f 74 74 6f 6d 20 73 6f |on the b|ottom so|
|00006280| 20 74 68 61 74 20 77 65 | 20 63 61 6e 20 72 65 73 | that we| can res|
|00006290| 65 74 0a 53 50 20 74 6f | 20 69 74 73 20 73 74 61 |et.SP to| its sta|
|000062a0| 72 74 2e 20 20 0a 0a 5b | 49 20 73 75 70 70 6f 73 |rt. ..[|I suppos|
|000062b0| 65 20 77 65 20 63 6f 75 | 6c 64 20 61 6c 73 6f 20 |e we cou|ld also |
|000062c0| 64 65 63 72 65 6d 65 6e | 74 20 53 50 20 62 79 20 |decremen|t SP by |
|000062d0| 74 68 65 20 61 67 67 72 | 65 67 61 74 65 20 73 69 |the aggr|egate si|
|000062e0| 7a 65 20 6f 66 20 74 68 | 65 20 64 69 73 63 61 72 |ze of th|e discar|
|000062f0| 64 65 64 0a 63 6f 6e 74 | 69 6e 75 61 74 69 6f 6e |ded.cont|inuation|
|00006300| 73 2e 5d 20 20 41 6e 6f | 74 68 65 72 20 61 64 76 |s.] Ano|ther adv|
|00006310| 61 6e 74 61 67 65 20 6f | 66 20 6b 6e 6f 77 69 6e |antage o|f knowin|
|00006320| 67 20 74 68 65 20 6f 72 | 64 65 72 20 69 6e 20 77 |g the or|der in w|
|00006330| 68 69 63 68 20 77 65 20 | 65 78 70 65 63 74 0a 63 |hich we |expect.c|
|00006340| 6f 6e 74 69 6e 75 61 74 | 69 6f 6e 73 20 74 6f 20 |ontinuat|ions to |
|00006350| 62 65 20 6f 6e 20 74 68 | 65 20 73 74 61 63 6b 20 |be on th|e stack |
|00006360| 69 73 20 74 68 61 74 20 | 69 74 20 61 6c 6c 6f 77 |is that |it allow|
|00006370| 73 20 75 73 20 74 6f 20 | 64 6f 20 73 6f 6d 65 20 |s us to |do some |
|00006380| 63 6f 6e 73 69 73 74 65 | 6e 63 79 0a 63 68 65 63 |consiste|ncy.chec|
|00006390| 6b 69 6e 67 2e 20 20 41 | 6c 73 6f 20 64 6f 69 6e |king. A|lso doin|
|000063a0| 67 20 61 20 6c 6f 63 61 | 6c 69 7a 65 64 20 67 72 |g a loca|lized gr|
|000063b0| 61 70 68 20 77 61 6c 6b | 20 61 72 6f 75 6e 64 20 |aph walk| around |
|000063c0| 74 68 65 20 76 61 6c 75 | 65 73 2d 72 65 63 65 69 |the valu|es-recei|
|000063d0| 76 65 72 20 69 73 0a 6c | 69 6b 65 6c 79 20 74 6f |ver is.l|ikely to|
|000063e0| 20 62 65 20 6d 75 63 68 | 20 6d 6f 72 65 20 65 66 | be much| more ef|
|000063f0| 66 69 63 69 65 6e 74 20 | 74 68 61 6e 20 64 6f 69 |ficient |than doi|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.