/* Ċ Ġ* ĠL 1 Translator . kt Ċ Ġ* ĠCopyright ĠÂ© Ġ 1 9 9 3 - 2 0 2 1 , ĠThe ĠAv ail ĠFoundation , ĠLLC . Ċ Ġ* ĠAll Ġrights Ġreserved . Ċ Ġ* Ċ Ġ* ĠRedistribution Ġand Ġuse Ġin Ġsource Ġand Ġbinary Ġforms , Ġwith Ġor Ġwithout Ċ Ġ* Ġmodification , Ġare Ġpermitted Ġprovided Ġthat Ġthe Ġfollowing Ġconditions Ġare Ġmet : Ċ Ġ* Ċ Ġ* Ġ* ĠRedistributions Ġof Ġsource Ġcode Ġmust Ġretain Ġthe Ġabove Ġcopyright Ġnotice , Ġthis Ċ Ġ* ĠĠ Ġlist Ġof Ġconditions Ġand Ġthe Ġfollowing Ġdisclaimer . Ċ Ġ* Ċ Ġ* Ġ* ĠRedistributions Ġin Ġbinary Ġform Ġmust Ġreproduce Ġthe Ġabove Ġcopyright Ġnotice , Ċ Ġ* ĠĠ Ġthis Ġlist Ġof Ġconditions Ġand Ġthe Ġfollowing Ġdisclaimer Ġin Ġthe Ġdocumentation Ċ Ġ* ĠĠ Ġand / or Ġother Ġmaterials Ġprovided Ġwith Ġthe Ġdistribution . Ċ Ġ* Ċ Ġ* Ġ* ĠNeither Ġthe Ġname Ġof Ġthe Ġcopyright Ġholder Ġnor Ġthe Ġnames Ġof Ġthe Ġcontributors Ċ Ġ* ĠĠ Ġmay Ġbe Ġused Ġto Ġendorse Ġor Ġpromote Ġproducts Ġderived Ġfrom Ġthis Ġsoftware Ċ Ġ* ĠĠ Ġwithout Ġspecific Ġprior Ġwritten Ġpermission . Ċ Ġ* Ċ Ġ* ĠTHIS ĠSOFTWARE ĠIS ĠPROVIDED ĠBY ĠTHE ĠCOPYRIGHT ĠHOLDERS ĠAND ĠCONTRIBUTORS Ġ" AS ĠIS " Ċ Ġ* ĠAND ĠANY ĠEXPRESS ĠOR ĠIMPLIED ĠWARRANTIES , ĠINCLUDING , ĠBUT ĠNOT ĠLIMITED ĠTO , ĠTHE Ċ Ġ* ĠIMPLIED ĠWARRANTIES ĠOF ĠMERCHANTABILITY ĠAND ĠFITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE Ċ Ġ* ĠARE ĠDISCLAIMED . ĠIN ĠNO ĠEVENT ĠSHALL ĠTHE ĠCOPYRIGHT ĠHOLDER ĠOR ĠCONTRIBUTORS ĠBE Ċ Ġ* ĠLIABLE ĠFOR ĠANY ĠDIRECT , ĠINDIRECT , ĠINCIDENTAL , ĠSPECIAL , ĠEXEMPLARY , ĠOR Ċ Ġ* ĠCONSEQUENTIAL ĠDAMAGES Ġ( INCLUDING , ĠBUT ĠNOT ĠLIMITED ĠTO , ĠPROCUREMENT ĠOF Ċ Ġ* ĠSUBSTITUTE ĠGOODS ĠOR ĠSERVICES ; ĠLOSS ĠOF ĠUSE , ĠDATA , ĠOR ĠPROFITS ; ĠOR ĠBUSINESS Ċ Ġ* ĠINTERRUPTION ) ĠHOWEVER ĠCAUSED ĠAND ĠON ĠANY ĠTHEORY ĠOF ĠLIABILITY , ĠWHETHER ĠIN Ċ Ġ* ĠCONTRACT , ĠSTRICT ĠLIABILITY , ĠOR ĠTORT Ġ( INCLUDING ĠNEGLIGENCE ĠOR ĠOTHERWISE ) Ċ Ġ* ĠARISING ĠIN ĠANY ĠWAY ĠOUT ĠOF ĠTHE ĠUSE ĠOF ĠTHIS ĠSOFTWARE , ĠEVEN ĠIF ĠADVISED ĠOF ĠTHE Ċ Ġ* ĠPOSSIBILITY ĠOF ĠSUCH ĠDAMAGE . Ċ Ġ*/ Ċ package Ġcom . avail . optimizer Ċ Ċ import Ġcom . avail . Avail Runtime . Hook Type Ċ import Ġcom . avail . Avail Runtime Support Ċ import Ġcom . avail . descriptor . atoms . A _ Atom . Companion . atom Name Ċ import Ġcom . avail . descriptor . atoms . Atom Descriptor . Companion . true Object Ċ import Ġcom . avail . descriptor . bundles . A _ Bundle Ċ import Ġcom . avail . descriptor . bundles . A _ Bundle . Companion . bundle Method Ċ import Ġcom . avail . descriptor . bundles . A _ Bundle . Companion . message Ċ import Ġcom . avail . descriptor . bundles . Message Bundle Descriptor Ċ import Ġcom . avail . descriptor . functions . A _ Continuation Ċ import Ġcom . avail . descriptor . functions . A _ Function Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . code Starting LineNumber Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . countdown To Re optimize Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . declaration Names Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . literal At Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . local Type At Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . methodName Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . module Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . num Args Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . num Local s Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . num Out ers Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . num Slots Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . outer Type At Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . returnType If Primitive Fails Ċ import Ġcom . avail . descriptor . functions . A _ Raw Function . Companion . starting Chunk Ċ import Ġcom . avail . descriptor . functions . Compiled Code Descriptor Ċ import Ġcom . avail . descriptor . functions . Compiled Code Descriptor . L 1 Instruction Decoder Ċ import Ġcom . avail . descriptor . functions . Function Descriptor . Companion . create Function Ċ import Ġcom . avail . descriptor . methods . A _ Definition Ċ import Ġcom . avail . descriptor . methods . A _ Method Ċ import Ġcom . avail . descriptor . methods . A _ Method . Companion . definitions At Or Below Ċ import Ġcom . avail . descriptor . methods . A _ Method . Companion . definitions Tuple Ċ import Ġcom . avail . descriptor . methods . A _ Method . Companion . lookup By Types From Tuple Ċ import Ġcom . avail . descriptor . methods . A _ Method . Companion . num Args Ċ import Ġcom . avail . descriptor . methods . A _ Method . Companion . testing Tree Ċ import Ġcom . avail . descriptor . methods . A _ Semantic Restriction Ċ import Ġcom . avail . descriptor . methods . A _ Send able . Companion . body Block Ċ import Ġcom . avail . descriptor . methods . A _ Send able . Companion . body Signature Ċ import Ġcom . avail . descriptor . methods . A _ Send able . Companion . is Method Definition Ċ import Ġcom . avail . descriptor . methods . MethodDescriptor Ċ import Ġcom . avail . descriptor . module . A _ Module . Companion . moduleName Ċ import Ġcom . avail . descriptor . numbers . A _ Number . Companion . equals Int Ċ import Ġcom . avail . descriptor . numbers . A _ Number . Companion . extract Int Ċ import Ġcom . avail . descriptor . po jos . Raw Po jo Descriptor . Companion . identity Po jo Ċ import Ġcom . avail . descriptor . representation . A _ Basic Object Ċ import Ġcom . avail . descriptor . representation . Avail Object Ċ import Ġcom . avail . descriptor . representation . Nil Descriptor . Companion . nil Ċ import Ġcom . avail . descriptor . sets . A _ Set . Companion . setSize Ċ import Ġcom . avail . descriptor . sets . Set Descriptor . Companion . set From Collection Ċ import Ġcom . avail . descriptor . tuples . A _ Tuple Ċ import Ġcom . avail . descriptor . tuples . A _ Tuple . Companion . tuple At Ċ import Ġcom . avail . descriptor . tuples . A _ Tuple . Companion . tuple Int At Ċ import Ġcom . avail . descriptor . tuples . A _ Tuple . Companion . tuple Size Ċ import Ġcom . avail . descriptor . tuples . Object Tuple Descriptor . Companion . tuple From List Ċ import Ġcom . avail . descriptor . types . A _ Type Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . args Tuple Type Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . could E ver Be Inv oked With Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . instance Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . instance Count Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . is Subtype Of Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . lower Bound Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . range Includes Long Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . read Type Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . returnType Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . size Range Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . type AtIndex Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . type Intersection Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . type Union Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . upper Bound Ċ import Ġcom . avail . descriptor . types . A _ Type . Companion . write Type Ċ import Ġcom . avail . descriptor . types . Abstract Enumeration TypeDescriptor . Companion . enumeration With Ċ import Ġcom . avail . descriptor . types . Bottom TypeDescriptor . Companion . bottom Ċ import Ġcom . avail . descriptor . types . Continuation TypeDescriptor . Companion . continu ation Type For FunctionType Ċ import Ġcom . avail . descriptor . types . Continuation TypeDescriptor . Companion . most General Continuation Type Ċ import Ġcom . avail . descriptor . types . FunctionType Descriptor . Companion . most General FunctionType Ċ import Ġcom . avail . descriptor . types . Instance Meta Descriptor . Companion . instance Meta Ċ import Ġcom . avail . descriptor . types . Integer Range TypeDescriptor . Companion . int 3 2 Ċ import Ġcom . avail . descriptor . types . Tuple TypeDescriptor . Companion . tuple Type For Types Ċ import Ġcom . avail . descriptor . types . Tuple TypeDescriptor . Companion . tuple Type For Types List Ċ import Ġcom . avail . descriptor . types . TypeDescriptor Ċ import Ġcom . avail . descriptor . types . TypeDescriptor . Types Ċ import Ġcom . avail . descriptor . variables . A _ Variable Ċ import Ġcom . avail . descriptor . variables . Variable Descriptor . Variable Access Reactor Ċ import Ġcom . avail . dispatch . Internal Lookup Tree Ċ import Ġcom . avail . dispatch . Lookup Tree Tra verser Ċ import Ġcom . avail . exceptions . Avail ErrorCode Ċ import Ġcom . avail . exceptions . Avail ErrorCode . E _ NO _ METHOD _ DEFINITION Ċ import Ġcom . avail . exceptions . Method Definition Exception Ċ import Ġcom . avail . interpreter . Primitive Ċ import Ġcom . avail . interpreter . Primitive . F al lib ility . Call Site Cannot Fail Ċ import Ġcom . avail . interpreter . Primitive . F al lib ility . Call Site Must Fail Ċ import Ġcom . avail . interpreter . Primitive . Flag Ċ import Ġcom . avail . interpreter . execution . Interpreter Ċ import Ġcom . avail . interpreter . execution . Interpreter . Companion . assignment Function Ċ import Ġcom . avail . interpreter . execution . Interpreter . Companion . log Ċ import Ġcom . avail . interpreter . level One . L 1 Operation Ċ import Ġcom . avail . interpreter . level One . L 1 Operation Dispatcher Ċ import Ġcom . avail . interpreter . level Two . L 2 Chunk Ċ import Ġcom . avail . interpreter . level Two . L 2 Chunk . Chunk EntryPoint Ċ import Ġcom . avail . interpreter . level Two . L 2 Chunk . Companion . countdown For New ly Optim ized Code Ċ import Ġcom . avail . interpreter . level Two . L 2 Instruction Ċ import Ġcom . avail . interpreter . level Two . L 2 Operation Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Comment Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Constant Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Int Immediate Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Primitive Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Read Boxed Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Read Boxed Vector Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Selector Operand Ċ import Ġcom . avail . interpreter . level Two . operand . L 2 Write Boxed Operand Ċ import Ġcom . avail . interpreter . level Two . operand . Type Restriction Ċ import Ġcom . avail . interpreter . level Two . operand . Type Restriction . Companion . restriction Ċ import Ġcom . avail . interpreter . level Two . operand . Type Restriction . Companion . restriction ForType Ċ import Ġcom . avail . interpreter . level Two . operand . Type Restriction . Restriction Flag Encoding . BOX ED _ FLAG Ċ import Ġcom . avail . interpreter . level Two . operand . Type Restriction . Restriction Flag Encoding . UN BOX ED _ FLOAT _ FLAG Ċ import Ġcom . avail . interpreter . level Two . operand . Type Restriction . Restriction Flag Encoding . UN BOX ED _ INT _ FLAG Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ CREATE _ CONT IN UATION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ CREATE _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ CREATE _ T UP LE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ CREATE _ VARIABLE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ DECRE MENT _ COUNTER _ AND _ RE OPTIMI ZE _ ON _ ZERO Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ ENTER _ L 2 _ CHUNK Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ ARGUMENT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ CURRENT _ CONT IN UATION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ CURRENT _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ IMP LICIT _ OB SER VE _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ INVALID _ MESSAGE _ SEND _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ LATE ST _ RETURN _ VALUE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ TYPE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ TYPE . source ValueOf Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ VARIABLE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ GET _ VARIABLE _ CLEAR ING Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ INTER PRE T _ LEVEL _ ONE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ IN VOKE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ IN VOKE _ CONSTANT _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ IN VOKE _ INVALID _ MESSAGE _ RESULT _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ IN VOKE _ UN ASS IGNED _ VARIABLE _ READ _ FUNCTION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ COMPARE _ INT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ EQUAL S _ CONSTANT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ INTERRUPT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ KIND _ OF _ CONSTANT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ KIND _ OF _ OBJECT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ OBJECTS _ EQUAL Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ SUB TYPE _ OF _ CONSTANT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ JUMP _ IF _ SUB TYPE _ OF _ OBJECT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ LOOK UP _ BY _ TYPES Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ LOOK UP _ BY _ VALUES Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ MOVE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ MOVE _ CONSTANT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ MOVE _ OUT ER _ VARIABLE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ PRE PARE _ NEW _ FRAME _ FOR _ L 1 Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RE ENTER _ L 1 _ CHUNK _ FROM _ CALL Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RE ENTER _ L 1 _ CHUNK _ FROM _ INTERRUPT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RE IFY Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RE IFY . Statistic Category Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RETURN Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RETURN _ FROM _ RE IFICATION _ HANDLER Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RUN _ INF AL LIB LE _ PR IMIT IVE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RUN _ INF AL LIB LE _ PR IMIT IVE . Companion . args Of Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ RUN _ INF AL LIB LE _ PR IMIT IVE . Companion . primitive Of Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ SAVE _ ALL _ AND _ PC _ TO _ INT Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ SET _ CONT IN UATION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ SET _ VARIABLE _ NO _ CHECK Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ TRY _ OPTIONAL _ PR IMIT IVE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ TRY _ PR IMIT IVE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ TYPE _ UNION Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ UN RE ACH ABLE _ CODE Ċ import Ġcom . avail . interpreter . level Two . operation . L 2 _ VIRTUAL _ CREATE _ LABEL Ċ import Ġcom . avail . interpreter . level Two . register . L 2 Register Ċ import Ġcom . avail . interpreter . primitive . cont ro lf low . P _ Restart Continuation Ċ import Ġcom . avail . interpreter . primitive . general . P _ Equality Ċ import Ġcom . avail . optimizer . L 2 Control Flow Graph . Zone Type Ċ import Ġcom . avail . optimizer . L 2 Generator . Companion . back Edge To Ċ import Ġcom . avail . optimizer . L 2 Generator . Companion . edge To Ċ import Ġcom . avail . optimizer . L 2 Generator . Optimization Level Ċ import Ġcom . avail . optimizer . L 2 Generator . Special Block . AFTER _ OPTIONAL _ PR IMIT IVE Ċ import Ġcom . avail . optimizer . L 2 Generator . Special Block . RE START _ LOOP _ HEAD Ċ import Ġcom . avail . optimizer . L 2 Generator . Special Block . START Ċ import Ġcom . avail . optimizer . L 2 Generator . Special Block . UN RE ACH ABLE Ċ import Ġcom . avail . optimizer . values . Frame Ċ import Ġcom . avail . optimizer . values . L 2 Semantic Constant Ċ import Ġcom . avail . optimizer . values . L 2 Semantic Un boxed Int Ċ import Ġcom . avail . optimizer . values . L 2 Semantic Value Ċ import Ġcom . avail . performance . Statistic Ċ import Ġcom . avail . performance . Statistic Report . L 1 _ NA IVE _ TRANSL ATION _ TIME Ċ import Ġcom . avail . performance . Statistic Report . L 2 _ OPTIMI Z ATION _ TIME Ċ import Ġcom . avail . performance . Statistic Report . L 2 _ TRANSL ATION _ VALUES Ċ import Ġjava . util . concurrent . atomic . Atomic Reference Ċ import Ġjava . util . logging . Level Ċ Ċ /** Ċ Ġ* ĠThe Ġ` L 1 Translator ` Ġtrans l iter ates Ġa Ġsequence Ġof Ċ Ġ* Ġ[ level &# 3 2 ; one &# 3 2 ; instructions ][ L 1 Operation ] Ġinto Ġone Ġor Ġmore Ġsimple Ċ Ġ* Ġ[ level &# 3 2 ; two &# 3 2 ; instructions ][ L 2 Instruction ], Ġunder Ġthe Ġassumption Ġthat Ċ Ġ* Ġfurther Ġoptimization Ġsteps Ġwill Ġbe Ġable Ġto Ġtransform Ġthis Ġcode Ġinto Ġsomething Ċ Ġ* Ġmuch Ġmore Ġefficient ĠâĢĵ Ġwithout Ġalter ing Ġthe Ġlevel Ġone Ġsemantics . Ċ Ġ* Ċ Ġ* Ġ@ author ĠMark Ġvan ĠG ul ik Ġ& lt ; mark @ avail lang . org & gt ; Ċ Ġ* Ġ@ author ĠT odd ĠL ĠSmith Ġ& lt ; tod d @ avail lang . org & gt ; Ċ Ġ* Ċ Ġ* Ġ@ property Ġgenerator Ċ Ġ* ĠĠ ĠThe Ġ[ L 2 Generator ] Ġfor Ġwhich ĠI 'm Ġproducing Ġan Ġinitial Ġtranslation . Ċ Ġ* Ġ@ property Ġinterpreter Ċ Ġ* ĠĠ ĠThe Ġ[ Interpreter ] Ġthat Ġtri pped Ġthe Ġtranslation Ġrequest . Ċ Ġ* Ġ@ property Ġcode Ċ Ġ* ĠĠ ĠThe Ġ[ raw &# 3 2 ; function ][ Compiled Code Descriptor ] Ġto Ġtrans l iterate Ġinto Ġlevel Ġtwo Ċ Ġ* ĠĠ Ġcode . Ċ Ġ* Ġ@ constructor Ċ Ġ* ĠCreate Ġa Ġnew ĠL 1 Ġna ive Ġtranslator Ġfor Ġthe Ġgiven Ġ[ L 2 Generator ]. Ċ Ġ* Ċ Ġ* Ġ@ param Ġgenerator Ċ Ġ* ĠĠ ĠThe Ġ[ L 2 Generator ] Ġfor Ġwhich ĠI 'm Ġproducing Ġan Ġinitial Ġtranslation Ġfrom ĠL 1 . Ċ Ġ* Ġ@ param Ġinterpreter Ċ Ġ* ĠĠ ĠThe Ġ[ Interpreter ] Ġthat Ġtri pped Ġthe Ġtranslation Ġrequest . Ċ Ġ* Ġ@ param Ġcode Ċ Ġ* ĠĠ ĠThe Ġ[ A _ Raw Function ] Ġwhich Ġis Ġthe Ġsource Ġof Ġthe Ġchunk Ġbeing Ġcreated . Ċ Ġ*/ Ċ class ĠL 1 Translator Ġprivate Ġconstructor ( Ċ ĉ val Ġgenerator : ĠL 2 Generator , Ċ ĉ private Ġval Ġinterpreter : ĠInterpreter , Ċ ĉ val Ġcode : ĠA _ Raw Function Ċ ) Ġ: ĠL 1 Operation Dispatcher Ċ { Ċ ĉ /** Ċĉ Ġ* ĠThe Ġnumber Ġof Ġslots Ġin Ġthe Ġvirtual ized Ġcontinuation . Ġ ĠThis Ġincludes Ġthe Ċĉ Ġ* Ġarguments , Ġthe Ġlocals Ġ( including Ġthe Ġoptional Ġprimitive Ġfailure Ġresult ), Ċĉ Ġ* Ġand Ġthe Ġstack Ġslots . Ċĉ Ġ*/ Ċ ĉ private Ġval Ġnum Slots : ĠInt Ġ= Ġcode . num Slots ĊĊ ĉ /** Ċĉ Ġ* ĠAn Ġarray Ġof Ġnames Ġof Ġarguments , Ġif Ġavailable , Ġto Ġmake Ġit Ġeasier Ġto Ġfollow Ċĉ Ġ* Ġ[ L 2 Control Flow Graph ] s . Ċĉ Ġ*/ Ċ ĉ private Ġval Ġslot Names Ġ= Ċĉ ĉ code . declaration Names . map Ġ{ Ġit . as Native String () Ġ}. to Typed Array () ĊĊ ĉ /** Ċĉ Ġ* ĠAn Ġarray Ġof Ġnames Ġof Ġarguments , Ġif Ġavailable , Ġto Ġmake Ġit Ġeasier Ġto Ġfollow Ċĉ Ġ* Ġ[ L 2 Control Flow Graph ] s . Ċĉ Ġ* Ċĉ Ġ* ĠTODO : ĠExtend Ġdeclaration Names () Ġfor Ġout ers . Ċĉ Ġ*/ Ċ ĉ val Ġouter Names Ġ= ĠArray ( code . num Out ers ) Ġ{ Ġ" Outer # ${ it + 1 }" Ġ} ĊĊ ĉ /** Ċĉ Ġ* ĠThe Ġ[ L 2 Semantic Value ] s Ġcorresponding Ġwith Ġthe Ġslots Ġof Ġthe Ġvirtual Ċĉ Ġ* Ġcontinuation . Ġ ĠThese Ġindices Ġare Ġzero - based , Ġbut Ġthe Ġslot Ġnumber ing Ġis Ċĉ Ġ* Ġone - based . Ċĉ Ġ*/ Ċ ĉ private Ġval Ġsemantic Slots : ĠArray < L 2 Semantic Value > ĊĊ ĉ /** Ċĉ Ġ* ĠThe Ġcurrent Ġlevel Ġone Ġny bble code Ġposition Ġduring Ġna ive Ġtranslation Ġto Ċĉ Ġ* Ġlevel Ġtwo . Ċĉ Ġ*/ Ċ ĉ val Ġinstruction Decoder Ġ= ĠL 1 Instruction Decoder () ĊĊ ĉ /** Ċĉ Ġ* ĠThe Ġcurrent Ġstack Ġdepth Ġduring Ġna ive Ġtranslation Ġto Ġlevel Ġtwo . Ċĉ Ġ*/ Ċ ĉ var Ġstack p : ĠInt ĊĊ ĉ /** Ċĉ Ġ* ĠThe Ġexact Ġfunction Ġthat Ġwe 're Ġtrans lating , Ġif Ġknown . Ġ ĠThis Ġis Ġonly Ċĉ Ġ* Ġnon - null Ġif Ġthe Ġfunction Ġcaptures Ġno Ġout ers . Ċĉ Ġ*/ Ċ ĉ private Ġval Ġexact Function OrNull : ĠA _ Function ? ĊĊ ĉ /** Ċĉ Ġ* ĠReturn Ġthe Ġtop Ġ[ Frame ] Ġfor Ġcode Ġgeneration . Ċĉ Ġ* Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠThe Ġtop Ġ[ Frame ], Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġtop Frame (): ĠFrame Ġ= Ġgenerator . top Frame ĊĊ ĉ /** Ċĉ Ġ* ĠAnswer Ġthe Ġcurrent Ġ[ L 2 Value Manifest ], Ġwhich Ġtracks Ġwhich Ġ[ L 2 Syn onym ] s Ċĉ Ġ* Ġhold Ġwhich Ġ[ L 2 Semantic Value ] s Ġat Ġthe Ġcurrent Ġcode Ġgeneration Ġpoint . Ċĉ Ġ* Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠThe Ġcurrent Ġ[ L 2 Value Manifest ]. Ċĉ Ġ*/ Ċ ĉ fun Ġcurrent Manifest (): ĠL 2 Value Manifest Ġ= Ġgenerator . current Manifest ĊĊ ĉ /** Ċĉ Ġ* ĠGet Ġthe Ġprogram Ġcounter Ġfor Ġthe Ġnext Ġinstruction Ġto Ġbe Ġdecoded . Ċĉ Ġ*/ Ċ ĉ val Ġpc : ĠInt Ġget () Ġ= Ġinstruction Decoder . pc () ĊĊ ĉ /** Ċĉ Ġ* ĠAnswer Ġthe Ġ[ L 2 Semantic Value ] Ġrepresenting Ġthe Ġvirtual Ġcontinuation Ġslot Ċĉ Ġ* Ġhaving Ġthe Ġgiven Ġone - based Ġindex . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġindex Ċĉ Ġ* ĠĠ ĠThe Ġone - based Ġslot Ġnumber . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Semantic Value ] Ġfor Ġthat Ġslot . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġsemantic Slot ( index : ĠInt ): ĠL 2 Semantic Value Ġ= Ċĉ ĉ semantic Slots [ index Ġ- Ġ 1 ] ĊĊ ĉ /** Ċĉ Ġ* ĠAnswer Ġthe Ġregister Ġholding Ġthe Ġlatest Ġassigned Ġversion Ġof Ġthe Ġspecified Ċĉ Ġ* Ġcontinuation Ġslot . ĠThe Ġslots Ġare Ġthe Ġarguments , Ġthen Ġthe Ġlocals , Ġthen Ġthe Ċĉ Ġ* Ġstack Ġentries . ĠThe Ġslots Ġare Ġnumber ed Ġstarting Ġat Ġ 1 . Ċĉ Ġ* Ċĉ Ġ* ĠThis Ġis Ġonly Ġpublic Ġto Ġallow Ġprimitives Ġlike Ġ[ P _ Restart Continuation ] Ġto Ċĉ Ġ* Ġbe Ġable Ġto Ġfetch Ġthe Ġcurrent Ġarguments . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġslot Index Ċĉ Ġ* ĠĠ ĠThe Ġindex Ġinto Ġthe Ġcontinuation 's Ġslots . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠAn Ġ[ L 2 Read Boxed Operand ] Ġrepresenting Ġthat Ġcontinuation Ġslot . Ċĉ Ġ*/ Ċ ĉ fun Ġread Slot ( slot Index : ĠInt ): ĠL 2 Read Boxed Operand Ġ= Ċĉ ĉ generator . read Boxed ( semantic Slot ( slot Index )) ĊĊ ĉ /** Ċĉ Ġ* ĠCreate Ġa Ġnew Ġsemantic Ġvalue Ġto Ġoverwrite Ġany Ġexisting Ġvalue Ġin Ġthe Ċĉ Ġ* Ġspecified Ġcontinuation Ġslot . Ġ ĠAnswer Ġa Ġwrite Ġof Ġa Ġsyn onym Ġcontaining Ġjust Ċĉ Ġ* Ġthat Ġsemantic Ġvalue . Ċĉ Ġ* Ċĉ Ġ* ĠThe Ġslots Ġare Ġthe Ġarguments , Ġthe Ġlocal Ġvariables , Ġthe Ġlocal Ġconstants , Ċĉ Ġ* Ġand Ġfinally Ġthe Ġstack Ġentries . Ġ ĠS lots Ġare Ġnumber ed Ġstarting Ġat Ġ 1 . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġslot Index Ċĉ Ġ* ĠĠ ĠThe Ġindex Ġinto Ġthe Ġcontinuation 's Ġslots . Ċĉ Ġ* Ġ@ param Ġeffective Pc Ċĉ Ġ* ĠĠ ĠThe ĠLevel ĠOne Ġpc Ġat Ġwhich Ġthis Ġwrite Ġshould Ġbe Ġconsidered Ġeffective . Ċĉ Ġ* Ġ@ param Ġrestriction Ċĉ Ġ* ĠĠ ĠThe Ġbounding Ġ[ Type Restriction ] Ġfor Ġthe Ġnew Ġregister . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠA Ġregister Ġwrite Ġrepresenting Ġthat Ġcontinuation Ġslot . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġwrite Slot ( Ċĉ ĉ slot Index : ĠInt , Ċĉ ĉ effective Pc : ĠInt , Ċĉ ĉ restriction : ĠType Restriction ): ĠL 2 Write Boxed Operand Ċ ĉ { Ċĉ ĉ // ĠCreate Ġa Ġnew Ġsemantic Ġslot Ġat Ġthe Ġcurrent Ġpc , Ġrepresenting Ġthis Ċĉ ĉ // Ġnewly Ġwritten Ġvalue . Ċĉ ĉ val Ġsemantic Value Ġ= Ġcreate Semantic Slot ( slot Index , Ġeffective Pc ) Ċĉ ĉ semantic Slots [ slot Index Ġ- Ġ 1 ] Ġ= Ġsemantic Value Ċĉ ĉ return Ġgenerator . boxed Write ( semantic Value , Ġrestriction ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠAssoci ate Ġthe Ġspecified Ġ[ L 2 Read Boxed Operand ] Ġwith Ġthe Ġsemantic Ġslot Ċĉ Ġ* Ġhaving Ġthe Ġgiven Ġindex Ġand Ġeffective Ġpc . Ġ ĠRe strict Ġthe Ġtype Ġbased Ġon Ġthe Ċĉ Ġ* Ġregister - read 's Ġ[ Type Restriction ]. Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġslot Index Ċĉ Ġ* ĠĠ ĠThe Ġslot Ġindex Ġto Ġreplace . Ċĉ Ġ* Ġ@ param Ġeffective Pc Ċĉ Ġ* ĠĠ ĠThe Ġeffective Ġpc . Ċĉ Ġ* Ġ@ param Ġregister Read Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġthat Ġshould Ġnow Ġbe Ġconsidered Ġthe Ġcurrent Ċĉ Ġ* ĠĠ Ġregister - read Ġrepresenting Ġthat Ġslot . Ċĉ Ġ*/ Ċ ĉ fun Ġforce Slot Register ( Ċĉ ĉ slot Index : ĠInt , Ċĉ ĉ effective Pc : ĠInt , Ċĉ ĉ register Read : ĠL 2 Read Boxed Operand ) Ċ ĉ { Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ slot Index , Ċĉĉ ĉ effective Pc , Ċĉĉ ĉ register Read . semantic Value (), Ċĉĉ ĉ register Read . restriction ()) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠAssoci ate Ġthe Ġspecified Ġregister Ġwith Ġthe Ġslot Ġsemantic Ġvalue Ġhaving Ġthe Ċĉ Ġ* Ġgiven Ġindex Ġand Ġeffective Ġpc . Ġ ĠNote Ġthat Ġthe Ġgiven Ġsyn onym Ġis Ġalways Ċĉ Ġ* Ġinvalid ated Ġby Ġa Ġmerge Ġin Ġthis Ġmethod . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġslot Index Ċĉ Ġ* ĠĠ ĠThe Ġslot Ġindex Ġto Ġreplace . Ċĉ Ġ* Ġ@ param Ġeffective Pc Ċĉ Ġ* ĠĠ ĠThe Ġeffective Ġpc . Ċĉ Ġ* Ġ@ param Ġsource Semantic Value Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Semantic Value ] Ġthat Ġis Ġmoved Ġinto Ġthe Ġslot . Ċĉ Ġ* Ġ@ param Ġrestriction Ċĉ Ġ* ĠĠ ĠThe Ġ[ Type Restriction ] Ġthat Ġcurrently Ġbounds Ġthe Ġsyn onym 's Ġpossible Ċĉ Ġ* ĠĠ Ġvalues . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġforce Slot Register ( Ċĉ ĉ slot Index : ĠInt , Ċĉ ĉ effective Pc : ĠInt , Ċĉ ĉ source Semantic Value : ĠL 2 Semantic Value , Ċĉ ĉ restriction : ĠType Restriction ) Ċ ĉ { Ċĉ ĉ // ĠCreate Ġa Ġnew ĠL 2 Semantic Slot Ġat Ġthe Ġeffective Ġpc , Ġrepresenting Ġthis Ċĉ ĉ // Ġnewly Ġwritten Ġvalue . Ċĉ ĉ val Ġslot Semantic Value Ġ= Ġcreate Semantic Slot ( slot Index , Ġeffective Pc ) Ċĉ ĉ semantic Slots [ slot Index Ġ- Ġ 1 ] Ġ= Ġslot Semantic Value Ċĉ ĉ generator . move Register ( Ċĉĉ ĉ L 2 _ MOVE . boxed , Ċĉĉ ĉ source Semantic Value , Ċĉĉ ĉ slot Semantic Value ) Ċĉ ĉ current Manifest (). set Restriction ( slot Semantic Value , Ġrestriction ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠWrite Ġnil Ġinto Ġa Ġnew Ġregister Ġrepresenting Ġthe Ġspecified Ġcontinuation Ċĉ Ġ* Ġslot . Ġ ĠThe Ġslots Ġare Ġthe Ġarguments , Ġthen Ġthe Ġlocals , Ġthen Ġthe Ġstack Ċĉ Ġ* Ġentries . Ġ ĠThe Ġslots Ġare Ġnumber ed Ġstarting Ġat Ġ 1 . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġslot Index Ċĉ Ġ* ĠĠ ĠThe Ġone - based Ġindex Ġinto Ġthe Ġvirtual Ġcontinuation 's Ġslots . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġnil Slot ( slot Index : ĠInt ) Ċ ĉ { Ċĉ ĉ move Constant To Slot ( nil , Ġslot Index ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGiven Ġan Ġ[ L 2 Write Boxed Operand ], Ġproduce Ġan Ġ[ L 2 Read Boxed Operand ] Ġof Ġthe Ċĉ Ġ* Ġsame Ġvalue , Ġbut Ġwith Ġthe Ġcurrent Ġmanifest 's Ġ[ Type Restriction ] Ġapplied . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġwrite Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Write Boxed Operand ] Ġfor Ġwhich Ġto Ġgenerate Ġa Ġread . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġthat Ġreads Ġthe Ġvalue . Ċĉ Ġ*/ Ċ ĉ fun Ġread Boxed ( write : ĠL 2 Write Boxed Operand ): ĠL 2 Read Boxed Operand Ġ= Ċĉ ĉ generator . read Boxed ( write ) ĊĊ ĉ /** Ċĉ Ġ* ĠWrite Ġinstructions Ġto Ġextract Ġthe Ġcurrent Ġfunction , Ġand Ġanswer Ġan Ċĉ Ġ* Ġ[ L 2 Read Boxed Operand ] Ġfor Ġthe Ġregister Ġthat Ġwill Ġhold Ġthe Ġfunction Ċĉ Ġ* Ġafter ward . Ċĉ Ġ*/ Ċ ĉ private Ġval Ġcurrent Function : ĠL 2 Read Boxed Operand Ċĉ ĉ get () Ċĉ ĉ { Ċĉĉ ĉ val Ġsemantic Function Ġ= Ġtop Frame (). function () Ċĉĉ ĉ if Ġ( current Manifest (). has Semantic Value ( semantic Function )) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠNote Ġthe Ġcurrent Ġfunction Ġcan 't Ġever Ġbe Ġan Ġint Ġor Ġfloat . Ċĉĉĉ ĉ return Ġgenerator . read Boxed ( semantic Function ) Ċĉĉ ĉ } Ċĉĉ ĉ // ĠWe Ġhave Ġto Ġget Ġit Ġinto Ġa Ġregister . Ċĉĉ ĉ if Ġ( exact Function OrNull Ġ!== Ġnull ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠThe Ġexact Ġfunction Ġis Ġknown . Ċĉĉĉ ĉ return Ġgenerator . boxed Constant ( exact Function OrNull ) Ċĉĉ ĉ } Ċĉĉ ĉ // ĠThe Ġexact Ġfunction Ġisn 't Ġknown , Ġbut Ġwe Ġknow Ġthe Ġraw Ġfunction , Ġso Ċĉĉ ĉ // Ġwe Ġstatic ally Ġknow Ġthe Ġfunction Ġtype . Ċĉĉ ĉ val Ġrestriction Ġ= Ċĉĉĉ ĉ restriction ForType ( code . function Type (), ĠBO X ED _ FLAG ) Ċĉĉ ĉ val Ġfunction Write Ġ= Ċĉĉĉ ĉ generator . boxed Write ( semantic Function , Ġrestriction ) Ċĉĉ ĉ add Instruction ( L 2 _ GET _ CURRENT _ FUNCTION , Ġfunction Write ) Ċĉĉ ĉ return Ġread Boxed ( function Write ) Ċĉ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠWrite Ġinstructions Ġto Ġextract Ġa Ġnumber ed Ġouter Ġfrom Ġthe Ġcurrent Ġfunction , Ċĉ Ġ* Ġand Ġanswer Ġan Ġ[ L 2 Read Boxed Operand ] Ġfor Ġthe Ġregister Ġthat Ġwill Ġhold Ġthe Ċĉ Ġ* Ġouter Ġvalue Ġafter ward . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġouter Index Ċĉ Ġ* ĠĠ ĠThe Ġindex Ġof Ġthe Ġouter Ġto Ġget . Ċĉ Ġ* Ġ@ param Ġouter Type Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġthat Ġthe Ġouter Ġis Ġknown Ġto Ġbe . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġwhere Ġthe Ġouter Ġwas Ġwritten . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġget Outer Register ( Ċĉ ĉ outer Index : ĠInt , Ċĉ ĉ outer Type : ĠA _ Type ): ĠL 2 Read Boxed Operand Ċ ĉ { Ċĉ ĉ // TODO Ġcapture Ġnames Ġof Ġout ers , Ġthen Ġuse : Ġouter Names [ outer Index Ġ- Ġ 1 ] Ċĉ ĉ val Ġsemantic Outer Ġ= Ġtop Frame (). outer ( outer Index , Ġnull ) Ċĉ ĉ if Ġ( current Manifest (). has Semantic Value ( semantic Outer )) Ċĉ ĉ { Ċĉĉ ĉ return Ġgenerator . read Boxed ( semantic Outer ) Ċĉ ĉ } Ċĉ ĉ if Ġ( outer Type . instance Count . equals Int ( 1 ) Ċĉĉ ĉ && Ġ! outer Type . is Instance Meta ) Ċĉ ĉ { Ċĉĉ ĉ // ĠThe Ġexact Ġouter Ġis Ġknown Ġstatic ally . Ċĉĉ ĉ return Ġgenerator . boxed Constant ( outer Type . instance ) Ċĉ ĉ } Ċĉ ĉ val Ġfunction Read Ġ= Ġcurrent Function Ċĉ ĉ val Ġrestriction Ġ= Ġrestriction ForType ( outer Type , ĠBO X ED _ FLAG ) Ċĉ ĉ val Ġouter Write Ġ= Ġgenerator . boxed Write ( semantic Outer , Ġrestriction ) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ MOVE _ OUT ER _ VARIABLE , Ċĉĉ ĉ L 2 Int Immediate Operand ( outer Index ), Ċĉĉ ĉ function Read , Ċĉĉ ĉ outer Write ) Ċĉ ĉ return Ġread Boxed ( outer Write ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠCapture Ġthe Ġlatest Ġvalue Ġreturned Ġby Ġthe Ġ[ L 2 _ RETURN ] Ġinstruction Ġin Ċĉ Ġ* Ġthis Ġ[ Interpreter ]. Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġguaranteed Type Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġthe Ġreturn Ġvalue Ġis Ġguaranteed Ġto Ġconform Ġto . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠAn Ġ[ L 2 Read Boxed Operand ] Ġthat Ġnow Ġholds Ġthe Ġreturned Ġvalue . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġget Latest ReturnValue ( gu arante ed Type : ĠA _ Type ): ĠL 2 Read Boxed Operand Ċ ĉ { Ċĉ ĉ val Ġwriter Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( gu arante ed Type , ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( L 2 _ GET _ LATE ST _ RETURN _ VALUE , Ġwriter ) Ċĉ ĉ return Ġread Boxed ( writer ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠCreate Ġand Ġadd Ġan Ġ[ L 2 Instruction ] Ġwith Ġthe Ġgiven Ġ[ L 2 Operation ] Ġand Ċĉ Ġ* Ġvariable Ġnumber Ġof Ġ[ L 2 Operand ] s . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġoperation Ċĉ Ġ* ĠĠ ĠThe Ġoperation Ġto Ġinvoke . Ċĉ Ġ* Ġ@ param Ġoperands Ċĉ Ġ* ĠĠ ĠThe Ġoperands Ġof Ġthe Ġinstruction . Ċĉ Ġ*/ Ċ ĉ fun Ġadd Instruction ( operation : ĠL 2 Operation , Ġvar arg Ġoperands : ĠL 2 Operand ) Ċ ĉ { Ċĉ ĉ generator . add Instruction ( operation , Ġ* operands ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠAdd Ġan Ġ[ L 2 Instruction ]. Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġinstruction Ċĉ Ġ* ĠĠ ĠThe Ġinstruction Ġto Ġadd . Ċĉ Ġ*/ Ċ ĉ fun Ġadd Instruction ( instruction : ĠL 2 Instruction ) Ċ ĉ { Ċĉ ĉ generator . add Instruction ( instruction ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġinstruction ( s ) Ġto Ġmove Ġthe Ġgiven Ġ[ Avail Object ] Ġinto Ġa Ġfresh Ċĉ Ġ* Ġwritable Ġslot Ġ[ L 2 Register ] Ġwith Ġthe Ġgiven Ġslot Ġindex . Ġ ĠThe Ġslot Ġit Ċĉ Ġ* Ġoccup ies Ġis Ġtagged Ġwith Ġthe Ġcurrent Ġpc . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġvalue Ċĉ Ġ* ĠĠ ĠThe Ġvalue Ġto Ġmove . Ċĉ Ġ* Ġ@ param Ġslot Index Ċĉ Ġ* ĠĠ ĠThe Ġindex Ġof Ġthe Ġslot Ġin Ġwhich Ġto Ġwrite Ġit . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġmove Constant To Slot ( value : ĠA _ Basic Object , Ġslot Index : ĠInt ) Ċ ĉ { Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ slot Index , Ġpc , Ġgenerator . boxed Constant ( value )) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġcode Ġto Ġcreate Ġthe Ġcurrent Ġcontinuation , Ġwith Ġa Ġnil Ġcaller , Ġthen Ċĉ Ġ* Ġ[ L 2 _ RETURN _ FROM _ RE IFICATION _ HANDLER ] ĠâĢĵ Ġso Ġthe Ġcalling Ġframes Ġwill Ġalso Ċĉ Ġ* Ġget Ġa Ġchance Ġto Ġadd Ġtheir Ġown Ġnil - caller Ġcontinu ations Ġto Ġthe Ġcurrent Ċĉ Ġ* Ġ[ Stack Re ifier ]. Ġ ĠThe Ġexecution Ġm achinery Ġwill Ġthen Ġassemble Ġthe Ġchain Ġof Ċĉ Ġ* Ġcontinu ations , Ġconnecting Ġthem Ġto Ġany Ġalready Ġre ified Ġcontinu ations Ġin Ċĉ Ġ* Ġthe Ġinterpreter . Ċĉ Ġ* Ċĉ Ġ* ĠAfter Ġre ification , Ġthe Ġinterpreter 's Ġnext Ġactivity Ġdepends Ġon Ġthe Ġflags Ċĉ Ġ* Ġset Ġin Ġthe Ġ[ Stack Re ifier ] Ġ( which Ġwas Ġcreated Ġvia Ġcode Ġgenerated Ġprior Ġto Ċĉ Ġ* Ġthis Ġclause ). Ġ ĠIf Ġit Ġwas Ġfor Ġinterrupt Ġprocessing , Ġthe Ġcontinuation Ġwill Ċĉ Ġ* Ġbe Ġstored Ġin Ġthe Ġfiber Ġwhile Ġan Ġinterrupt Ġis Ġprocessed , Ġthen Ġmost Ġlikely Ċĉ Ġ* Ġres umed Ġat Ġa Ġlater Ġtime . Ġ ĠIf Ġit Ġwas Ġfor Ġgetting Ġinto Ġa Ġstate Ġsuitable Ġfor Ċĉ Ġ* Ġcreating Ġan ĠL 1 Ġlabel , Ġthe Ġtop Ġcontinuation 's Ġchunk Ġis Ġres umed Ċĉ Ġ* Ġimmediately , Ġwhere upon Ġthe Ġcontinuation Ġwill Ġbe Ġpop ped Ġand Ġexplo ded Ġback Ċĉ Ġ* Ġinto Ġregisters , Ġand Ġthe Ġactual Ġlabel Ġwill Ġbe Ġcreated Ġfrom Ġthe Ċĉ Ġ* Ġcontinuation Ġthat Ġwas Ġjust Ġres umed . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġexpected Value OrNull Ċĉ Ġ* ĠĠ ĠA Ġconstant Ġtype Ġto Ġreplace Ġthe Ġtop - of - stack Ġin Ġthe Ġre ified Ċĉ Ġ* ĠĠ Ġcontinuation . Ġ ĠIf Ġ` null `, Ġdon 't Ġreplace Ġthe Ġtop - of - stack . Ċĉ Ġ* Ġ@ param ĠtypeOf EntryPoint Ċĉ Ġ* ĠĠ ĠThe Ġkind Ġof Ġ[ Chunk EntryPoint ] Ġto Ġre - enter Ġat . Ċĉ Ġ*/ Ċ ĉ @ Suppress (" UN CHECK ED _ CAST ") Ċ ĉ fun Ġre ify ( expected Value OrNull : ĠA _ Type ?, ĠtypeOf EntryPoint : ĠChunk EntryPoint ) Ċ ĉ { Ċĉ ĉ // ĠUse Ġthe Ġcurrent Ġblock 's Ġzone Ġfor Ġsubsequent Ġnodes Ġthat Ġare Ġinside Ċĉ ĉ // Ġthis Ġre ification Ġhandler . Ċĉ ĉ val Ġzone Ġ= Ġgenerator . current Block (). zone Ċĉ ĉ val Ġnew Continuation Write Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( most General Continuation Type (), ĠBO X ED _ FLAG )) Ċĉ ĉ val Ġon Return Into Re ified Ġ= Ċĉĉ ĉ generator . create BasicBlock (" Return Ġinto Ġre ified Ġcontinuation ") ĊĊĉ ĉ // ĠCreate Ġread Slots Ġfor Ġconstructing Ġthe Ġcontinuation . Ġ ĠAlso Ġcreate Ċĉ ĉ // Ġwrite Semantic Values Ġand Ġwrite Restrictions Ġfor Ġrest oring Ġthe Ġstate Ċĉ ĉ // Ġfrom Ġthe Ġcontinuation Ġwhen Ġit 's Ġres umed . Ċĉ ĉ val Ġread Slots Before Ġ= ĠarrayOf Null s < L 2 Read Boxed Operand >( num Slots ) Ċĉ ĉ val Ġwrite Semantic Values Ġ= ĠarrayOf Null s < L 2 Semantic Value >( num Slots ) Ċĉ ĉ val Ġwrite Restrictions Ġ= ĠarrayOf Null s < Type Restriction >( num Slots ) Ċĉ ĉ for Ġ( i Ġin Ġ 0 Ġuntil Ġnum Slots ) Ċĉ ĉ { Ċĉĉ ĉ val Ġsemantic Value Ġ= Ġsemantic Slot ( i Ġ+ Ġ 1 ) Ċĉĉ ĉ val Ġread : ĠL 2 Read Boxed Operand Ġ= Ċĉĉ ĉ if Ġ( i Ġ+ Ġ 1 Ġ== Ġstack p Ġ&& Ġexpected Value OrNull Ġ!== Ġnull ) Ċĉĉ ĉ { Ċĉĉĉ ĉ generator . boxed Constant ( expected Value OrNull ) Ċĉĉ ĉ } Ċĉĉ ĉ else Ċĉĉ ĉ { Ċĉĉĉ ĉ generator . read Boxed ( semantic Value ). apply Ġ{ Ċĉĉĉĉ ĉ val Ġrestriction Ġ= Ġrestriction () Ċĉĉĉĉ ĉ assert ( restriction . is Boxed ) Ċĉĉĉĉ ĉ write Semantic Values [ i ] Ġ= Ġsemantic Value Ċĉĉĉĉ ĉ // ĠOnly Ġrestore Ġthe Ġbox ed Ġform Ġon Ġre entry , Ġbut Ġpreserve Ġany Ċĉĉĉĉ ĉ // Ġguarantee Ġof Ġim mut ability . Ċĉĉĉĉ ĉ write Restrictions [ i ] Ġ= Ġrestriction Ċĉĉĉĉĉ ĉ . without Flag ( UN BOX ED _ INT _ FLAG ) Ċĉĉĉĉĉ ĉ . without Flag ( UN BOX ED _ FLOAT _ FLAG ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ read Slots Before [ i ] Ġ= Ġread Ċĉ ĉ } Ċĉ ĉ read Slots Before Ġas ĠArray < L 2 Read Boxed Operand > Ċĉ ĉ write Semantic Values Ġas ĠArray < L 2 Semantic Value > Ċĉ ĉ write Restrictions Ġas ĠArray < Type Restriction > Ċĉ ĉ // ĠNow Ġgenerate Ġthe Ġre ification Ġinstructions , Ġensuring Ġthat Ġwhen Ċĉ ĉ // Ġreturning Ġinto Ġthe Ġresulting Ġcontinuation Ġit Ġwill Ġenter Ġa Ġblock Ġwhere Ċĉ ĉ // Ġthe Ġslot Ġregisters Ġare Ġthe Ġnew Ġones Ġwe Ġjust Ġcreated . Ċĉ ĉ val Ġwrite Offset Ġ= Ġgenerator . int Write Temp ( Ċĉĉ ĉ restriction ForType ( int 3 2 , ĠUN BOX ED _ INT _ FLAG )) Ċĉ ĉ val Ġwrite Register Dump Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( Types . ANY . o , ĠBO X ED _ FLAG )) Ċĉ ĉ val Ġfall Through Ġ= Ġgenerator . create BasicBlock (" Off - ramp ", Ġzone ) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ SAVE _ ALL _ AND _ PC _ TO _ INT , Ċĉĉ ĉ edge To ( on Return Into Re ified ), Ċĉĉ ĉ write Offset , Ċĉĉ ĉ write Register Dump , Ċĉĉ ĉ edge To ( fall Through )) Ċĉ ĉ generator . start Block ( fall Through ) Ċĉ ĉ // ĠWe 're Ġin Ġa Ġre ification Ġhandler Ġhere , Ġso Ġthe Ġcaller Ġis Ġguaranteed Ġto Ċĉ ĉ // Ġcontain Ġthe Ġre ified Ġcaller . Ċĉ ĉ val Ġwrite Re ified Caller Ġ= Ġgenerator . boxed Write ( Ċĉĉ ĉ top Frame (). re ified Caller (), Ċĉĉ ĉ restriction ForType ( most General Continuation Type (), ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ GET _ CURRENT _ CONT IN UATION , Ċĉĉ ĉ write Re ified Caller ) Ċĉ ĉ val Ġunreachable Ġ= ĠL 2 BasicBlock (" unreachable ") Ċĉ ĉ if Ġ( type Of EntryPoint Ġ=== ĠChunk EntryPoint . TRAN SI ENT ) Ċĉ ĉ { Ċĉĉ ĉ // ĠL 1 Ġcan Ġnever Ġsee Ġthis Ġcontinuation , Ġso Ġit Ġcan Ġbe Ġminimal . Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ CREATE _ CONT IN UATION , Ċĉĉĉ ĉ current Function , Ċĉĉĉ ĉ generator . read Boxed ( write Re ified Caller ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( Int . MAX _ VALUE ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( Int . MAX _ VALUE ), Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( emptyList ()), Ċĉĉĉ ĉ new Continuation Write , Ċĉĉĉ ĉ generator . readInt ( write Offset . only Semantic Value (), Ġunreachable ), Ċĉĉĉ ĉ generator . read Boxed ( write Register Dump ), Ċĉĉĉ ĉ L 2 Comment Operand ( Ċĉĉĉĉ ĉ " Create Ġa Ġdummy Ġre ification Ġcontinuation .")) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ // ĠMake Ġan ĠL 1 - complete Ġcontinuation , Ġsince Ġan Ġinvalid ation Ġcan Ġcause Ċĉĉ ĉ // Ġit Ġto Ġresume Ġin Ġthe ĠL 2 Chunk # un optimized Chunk , Ġwhich Ġcan Ġonly Ġsee Ċĉĉ ĉ // ĠL 1 Ġcontent . Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ CREATE _ CONT IN UATION , Ċĉĉĉ ĉ current Function , Ċĉĉĉ ĉ read Boxed ( write Re ified Caller ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( pc ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( stack p ), Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( read Slots Before . toList ()), Ċĉĉĉ ĉ new Continuation Write , Ċĉĉĉ ĉ generator . readInt ( write Offset . only Semantic Value (), Ġunreachable ), Ċĉĉĉ ĉ generator . read Boxed ( write Register Dump ), Ċĉĉĉ ĉ L 2 Comment Operand (" Create Ġa Ġre ification Ġcontinuation .")) Ċĉ ĉ } Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ SET _ CONT IN UATION , Ċĉĉ ĉ generator . read Boxed ( new Continuation Write )) ĊĊĉ ĉ // ĠRight Ġafter Ġcreating Ġthe Ġcontinuation . Ċĉ ĉ add Instruction ( L 2 _ RETURN _ FROM _ RE IFICATION _ HANDLER ) ĊĊĉ ĉ generator . start Block ( unreachable ) Ċĉ ĉ generator . add Instruction ( L 2 _ UN RE ACH ABLE _ CODE ) ĊĊĉ ĉ // ĠHere Ġit 's Ġreturning Ġinto Ġthe Ġre ified Ġcontinuation . Ċĉ ĉ generator . start Block ( on Return Into Re ified ) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ ENTER _ L 2 _ CHUNK , Ċĉĉ ĉ L 2 Int Immediate Operand ( type Of EntryPoint . offset In Default Chunk ), Ċĉĉ ĉ L 2 Comment Operand ( Ċĉĉĉ ĉ " If Ġinvalid , Ġre enter ĠÂ« default Â» Ġat Ġ${ type Of EntryPoint . name }. ")) Ċĉ ĉ if Ġ( expected Value OrNull Ġ!== Ġnull Ġ&& Ġexpected Value OrNull . is Vac u ous Type ) Ċĉ ĉ { Ċĉĉ ĉ generator . add Un reachable Code () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠA Ġme ment o Ġto Ġbe Ġused Ġfor Ġcoord in ating Ġcode Ġgeneration Ġbetween Ġthe Ċĉ Ġ* Ġbranches Ġof Ġan Ġ[ Internal Lookup Tree ]. Ċĉ Ġ* Ċĉ Ġ* Ġ@ property Ġargument Index To Test Ċĉ Ġ* ĠĠ ĠThe Ġone - based Ġindex Ġof Ġthe Ġargument Ġbeing Ġtested . Ċĉ Ġ* Ġ@ property Ġtype To Test Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Type ] Ġthat Ġshould Ġbe Ġsubtract ed Ġfrom Ġargument 's Ġpossible Ġtype Ċĉ Ġ* ĠĠ Ġalong Ġthe Ġpath Ġwhere Ġthe Ġtype Ġtest Ġfails . Ċĉ Ġ* Ċĉ Ġ* Ġ@ constructor Ċĉ Ġ* ĠConstruct Ġa Ġnew Ġme ment o . Ġ ĠMake Ġthe Ġlabel Ġsomething Ġmeaningful Ġto Ċĉ Ġ* Ġmake Ġit Ġeasier Ġto Ġdec ipher . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġargument Index To Test Ċĉ Ġ* ĠĠ ĠThe Ġone - based Ġsub script Ġof Ġthe Ġargument Ġbeing Ġtested . Ċĉ Ġ* Ġ@ param Ġtype To Test Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġto Ġtest Ġthe Ġargument Ġagainst . Ċĉ Ġ* Ġ@ param Ġbranch Label Counter Ċĉ Ġ* ĠĠ ĠAn Ġint Ġunique Ġto Ġthis Ġdispatch Ġtree , Ġmon oton ically Ġallocated Ġat Ġeach Ċĉ Ġ* ĠĠ Ġbranch . Ċĉ Ġ*/ Ċ ĉ inner Ġclass ĠInternal Node Mem ento Ġconstructor ( Ċĉ ĉ private Ġval Ġargument Index To Test : ĠInt , Ċĉ ĉ private Ġval Ġtype To Test : ĠA _ Type , Ċĉ ĉ branch Label Counter : ĠInt ) Ċ ĉ { Ċĉ ĉ private Ġval Ġshort TypeName Ġ= Ċĉĉ ĉ "$ branch Label Counter Ġ( arg #$ argument Index To Test Ġis Ġ" Ġ+ Ċĉĉĉ ĉ type To Test . tra versed (). descriptor (). type Tag . name Ċĉĉĉĉ ĉ . replace ("_ TAG ", Ġ"") Ġ+ Ġ")" ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġif Ġthe Ġ[ Internal Lookup Tree ]' s Ġtype Ġtest Ġis Ġtrue . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġpass Check BasicBlock Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " pass Ġlookup Ġtest Ġ#$ short TypeName ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġif Ġthe Ġ[ Internal Lookup Tree ]' s Ġtype Ġtest Ġis Ġfalse . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġfail Check BasicBlock Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " fail Ġlookup Ġtest Ġ#$ short TypeName ") Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠA Ġhelper Ġthat Ġaggreg ates Ġparameters Ġfor Ġpol ymorphic Ġdispatch Ġin lining . Ċĉ Ġ* Ċĉ Ġ* Ġ@ property Ġbundle Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Bundle ] Ġbeing Ġdis patched Ċĉ Ġ* Ġ@ property Ġsuper Union Type Ċĉ Ġ* ĠĠ ĠBottom Ġin Ġthe Ġnormal Ġcase , Ġbut Ġfor Ġa Ġsuper - call Ġthis Ġis Ġa Ġtuple Ġtype Ċĉ Ġ* ĠĠ Ġwith Ġthe Ġsame Ġsize Ġas Ġthe Ġnumber Ġof Ġarguments . Ġ ĠFor Ġthe Ġpurpose Ġof Ċĉ Ġ* ĠĠ Ġlooking Ġup Ġthe Ġappropriate Ġ[ A _ Definition ], Ġthe Ġtype Ġunion Ġof Ġeach Ċĉ Ġ* ĠĠ Ġargument 's Ġdynamic Ġtype Ġand Ġthe Ġcorresponding Ġentry Ġtype Ġfrom Ġthis Ċĉ Ġ* ĠĠ Ġfield Ġis Ġcomputed , Ġand Ġthat 's Ġused Ġfor Ġthe Ġlookup . Ċĉ Ġ* Ġ@ property Ġexpected Type Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġexpected Ġto Ġbe Ġreturned Ġby Ġinvoking Ġthe Ġfunction . Ġ ĠThis Ġmay Ċĉ Ġ* ĠĠ Ġbe Ġstrong er Ġthan Ġthe Ġtype Ġguaranteed Ġby Ġthe ĠVM , Ġwhich Ġrequires Ġa Ċĉ Ġ* ĠĠ Ġruntime Ġcheck . Ċĉ Ġ* Ċĉ Ġ* Ġ@ constructor Ċĉ Ġ* ĠCreate Ġthe Ġhelper , Ġconstructing Ġbasic Ġblocks Ġthat Ġmay Ġor Ġmay Ġnot Ġbe Ċĉ Ġ* Ġultimately Ġgenerated , Ġdepending Ġon Ġwhether Ġthey 're Ġreachable . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġbundle Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Bundle ] Ġbeing Ġinvoked . Ċĉ Ġ* Ġ@ param Ġsuper Union Type Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġwhose Ġunion Ġwith Ġthe Ġarguments Ġtuple Ġtype Ġis Ġused Ġfor Ġlookup . Ċĉ Ġ* ĠĠ ĠThis Ġis ĠâĬ ¥ Ġfor Ġordinary Ġcalls , Ġand Ġother Ġtypes Ġfor Ġsuper Ġcalls . Ċĉ Ġ* Ġ@ param Ġexpected Type Ċĉ Ġ* ĠĠ ĠThe Ġexpected Ġresult Ġtype Ġthat Ġhas Ġbeen Ġst reng then ed Ġby Ċĉ Ġ* ĠĠ Ġ[ A _ Semantic Restriction ] s Ġat Ġthis Ġcall Ġsite . Ġ ĠThe ĠVM Ġdoes Ġnot Ġalways Ċĉ Ġ* ĠĠ Ġguarantee Ġthis Ġtype Ġwill Ġbe Ġreturned , Ġbut Ġit Ġinserts Ġruntime Ġchecks Ġin Ċĉ Ġ* ĠĠ Ġthe Ġcase Ġthat Ġit Ġcan 't Ġprove Ġit . Ċĉ Ġ*/ Ċ ĉ inner Ġclass ĠCall Site Helper Ġinternal Ġconstructor ( Ċĉ ĉ val Ġbundle : ĠA _ Bundle , Ċĉ ĉ val Ġsuper Union Type : ĠA _ Type , Ċĉ ĉ val Ġexpected Type : ĠA _ Type ) Ċ ĉ { Ċĉ ĉ /** ĠA ĠJava Ġ[ String ] Ġnaming Ġthe Ġ[ A _ Bundle ]. Ġ*/ Ċĉ ĉ val Ġquoted Bundle Name Ġ= Ġbundle . message . atom Name . as Native String () ĊĊĉ ĉ /** ĠA Ġcounter Ġfor Ġgenerating Ġunique Ġbranch Ġnames Ġfor Ġthis Ġdispatch . Ġ*/ Ċĉ ĉ var Ġbranch Label Counter Ġ= Ġ 1 ĊĊĉ ĉ /** ĠWhether Ġthis Ġcall Ġsite Ġis Ġa Ġsuper Ġlookup . Ġ*/ Ċĉ ĉ val Ġis Super Ġ= Ġ! super Union Type . is Bottom ĊĊĉ ĉ /** ĠWhere Ġto Ġjump Ġto Ġperform Ġthe Ġslow Ġlookup . Ġ*/ Ċĉ ĉ val Ġon Fall Back ToS low Lookup Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " fall Ġback Ġto Ġslow Ġlookup Ġduring Ġ$ quoted Bundle Name ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġto Ġperform Ġre ification , Ġeventually Ġleading Ġto Ġa Ġreturn Ċĉĉ Ġ* Ġtype Ġcheck Ġafter Ġcompletion . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġon Re ification With Check Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " re ify Ġwith Ġcheck Ġduring Ġ$ quoted Bundle Name ", Ċĉĉ ĉ Zone Type . PROP AG ATE _ RE IFICATION _ FOR _ IN VOKE . create Zone ( Ċĉĉĉ ĉ " Continue Ġre ification Ġleading Ġto Ġreturn Ġcheck ")) ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġto Ġperform Ġre ification Ġwithout Ġthe Ġneed Ġfor Ġan Ġevent ual Ċĉĉ Ġ* Ġreturn Ġtype Ġcheck . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġon Re ification No Check Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " re ify Ġno Ġcheck Ġduring Ġ$ quoted Bundle Name ", Ċĉĉ ĉ Zone Type . PROP AG ATE _ RE IFICATION _ FOR _ IN VOKE . create Zone ( Ċĉĉĉ ĉ " Continue Ġre ification Ġwithout Ġreturn Ġcheck ")) ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġto Ġperform Ġre ification Ġduring Ġa Ġcall Ġthat Ġcannot Ġever Ċĉĉ Ġ* Ġreturn . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġon Re ification Un return able Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " re ify Ġun return able Ġ$ quoted Bundle Name ", Ċĉĉ ĉ Zone Type . PROP AG ATE _ RE IFICATION _ FOR _ IN VOKE . create Zone ( Ċĉĉĉ ĉ " Continue Ġre ification Ġfor Ġun return able ")) ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġafter Ġa Ġcompleted Ġcall Ġto Ġperform Ġa Ġreturn Ġtype Ġcheck . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġafter Call With Check Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ if Ġ( is Super ) Ġ" after Ġsuper Ġcall Ġwith Ġcheck Ġof Ġ$ quoted Bundle Name " Ċĉĉ ĉ else Ġ" after Ġcall Ġwith Ġcheck Ġof Ġ$ quoted Bundle Name ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġto Ġjump Ġafter Ġa Ġcompleted Ġcall Ġif Ġa Ġreturn Ġtype Ġcheck Ġisn 't Ċĉĉ Ġ* Ġneeded . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġafter Call No Check Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ if Ġ( is Super ) Ġ" after Ġsuper Ġno - check Ġcall Ġof Ġ$ quoted Bundle Name " Ċĉĉ ĉ else Ġ" after Ġcall Ġno - check Ġof Ġ$ quoted Bundle Name ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠWhere Ġit Ġends Ġup Ġafter Ġthe Ġentire Ġcall , Ġregardless Ġof Ġwhether Ġthe Ċĉĉ Ġ* Ġreturned Ġvalue Ġhad Ġto Ġbe Ġchecked Ġor Ġnot . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġafter Everything Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ if Ġ( is Super ) Ġ" after Ġentire Ġsuper Ġcall Ġof Ġ$ quoted Bundle Name " Ċĉĉ ĉ else Ġ" after Ġentire Ġcall Ġof Ġ$ quoted Bundle Name ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠA Ġmap Ġfrom Ġeach Ġreachable Ġlooked - up Ġ[ A _ Function ] Ġto Ġa Ġ[ Pair ] Ċĉĉ Ġ* Ġcontaining Ġan Ġ[ L 2 BasicBlock ] Ġin Ġwhich Ġcode Ġgeneration Ġfor Ġinvocation Ċĉĉ Ġ* Ġof Ġthis Ġfunction Ġshould / did Ġtake Ġplace , Ġand Ġa Ġlambda Ġwhich Ċĉĉ Ġ* Ġwill Ġcause Ġthat Ġcode Ġgeneration Ġto Ġhappen . Ċĉĉ Ġ* Ċĉĉ Ġ* ĠThis Ġconstruct Ġtheoret ically Ġdeals Ġwith Ġmethod Ġlook ups Ġthat Ġlead Ċĉĉ Ġ* Ġto Ġthe Ġsame Ġfunction Ġmultiple Ġways Ġ( it 's Ġun clear Ġif Ġthe Ġlookup Ġtree Ċĉĉ Ġ* Ġmechanism Ġwill Ġever Ġev olve Ġto Ġproduce Ġthis Ġsituation ), Ġbut Ġmore Ċĉĉ Ġ* Ġpract ically , Ġit Ġcan Ġde - duplicate Ġa Ġsuccessful Ġin lined Ġlookup Ġand Ġthe Ċĉĉ Ġ* Ġsuccess Ġpath Ġof Ġthe Ġfall - back Ġslow Ġlookup Ġ* when Ġit Ġknows Ġthere Ġis Ċĉĉ Ġ* Ġonly Ġone Ġparticular Ġdefinition Ġthat Ġa Ġsuccessful Ġslow Ġlookup Ġcould Ċĉĉ Ġ* Ġproduce .* Ċĉĉ Ġ*/ Ċĉ ĉ val Ġinvocation Sites To Create Ġ= Ċĉĉ ĉ mutable Map Of < A _ Function , ĠPair < L 2 BasicBlock , Ġ() -> Unit >>() ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠAnswer Ġthe Ġ[ L 1 Translator ] Ġthat Ġthis Ġ[ Call Site Helper ] Ġis Ġwithin . Ċĉĉ Ġ*/ Ċĉ ĉ fun Ġtranslator (): ĠL 1 Translator Ġ= Ġthis @ L 1 Translator ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠAnswer Ġthe Ġ[ L 2 Generator ] Ġthat Ġthis Ġ[ Call Site Helper ] Ġis Ġwithin . Ċĉĉ Ġ*/ Ċĉ ĉ fun Ġgenerator (): ĠL 2 Generator Ġ= Ġthis @ L 1 Translator . generator ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠRecord Ġthe Ġfact Ġthat Ġthis Ġcall Ġhas Ġproduced Ġa Ġvalue Ġin Ġa Ġparticular Ċĉĉ Ġ* Ġregister Ġwhich Ġis Ġto Ġrepresent Ġthe Ġnew Ġtop - of - stack Ġvalue . Ċĉĉ Ġ* Ċĉĉ Ġ* Ġ@ param Ġanswer Reg Ċĉĉ Ġ* ĠĠ ĠThe Ġregister Ġwhich Ġwill Ġalready Ġhold Ġthe Ġreturn Ġvalue Ġat Ġthis Ċĉĉ Ġ* ĠĠ Ġpoint . Ġ ĠThe Ġvalue Ġhas Ġnot Ġyet Ġbeen Ġtype Ġchecked Ġagainst Ġthe Ċĉĉ Ġ* ĠĠ Ġexpected Type Ġat Ġthis Ġpoint , Ġbut Ġit Ġshould Ġcomp ly Ġwith Ġthe Ġtype Ċĉĉ Ġ* ĠĠ Ġguarantees Ġof Ġthe ĠVM . Ċĉĉ Ġ*/ Ċĉ ĉ fun Ġuse Answer ( answer Reg : ĠL 2 Read Boxed Operand ) Ċĉ ĉ { Ċĉĉ ĉ val Ġanswer Type Ġ= Ġanswer Reg . type () Ċĉĉ ĉ when Ċĉĉ ĉ { Ċĉĉĉ ĉ answer Type . is Bottom Ġ-> Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠThe ĠVM Ġsays Ġwe Ġcan 't Ġactually Ġget Ġhere . Ġ ĠDon 't Ġbother Ċĉĉĉĉ ĉ // Ġassoci ating Ġthe Ġreturn Ġvalue Ġwith Ġeither Ġthe Ġchecked Ġor Ċĉĉĉĉ ĉ // Ġunchecked Ġreturn Ġresult ĠL 2 Semantic Slot . Ċĉĉĉĉ ĉ generator . add Un reachable Code () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ answer Type . is Subtype Of ( expected Type ) Ġ-> Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠCapture Ġit Ġas Ġthe Ġchecked Ġvalue ĠL 2 Semantic Slot . Ċĉĉĉĉ ĉ force Slot Register ( Ċĉĉĉĉĉ ĉ stack p , Ġpc , Ġanswer Reg ) Ċĉĉĉĉ ĉ generator . jump To ( after Call No Check ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ġ-> Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠCapture Ġit Ġas Ġthe Ġunchecked Ġreturn Ġvalue ĠSemantic Slot Ġby Ċĉĉĉĉ ĉ // Ġusing Ġpc Ġ- Ġ 1 . Ċĉĉĉĉ ĉ force Slot Register ( Ċĉĉĉĉĉ ĉ stack p , Ġpc Ġ- Ġ 1 , Ġanswer Reg ) Ċĉĉĉĉ ĉ generator . jump To ( after Call With Check ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠFor Ġevery Ġ[ L 2 BasicBlock ] Ġin Ġmy Ġ[ invocation Sites To Create ] Ġthat Ġis Ċĉĉ Ġ* Ġreachable , Ġgenerate Ġan Ġinvocation Ġof Ġthe Ġcorresponding Ġ[ A _ Function ]. Ċĉĉ Ġ* Ġ[ A _ Bundle . message ] Ċĉĉ Ġ*/ Ċĉ ĉ fun Ġgenerate All Invocation Sites () Ċĉ ĉ { Ċĉĉ ĉ invocation Sites To Create . values . forEach Ġ{ Ċĉĉĉ ĉ (_, Ġaction ) Ġ-> Ġaction () Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġcode Ġto Ġperform Ġa Ġmethod Ġinvocation . Ġ ĠIf Ġa Ġsuper Union Type Ġother Ċĉ Ġ* Ġthan Ġ[ bottom ] Ġis Ġsupplied , Ġproduce Ġa Ġsuper - directed Ġmult ime thod Ċĉ Ġ* Ġinvocation . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġbundle Ċĉ Ġ* ĠĠ ĠThe Ġ[ message Ġbundle ][ Message Bundle Descriptor ] Ġto Ġinvoke . Ċĉ Ġ* Ġ@ param Ġexpected Type Ċĉ Ġ* ĠĠ ĠThe Ġexpected Ġreturn Ġ[ type ][ TypeDescriptor ]. Ċĉ Ġ* Ġ@ param Ġsuper Union Type Ċĉ Ġ* ĠĠ ĠA Ġtuple Ġtype Ġto Ġcombine Ġthrough Ġa Ġtype Ġunion Ġwith Ġthe Ġpushed Ġarguments ' Ċĉ Ġ* ĠĠ Ġdynamic Ġtypes , Ġto Ġuse Ġduring Ġmethod Ġlookup . Ġ ĠThis Ġis Ġ[ bottom ] Ġfor Ċĉ Ġ* ĠĠ Ġnon - super Ġcalls . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġgenerate Call ( Ċĉ ĉ bundle : ĠA _ Bundle , Ċĉ ĉ expected Type : ĠA _ Type , Ċĉ ĉ super Union Type : ĠA _ Type ) Ċ ĉ { Ċĉ ĉ val Ġcall Site Helper Ġ= ĠCall Site Helper ( Ċĉĉ ĉ bundle , Ġsuper Union Type , Ġexpected Type ) Ċĉ ĉ val Ġmethod : ĠA _ Method Ġ= Ġbundle . bundle Method Ċĉ ĉ generator . add Cont ing ent Value ( method ) Ċĉ ĉ val Ġn Args Ġ= Ġmethod . num Args Ċĉ ĉ val Ġsemantic Arguments Ġ= Ġmutable ListOf < L 2 Semantic Value >() Ċĉ ĉ for Ġ( i Ġin Ġn Args Ġ- Ġ 1 Ġdown To Ġ 0 ) Ċĉ ĉ { Ċĉĉ ĉ semantic Arguments . add ( semantic Slot ( stack p Ġ+ Ġi )) Ċĉĉ ĉ // ĠNo Ġpoint Ġn illing Ġthe Ġfirst Ġargument , Ġsince Ġit 'll Ġbe Ġoverwritten Ċĉĉ ĉ // Ġbelow Ġwith Ġa Ġconstant Ġmove Ġof Ġthe Ġexpected Type . Ċĉĉ ĉ if Ġ( i Ġ!= Ġn Args Ġ- Ġ 1 ) Ċĉĉ ĉ { Ċĉĉĉ ĉ move Constant To Slot ( nil , Ġstack p Ġ+ Ġi ) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ // ĠPop Ġthe Ġarguments , Ġbut Ġpush Ġa Ġslot Ġfor Ġthe Ġexpected Type . Ċĉ ĉ stack p Ġ+= Ġn Args Ġ- Ġ 1 Ċĉ ĉ // ĠAt Ġthis Ġpoint Ġwe 've Ġcaptured Ġand Ġpop ped Ġthe Ġargument Ġregisters , Ġand Ċĉ ĉ // Ġnil led Ġtheir Ġnew ĠS SA Ġversions Ġfor Ġre ification . Ġ ĠThe Ġre ification Ċĉ ĉ // Ġclauses Ġwill Ġexplicitly Ġensure Ġthe Ġexpected Ġtype Ġappears Ġin Ġthe Ġtop Ċĉ ĉ // Ġof Ġstack Ġposition . ĊĊĉ ĉ // ĠDetermine Ġwhich Ġapplicable Ġdefinitions Ġhave Ġalready Ġbeen Ġexpanded Ġin Ċĉ ĉ // Ġthe Ġlookup Ġtree . Ċĉ ĉ val Ġtree Ġ= Ġmethod . testing Tree Ċĉ ĉ val Ġargument Restrictions Ġ= Ġsemantic Arguments Ċĉĉ ĉ . map Ġ{ Ġcurrent Manifest (). restriction For ( it ) Ġ} ĊĊĊĉ ĉ // ĠSpecial Ġcase : ĠIf Ġthere 's Ġonly Ġone Ġmethod Ġdefinition Ġand Ġthe Ġtype Ġtree Ċĉ ĉ // Ġhas Ġnot Ġyet Ġbeen Ġexpanded , Ġgo Ġahead Ġand Ġdo Ġso . Ġ ĠIt Ġtakes Ġless Ġspace Ċĉ ĉ // Ġin ĠL 2 / JVM Ġto Ġstore Ġthe Ġsimple Ġinvocation Ġthan Ġa Ġfull Ġlookup . Ċĉ ĉ if Ġ( method . definitions Tuple . tuple Size Ġ<= Ġ 1 ) Ċĉ ĉ { Ċĉĉ ĉ val Ġarg Types Ġ= Ġargument Restrictions Ċĉĉĉ ĉ . map Ġ{ Ġrestriction : ĠType Restriction Ġ-> Ġrestriction . type Ġ} Ċĉĉ ĉ try Ċĉĉ ĉ { Ċĉĉĉ ĉ val Ġresult Ġ= Ċĉĉĉĉ ĉ method . lookup By Types From Tuple ( tuple From List ( arg Types )) Ċĉĉĉ ĉ assert ( result . equals ( method . definitions Tuple . tuple At ( 1 ))) Ċĉĉ ĉ } Ċĉĉ ĉ catch Ġ( e : ĠMethod Definition Exception ) Ċĉĉ ĉ { Ċĉĉĉ ĉ assert ( false ) Ġ{ Ġ" Couldn 't Ġlook Ġup Ġmethod Ġby Ġits Ġown Ġsignature " Ġ} Ċĉĉ ĉ } Ċĉĉ ĉ // ĠThe Ġtree Ġis Ġnow Ġwar med Ġup Ġfor Ġa Ġmon omorphic Ġinline . Ċĉ ĉ } Ċĉ ĉ val Ġapplicable Expanded Le aves Ġ= Ġmutable ListOf < A _ Definition >() Ċĉ ĉ val Ġdefinition Collector Ġ= Ċĉĉ ĉ object Ġ: ĠLookup Tree Tra verser < A _ Definition , ĠA _ Tuple , ĠUnit , ĠBoolean >( Ċĉĉĉ ĉ MethodDescriptor . runtime Dispatcher , ĠUnit , Ġfalse ) Ċĉ ĉ { Ċĉĉ ĉ override Ġfun Ġvisit Pre Internal Node ( Ċĉĉĉ ĉ argument Index : ĠInt , Ġargument Type : ĠA _ Type ): ĠBoolean Ġ= Ġtrue ĊĊĉĉ ĉ override Ġfun Ġvisit Leaf Node ( lookup Result : ĠA _ Tuple ) Ċĉĉ ĉ { Ċĉĉĉ ĉ if Ġ( lookup Result . tuple Size Ġ!= Ġ 1 ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ return Ċĉĉĉ ĉ } Ċĉĉĉ ĉ val Ġdefinition : ĠA _ Definition Ġ= Ġlookup Result . tuple At ( 1 ) Ċĉĉĉ ĉ // ĠOnly Ġinline Ġsuccessful Ġlook ups . Ċĉĉĉ ĉ if Ġ(! definition . is Method Definition ()) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ return Ċĉĉĉ ĉ } Ċĉĉĉ ĉ val Ġsignature Ġ= Ġdefinition . body Signature () Ċĉĉĉ ĉ if Ġ( signature . could E ver Be Inv oked With ( argument Restrictions ) Ċĉĉĉĉ ĉ && Ġsuper Union Type . is Subtype Of ( Ċĉĉĉĉĉ ĉ signature . args Tuple Type )) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ applic able Expanded Le aves . add ( definition ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ definition Collector . traverse Ent ire Tree ( tree ) Ċĉ ĉ if Ġ( applic able Expanded Le aves . size Ġ<= Ċĉĉ ĉ L 2 Generator . max Pol ym orphism To Inline Dispatch ) Ċĉ ĉ { Ċĉĉ ĉ val Ġtra verser Ġ= Ġobject Ġ: Ċĉĉĉ ĉ Lookup Tree Tra verser Ċĉĉĉĉ ĉ < A _ Definition , ĠA _ Tuple , ĠUnit , ĠInternal Node Mem ento >( Ċĉĉĉĉĉ ĉ MethodDescriptor . runtime Dispatcher , ĠUnit , Ġfalse ) Ċĉĉ ĉ { Ċĉĉĉ ĉ override Ġfun Ġvisit Pre Internal Node ( Ċĉĉĉĉ ĉ argument Index : ĠInt , Ċĉĉĉĉ ĉ argument Type : ĠA _ Type Ċĉĉĉ ĉ ): ĠInternal Node Mem ento Ġ= Ġpre Internal Visit ( Ċĉĉĉĉ ĉ call Site Helper , Ċĉĉĉĉ ĉ semantic Arguments , Ċĉĉĉĉ ĉ argument Index , Ċĉĉĉĉ ĉ argument Type ) ĊĊĉĉĉ ĉ override Ġfun Ġvisit In tra Internal Node ( me ment o : ĠInternal Node Mem ento ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠEvery Ġleaf Ġand Ġun expanded Ġinternal Ġnode Ġends Ġwith Ġan Ġedge Ċĉĉĉĉ ĉ // Ġto Ġafter Call * Ġand / or Ġon Re ification * Ġand / or Ġthe Ċĉĉĉĉ ĉ // Ġunreachable Block . Ċĉĉĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉĉĉĉ ĉ generator . start Block ( me ment o . fail Check BasicBlock ) Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ override Ġfun Ġvisit Post Internal Node ( me ment o : ĠInternal Node Mem ento ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠThe Ġleaves Ġalready Ġend Ġwith Ġjumps , Ġand Ġthe Ġmanifest Ċĉĉĉĉ ĉ // Ġat Ġthe Ġnext Ġsite Ġshould Ġhave Ġthe Ġwe aker Ġtypes Ġthat Ċĉĉĉĉ ĉ // Ġwere Ġknown Ġbefore Ġthis Ġtest . Ċĉĉĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ override Ġfun Ġvisit Un expanded () Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠThis Ġpart Ġof Ġthe Ġlookup Ġtree Ġwasn 't Ġexpanded Ġyet , Ġso Ġfall Ċĉĉĉĉ ĉ // Ġback Ġto Ġthe Ġslow Ġdispatch . Ċĉĉĉĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ generator . jump To ( call Site Helper . on Fall Back ToS low Lookup ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ override Ġfun Ġvisit Leaf Node ( lookup Result : ĠA _ Tuple ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ leaf Visit ( semantic Arguments , Ġcall Site Helper , Ġlookup Result ) Ċĉĉĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ tra verser . traverse Ent ire Tree ( tree ) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ // ĠAlways Ġfall Ġback . Ċĉĉ ĉ generator . jump To ( call Site Helper . on Fall Back ToS low Lookup ) Ċĉ ĉ } Ċĉ ĉ assert (! generator . currently Reach able ()) ĊĊĉ ĉ // ĠCalculate Ġthe Ġunion Ġof Ġthe Ġtypes Ġguaranteed Ġto Ġbe Ġproduced Ġby Ġthe Ċĉ ĉ // Ġpossible Ġdefinitions , Ġincluding Ġanalysis Ġof Ġprimitives . Ġ ĠThe Ġphi Ċĉ ĉ // Ġcombining Ġfinal Ġresults Ġwill Ġproduce Ġsomething Ġat Ġleast Ġthis Ġstrict . Ċĉ ĉ var Ġtemp Union Ġ= Ġbottom Ċĉ ĉ for Ġ( definition Ġin Ġmethod . definitions At Or Below ( argument Restrictions )) Ċĉ ĉ { Ċĉĉ ĉ if Ġ( definition . is Method Definition ()) Ċĉĉ ĉ { Ċĉĉĉ ĉ val Ġfunction Ġ= Ġdefinition . body Block () Ċĉĉĉ ĉ val Ġraw Function Ġ= Ġfunction . code () Ċĉĉĉ ĉ val Ġprimitive Ġ= Ġraw Function . code Primitive () Ċĉĉĉ ĉ val ĠreturnType : ĠA _ Type Ġ= Ġif Ġ( primitive Ġ!== Ġnull ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ val Ġsignature Tuple Type Ġ= Ċĉĉĉĉĉ ĉ raw Function . function Type (). args Tuple Type Ċĉĉĉĉ ĉ val Ġintersect ed Argument Types Ġ= Ġmutable ListOf < A _ Type >() Ċĉĉĉĉ ĉ for Ġ( i Ġin Ġargument Restrictions . indices ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ val Ġintersection Ġ= Ċĉĉĉĉĉĉ ĉ argument Restrictions [ i ]. intersection WithType ( Ċĉĉĉĉĉĉĉ ĉ signature Tuple Type . type AtIndex ( i Ġ+ Ġ 1 )) Ċĉĉĉĉĉ ĉ intersect ed Argument Types . add ( intersection . type ) Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ primitive . returnType Gu arante edBy VM ( Ċĉĉĉĉĉ ĉ raw Function , Ġintersect ed Argument Types ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ raw Function . function Type (). returnType Ċĉĉĉ ĉ } Ċĉĉĉ ĉ temp Union Ġ= Ġtemp Union . type Union ( returnType ) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ val Ġunion Of Possible Results Ġ= Ġtemp Union ĊĊĉ ĉ // ĠNow Ġgenerate Ġthe Ġreachable Ġexit Ġclauses Ġfor : Ċĉ ĉ // ĠĠĠĠ 1 . Ġdefault Ġlookup , Ċĉ ĉ // ĠĠĠĠ 2 . Ġre ification Ġleading Ġto Ġreturn Ġcheck , Ċĉ ĉ // ĠĠĠĠ 3 . Ġre ification Ġwith Ġno Ġcheck , Ċĉ ĉ // ĠĠĠĠ 4 . Ġre ification Ġfor Ġun return able Ġcall , Ċĉ ĉ // ĠĠĠĠ 5 . Ġafter Ġcall Ġwith Ġreturn Ġcheck , Ċĉ ĉ // ĠĠĠĠ 6 . Ġafter Ġcall Ġwith Ġno Ġcheck , Ċĉ ĉ // ĠĠĠĠ 7 . Ġafter Ġeverything . Ċĉ ĉ // ĠClause Ġ{ 2 . 3 } Ġentry Ġexpects Ġthe Ġvalue Ġin Ġinterpreter . latest Result . Ċĉ ĉ // ĠClause Ġ{ 4 , 5 } Ġentry Ġexpects Ġthe Ġvalue Ġin Ġtop - of - stack . Ċĉ ĉ // ĠThere Ġare Ġedges Ġbetween Ċĉ ĉ // ĠĠĠĠ 1 Ġ-> Ġ{< 2 . 5 >, Ġ< 3 , 6 >} Ġdepending Ġon Ġtype Ġguarantees , Ċĉ ĉ // ĠĠĠĠ 2 Ġ-> Ġ{ 5 } Ċĉ ĉ // ĠĠĠĠ 3 Ġ-> Ġ{ 6 } Ċĉ ĉ // ĠĠĠĠ 4 Ġ-> Ġunreachable Ġblock Ċĉ ĉ // ĠĠĠĠ 5 Ġ-> Ġ{ 7 } Ċĉ ĉ // ĠĠĠĠ 6 Ġ-> Ġ{ 7 }. Ċĉ ĉ // ĠClause s Ġwith Ġno Ġactual Ġpre decess ors Ġare Ġnot Ġgenerated . ĊĊĉ ĉ // Ġ# 1 : ĠDefault Ġlookup . Ċĉ ĉ generator . start Block ( call Site Helper . on Fall Back ToS low Lookup ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ generate Slow Pol ymorphic Call ( call Site Helper , Ġsemantic Arguments ) Ċĉ ĉ } ĊĊĉ ĉ // Ġ# 1 b : ĠAt Ġthis Ġpoint , Ġinvocation Sites To Create Ġis Ġfully Ġpopulated Ġwith Ċĉ ĉ // Ġbasic Ġblocks Ġin Ġwhich Ġto Ġgenerate Ġinv ocations Ġof Ġthe Ġcorresponding Ċĉ ĉ // Ġmethod Ġdefinition Ġbodies . Ġ ĠGenerate Ġthem Ġall Ġnow , Ġas Ġthey Ġwill Ġlead Ċĉ ĉ // Ġto Ġthe Ġexits Ġthat Ġwe 'll Ġgenerate Ġin Ġthe Ġnext Ġstep . Ċĉ ĉ call Site Helper . generate All Invocation Sites () ĊĊĉ ĉ // Ġ# 2 : ĠRe ification Ġwith Ġreturn Ġcheck . Ċĉ ĉ generator . start Block ( call Site Helper . on Re ification With Check ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ re ify ( expected Type , ĠChunk EntryPoint . TO _ RETURN _ IN TO ) Ċĉĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠCapture Ġthe Ġvalue Ġbeing Ġreturned Ġinto Ġthe Ġon - ramp . Ċĉĉĉ ĉ if Ġ( union Of Possible Results . is Vac u ous Type ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ generator . add Un reachable Code () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ force Slot Register ( Ċĉĉĉĉĉ ĉ stack p , Ċĉĉĉĉĉ ĉ pc Ġ- Ġ 1 , Ċĉĉĉĉĉ ĉ get Latest ReturnValue ( union Of Possible Results )) Ċĉĉĉĉ ĉ generator . jump To ( call Site Helper . after Call With Check ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // Ġ# 3 : ĠRe ification Ġwithout Ġreturn Ġcheck . Ċĉ ĉ generator . start Block ( call Site Helper . on Re ification No Check ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ re ify ( expected Type , ĠChunk EntryPoint . TO _ RETURN _ IN TO ) Ċĉĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠCapture Ġthe Ġvalue Ġbeing Ġreturned Ġinto Ġthe Ġon - ramp . Ċĉĉĉ ĉ val Ġguaranteed Type Ġ= Ġunion Of Possible Results . type Intersection ( Ċĉĉĉĉ ĉ expected Type ) Ċĉĉĉ ĉ if Ġ( gu arante ed Type . is Vac u ous Type ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ generator . add Un reachable Code () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ force Slot Register ( Ċĉĉĉĉĉ ĉ stack p , Ċĉĉĉĉĉ ĉ pc , Ċĉĉĉĉĉ ĉ get Latest ReturnValue ( gu arante ed Type )) Ċĉĉĉĉ ĉ generator . jump To ( call Site Helper . after Call No Check ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // Ġ# 4 : ĠRe ification Ġfor Ġun return able Ġcall . Ċĉ ĉ generator . start Block ( call Site Helper . on Re ification Un return able ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ re ify ( expected Type , ĠChunk EntryPoint . TO _ RETURN _ IN TO ) Ċĉĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉĉ ĉ { Ċĉĉĉ ĉ generator . add Un reachable Code () Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // Ġ# 5 : ĠAfter Ġcall Ġwith Ġreturn Ġcheck . Ċĉ ĉ generator . start Block ( call Site Helper . after Call With Check ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ // ĠThe Ġunchecked Ġreturn Ġvalue Ġwill Ġhave Ġbeen Ġput Ġinto Ġthe Ġregister Ċĉĉ ĉ // Ġbound Ġto Ġthe ĠL 2 Semantic Slot Ġfor Ġthe Ġstack p Ġand Ġpc Ġjust Ġafter Ġthe Ċĉĉ ĉ // Ġcall ĠMIN US ĠONE . Ġ ĠCheck Ġit , Ġmoving Ġit Ġto Ġa Ġregister Ġthat 's Ġbound Ċĉĉ ĉ // Ġto Ġthe ĠL 2 Semantic Slot Ġfor Ġthe Ġstack p Ġand Ġpc Ġjust Ġafter Ġthe Ġcall . Ċĉĉ ĉ generate ReturnType Check ( expected Type ) Ċĉĉ ĉ generator . jump To ( call Site Helper . after Everything ) Ċĉ ĉ } ĊĊĉ ĉ // Ġ# 6 : ĠAfter Ġcall Ġwithout Ġreturn Ġcheck . Ċĉ ĉ // ĠMake Ġthe Ġversion Ġof Ġthe Ġstack Ġwith Ġthe Ġunchecked Ġvalue Ġavailable . Ċĉ ĉ generator . start Block ( call Site Helper . after Call No Check ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ // ĠThe Ġvalue Ġwill Ġhave Ġbeen Ġput Ġinto Ġa Ġregister Ġbound Ġto Ġthe Ċĉĉ ĉ // ĠL 2 Semantic Slot Ġfor Ġthe Ġstack p Ġand Ġpc Ġjust Ġafter Ġthe Ġcall . Ċĉĉ ĉ generator . jump To ( call Site Helper . after Everything ) Ċĉ ĉ } ĊĊĉ ĉ // Ġ# 7 : ĠAfter Ġeverything . Ġ ĠIf Ġit 's Ġpossible Ġto Ġreturn Ġa Ġvalid Ġvalue Ġfrom Ċĉ ĉ // Ġthe Ġcall , Ġthis Ġwill Ġbe Ġreachable . Ċĉ ĉ generator . start Block ( call Site Helper . after Everything ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠA Ġleaf Ġlookup Ġtree Ġwas Ġfound Ġat Ġthis Ġposition Ġin Ġthe Ġin lined Ġdispatch . Ċĉ Ġ* ĠIf Ġit 's Ġa Ġsingular Ġmethod Ġdefinition , Ġembed Ġa Ġcall Ġto Ġit , Ġotherwise Ġjump Ċĉ Ġ* Ġto Ġthe Ġfallback Ġlookup Ġcode Ġto Ġreproduce Ġand Ġhandle Ġlookup Ġerrors . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġsemantic Arguments Ċĉ Ġ* ĠĠ ĠThe Ġlist Ġof Ġ[ L 2 Semantic Value ] s Ġsupply ing Ġargument Ġvalues . ĠThese Ġbecome Ċĉ Ġ* ĠĠ Ġst reng then ed Ġby Ġtype Ġtests Ġin Ġthe Ġcurrent Ġmanifest . Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠThe Ġ[ Call Site Helper ] Ġobject Ġfor Ġthis Ġdispatch . Ċĉ Ġ* Ġ@ param Ġsolutions Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Tuple ] Ġof Ġ[ A _ Definition ] s Ġat Ġthis Ġleaf Ġof Ġthe Ġlookup Ġtree . Ġ ĠIf Ċĉ Ġ* ĠĠ Ġthere 's Ġexactly Ġone , Ġand Ġit 's Ġa Ġmethod Ġdefinition , Ġthe Ġlookup Ġis Ċĉ Ġ* ĠĠ Ġconsidered Ġsuccessful , Ġotherwise Ġit 's Ġa Ġfailed Ġlookup . Ċĉ Ġ*/ Ċ ĉ fun Ġleaf Visit ( Ċĉ ĉ semantic Arguments : ĠList < L 2 Semantic Value >, Ċĉ ĉ call Site Helper : ĠCall Site Helper , Ċĉ ĉ solutions : ĠA _ Tuple ) Ċ ĉ { Ċĉ ĉ if Ġ(! generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ if Ġ( solutions . tuple Size Ġ== Ġ 1 ) Ċĉ ĉ { Ċĉĉ ĉ val Ġsolution : ĠA _ Definition Ġ= Ġsolutions . tuple At ( 1 ) Ċĉĉ ĉ if Ġ( solution . is Method Definition ()) Ċĉĉ ĉ { Ċĉĉĉ ĉ promise To Handle Call For Definition Body ( Ċĉĉĉĉ ĉ solution . body Block (), Ġsemantic Arguments , Ġcall Site Helper ) Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ // ĠFailed Ġdis patches Ġbasically Ġnever Ġhappen , Ġso Ġjump Ġto Ġthe Ġfallback Ċĉ ĉ // Ġlookup , Ġwhich Ġwill Ġdo Ġits Ġown Ġproblem Ġreporting . Ċĉ ĉ generator . jump To ( call Site Helper . on Fall Back ToS low Lookup ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠA Ġleaf Ġlookup Ġtree Ġwas Ġfound Ġat Ġthis Ġposition Ġin Ġthe Ġin lined Ġdispatch . Ċĉ Ġ* ĠIf Ġit 's Ġa Ġsingular Ġmethod Ġdefinition , Ġembed Ġa Ġcall Ġto Ġit , Ġotherwise Ġjump Ċĉ Ġ* Ġto Ġthe Ġfallback Ġlookup Ġcode Ġto Ġreproduce Ġand Ġhandle Ġlookup Ġerrors . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġfunction Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Definition ] Ġbody Ġ[ A _ Function ] Ġto Ġbe Ġinvoked . Ċĉ Ġ* Ġ@ param Ġsemantic Arguments Ċĉ Ġ* ĠĠ ĠThe Ġlist Ġof Ġ[ L 2 Semantic Value ] s Ġsupply ing Ġargument Ġvalues . ĠThese Ġbecome Ċĉ Ġ* ĠĠ Ġst reng then ed Ġby Ġtype Ġtests Ġin Ġthe Ġcurrent Ġmanifest . Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠThe Ġ[ Call Site Helper ] Ġobject Ġfor Ġthis Ġdispatch . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġpromise To Handle Call For Definition Body ( Ċĉ ĉ function : ĠA _ Function , Ċĉ ĉ semantic Arguments : ĠList < L 2 Semantic Value >, Ċĉ ĉ call Site Helper : ĠCall Site Helper ) Ċ ĉ { Ċĉ ĉ val Ġexisting Pair Ġ= Ċĉĉ ĉ call Site Helper . invocation Sites To Create [ function ] Ċĉ ĉ val Ġblock : ĠL 2 BasicBlock Ċĉ ĉ if Ġ( existing Pair Ġ=== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ block Ġ= Ġgenerator . create BasicBlock (" successful Ġlookup ") Ċĉĉ ĉ // ĠS afety Ġcheck . Ċĉĉ ĉ var Ġran Ġ= Ġ 0 Ċĉĉ ĉ val Ġnew Action Ġ= Ġ{ Ċĉĉĉ ĉ assert ( ran Ġ== Ġ 0 ) Ċĉĉĉ ĉ ran ++ Ċĉĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉĉĉ ĉ if Ġ( block . pre decessor Edges (). isNotEmpty ()) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ generator . start Block ( block ) Ċĉĉĉĉ ĉ generate General Function Invocation ( Ċĉĉĉĉĉ ĉ generator . boxed Constant ( function ), Ċĉĉĉĉĉ ĉ semantic Arguments . map Ġ{ Ċĉĉĉĉĉĉ ĉ current Manifest (). read Boxed ( it ) Ċĉĉĉĉĉ ĉ }, Ċĉĉĉĉĉ ĉ true , Ċĉĉĉĉĉ ĉ call Site Helper ) Ċĉĉĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ call Site Helper . invocation Sites To Create [ function ] Ġ= Ċĉĉĉ ĉ block Ġto Ġnew Action Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ block Ġ= Ġexisting Pair . first Ċĉ ĉ } Ċĉ ĉ // ĠWhether Ġwe Ġjust Ġcreated Ġthis Ġpair Ġor Ġfound Ġit , Ġemit Ġa Ġjump Ġto Ċĉ ĉ // Ġthe Ġblock . Ċĉ ĉ generator . jump To ( block ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠAn Ġexpanded Ġinternal Ġnode Ġhas Ġbeen Ġreached . Ġ ĠEmit Ġa Ġtype Ġtest Ġto Ċĉ Ġ* Ġdetermine Ġwhich Ġway Ġto Ġjump . Ġ ĠAnswer Ġa Ġnew Ġ[ Internal Node Mem ento ] Ġto Ġpass Ċĉ Ġ* Ġalong Ġto Ġother Ġvisitor Ġoperations Ġto Ġcoordinate Ġbranch Ġtargets . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠThe Ġ[ Call Site Helper ] Ġobject Ġfor Ġthis Ġdispatch . Ċĉ Ġ* Ġ@ param Ġsemantic Arguments Ċĉ Ġ* ĠĠ ĠThe Ġlist Ġof Ġ[ L 2 Semantic Value ] s Ġsupply ing Ġargument Ġvalues . ĠThese Ġbecome Ċĉ Ġ* ĠĠ Ġst reng then ed Ġby Ġtype Ġtests Ġin Ġthe Ġcurrent Ġmanifest . Ċĉ Ġ* Ġ@ param Ġargument Index To Test Ċĉ Ġ* ĠĠ ĠThe Ġargument Ġnumber Ġto Ġtest Ġhere . Ġ ĠThis Ġis Ġa Ġone - based Ġindex Ġinto Ġthe Ċĉ Ġ* ĠĠ Ġlist Ġof Ġarguments Ġ( which Ġis Ġzero - based ). Ċĉ Ġ* Ġ@ param Ġtype To Test Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġto Ġcheck Ġthe Ġargument Ġagainst . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠAn Ġ[ Internal Node Mem ento ] Ġwhich Ġis Ġmade Ġavailable Ġin Ġother Ġcallbacks Ġfor Ċĉ Ġ* ĠĠ Ġthis Ġparticular Ġtype Ġtest Ġnode . Ġ ĠIt Ġcaptures Ġbranch Ġlabels , Ġfor Ċĉ Ġ* ĠĠ Ġexample . Ċĉ Ġ*/ Ċ ĉ fun Ġpre Internal Visit ( Ċĉ ĉ call Site Helper : ĠCall Site Helper , Ċĉ ĉ semantic Arguments : ĠList < L 2 Semantic Value >, Ċĉ ĉ argument Index To Test : ĠInt , Ċĉ ĉ type To Test : ĠA _ Type ): ĠInternal Node Mem ento Ċ ĉ { Ċĉ ĉ val Ġme ment o Ġ= Ġpre Internal Visit For Just The Jump s ( Ċĉĉ ĉ call Site Helper , Ċĉĉ ĉ semantic Arguments , Ċĉĉ ĉ argument Index To Test , Ċĉĉ ĉ type To Test ) ĊĊĉ ĉ // ĠPrepare Ġto Ġgenerate Ġthe Ġpass Ġblock , Ġif Ġreachable . Ċĉ ĉ generator . start Block ( me ment o . pass Check BasicBlock ) Ċĉ ĉ if Ġ(! generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ return Ġme ment o Ċĉ ĉ } Ċĉ ĉ // ĠReplace Ġthe Ġcurrent Ġargument Ġwith Ġa Ġpass - st reng then ed Ġreader . Ġ ĠIt 'll Ċĉ ĉ // Ġbe Ġreplaced Ġwith Ġa Ġfail - st reng then ed Ġreader Ġduring Ġthe Ċĉ ĉ // Ġintra Internal Node , Ġthen Ġreplaced Ġwith Ġwhatever Ġit Ġwas Ġupon Ġentry Ġto Ċĉ ĉ // Ġthis Ġsubtree Ġduring Ġthe Ġpost Internal Node . Ċĉ ĉ val Ġsemantic Argument Ġ= Ġsemantic Arguments [ argument Index To Test Ġ- Ġ 1 ] Ċĉ ĉ val Ġargument Restriction Ġ= Ċĉĉ ĉ current Manifest (). restriction For ( semantic Argument ) Ċĉ ĉ if Ġ(! argument Restriction . intersect sType ( type To Test )) Ċĉ ĉ { Ċĉĉ ĉ generator . add Un reachable Code () Ċĉ ĉ } Ċĉ ĉ return Ġme ment o Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠAn Ġexpanded Ġinternal Ġnode Ġhas Ġbeen Ġreached . Ġ ĠEmit Ġa Ġtype Ġtest Ġto Ċĉ Ġ* Ġdetermine Ġwhich Ġway Ġto Ġjump . Ġ ĠAnswer Ġa Ġnew Ġ[ Internal Node Mem ento ] Ġto Ġpass Ċĉ Ġ* Ġalong Ġto Ġother Ġvisitor Ġoperations Ġto Ġcoordinate Ġbranch Ġtargets . ĠDon 't Ċĉ Ġ* Ġst reng then Ġthe Ġtested Ġargument Ġtype Ġyet . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠThe Ġ[ Call Site Helper ] Ġobject Ġfor Ġthis Ġdispatch . Ċĉ Ġ* Ġ@ param Ġsemantic Arguments Ċĉ Ġ* ĠĠ ĠThe Ġlist Ġof Ġ[ L 2 Semantic Value ] s Ġsupply ing Ġargument Ġvalues . ĠThese Ġbecome Ċĉ Ġ* ĠĠ Ġst reng then ed Ġby Ġtype Ġtests Ġin Ġthe Ġcurrent Ġmanifest . Ċĉ Ġ* Ġ@ param Ġargument Index To Test Ċĉ Ġ* ĠĠ ĠThe Ġargument Ġnumber Ġto Ġtest Ġhere . Ġ ĠThis Ġis Ġa Ġone - based Ġindex Ġinto Ġthe Ċĉ Ġ* ĠĠ Ġlist Ġof Ġarguments Ġ( which Ġis Ġzero - based ). Ċĉ Ġ* Ġ@ param Ġtype To Test Ċĉ Ġ* ĠĠ ĠThe Ġtype Ġto Ġcheck Ġthe Ġargument Ġagainst . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠAn Ġ[ Internal Node Mem ento ] Ġwhich Ġis Ġmade Ġavailable Ġin Ġother Ġcallbacks Ġfor Ċĉ Ġ* ĠĠ Ġthis Ġparticular Ġtype Ġtest Ġnode . Ġ ĠIt Ġcaptures Ġbranch Ġlabels , Ġfor Ċĉ Ġ* ĠĠ Ġexample . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġpre Internal Visit For Just The Jump s ( Ċĉ ĉ call Site Helper : ĠCall Site Helper , Ċĉ ĉ semantic Arguments : ĠList < L 2 Semantic Value >, Ċĉ ĉ argument Index To Test : ĠInt , Ċĉ ĉ type To Test : ĠA _ Type ): ĠInternal Node Mem ento Ċ ĉ { Ċĉ ĉ val Ġsemantic Argument Ġ= Ċĉĉ ĉ semantic Arguments [ argument Index To Test Ġ- Ġ 1 ] Ċĉ ĉ val Ġarg Read Ġ= Ċĉĉ ĉ current Manifest (). read Boxed ( semantic Argument ) Ċĉ ĉ val Ġme ment o Ġ= ĠInternal Node Mem ento ( Ċĉĉ ĉ argument Index To Test , Ċĉĉ ĉ type To Test , Ċĉĉ ĉ call Site Helper . branch Label Counter ++) Ċĉ ĉ if Ġ(! generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ // ĠIf Ġno Ġpaths Ġlead Ġhere , Ġdon 't Ġgenerate Ġcode . Ġ ĠThis Ġcan Ġhappen Ġwhen Ċĉĉ ĉ // Ġwe Ġshort - circuit Ġtype - tests Ġinto Ġun conditional Ġjumps , Ġdue Ġto Ġthe Ċĉĉ ĉ // Ġcomplexity Ġof Ġsuper Ġcalls . Ġ ĠWe Ġshort - circuit Ġcode Ġgeneration Ċĉĉ ĉ // Ġwithin Ġthis Ġentire Ġsubtree Ġby Ġperforming Ġthe Ġsame Ġcheck Ġin Ġeach Ċĉĉ ĉ // Ġcallback . Ċĉĉ ĉ return Ġme ment o Ċĉ ĉ } Ċĉ ĉ val Ġarg Restriction Ġ= Ġarg Read . restriction () ĊĊĉ ĉ // ĠTr icky Ġhere . Ġ ĠWe Ġhave Ġthe Ġtype Ġwe Ġwant Ġto Ġtest Ġfor , Ġand Ġwe Ġhave Ġthe Ċĉ ĉ // Ġargument Ġfor Ġwhich Ġwe Ġwant Ġto Ġtest Ġthe Ġtype , Ġbut Ġwe Ġalso Ġhave Ġan Ċĉ ĉ // Ġelement Ġof Ġthe Ġsuper Union Type Ġto Ġconsider . Ġ ĠAnd Ġthat Ġelement Ġmight Ġbe Ċĉ ĉ // Ġa Ġcombination Ġof Ġrestrictions Ġand Ġbottom s . Ġ ĠDe al Ġwith Ġthe Ġeasy , Ċĉ ĉ // Ġcommon Ġcases Ġfirst . Ċĉ ĉ val Ġsuper Union ElementType Ġ= Ċĉĉ ĉ call Site Helper . super Union Type . type AtIndex ( argument Index To Test ) Ċĉ ĉ if Ġ( super Union ElementType . is Bottom ) Ċĉ ĉ { Ċĉĉ ĉ // ĠIt 's Ġnot Ġa Ġsuper Ġcall , Ġor Ġat Ġleast Ġthis Ġtest Ġisn 't Ġrelated Ġto Ġany Ċĉĉ ĉ // Ġparts Ġthat Ġare Ġsuper cast Ġup ward . Ċĉĉ ĉ val Ġintersection Ġ= Ġarg Restriction . intersection WithType ( type To Test ) Ċĉĉ ĉ if Ġ( intersection Ġ=== ĠType Restriction . bottom Restriction ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠIt Ġwill Ġalways Ġfail Ġthe Ġtest . Ċĉĉĉ ĉ generator . jump To ( me ment o . fail Check BasicBlock ) Ċĉĉĉ ĉ return Ġme ment o Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ( arg Restriction . type . is Subtype Of ( type To Test )) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠIt Ġwill Ġalways Ġpass Ġthe Ġtest . Ċĉĉĉ ĉ generator . jump To ( me ment o . pass Check BasicBlock ) Ċĉĉĉ ĉ return Ġme ment o Ċĉĉ ĉ } ĊĊĉĉ ĉ // ĠA Ġruntime Ġtest Ġis Ġneeded . Ġ ĠTry Ġto Ġspecial - case Ġsmall Ġenumeration . Ċĉĉ ĉ val Ġpossible Values Ġ= Ċĉĉĉ ĉ intersection . enumeration Values OrNull ( Ċĉĉĉĉ ĉ L 2 Generator . max Expanded Equality Checks ) Ċĉĉ ĉ if Ġ( possible Values Ġ!== Ġnull ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠThe Ġrestriction Ġhas Ġa Ġsmall Ġnumber Ġof Ġvalues . Ġ ĠUse Ġequality Ċĉĉĉ ĉ // Ġchecks Ġrather Ġthan Ġthe Ġmore Ġgeneral Ġtype Ġchecks . Ċĉĉĉ ĉ val Ġiterator : ĠIterator < Avail Object > Ġ= Ġpossible Values . iterator () Ċĉĉĉ ĉ var Ġinstance : ĠA _ Basic Object Ġ= Ġiterator . next () Ċĉĉĉ ĉ while Ġ( iterator . hasNext ()) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ val Ġnext Check OrFail Ġ= Ġgenerator . create BasicBlock ( Ċĉĉĉĉĉ ĉ " test Ġnext Ġcase Ġof Ġenumeration ") Ċĉĉĉĉ ĉ jump If Equals Constant ( Ċĉĉĉĉĉ ĉ arg Read , Ċĉĉĉĉĉ ĉ instance , Ċĉĉĉĉĉ ĉ me ment o . pass Check BasicBlock , Ċĉĉĉĉĉ ĉ next Check OrFail ) Ċĉĉĉĉ ĉ generator . start Block ( next Check OrFail ) Ċĉĉĉĉ ĉ instance Ġ= Ġiterator . next () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ jump If Equals Constant ( Ċĉĉĉĉ ĉ arg Read , Ċĉĉĉĉ ĉ instance , Ċĉĉĉĉ ĉ me ment o . pass Check BasicBlock , Ċĉĉĉĉ ĉ me ment o . fail Check BasicBlock ) Ċĉĉĉ ĉ return Ġme ment o Ċĉĉ ĉ } Ċĉĉ ĉ // ĠA Ġruntime Ġtest Ġis Ġneeded , Ġand Ġit 's Ġnot Ġa Ġsmall Ġenumeration . Ċĉĉ ĉ jump If Kind Of Constant ( Ċĉĉĉ ĉ arg Read , Ċĉĉĉ ĉ type To Test , Ċĉĉĉ ĉ me ment o . pass Check BasicBlock , Ċĉĉĉ ĉ me ment o . fail Check BasicBlock ) Ċĉĉ ĉ return Ġme ment o Ċĉ ĉ } ĊĊĉ ĉ // ĠThe Ġargument Ġis Ġsubject Ġto Ġa Ġsuper - cast . Ċĉ ĉ if Ġ( arg Restriction . type . is Subtype Of ( super Union ElementType )) Ċĉ ĉ { Ċĉĉ ĉ // ĠThe Ġargument 's Ġactual Ġtype Ġwill Ġalways Ġbe Ġa Ġsubtype Ġof Ġthe Ċĉĉ ĉ // Ġsuper Union Ġtype , Ġso Ġthe Ġdispatch Ġwill Ġalways Ġbe Ġdecided Ġby Ġonly Ċĉĉ ĉ // Ġthe Ġsuper Union Ġtype , Ġwhich Ġdoes Ġnot Ġvary Ġat Ġruntime . Ġ ĠDec ide Ċĉĉ ĉ // Ġthe Ġbranch Ġdirection Ġright Ġnow . Ċĉĉ ĉ generator . jump To ( Ċĉĉĉ ĉ if Ġ( super Union ElementType . is Subtype Of ( type To Test )) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ me ment o . pass Check BasicBlock Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ me ment o . fail Check BasicBlock Ċĉĉĉ ĉ }) Ċĉĉ ĉ return Ġme ment o Ċĉ ĉ } ĊĊĉ ĉ // ĠThis Ġis Ġthe Ġmost Ġcomplex Ġcase , Ġwhere Ġthe Ġargument Ġdispatch Ġtype Ġis Ġa Ċĉ ĉ // Ġmixture Ġof Ġsuper casts Ġand Ġnon - super casts . Ġ ĠDo Ġit Ġthe Ġslow Ġway Ġwith Ġa Ċĉ ĉ // Ġtype Ġunion . Ġ ĠTech n ically , Ġthe Ġsuper Union ElementType 's Ġrecursive Ġtuple Ċĉ ĉ // Ġstructure Ġm im ics Ġthe Ġcall Ġsite , Ġso Ġit Ġmust Ġhave Ġa Ġfixed , Ġfinite Ċĉ ĉ // Ġstructure Ġcorresponding Ġwith Ġoccurrences Ġof Ġsuper casts Ġsynt act ically . Ċĉ ĉ // ĠThus , Ġin Ġtheory Ġwe Ġcould Ġanalyze Ġthe Ġsuper Union ElementType Ġand Ċĉ ĉ // Ġgenerate Ġa Ġmore Ġcomplex Ġcollection Ġof Ġbranches ĠâĢĵ Ġbut Ġthis Ġis Ġalready Ċĉ ĉ // Ġa Ġpretty Ġrare Ġcase . Ċĉ ĉ val Ġarg Meta Ġ= Ċĉĉ ĉ instance Meta ( arg Restriction . type ) Ċĉ ĉ val Ġarg Type Write Ġ= Ċĉĉ ĉ generator . boxed Write Temp ( arg Restriction . meta Restriction ()) Ċĉ ĉ add Instruction ( L 2 _ GET _ TYPE , Ġarg Read , Ġarg Type Write ) Ċĉ ĉ val Ġsuper Union Reg Ġ= Ċĉĉ ĉ generator . boxed Constant ( super Union ElementType ) Ċĉ ĉ val Ġunion Reg Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( Ċĉĉĉ ĉ arg Meta . type Union ( super Union Reg . type ()), ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ TYPE _ UNION , Ċĉĉ ĉ read Boxed ( arg Type Write ), Ċĉĉ ĉ super Union Reg , Ċĉĉ ĉ union Reg ) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ JUMP _ IF _ SUB TYPE _ OF _ CONSTANT , Ċĉĉ ĉ read Boxed ( union Reg ), Ċĉĉ ĉ L 2 Constant Operand ( type To Test ), Ċĉĉ ĉ edge To ( me ment o . pass Check BasicBlock ), Ċĉĉ ĉ edge To ( me ment o . fail Check BasicBlock )) Ċĉ ĉ return Ġme ment o Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġa Ġconditional Ġbranch Ġto Ġeither Ġ` pass Block ` Ġor Ġ` fail Block `, Ġbased Ċĉ Ġ* Ġon Ġwhether Ġthe Ġgiven Ġregister Ġequals Ġthe Ġgiven Ġconstant Ġvalue . Ċĉ Ġ* Ċĉ Ġ* ĠIf Ġthe Ġconstant Ġto Ġcompare Ġagainst Ġis Ġa Ġboolean , Ġcheck Ġthe Ġpro venance Ċĉ Ġ* Ġof Ġthe Ġregister . Ġ ĠIf Ġit 's Ġthe Ġresult Ġof Ġa Ġsuitable Ġcomparison Ġprimitive , Ċĉ Ġ* Ġgenerate Ġa Ġmore Ġefficient Ġcompare - and - branch Ġinstruction Ġinstead Ġof Ċĉ Ġ* Ġcreating Ġthe Ġboolean Ġonly Ġto Ġhave Ġit Ġcompared Ġto Ġa Ġboolean Ġconstant . Ċĉ Ġ* Ċĉ Ġ* ĠIf Ġthe Ġvalue Ġof Ġthe Ġboolean - pro ducing Ġinstruction Ġis Ġnot Ġused , Ġit Ġwill Ċĉ Ġ* Ġeventually Ġbe Ġremoved Ġas Ġdead Ġcode . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġregister To Test Ċĉ Ġ* ĠĠ ĠThe Ġregister Ġwhose Ġcontent Ġshould Ġbe Ġcompared . Ċĉ Ġ* Ġ@ param Ġconstant Value Ċĉ Ġ* ĠĠ ĠThe Ġconstant Ġvalue Ġto Ġcompare Ġagainst . Ċĉ Ġ* Ġ@ param Ġpass Block Ċĉ Ġ* ĠĠ ĠWhere Ġto Ġgo Ġif Ġthe Ġregister 's Ġvalue Ġequals Ġthe Ġconstant . Ċĉ Ġ* Ġ@ param Ġfail Block Ċĉ Ġ* ĠĠ ĠWhere Ġto Ġgo Ġif Ġthe Ġregister 's Ġvalue Ġdoes Ġnot Ġequal Ġthe Ġconstant . Ċĉ Ġ*/ Ċ ĉ fun Ġjump If Equals Constant ( Ċĉ ĉ register To Test : ĠL 2 Read Boxed Operand , Ċĉ ĉ constant Value : ĠA _ Basic Object , Ċĉ ĉ pass Block : ĠL 2 BasicBlock , Ċĉ ĉ fail Block : ĠL 2 BasicBlock ) Ċ ĉ { Ċĉ ĉ if Ġ( constant Value . is Boolean ) Ċĉ ĉ { Ċĉĉ ĉ val Ġconstant Bool Ġ= Ġconstant Value . equals ( true Object ) Ċĉĉ ĉ val Ġbool Source Ġ= Ġregister To Test . definition Skipping Moves ( true ) Ċĉĉ ĉ when Ċĉĉ ĉ { Ċĉĉĉ ĉ bool Source . operation () Ġ! is ĠL 2 _ RUN _ INF AL LIB LE _ PR IMIT IVE Ġ-> Ġ{ Ġ} Ċĉĉĉ ĉ primitive Of ( bool Source ) Ġ=== ĠP _ Equality Ġ-> Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ val Ġ( read 1 , Ġread 2 ) Ġ= Ġargs Of ( bool Source ) Ċĉĉĉĉ ĉ // ĠIf Ġeither Ġoperand Ġof ĠP _ Equality Ġis Ġa Ġconstant , Ġrecurse Ġto Ċĉĉĉĉ ĉ // Ġallow Ġdeeper Ġreplacement . Ċĉĉĉĉ ĉ var Ġprevious Constant Ġ= Ġread 1 . constant OrNull () Ċĉĉĉĉ ĉ val Ġprevious Register : ĠL 2 Read Boxed Operand Ċĉĉĉĉ ĉ if Ġ( previous Constant Ġ!== Ġnull ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ previous Register Ġ= Ġread 2 Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ else Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ previous Constant Ġ= Ġread 2 . constant OrNull () Ċĉĉĉĉĉ ĉ previous Register Ġ= Ġread 1 Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ if Ġ( previous Constant Ġ!== Ġnull ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠIt 's Ġa Ġcomparison Ġagainst Ġa Ġconstant . Ġ ĠRe cur se Ġto Ċĉĉĉĉĉ ĉ // Ġdeal Ġwith Ġcomparing Ġthe Ġresult Ġof Ġa Ġprior Ġcomparison Ċĉĉĉĉĉ ĉ // Ġto Ġsome Ġboolean . Ċĉĉĉĉĉ ĉ jump If Equals Constant ( Ċĉĉĉĉĉĉ ĉ previous Register , Ċĉĉĉĉĉĉ ĉ previous Constant , Ċĉĉĉĉĉĉ ĉ if Ġ( constant Bool ) Ġpass Block Ġelse Ġfail Block , Ċĉĉĉĉĉĉ ĉ if Ġ( constant Bool ) Ġfail Block Ġelse Ġpass Block ) Ċĉĉĉĉĉ ĉ return Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ // ĠNeither Ġvalue Ġis Ġa Ġconstant , Ġbut Ġwe Ġcan Ġstill Ġdo Ġthe Ċĉĉĉĉ ĉ // Ġcompare - and - branch Ġwithout Ġinvol ving ĠAv ail Ġb ooleans . Ċĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉ ĉ L 2 _ JUMP _ IF _ OBJECTS _ EQUAL , Ċĉĉĉĉĉ ĉ read 1 , Ċĉĉĉĉĉ ĉ read 2 , Ċĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġpass Block Ġelse Ġfail Block ), Ċĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġfail Block Ġelse Ġpass Block )) Ċĉĉĉĉ ĉ return Ċĉĉĉ ĉ } Ċĉĉĉ ĉ bool Source . operation () Ġ=== ĠL 2 _ JUMP _ IF _ SUB TYPE _ OF _ CONSTANT Ġ-> Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠInstance - of Ġtesting Ġis Ġdone Ġby Ġextracting Ġthe Ġtype Ġand Ċĉĉĉĉ ĉ // Ġtesting Ġif Ġit 's Ġa Ġsubtype . Ġ ĠSee Ġif Ġthe Ġoperand Ġto Ġthe Ċĉĉĉĉ ĉ // Ġis - subtype Ġtest Ġis Ġa Ġget - type Ġinstruction . Ċĉĉĉĉ ĉ val Ġfirst Type Operand Ġ= Ċĉĉĉĉĉ ĉ bool Source . operand < L 2 Read Boxed Operand >( 0 ) Ċĉĉĉĉ ĉ val Ġsecond Constant Operand Ġ= Ċĉĉĉĉĉ ĉ bool Source . operand < L 2 Constant Operand >( 1 ) Ċĉĉĉĉ ĉ val Ġfirst Type Source Ġ= Ċĉĉĉĉĉ ĉ first Type Operand . definition Skipping Moves ( true ) Ċĉĉĉĉ ĉ if Ġ( first Type Source . operation () Ġ=== ĠL 2 _ GET _ TYPE ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠThere 's Ġa Ġget - type Ġfollowed Ġby Ġan Ġis - subtype Ċĉĉĉĉĉ ĉ // Ġfollowed Ġby Ġa Ġcompare - and - branch Ġof Ġthe Ġresult Ċĉĉĉĉĉ ĉ // Ġagainst Ġa Ġconstant Ġboolean . Ġ ĠReplace Ġwith Ġa Ċĉĉĉĉĉ ĉ // Ġbranch - if - kind . Ċĉĉĉĉĉ ĉ val Ġvalue Source Ġ= Ġsource ValueOf ( first Type Source ) Ċĉĉĉĉĉ ĉ jump If Kind Of Constant ( Ċĉĉĉĉĉĉ ĉ value Source , Ċĉĉĉĉĉĉ ĉ second Constant Operand . constant , Ċĉĉĉĉĉĉ ĉ if Ġ( constant Bool ) Ġpass Block Ġelse Ġfail Block , Ċĉĉĉĉĉĉ ĉ if Ġ( constant Bool ) Ġfail Block Ġelse Ġpass Block ) Ċĉĉĉĉĉ ĉ return Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ // ĠPerform Ġa Ġbranch - if - is - subtype - of Ġinstead Ġof Ġchecking Ċĉĉĉĉ ĉ // Ġwhether Ġthe ĠAv ail Ġboolean Ġis Ġtrue Ġor Ġfalse . Ċĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉ ĉ L 2 _ JUMP _ IF _ SUB TYPE _ OF _ CONSTANT , Ċĉĉĉĉĉ ĉ first Type Operand , Ċĉĉĉĉĉ ĉ second Constant Operand , Ċĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġpass Block Ġelse Ġfail Block ), Ċĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġfail Block Ġelse Ġpass Block )) Ċĉĉĉĉ ĉ return Ċĉĉĉ ĉ } Ċĉĉĉ ĉ bool Source . operation () Ġ=== ĠL 2 _ JUMP _ IF _ SUB TYPE _ OF _ OBJECT Ġ-> Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠInstance - of Ġtesting Ġis Ġdone Ġby Ġextracting Ġthe Ġtype Ġand Ċĉĉĉĉ ĉ // Ġtesting Ġif Ġit 's Ġa Ġsubtype . Ġ ĠSee Ġif Ġthe Ġoperand Ġto Ġthe Ċĉĉĉĉ ĉ // Ġis - subtype Ġtest Ġis Ġa Ġget - type Ġinstruction . Ċĉĉĉĉ ĉ val Ġfirst Type Operand Ġ= Ċĉĉĉĉĉ ĉ bool Source . operand < L 2 Read Boxed Operand >( 0 ) Ċĉĉĉĉ ĉ val Ġsecond Type Operand Ġ= Ċĉĉĉĉĉ ĉ bool Source . operand < L 2 Read Boxed Operand >( 0 ) Ċĉĉĉĉ ĉ val Ġfirst Type Source Ġ= Ċĉĉĉĉĉ ĉ first Type Operand . definition Skipping Moves ( true ) Ċĉĉĉĉ ĉ if Ġ( first Type Source . operation () Ġ=== ĠL 2 _ GET _ TYPE ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠThere 's Ġa Ġget - type Ġfollowed Ġby Ġan Ġis - subtype Ċĉĉĉĉĉ ĉ // Ġfollowed Ġby Ġa Ġcompare - and - branch Ġof Ġthe Ġresult Ċĉĉĉĉĉ ĉ // Ġagainst Ġa Ġconstant Ġboolean . Ġ ĠReplace Ġwith Ġa Ċĉĉĉĉĉ ĉ // Ġbranch - if - kind . Ċĉĉĉĉĉ ĉ val Ġvalue Source Ġ= Ġsource ValueOf ( first Type Source ) Ċĉĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉĉ ĉ L 2 _ JUMP _ IF _ KIND _ OF _ OBJECT , Ċĉĉĉĉĉĉ ĉ value Source , Ċĉĉĉĉĉĉ ĉ second Type Operand , Ċĉĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġpass Block Ġelse Ġfail Block ), Ċĉĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġfail Block Ġelse Ġpass Block )) Ċĉĉĉĉĉ ĉ return Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ // ĠPerform Ġa Ġbranch - if - is - subtype - of Ġinstead Ġof Ġchecking Ċĉĉĉĉ ĉ // Ġwhether Ġthe ĠAv ail Ġboolean Ġis Ġtrue Ġor Ġfalse . Ċĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉ ĉ L 2 _ JUMP _ IF _ SUB TYPE _ OF _ OBJECT , Ċĉĉĉĉĉ ĉ first Type Operand , Ċĉĉĉĉĉ ĉ second Type Operand , Ċĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġpass Block Ġelse Ġfail Block ), Ċĉĉĉĉĉ ĉ edge To ( if Ġ( constant Bool ) Ġfail Block Ġelse Ġpass Block )) Ċĉĉĉĉ ĉ return Ċĉĉĉ ĉ } Ċĉĉĉ ĉ // ĠTODO ĠM v G Ġ- ĠWe Ġcould Ġcheck Ġfor Ġother Ġspecial Ġcases Ġhere , Ġlike Ċĉĉĉ ĉ // Ġnumeric Ġless - than . Ġ ĠFor Ġnow , Ġfall Ġthrough Ġto Ġcompare Ġthe Ċĉĉĉ ĉ // Ġvalue Ġagainst Ġthe Ġconstant . Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ // ĠGenerate Ġthe Ġgeneral Ġcase . Ġ ĠIn Ġthe Ġpass Ġcase , Ġflow Ġthrough Ġan Ċĉ ĉ // Ġintermediate Ġblock Ġthat Ġuses Ġa Ġmove Ġto Ġa Ġtemp Ġto Ġforce Ġthe Ġconstant Ċĉ ĉ // Ġvalue Ġto Ġbe Ġvisible Ġin Ġa Ġregister . Ċĉ ĉ val Ġinner Pass Ġ= ĠL 2 BasicBlock (" st reng then Ġto Ġconstant ") Ċĉ ĉ if Ġ( constant Value . is Int Ċĉĉ ĉ && Ġregister To Test . restriction (). contained ByType ( int 3 2 )) Ċĉ ĉ { Ċĉĉ ĉ // ĠThe Ġconstant Ġand Ġthe Ġvalue Ġare Ġboth Ġint 3 2 s . Ġ ĠUse Ġthe Ġqu icker Ġint Ċĉĉ ĉ // Ġtest , Ġun box ing Ġthe Ġint Ġregister Ġif Ġneeded . Ċĉĉ ĉ val Ġtruly Un reachable Ġ= ĠL 2 BasicBlock (" tr uly Ġunreachable ") Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ JUMP _ IF _ COMPARE _ INT . equal , Ċĉĉĉ ĉ generator . readInt ( Ċĉĉĉĉ ĉ L 2 Semantic Un boxed Int ( register To Test . semantic Value ()), Ċĉĉĉĉ ĉ tr uly Un reachable ), Ċĉĉĉ ĉ generator . un boxed Int Constant ( Ċĉĉĉĉ ĉ ( constant Value Ġas ĠAv ail Object ). extract Int ), Ċĉĉĉ ĉ edge To ( inner Pass ), Ċĉĉĉ ĉ edge To ( fail Block )) Ċĉĉ ĉ assert ( tr uly Un reachable . pre decessor Edges (). isEmpty ()) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ JUMP _ IF _ EQUAL S _ CONSTANT , Ċĉĉĉ ĉ register To Test , Ċĉĉĉ ĉ L 2 Constant Operand ( constant Value ), Ċĉĉĉ ĉ edge To ( inner Pass ), Ċĉĉĉ ĉ edge To ( fail Block )) Ċĉ ĉ } Ċĉ ĉ generator . start Block ( inner Pass ) Ċĉ ĉ val Ġsemantic Constant Ġ= ĠL 2 Semantic Constant ( constant Value ) Ċĉ ĉ if Ġ(! generator . current Manifest (). has Semantic Value ( semantic Constant )) Ċĉ ĉ { Ċĉĉ ĉ generator . move Register ( Ċĉĉĉ ĉ L 2 _ MOVE . boxed , Ċĉĉĉ ĉ register To Test . semantic Value (), Ċĉĉĉ ĉ semantic Constant ) Ċĉ ĉ } Ċĉ ĉ generator . jump To ( pass Block ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġcode Ġto Ġinvoke Ġa Ġfunction Ġin Ġa Ġregister Ġwith Ġarguments Ġin Ċĉ Ġ* Ġregisters . Ġ ĠAlso Ġbranch Ġto Ġthe Ġappropriate Ġre ification Ġand Ġreturn Ġclauses Ċĉ Ġ* Ġdepending Ġon Ġwhether Ġthe Ġreturned Ġvalue Ġis Ġguaranteed Ġto Ġsatisfy Ġthe Ċĉ Ġ* Ġexpected Type Ġor Ġnot . Ċĉ Ġ* Ċĉ Ġ* ĠThe Ġcode Ġgeneration Ġposition Ġis Ġnever Ġ[ L 2 Generator . currently Reach able ] Ċĉ Ġ* Ġafter Ġthis Ġ( Kotlin ) Ġmethod Ġcompletes . Ċĉ Ġ* Ċĉ Ġ* ĠThe Ġfinal Ġoutput Ġfrom Ġthe Ġentire Ġpol ymorphic Ġcall Ġwill Ġalways Ġbe Ġfully Ċĉ Ġ* Ġst reng then ed Ġto Ġthe Ġintersection Ġof Ġthe ĠVM - gu arante ed Ġtype Ġand Ġthe Ċĉ Ġ* Ġexpected Type Ġof Ġthe Ġcall Site Helper , Ġalthough Ġan Ġexplicit Ġtype Ġcheck Ġmay Ċĉ Ġ* Ġhave Ġto Ġbe Ġgenerated Ġalong Ġsome Ġpaths . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġfunction To Call Reg Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġcontaining Ġthe Ġfunction Ġto Ġinvoke . Ċĉ Ġ* Ġ@ param Ġarguments Ċĉ Ġ* ĠĠ ĠThe Ġ[ List ] Ġof Ġ[ L 2 Read Boxed Operand ] s Ġthat Ġsupply Ġarguments Ġto Ġthe Ċĉ Ġ* ĠĠ Ġfunction . Ċĉ Ġ* Ġ@ param Ġtry To Generate Special Primitive Invocation Ċĉ Ġ* ĠĠ Ġ` true ` Ġif Ġan Ġattempt Ġshould Ġbe Ġmade Ġto Ġgenerate Ġa Ġcustomized Ċĉ Ġ* ĠĠ Ġ[ L 2 Instruction ] Ġsequence Ġfor Ġa Ġ[ Primitive ] Ġinvocation , Ġ` false ` Ċĉ Ġ* ĠĠ Ġotherwise . ĠThis Ġshould Ġgenerally Ġbe Ġ` false ` Ġonly Ġto Ġprevent Ġrecursion Ċĉ Ġ* ĠĠ Ġfrom Ġ` Primitive ` Ġcustomization . Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠInformation Ġabout Ġthe Ġcall Ġbeing Ġgenerated . Ċĉ Ġ*/ Ċ ĉ fun Ġgenerate General Function Invocation ( Ċĉ ĉ function To Call Reg : ĠL 2 Read Boxed Operand , Ċĉ ĉ arguments : ĠList < L 2 Read Boxed Operand >, Ċĉ ĉ try To Generate Special Primitive Invocation : ĠBoolean , Ċĉ ĉ call Site Helper : ĠCall Site Helper ) Ċ ĉ { Ċĉ ĉ assert ( function To Call Reg . type (). is Subtype Of ( most General FunctionType ())) ĊĊĉ ĉ // ĠSan ity Ġcheck Ġthe Ġnumber Ġof Ġarguments Ġagainst Ġthe Ġfunction . Ġ ĠThe Ċĉ ĉ // Ġfunction Ġtype 's Ġacceptable Ġarguments Ġtuple Ġtype Ġmay Ġbe Ġbottom , Ċĉ ĉ // Ġindicating Ġthe Ġsize Ġis Ġnot Ġknown . Ġ ĠIt Ġmay Ġalso Ġbe Ġa Ġsingular Ġinteger Ċĉ ĉ // Ġrange Ġ( e . g ., Ġ[ 3 .. 3 ]), Ġindicating Ġexactly Ġhow Ġmany Ġarguments Ġmust Ġbe Ċĉ ĉ // Ġsupplied . Ġ ĠIf Ġit 's Ġa Ġvariable Ġsize , Ġthen Ġby Ġthe Ġargument Ċĉ ĉ // Ġcontr av ari ance Ġrules , Ġit Ġwould Ġrequire Ġeach Ġ( not Ġjust Ġany ) Ġof Ġthose Ċĉ ĉ // Ġsizes Ġon Ġevery Ġcall , Ġwhich Ġis Ġa Ġcontr ad iction , Ġalthough Ġit 's Ġallowed Ċĉ ĉ // Ġas Ġa Ġden ormal ized Ġun instant iable Ġtype . Ġ ĠFor Ġnow Ġjust Ġtreat Ġa Ġspread Ċĉ ĉ // Ġof Ġsizes Ġlike Ġbottom Ġ( i . e ., Ġthe Ġcount Ġis Ġnot Ġknown ). Ċĉ ĉ val Ġargument Count Ġ= Ġarguments . size Ċĉ ĉ val Ġsize Range Ġ= Ġfunction To Call Reg . type (). args Tuple Type . size Range Ċĉ ĉ assert ( Ċĉĉ ĉ size Range . is Bottom Ċĉĉĉ ĉ || Ġ! size Range . lower Bound . equals ( size Range . upper Bound ) Ċĉĉĉ ĉ || Ġsize Range . range Includes Long ( argument Count . to Long ())) Ċĉ ĉ val Ġguaranteed Result Type : ĠA _ Type Ċĉ ĉ val Ġraw Function Ġ= Ġdetermine Raw Function ( function To Call Reg ) Ċĉ ĉ val Ġprimitive Ġ= Ġraw Function ?. code Primitive () Ċĉ ĉ if Ġ( primitive Ġ!== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ val Ġargs Tuple Type Ġ= Ġraw Function . function Type (). args Tuple Type Ċĉĉ ĉ val Ġargument Types : ĠList < A _ Type > Ċĉĉ ĉ val Ġgenerated : ĠBoolean Ċĉĉ ĉ if Ġ( try To Generate Special Primitive Invocation ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠWe Ġare Ġnot Ġrecur sing Ġhere Ġfrom Ġa Ġprimitive Ġoverride Ġof Ċĉĉĉ ĉ // Ġtry To Generate Special Primitive Invocation (), Ġso Ġtry Ġto Ġgenerate Ċĉĉĉ ĉ // Ġa Ġspecial Ġprimitive Ġinvocation . Ġ ĠNote Ġthat Ġthis Ġlookup Ġwas Ċĉĉĉ ĉ // Ġmon omorphic Ġ* in Ġthe Ġevent Ġof Ġsuccess *, Ġso Ġwe Ġcan Ġsafely Ċĉĉĉ ĉ // Ġtight en Ġthe Ġargument Ġtypes Ġhere Ġto Ġconform Ġto Ġthe Ġonly Ċĉĉĉ ĉ // Ġpossible Ġfound Ġfunction . Ċĉĉĉ ĉ val Ġmanifest Ġ= Ġcurrent Manifest () Ċĉĉĉ ĉ val Ġstrong Arguments Ġ= Ġ( 0 Ġuntil Ġargument Count ). map Ġ{ Ċĉĉĉĉ ĉ val Ġarg Ġ= Ġarguments [ it ] Ċĉĉĉĉ ĉ val Ġarg Semantic Value Ġ= Ġarg . semantic Value () Ċĉĉĉĉ ĉ val Ġstrong Restriction Ġ= Ġarg . restriction () Ċĉĉĉĉĉ ĉ . intersection ( manifest . restriction For ( arg Semantic Value )) Ċĉĉĉĉĉ ĉ . intersection WithType ( args Tuple Type . type AtIndex ( it Ġ+ Ġ 1 )) Ċĉĉĉĉ ĉ manifest . set Restriction ( arg Semantic Value , Ġstrong Restriction ) Ċĉĉĉĉ ĉ L 2 Read Boxed Operand ( Ċĉĉĉĉĉ ĉ arg Semantic Value , Ġstrong Restriction , Ġmanifest ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ argument Types Ġ= Ġstrong Arguments . map Ġ{ Ġit . type () Ġ} Ċĉĉĉ ĉ generated Ġ= Ġtry To Generate Special Invocation ( Ċĉĉĉĉ ĉ function To Call Reg , Ċĉĉĉĉ ĉ raw Function , Ċĉĉĉĉ ĉ primitive , Ċĉĉĉĉ ĉ strong Arguments , Ċĉĉĉĉ ĉ call Site Helper ) Ċĉĉ ĉ } Ċĉĉ ĉ else Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠWe Ġare Ġrecur sing Ġhere Ġfrom Ġa Ġprimitive Ġoverride Ġof Ċĉĉĉ ĉ // Ġtry To Generate Special Primitive Invocation (), Ġso Ġdo Ġnot Ċĉĉĉ ĉ // Ġrecurse Ġagain ; Ġjust Ġgenerate Ġthe Ġbest Ġinvocation Ġpossible Ċĉĉĉ ĉ // Ġgiven Ġwhat Ġwe Ġknow . Ċĉĉĉ ĉ argument Types Ġ= Ġarguments . map Indexed Ġ{ Ġzero Index , Ġargument Ġ-> Ċĉĉĉĉ ĉ argument . type (). type Intersection ( Ċĉĉĉĉĉ ĉ args Tuple Type . type AtIndex ( zero Index Ġ+ Ġ 1 )) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ if Ġ( primitive . fal lib ility For Argument Types ( argument Types ) Ċĉĉĉĉ ĉ === ĠCall Site Cannot Fail ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ // ĠThe Ġprimitive Ġcannot Ġfail Ġat Ġthis Ġsite . ĠOutput Ġcode Ċĉĉĉĉ ĉ // Ġto Ġrun Ġthe Ġprimitive Ġas Ġsimply Ġas Ġpossible , Ġfeed ing Ġa Ċĉĉĉĉ ĉ // Ġregister Ġwith Ġas Ġstrong Ġa Ġtype Ġas Ġpossible . Ċĉĉĉĉ ĉ var Ġresult Type Ġ= Ġprimitive . returnType Gu arante edBy VM ( Ċĉĉĉĉĉ ĉ raw Function , Ġargument Types ) Ċĉĉĉĉ ĉ if Ġ( result Type . is Bottom ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠEven Ġthough Ġthe ĠP _ Invoke With Tuple Ġprimitive Ġcan 't Ċĉĉĉĉĉ ĉ // Ġfail , Ġthe Ġultimately Ġcalled Ġfunction Ġwon 't Ġreturn . Ċĉĉĉĉĉ ĉ // ĠIn Ġthis Ġcase , Ġwe aken Ġthe Ġresult Type Ġto Ġavoid ĠâĬ ¥ , Ġjust Ċĉĉĉĉĉ ĉ // Ġto Ġkeep Ġthe Ġcall Ġm achinery Ġhappy . Ċĉĉĉĉĉ ĉ result Type Ġ= ĠTypes . ANY . o Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ val Ġwriter Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉĉĉĉ ĉ restriction ForType ( result Type , ĠBO X ED _ FLAG )) Ċĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉ ĉ L 2 _ RUN _ INF AL LIB LE _ PR IMIT IVE . for Primitive ( primitive ), Ċĉĉĉĉĉ ĉ L 2 Constant Operand ( raw Function ), Ċĉĉĉĉĉ ĉ L 2 Primitive Operand ( primitive ), Ċĉĉĉĉĉ ĉ L 2 Read Boxed Vector Operand ( arguments ), Ċĉĉĉĉĉ ĉ writer ) Ċĉĉĉĉ ĉ call Site Helper . use Answer ( read Boxed ( writer )) Ċĉĉĉĉ ĉ generated Ġ= Ġtrue Ċĉĉĉ ĉ } Ċĉĉĉ ĉ else Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ generated Ġ= Ġfalse Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ( generated ) Ċĉĉ ĉ { Ċĉĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉĉ ĉ // ĠThe Ġraw Ġfunction Ġis Ġknown . Ġ ĠAsk Ġthe Ġprimitive Ġwhat Ġit Ġguarantees Ċĉĉ ĉ // Ġif Ġsuccessful , Ġand Ġtake Ġthe Ġunion Ġwith Ġwhat Ġthe Ġraw Ġfunction Ġsays Ċĉĉ ĉ // Ġit 'll Ġproduce Ġif Ġthe Ġprimitive Ġis Ġun successful . Ġ ĠTake Ġinto Ċĉĉ ĉ // Ġaccount Ġwhether Ġthe Ġprimitive Ġwill Ġnever , Ġalways , Ġor Ġsometimes Ċĉĉ ĉ // Ġfail Ġfor Ġthe Ġgiven Ġargument Ġtypes . Ċĉĉ ĉ gu arante ed Result Type Ġ= Ċĉĉĉ ĉ when Ġ( primitive . fal lib ility For Argument Types ( argument Types )) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ Call Site Cannot Fail Ġ-> Ġprimitive . returnType Gu arante edBy VM ( Ċĉĉĉĉĉ ĉ raw Function , Ġargument Types ) Ċĉĉĉĉ ĉ Call Site Must Fail Ġ-> Ċĉĉĉĉĉ ĉ raw Function . returnType If Primitive Fails Ċĉĉĉĉ ĉ else Ġ-> Ġraw Function . returnType If Primitive Fails . type Union ( Ċĉĉĉĉĉ ĉ primitive . returnType Gu arante edBy VM ( Ċĉĉĉĉĉĉ ĉ raw Function , Ġargument Types )) Ċĉĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ // ĠExact Ġfunction Ġwas Ġunknown , Ġor Ġit Ġwasn 't Ġa Ġprimitive . Ċĉĉ ĉ gu arante ed Result Type Ġ= Ġfunction To Call Reg . type (). returnType Ċĉ ĉ } ĊĊĉ ĉ // ĠThe Ġfunction Ġisn 't Ġknown Ġto Ġbe Ġa Ġparticular Ġprimitive Ġfunction , Ġor Ċĉ ĉ // Ġthe Ġprimitive Ġwasn 't Ġable Ġto Ġgenerate Ġspecial Ġcode Ġfor Ġit , Ġso Ġjust Ċĉ ĉ // Ġinvoke Ġit Ġlike Ġa Ġnon - primitive . Ċĉ ĉ val Ġskip Check Ġ= Ċĉĉ ĉ gu arante ed Result Type . is Subtype Of ( call Site Helper . expected Type ) Ċĉ ĉ val Ġconstant Function : ĠA _ Function ? Ġ= Ġfunction To Call Reg . constant OrNull () Ċĉ ĉ val Ġcan Return Ġ= Ġ! gu arante ed Result Type . is Vac u ous Type Ċĉ ĉ val Ġsuccess Block Ġ= Ġgenerator . create BasicBlock (" successful Ġinvocation ") Ċĉ ĉ val Ġtarget Block Ġ= Ċĉĉ ĉ when Ċĉĉ ĉ { Ċĉĉĉ ĉ ! can Return Ġ-> Ġcall Site Helper . on Re ification Un return able Ċĉĉĉ ĉ skip Check Ġ-> Ġcall Site Helper . on Re ification No Check Ċĉĉĉ ĉ else Ġ-> Ġcall Site Helper . on Re ification With Check Ċĉĉ ĉ } Ċĉ ĉ val Ġre ification Target Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " invoke Ġre ification Ġtarget ", Ġtarget Block . zone ) Ċĉ ĉ val Ġwrite Result Ġ= Ġwrite Slot ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ if Ġ( skip Check ) Ġpc Ġelse Ġpc Ġ- Ġ 1 , Ċĉĉ ĉ restriction ForType ( Ċĉĉĉ ĉ if Ġ( gu arante ed Result Type . is Bottom ) ĠTypes . ANY . o Ġ// Ġunreachable Ċĉĉĉ ĉ else Ġguaranteed Result Type , ĠBO X ED _ FLAG )) Ċĉ ĉ val Ġunreachable Ġ= ĠL 2 BasicBlock (" unreachable ") Ċĉ ĉ if Ġ( constant Function Ġ!== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ IN VOKE _ CONSTANT _ FUNCTION , Ċĉĉĉ ĉ L 2 Constant Operand ( constant Function ), Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( arguments ), Ċĉĉĉ ĉ write Result , Ċĉĉĉ ĉ edge To ( if Ġ( can Return ) Ġsuccess Block Ġelse Ġunreachable ), Ċĉĉĉ ĉ edge To ( re ification Target )) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ IN VOKE , Ċĉĉĉ ĉ function To Call Reg , Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( arguments ), Ċĉĉĉ ĉ write Result , Ċĉĉĉ ĉ edge To ( if Ġ( can Return ) Ġsuccess Block Ġelse Ġunreachable ), Ċĉĉĉ ĉ edge To ( re ification Target )) Ċĉ ĉ } Ċĉ ĉ generator . start Block ( unreachable ) Ċĉ ĉ generator . add Instruction ( L 2 _ UN RE ACH ABLE _ CODE ) ĊĊĉ ĉ generator . start Block ( re ification Target ) Ċĉ ĉ generator . add Instruction ( Ċĉĉ ĉ L 2 _ ENTER _ L 2 _ CHUNK , Ċĉĉ ĉ L 2 Int Immediate Operand ( Ċĉĉĉ ĉ Chunk EntryPoint . TRAN SI ENT . offset In Default Chunk ), Ċĉĉ ĉ L 2 Comment Operand (" Transient Ġ- Ġcannot Ġbe Ġinvalid .")) Ċĉ ĉ generator . jump To ( target Block ) ĊĊĉ ĉ generator . start Block ( success Block ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ generator . jump To ( Ċĉĉĉ ĉ if Ġ( skip Check ) Ġcall Site Helper . after Call No Check Ċĉĉĉ ĉ else Ġcall Site Helper . after Call With Check ) Ċĉĉ ĉ assert (! generator . currently Reach able ()) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġcode Ġto Ġperform Ġa Ġtype Ġcheck Ġof Ġthe Ġtop - of - stack Ġregister Ċĉ Ġ* Ġagainst Ġthe Ġgiven Ġexpected Type Ġ( an Ġ[ A _ Type ] Ġthat Ġhas Ġbeen Ġst reng then ed Ġby Ċĉ Ġ* Ġsemantic Ġrestrictions ). Ċĉ Ġ* Ċĉ Ġ* ĠIf Ġthe Ġcheck Ġfails , Ġinvoke Ġthe Ġout - of - line ĠâĬ ¥ - valu ed Ġhelper Ġmethod Ċĉ Ġ* Ġ[ Interpreter . report Wrong ReturnType ], Ġpassing Ġenough Ġinformation Ġfor Ġit Ġto Ċĉ Ġ* Ġbe Ġable Ġto Ġconstruct Ġa Ġre ified Ġcontinuation Ġif Ġrequired . Ċĉ Ġ* Ċĉ Ġ* ĠIf Ġthe Ġcheck Ġpasses , Ġthe Ġvalue Ġwill Ġbe Ġst reng then ed Ġin Ġthe Ġtop - of - stack Ċĉ Ġ* Ġregister . Ċĉ Ġ* Ċĉ Ġ* ĠIt 's Ġincorrect Ġto Ġcall Ġthis Ġif Ġthe Ġregister 's Ġtype Ġis Ġalready Ġstrong Ċĉ Ġ* Ġenough Ġto Ġsatisfy Ġthe Ġexpected Type . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġexpected Type Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Type ] Ġto Ġcheck Ġthe Ġvalue Ġagainst . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġgenerate ReturnType Check ( expected Type : ĠA _ Type ) Ċ ĉ { Ċĉ ĉ // ĠThe Ġunchecked Ġreturn Ġvalue Ġis Ġassociated Ġwith Ġthe Ġny bble Ġjust Ġbefore Ċĉ ĉ // Ġthe Ġinstruction Ġafter Ġthe Ġcall Ġ( which Ġtakes Ġat Ġleast Ġthree Ġny bb les ). Ċĉ ĉ val Ġsemantic Value Ġ= Ċĉĉ ĉ create Semantic Slot ( stack p , Ġpc Ġ- Ġ 1 ) Ċĉ ĉ val Ġunchecked Value Read Ġ= Ġcurrent Manifest (). read Boxed ( semantic Value ) Ċĉ ĉ if Ġ( unchecked Value Read . type (). is Vac u ous Type ) Ċĉ ĉ { Ċĉĉ ĉ // ĠThere Ġare Ġno Ġreturn Ġvalues Ġpossible , Ġso Ġwe Ġcan 't Ġget Ġhere . Ġ ĠIt Ċĉĉ ĉ // Ġwould Ġbe Ġwrong Ġto Ġdo Ġthis Ġbased Ġon Ġthe Ġexpected Type Ġbeing Ġbottom , Ċĉĉ ĉ // Ġsince Ġthat 's Ġonly Ġan Ġerr one ous Ġsemantic Ġrestriction , Ġnot Ġa ĠVM Ċĉĉ ĉ // Ġproblem . Ċĉĉ ĉ // ĠNOTE Ġthat Ġthis Ġtest Ġtermin ates Ġa Ġmut ual Ġrecursion Ġbetween Ġthis Ċĉĉ ĉ // Ġmethod Ġand Ġgenerate General Function Invocation (). Ċĉĉ ĉ generator . add Un reachable Code () Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ // ĠCheck Ġthe Ġreturn Ġvalue Ġagainst Ġthe Ġexpected Type . Ċĉ ĉ val Ġpassed Check Ġ= Ġgenerator . create BasicBlock (" passed Ġreturn Ġcheck ") Ċĉ ĉ val Ġfailed Check Ġ= Ġgenerator . create BasicBlock (" failed Ġreturn Ġcheck ") Ċĉ ĉ if Ġ(! unchecked Value Read . restriction (). intersect sType ( expected Type )) Ċĉ ĉ { Ċĉĉ ĉ // ĠIt 's Ġimpossible Ġto Ġreturn Ġa Ġvalid Ġvalue Ġhere , Ġsince Ġthe Ġvalue 's Ċĉĉ ĉ // Ġtype Ġbound Ġand Ġthe Ġexpected Ġtype Ġdon 't Ġintersect . Ġ ĠAlways Ġinvoke Ċĉĉ ĉ // Ġthe Ġbad Ġtype Ġhandler . Ċĉĉ ĉ generator . jump To ( failed Check ) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ assert (! unchecked Value Read . type (). is Subtype Of ( expected Type )) Ċĉĉĉ ĉ { Ġ" At tempting Ġto Ġcreate Ġunnecessary Ġtype Ġcheck " Ġ} Ċĉĉ ĉ jump If Kind Of Constant ( Ċĉĉĉ ĉ unchecked Value Read , Ġexpected Type , Ġpassed Check , Ġfailed Check ) Ċĉ ĉ } ĊĊĉ ĉ // ĠThe Ġtype Ġcheck Ġfailed , Ġso Ġreport Ġit . Ċĉ ĉ generator . start Block ( failed Check ) Ċĉ ĉ generator . add Instruction ( Ċĉĉ ĉ L 2 _ IN VOKE _ INVALID _ MESSAGE _ RESULT _ FUNCTION , Ċĉĉ ĉ unchecked Value Read , Ċĉĉ ĉ L 2 Constant Operand ( expected Type ), Ċĉĉ ĉ L 2 Int Immediate Operand ( pc ), Ċĉĉ ĉ L 2 Int Immediate Operand ( stack p ), Ċĉĉ ĉ L 2 Read Boxed Vector Operand ( Ċĉĉĉ ĉ ( 1 .. num Slots ). map Ġ{ Ċĉĉĉĉ ĉ when Ġ( it ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠMake Ġit Ġlook Ġlike Ġthe Ġexpected Type Ġhas Ġbeen Ġpushed . Ċĉĉĉĉĉ ĉ stack p Ġ-> Ġgenerator . boxed Constant ( expected Type ) Ċĉĉĉĉĉ ĉ else Ġ-> Ġread Slot ( it ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ })) Ċĉ ĉ assert (! generator . currently Reach able ()) ĊĊĉ ĉ // ĠGenerate Ġthe Ġmuch Ġmore Ġlikely Ġpassed - check Ġflow . Ċĉ ĉ generator . start Block ( passed Check ) Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ force Slot Register ( Ċĉĉĉ ĉ stack p , Ċĉĉĉ ĉ pc , Ċĉĉĉ ĉ unchecked Value Read . semantic Value (), Ċĉĉĉ ĉ unchecked Value Read . restriction (). intersection ( Ċĉĉĉĉ ĉ restriction ForType ( expected Type , ĠBO X ED _ FLAG ))) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġcode Ġto Ġtest Ġthe Ġvalue Ġin Ġ` value Read ` Ġagainst Ġthe Ġconstant Ċĉ Ġ* Ġ` expected Type `, Ġjump ing Ġto Ġ` passed Check ` Ġif Ġit Ġcon forms , Ġor Ġ` failed Check ` Ċĉ Ġ* Ġotherwise . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġvalue Read Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġthat Ġprovides Ġthe Ġvalue Ġto Ġcheck . Ċĉ Ġ* Ġ@ param Ġexpected Type Ċĉ Ġ* ĠĠ ĠThe Ġexact Ġ[ A _ Type ] Ġto Ġcheck Ġthe Ġvalue Ġagainst . Ċĉ Ġ* Ġ@ param Ġpassed Check Ċĉ Ġ* ĠĠ ĠWhere Ġto Ġjump Ġif Ġthe Ġvalue 's Ġtype Ġis Ġof Ġthe Ġexpected Ġtype . Ċĉ Ġ* Ġ@ param Ġfailed Check Ċĉ Ġ* ĠĠ ĠWhere Ġto Ġjump Ġif Ġthe Ġvalue 's Ġtype Ġis Ġnot Ġof Ġthe Ġexpected Ġtype . Ċĉ Ġ*/ Ċ ĉ fun Ġjump If Kind Of Constant ( Ċĉ ĉ value Read : ĠL 2 Read Boxed Operand , Ċĉ ĉ expected Type : ĠA _ Type , Ċĉ ĉ passed Check : ĠL 2 BasicBlock , Ċĉ ĉ failed Check : ĠL 2 BasicBlock ) Ċ ĉ { Ċĉ ĉ // ĠCheck Ġfor Ġspecial Ġcases . Ċĉ ĉ if Ġ( value Read . restriction (). contained ByType ( expected Type )) Ċĉ ĉ { Ċĉĉ ĉ generator . jump To ( passed Check ) Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ if Ġ(! value Read . restriction (). intersect sType ( expected Type )) Ċĉ ĉ { Ċĉĉ ĉ generator . jump To ( failed Check ) Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ // ĠTrace Ġback Ġto Ġthe Ġdefinition Ġof Ġthe Ġread 's Ġregister , Ġto Ġsee Ġif Ġit 's Ċĉ ĉ // Ġa Ġfunction Ġthat 's Ġcreated Ġin Ġthe Ġcurrent Ġchunk . Ċĉ ĉ val Ġraw Function Ġ= Ġdetermine Raw Function ( value Read ) Ċĉ ĉ if Ġ( raw Function Ġ!== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ val Ġexact Kind Ġ= Ġraw Function . function Type () Ċĉĉ ĉ if Ġ( exact Kind . is Subtype Of ( expected Type )) Ċĉĉ ĉ { Ċĉĉĉ ĉ generator . jump To ( passed Check ) Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ(! expected Type . is Enumeration ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠDon 't Ġcheck Ġfor Ġvac u ous Ġtype Ġintersection Ġhere . Ġ ĠWe Ġknow Ġthe Ċĉĉĉ ĉ // Ġexact Ġkind , Ġand Ġit 's Ġspecifically Ġ* not * Ġa Ġsubtype Ġof Ġthe Ċĉĉĉ ĉ // Ġexpected Type , Ġwhich Ġis Ġalso Ġa Ġkind Ġ( i . e ., Ġnot Ġan Ċĉĉĉ ĉ // Ġenumeration ). Ċĉĉĉ ĉ generator . jump To ( failed Check ) Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ // ĠWe Ġcan 't Ġpin Ġit Ġdown Ġstatic ally , Ġso Ġdo Ġthe Ġdynamic Ġcheck . Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ JUMP _ IF _ KIND _ OF _ CONSTANT , Ċĉĉ ĉ value Read , Ċĉĉ ĉ L 2 Constant Operand ( expected Type ), Ċĉĉ ĉ edge To ( passed Check ), Ċĉĉ ĉ edge To ( failed Check )) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠAttempt Ġto Ġcreate Ġa Ġmore Ġspecific Ġinstruction Ġsequence Ġthan Ġjust Ġan Ċĉ Ġ* Ġ[ L 2 _ IN VOKE ]. Ġ ĠIn Ġparticular , Ġsee Ġif Ġthe Ġ` function To Call Reg ` Ġis Ġknown Ġto Ċĉ Ġ* Ġcontain Ġa Ġconstant Ġfunction Ġ( a Ġcommon Ġcase ) Ġwhich Ġis Ġan Ġinline able Ċĉ Ġ* Ġprimitive , Ġand Ġif Ġso , Ġdelegate Ġthis Ġopportunity Ġto Ġthe Ġprimitive . Ċĉ Ġ* Ċĉ Ġ* ĠWe Ġmust Ġeither Ġanswer Ġ` false ` Ġand Ġgenerate Ġno Ġcode , Ġor Ġanswer Ġ` true ` Ġand Ċĉ Ġ* Ġgenerate Ġcode Ġthat Ġhas Ġthe Ġsame Ġeffect Ġas Ġhaving Ġrun Ġthe Ġfunction Ġin Ġthe Ċĉ Ġ* Ġregister Ġwithout Ġfear Ġof Ġre ification Ġor Ġab normal Ġcontrol Ġflow . Ġ ĠA Ġfol ded Ċĉ Ġ* Ġprimitive , Ġfor Ġexample , Ġcan Ġgenerate Ġa Ġsimple Ġ[ L 2 _ MOVE _ CONSTANT ] Ġinto Ġthe Ċĉ Ġ* Ġtop - of - stack Ġregister Ġand Ġanswer Ġtrue . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġfunction To Call Reg Ċĉ Ġ* ĠĠ ĠThe Ġregister Ġcontaining Ġthe Ġ[ function ][ A _ Function ] Ġto Ġinvoke . Ċĉ Ġ* Ġ@ param Ġraw Function Ċĉ Ġ* ĠĠ ĠThe Ġ[ raw Ġfunction ][ A _ Raw Function ] Ġbeing Ġinvoked . Ċĉ Ġ* Ġ@ param Ġprimitive Ċĉ Ġ* ĠĠ ĠThe Ġ[ Primitive ] Ġbeing Ġinvoked . Ċĉ Ġ* Ġ@ param Ġarguments Ċĉ Ġ* ĠĠ ĠThe Ġarguments Ġto Ġsupply Ġto Ġthe Ġfunction . Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠInformation Ġabout Ġthe Ġmethod Ġcall Ġsite Ġhaving Ġits Ġdispatch Ġtree Ċĉ Ġ* ĠĠ Ġin lined . Ġ ĠIt Ġalso Ġcontains Ġmerge Ġpoints Ġfor Ġthis Ġcall , Ġso Ġif Ġa Ġspecific Ċĉ Ġ* ĠĠ Ġcode Ġgeneration Ġhappens Ġit Ġshould Ġjump Ġto Ġone Ġof Ġthese . Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ Ġ` true ` Ġif Ġa Ġspecial Ġinstruction Ġsequence Ġwas Ġgenerated , Ġ` false ` Ċĉ Ġ* ĠĠ Ġotherwise . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġtry To Generate Special Invocation ( Ċĉ ĉ function To Call Reg : ĠL 2 Read Boxed Operand , Ċĉ ĉ raw Function : ĠA _ Raw Function , Ċĉ ĉ primitive : ĠPrimitive , Ċĉ ĉ arguments : ĠList < L 2 Read Boxed Operand >, Ċĉ ĉ call Site Helper : ĠCall Site Helper ): ĠBoolean Ċ ĉ { Ċĉ ĉ val Ġargument Count Ġ= Ġarguments . size Ċĉ ĉ if Ġ( primitive . has Flag ( Flag . Can Fold )) Ċĉ ĉ { Ċĉĉ ĉ // ĠIt Ġcan Ġbe Ġfol ded , Ġif Ġsupplied Ġwith Ġconstants . Ċĉĉ ĉ val Ġconstants Ġ= Ġmutable ListOf < Avail Object >() Ċĉĉ ĉ for Ġ( reg Read Ġin Ġarguments ) Ċĉĉ ĉ { Ċĉĉĉ ĉ val Ġconstant Ġ= Ġreg Read . constant OrNull () Ġ?: Ġbreak Ċĉĉĉ ĉ constants . add ( constant ) Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ( constants . size Ġ== Ġargument Count ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠFold Ġthe Ġprimitive . Ġ ĠA Ġfold able Ġprimitive Ġmust Ġnot Ċĉĉĉ ĉ // Ġrequire Ġaccess Ġto Ġthe Ġen closing Ġfunction Ġor Ġits Ġcode . Ċĉĉĉ ĉ val Ġsaved Function Ġ= Ġinterpreter . function Ċĉĉĉ ĉ interpreter . function Ġ= Ġnull Ċĉĉĉ ĉ val Ġsaved Debug Mode String Ġ= Ġinterpreter . debug Mode String Ċĉĉĉ ĉ if Ġ( Interpreter . debug L 2 ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ log ( Ċĉĉĉĉĉ ĉ Interpreter . logger Debug L 2 , Ċĉĉĉĉĉ ĉ Level . FIN ER , Ċĉĉĉĉĉ ĉ "{ 0 } FOLD Ġ{ 1 } :", Ċĉĉĉĉĉ ĉ interpreter . debug Mode String , Ċĉĉĉĉĉ ĉ primitive . name ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ val Ġsuccess : ĠPrimitive . Result Ġ= Ġtry Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ interpreter . args Buffer . clear () Ċĉĉĉĉ ĉ interpreter . args Buffer . addAll ( constants ) Ċĉĉĉĉ ĉ primitive . attempt ( interpreter ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ finally Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ interpreter . debug Mode String Ġ= Ġsaved Debug Mode String Ċĉĉĉĉ ĉ interpreter . function Ġ= Ġsaved Function Ċĉĉĉ ĉ } Ċĉĉĉ ĉ if Ġ( success Ġ=== ĠPrimitive . Result . SUCCESS ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ call Site Helper . use Answer ( Ċĉĉĉĉĉ ĉ generator . boxed Constant ( Ċĉĉĉĉĉĉ ĉ interpreter . get Latest Result (). make Immutable ())) Ċĉĉĉĉ ĉ return Ġtrue Ċĉĉĉ ĉ } Ċĉĉĉ ĉ assert ( success Ġ=== ĠPrimitive . Result . FAILURE ) Ċĉĉĉ ĉ assert (! primitive . has Flag ( Flag . Cannot Fail )) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // ĠThe Ġprimitive Ġcan 't Ġbe Ġfol ded , Ġso Ġlet Ġit Ġgenerate Ġits Ġown Ġcode Ċĉ ĉ // Ġequivalent Ġto Ġinvocation . Ċĉ ĉ val Ġsignature Tuple Type Ġ= Ġraw Function . function Type (). args Tuple Type Ċĉ ĉ val Ġnarrow ed Arg Types Ġ= Ġmutable ListOf < A _ Type >() Ċĉ ĉ val Ġnarrow ed Arguments Ġ= Ġmutable ListOf < L 2 Read Boxed Operand >() Ċĉ ĉ for Ġ( i Ġin Ġ 0 Ġuntil Ġargument Count ) Ċĉ ĉ { Ċĉĉ ĉ val Ġargument Ġ= Ġgenerator . read Boxed ( arguments [ i ]. semantic Value ()) Ċĉĉ ĉ assert ( Ċĉĉĉ ĉ argument . restriction (). type . is Subtype Of ( Ċĉĉĉĉ ĉ signature Tuple Type . type AtIndex ( i Ġ+ Ġ 1 ))) Ċĉĉ ĉ narrow ed Arg Types . add ( argument . restriction (). type ) Ċĉĉ ĉ narrow ed Arguments . add ( argument ) Ċĉ ĉ } Ċĉ ĉ val Ġgenerated Ġ= Ġprimitive . try To Generate Special Primitive Invocation ( Ċĉĉ ĉ function To Call Reg , Ċĉĉ ĉ raw Function , Ċĉĉ ĉ narrow ed Arguments , Ċĉĉ ĉ narrow ed Arg Types , Ċĉĉ ĉ this , Ċĉĉ ĉ call Site Helper ) Ċĉ ĉ if Ġ( generated Ġ&& Ġgenerator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ // ĠThe Ġtop - of - stack Ġwas Ġreplaced , Ġbut Ġit Ġwasn 't Ġconvenient Ġto Ġdo Ċĉĉ ĉ // Ġa Ġjump Ġto Ġthe Ġappropriate Ġexit Ġhandlers . Ġ ĠDo Ġthat Ġnow . Ċĉĉ ĉ call Site Helper . use Answer ( read Slot ( stack p )) Ċĉ ĉ } Ċĉ ĉ return Ġgenerated Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġa Ġslower , Ġbut Ġmuch Ġmore Ġcompact Ġinvocation Ġof Ġa Ġpol ymorphic Ċĉ Ġ* Ġmethod Ġcall . Ġ ĠThe Ġslots Ġhave Ġalready Ġbeen Ġadjusted Ġto Ġbe Ġconsistent Ġwith Ċĉ Ġ* Ġhaving Ġpop ped Ġthe Ġarguments Ġand Ġpushed Ġthe Ġexpected Ġtype . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠInformation Ġabout Ġthe Ġmethod Ġcall Ġsite . Ċĉ Ġ* Ġ@ param Ġsemantic Arguments Ċĉ Ġ* ĠĠ ĠThe Ġlist Ġof Ġ[ L 2 Semantic Value ] s Ġsupply ing Ġargument Ġvalues . ĠThese Ġbecome Ċĉ Ġ* ĠĠ Ġst reng then ed Ġby Ġtype Ġtests Ġin Ġthe Ġcurrent Ġmanifest . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġgenerate Slow Pol ymorphic Call ( Ċĉ ĉ call Site Helper : ĠCall Site Helper , Ċĉ ĉ semantic Arguments : ĠList < L 2 Semantic Value >) Ċ ĉ { Ċĉ ĉ val Ġbundle Ġ= Ġcall Site Helper . bundle Ċĉ ĉ val Ġmethod : ĠA _ Method Ġ= Ġbundle . bundle Method Ċĉ ĉ val Ġn Args Ġ= Ġmethod . num Args Ċĉ ĉ val Ġlookup Succeeded Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " lookup Ġsucceeded Ġfor Ġ" Ġ+ Ġcall Site Helper . quoted Bundle Name ) Ċĉ ĉ val Ġlookup Failed Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " lookup Ġfailed Ġfor Ġ" Ġ+ Ġcall Site Helper . quoted Bundle Name ) Ċĉ ĉ val Ġargument Restrictions Ġ= Ċĉĉ ĉ mutable ListOf < Type Restriction >() Ċĉ ĉ for Ġ( i Ġin Ġ 1 Ġ.. Ġn Args ) Ċĉ ĉ { Ċĉĉ ĉ val Ġargument Restriction Ġ= Ċĉĉĉ ĉ current Manifest (). restriction For ( semantic Arguments [ i Ġ- Ġ 1 ]) Ċĉĉ ĉ val Ġunion Restriction Ġ= Ġargument Restriction . union ( Ċĉĉĉ ĉ restriction ForType ( Ċĉĉĉĉ ĉ call Site Helper . super Union Type . type AtIndex ( i ), ĠBO X ED _ FLAG )) Ċĉĉ ĉ argument Restrictions . add ( union Restriction ) Ċĉ ĉ } Ċĉ ĉ val Ġpossible Functions Ġ= Ġmutable ListOf < A _ Function >() Ċĉ ĉ for Ġ( definition Ġin Ċĉĉ ĉ bundle . bundle Method . definitions At Or Below ( argument Restrictions )) Ċĉ ĉ { Ċĉĉ ĉ if Ġ( definition . is Method Definition ()) Ċĉĉ ĉ { Ċĉĉĉ ĉ possible Functions . add ( definition . body Block ()) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ val Ġfunction Type Union Ġ= Ċĉĉ ĉ enumeration With ( set From Collection ( possible Functions )) Ċĉ ĉ val Ġargument Reads Ġ= Ċĉĉ ĉ semantic Arguments . map Ġ{ Ġcurrent Manifest (). read Boxed ( it ) Ġ} ĊĊĉ ĉ // ĠAt Ġsome Ġpoint Ġwe Ġmight Ġwant Ġto Ġintroduce Ġa ĠSemantic Value Ġfor Ġtagging Ċĉ ĉ // Ġthis Ġregister . Ċĉ ĉ if Ġ( function Type Union . is Bottom ) Ċĉ ĉ { Ċĉĉ ĉ // ĠThere Ġwere Ġno Ġpossible Ġmethod Ġdefinitions , Ġso Ġjump Ġimmediately Ġto Ċĉĉ ĉ // Ġthe Ġlookup Ġfailure Ġclause . Ġ ĠDon 't Ġgenerate Ġthe Ġsuccess Ġcase . Ċĉĉ ĉ // ĠFor Ġconsistency , Ġgenerate Ġa Ġjump Ġto Ġthe Ġlookup Failed Ġexit Ġpoint , Ċĉĉ ĉ // Ġthen Ġgenerate Ġit Ġimmediately . Ċĉĉ ĉ generator . jump To ( lookup Failed ) Ċĉĉ ĉ generator . start Block ( lookup Failed ) Ċĉĉ ĉ generate Lookup Failure ( Ċĉĉĉ ĉ method , Ċĉĉĉ ĉ call Site Helper , Ċĉĉĉ ĉ generator . boxed Constant ( E _ NO _ METHOD _ DEFINITION . numeric Code ()), Ċĉĉĉ ĉ argument Restrictions , Ċĉĉĉ ĉ argument Reads ) Ċĉĉ ĉ return Ċĉ ĉ } Ċĉ ĉ // ĠIt Ġdoesn 't Ġnecessarily Ġalways Ġfail , Ġso Ġtry Ġa Ġlookup . Ċĉ ĉ val Ġfunction Write Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( function Type Union , ĠBO X ED _ FLAG )) Ċĉ ĉ val ĠerrorCode Write Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( Ċĉĉĉ ĉ L 2 _ LOOK UP _ BY _ VALUES . lookup Errors Type , ĠBO X ED _ FLAG )) Ċĉ ĉ if Ġ(! call Site Helper . is Super ) Ċĉ ĉ { Ċĉĉ ĉ // ĠNot Ġa Ġsuper - call . Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ LOOK UP _ BY _ VALUES , Ċĉĉĉ ĉ L 2 Selector Operand ( bundle ), Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( argument Reads ), Ċĉĉĉ ĉ function Write , Ċĉĉĉ ĉ errorCode Write , Ċĉĉĉ ĉ edge To ( lookup Succeeded ), Ċĉĉĉ ĉ edge To ( lookup Failed )) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ // ĠExtract Ġa Ġtuple Ġtype Ġfrom Ġthe Ġruntime Ġtypes Ġof Ġthe Ġarguments , Ċĉĉ ĉ // Ġtake Ġthe Ġtype Ġunion Ġwith Ġthe Ġsuper Union Type , Ġthen Ġperform Ġa Ċĉĉ ĉ // Ġlookup - by - types Ġusing Ġthat Ġtuple Ġtype . Ċĉĉ ĉ val Ġarg Type Regs Ġ= Ġmutable ListOf < L 2 Read Boxed Operand >() Ċĉĉ ĉ for Ġ( i Ġin Ġ 1 Ġ.. Ġn Args ) Ċĉĉ ĉ { Ċĉĉĉ ĉ val Ġarg Reg Ġ= Ġargument Reads [ i Ġ- Ġ 1 ] Ċĉĉĉ ĉ val Ġarg Static Type Ġ= Ġarg Reg . type () Ċĉĉĉ ĉ val Ġsuper Union ElementType Ġ= Ċĉĉĉĉ ĉ call Site Helper . super Union Type . type AtIndex ( i ) Ċĉĉĉ ĉ val Ġarg Type Reg : ĠL 2 Read Boxed Operand Ġ= Ċĉĉĉĉ ĉ if Ġ( arg Static Type . is Subtype Of ( super Union ElementType )) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠThe Ġlookup Ġis Ġentirely Ġdetermined Ġby Ġthe Ġsuper - union . Ċĉĉĉĉĉ ĉ generator . boxed Constant ( super Union ElementType ) Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ else Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ val Ġtype Bound Ġ= Ċĉĉĉĉĉĉ ĉ arg Static Type . type Union ( super Union ElementType ) Ċĉĉĉĉĉ ĉ val Ġarg Type Write Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉĉĉĉĉ ĉ restriction ForType ( Ċĉĉĉĉĉĉĉ ĉ instance Meta ( type Bound ), ĠBO X ED _ FLAG )) Ċĉĉĉĉĉ ĉ if Ġ( super Union ElementType . is Bottom ) Ċĉĉĉĉĉ ĉ { Ċĉĉĉĉĉĉ ĉ // ĠOnly Ġthis Ġargument 's Ġactual Ġtype Ġmatters . Ċĉĉĉĉĉĉ ĉ add Instruction ( L 2 _ GET _ TYPE , Ġarg Reg , Ġarg Type Write ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ else Ċĉĉĉĉĉ ĉ { Ċĉĉĉĉĉĉ ĉ // ĠThe Ġlookup Ġis Ġconstr ained Ġby Ġthe Ġactual Ċĉĉĉĉĉĉ ĉ // Ġargument 's Ġtype Ġ* and * Ġthe Ġsuper - union . Ġ ĠThis Ġis Ċĉĉĉĉĉĉ ĉ // Ġpossible Ġbecause Ġthis Ġis Ġa Ġtop - level Ġargument , Ċĉĉĉĉĉĉ ĉ // Ġbut Ġit 's Ġthe Ġleaf Ġarguments Ġthat Ġindividually Ċĉĉĉĉĉĉ ĉ // Ġspecify Ġsuper casts . Ċĉĉĉĉĉĉ ĉ val Ġoriginal Arg Type Write Ġ= Ċĉĉĉĉĉĉĉ ĉ generator . boxed Write Temp ( Ċĉĉĉĉĉĉĉĉ ĉ restriction ForType ( Ċĉĉĉĉĉĉĉĉĉ ĉ instance Meta ( type Bound ), ĠBO X ED _ FLAG )) Ċĉĉĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉĉĉ ĉ L 2 _ GET _ TYPE , Ġarg Reg , Ġoriginal Arg Type Write ) Ċĉĉĉĉĉĉ ĉ add Instruction ( Ċĉĉĉĉĉĉĉ ĉ L 2 _ TYPE _ UNION , Ċĉĉĉĉĉĉĉ ĉ read Boxed ( original Arg Type Write ), Ċĉĉĉĉĉĉĉ ĉ generator . boxed Constant ( super Union ElementType ), Ċĉĉĉĉĉĉĉ ĉ arg Type Write ) Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ read Boxed ( arg Type Write ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ arg Type Regs . add ( arg Type Reg ) Ċĉĉ ĉ } Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ LOOK UP _ BY _ TYPES , Ċĉĉĉ ĉ L 2 Selector Operand ( bundle ), Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( arg Type Regs ), Ċĉĉĉ ĉ function Write , Ċĉĉĉ ĉ errorCode Write , Ċĉĉĉ ĉ edge To ( lookup Succeeded ), Ċĉĉĉ ĉ edge To ( lookup Failed )) Ċĉ ĉ } Ċĉ ĉ // ĠAt Ġthis Ġpoint , Ġwe 've Ġattempted Ġto Ġlook Ġup Ġthe Ġmethod , Ġand Ġeither Ċĉ ĉ // Ġjump ed Ġto Ġlookup Succeeded Ġwith Ġfunction Write Ġset Ġto Ġthe Ġbody Ċĉ ĉ // Ġfunction , Ġor Ġjump ed Ġto Ġlookup Failed Ġwith ĠerrorCode Write Ġset Ġto Ċĉ ĉ // Ġthe Ġlookup Ġerror Ġcode . ĊĊĉ ĉ // ĠEmit Ġthe Ġlookup Ġfailure Ġcase . Ċĉ ĉ generator . start Block ( lookup Failed ) Ċĉ ĉ generate Lookup Failure ( Ċĉĉ ĉ method , Ċĉĉ ĉ call Site Helper , Ċĉĉ ĉ read Boxed ( errorCode Write ), Ċĉĉ ĉ argument Restrictions , Ċĉĉ ĉ argument Reads ) ĊĊĉ ĉ // ĠNow Ġinvoke Ġthe Ġmethod Ġdefinition 's Ġbody . Ġ ĠWe 've Ġalready Ġexam ined Ġall Ċĉ ĉ // Ġpossible Ġmethod Ġdefinition Ġbodies Ġto Ġsee Ġif Ġthey Ġall Ġconform Ġwith Ġthe Ċĉ ĉ // Ġexpected Type , Ġand Ġcaptured Ġthat Ġin Ġalways Skip Result Check . Ċĉ ĉ generator . start Block ( lookup Succeeded ) Ċĉ ĉ val Ġconstant Function : ĠA _ Function ? Ġ= Ċĉĉ ĉ read Boxed ( function Write ). restriction (). constant OrNull Ċĉ ĉ if Ġ( constant Function Ġ!== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ // ĠEven Ġthough Ġwe Ġcouldn 't Ġprove Ġstatic ally Ġthat Ġthis Ġfunction Ġwas Ċĉĉ ĉ // Ġalways Ġlooked Ġup , Ġwe Ġpro ved Ġthe Ġslightly Ġwe aker Ġcondition Ġthat Ġif Ċĉĉ ĉ // Ġthe Ġlookup Ġwas Ġsuccessful , Ġit Ġmust Ġhave Ġproduced Ġthis Ġfunction . Ċĉĉ ĉ // ĠJump Ġinto Ġthe Ġsame Ġblock Ġthat Ġwill Ġbe Ġgenerated Ġfor Ġa Ġpositive Ċĉĉ ĉ // Ġin lined Ġlookup Ġof Ġthe Ġsame Ġfunction . Ċĉĉ ĉ promise To Handle Call For Definition Body ( Ċĉĉĉ ĉ constant Function , Ġsemantic Arguments , Ġcall Site Helper ) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ generate General Function Invocation ( Ċĉĉĉ ĉ read Boxed ( function Write ), Ċĉĉĉ ĉ argument Reads , Ċĉĉĉ ĉ true , Ċĉĉĉ ĉ call Site Helper ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠGenerate Ġcode Ġto Ġreport Ġa Ġlookup Ġfailure . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġmethod Ċĉ Ġ* ĠĠ ĠThe Ġ[ A _ Method ] Ġthat Ġcould Ġnot Ġbe Ġfound Ġat Ġthe Ġcall Ġsite . Ċĉ Ġ* Ġ@ param Ġcall Site Helper Ċĉ Ġ* ĠĠ ĠInformation Ġabout Ġthe Ġmethod Ġcall Ġsite . Ċĉ Ġ* Ġ@ param ĠerrorCode Read Ċĉ Ġ* ĠĠ ĠThe Ġregister Ġcontaining Ġthe Ġnumeric Ġ[ Avail ErrorCode ] Ġindicating Ġthe Ċĉ Ġ* ĠĠ Ġlookup Ġproblem . Ċĉ Ġ* Ġ@ param Ġargument Restrictions Ċĉ Ġ* ĠĠ ĠThe Ġ[ Type Restriction ] s Ġon Ġthe Ġarguments . Ċĉ Ġ* Ġ@ param Ġargument Reads Ċĉ Ġ* ĠĠ ĠThe Ġsource Ġ[ L 2 Read Boxed Vector Operand ] s Ġsupply ing Ġarguments . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġgenerate Lookup Failure ( Ċĉ ĉ method : ĠA _ Method , Ċĉ ĉ call Site Helper : ĠCall Site Helper , Ċĉ ĉ errorCode Read : ĠL 2 Read Boxed Operand , Ċĉ ĉ argument Restrictions : ĠList < Type Restriction >, Ċĉ ĉ argument Reads : ĠList < L 2 Read Boxed Operand >) Ċ ĉ { Ċĉ ĉ val Ġinvalid Send Reg Ġ= Ċĉĉ ĉ generator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( Ċĉĉĉ ĉ Hook Type . INVALID _ MESSAGE _ SEND . function Type , ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ GET _ INVALID _ MESSAGE _ SEND _ FUNCTION , Ċĉĉ ĉ invalid Send Reg ) Ċĉ ĉ // ĠCollect Ġthe Ġargument Ġtypes Ġinto Ġa Ġtuple Ġtype . Ċĉ ĉ val Ġarg Types Ġ= Ġargument Restrictions . map Ġ{ Ġit . type Ġ} Ċĉ ĉ val Ġarguments Tuple Write Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( tuple Type For Types List ( arg Types ), ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ CREATE _ T UP LE , Ċĉĉ ĉ L 2 Read Boxed Vector Operand ( argument Reads ), Ċĉĉ ĉ arguments Tuple Write ) Ċĉ ĉ val Ġon Re ification During Failure Ġ= Ċĉĉ ĉ generator . create BasicBlock ( Ċĉĉĉ ĉ " re ify Ġin Ġmethod Ġlookup Ġfailure Ġhandler Ġfor " Ġ+ Ċĉĉĉĉ ĉ call Site Helper . quoted Bundle Name , Ċĉĉĉ ĉ Zone Type . PROP AG ATE _ RE IFICATION _ FOR _ IN VOKE . create Zone ( Ċĉĉ ĉ " Continue Ġre ification Ġduring Ġlookup Ġfailure Ġhandler ")) Ċĉ ĉ val Ġunreachable Ġ= ĠL 2 BasicBlock (" unreachable ") Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ IN VOKE , Ċĉĉ ĉ read Boxed ( invalid Send Reg ), Ċĉĉ ĉ L 2 Read Boxed Vector Operand ( Ċĉĉĉ ĉ listOf ( Ċĉĉĉĉ ĉ errorCode Read , Ċĉĉĉĉ ĉ generator . boxed Constant ( method ), Ċĉĉĉĉ ĉ read Boxed ( arguments Tuple Write ))), Ċĉĉ ĉ generator . boxed Write Temp ( Type Restriction . any Restriction ), Ġ Ġ// Ġunreachable Ċĉĉ ĉ edge To ( unreachable ), Ċĉĉ ĉ edge To ( on Re ification During Failure )) ĊĊĉ ĉ generator . start Block ( unreachable ) Ċĉ ĉ generator . add Instruction ( L 2 _ UN RE ACH ABLE _ CODE ) ĊĊĉ ĉ // ĠRe ification Ġhas Ġbeen Ġrequested Ġwhile Ġthe Ġfailure Ġcall Ġis Ġin Ċĉ ĉ // Ġprogress . Ċĉ ĉ generator . start Block ( on Re ification During Failure ) Ċĉ ĉ generator . add Instruction ( Ċĉĉ ĉ L 2 _ ENTER _ L 2 _ CHUNK , Ċĉĉ ĉ L 2 Int Immediate Operand ( Chunk EntryPoint . TRAN SI ENT . offset In Default Chunk ), Ċĉĉ ĉ L 2 Comment Operand ( Ċĉĉĉ ĉ " Transient Ġ- Ġcannot Ġbe Ġinvalid .")) Ċĉ ĉ re ify ( bottom , ĠChunk EntryPoint . TO _ RETURN _ IN TO ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠEmit Ġcode Ġto Ġcheck Ġfor Ġan Ġinterrupt Ġand Ġservice Ġit Ġif Ġnecessary , Ċĉ Ġ* Ġincluding Ġgeneration Ġof Ġthe Ġsubsequent ly Ġcontinued Ġon - ramp . Ġ ĠThe Ċĉ Ġ* Ġgenerated Ġcode Ġshould Ġonly Ġbe Ġreachable Ġat Ġpositions Ġthat Ġare Ġeffectively Ċĉ Ġ* Ġbetween ĠL 1 Ġny bble codes , Ġsince Ġduring Ġsuch Ġan Ġinterrupt Ġany Ġ[ L 2 Chunk ] s Ġcan Ċĉ Ġ* Ġbe Ġinvalid ated . Ġ ĠNot Ġ* all * Ġpositions Ġbetween Ġny bble codes Ġneed Ġto Ġcheck Ċĉ Ġ* Ġfor Ġinterrupts , Ġbut Ġthere Ġshouldn 't Ġbe Ġan Ġar bitr arily Ġlarge Ġamount Ġof Ċĉ Ġ* Ġtime Ġthat Ġpasses Ġbetween Ġwhen Ġan Ġinterrupt Ġis Ġindicated Ġand Ġwhen Ġit Ġis Ċĉ Ġ* Ġserv iced . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġemit Interrupt Off R amp () Ċ ĉ { Ċĉ ĉ val Ġservice Interrupt Ġ= Ċĉĉ ĉ generator . create BasicBlock (" service Ġinterrupt ") Ċĉ ĉ val Ġmerge Ġ= Ċĉĉ ĉ generator . create BasicBlock (" merge Ġafter Ġpossible Ġinterrupt ") Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ JUMP _ IF _ INTERRUPT , Ċĉĉ ĉ edge To ( service Interrupt ), Ċĉĉ ĉ edge To ( merge )) Ċĉ ĉ generator . start Block ( service Interrupt ) Ċĉ ĉ // ĠService Ġthe Ġinterrupt : Ġ ĠGenerate Ġthe Ġre ification Ġinstructions , Ċĉ ĉ // Ġensuring Ġthat Ġwhen Ġreturning Ġinto Ġthe Ġresulting Ġcontinuation , Ġit Ġwill Ċĉ ĉ // Ġenter Ġa Ġblock Ġwhere Ġthe Ġslot Ġregisters Ġare Ġthe Ġnew Ġones Ġwe Ġjust Ċĉ ĉ // Ġcreated . Ġ ĠAfter Ġcreating Ġthe Ġcontinuation , Ġactually Ġservice Ġthe Ċĉ ĉ // Ġinterrupt . ĊĊĉ ĉ // ĠRe ify Ġevery body Ġelse , Ġstarting Ġat Ġthe Ġcaller . Ċĉ ĉ val Ġon Re ification Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " On Ġre ification Ġfor Ġinterrupt ", Ċĉĉ ĉ Zone Type . BEGIN _ RE IFICATION _ FOR _ INTERRUPT . create Zone ( Ċĉĉĉ ĉ " Start Ġre ification Ġand Ġrun Ġinterrupt ")) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ RE IFY , Ċĉĉ ĉ L 2 Int Immediate Operand ( 1 ), Ċĉĉ ĉ L 2 Int Immediate Operand ( 1 ), Ċĉĉ ĉ L 2 Constant Operand ( Ċĉĉĉ ĉ identity Po jo ( Ċĉĉĉĉ ĉ Statistic Category . INTERRUPT _ OFF _ R AMP _ IN _ L 2 . statistic )), Ċĉĉ ĉ edge To ( on Re ification )) Ċĉ ĉ generator . start Block ( on Re ification ) Ċĉ ĉ generator . add Instruction ( Ċĉĉ ĉ L 2 _ ENTER _ L 2 _ CHUNK , Ċĉĉ ĉ L 2 Int Immediate Operand ( Ċĉĉĉ ĉ Chunk EntryPoint . TRAN SI ENT . offset In Default Chunk ), Ċĉĉ ĉ L 2 Comment Operand ( Ċĉĉĉ ĉ " Transient , Ġfor Ġinterrupt Ġ- Ġcannot Ġbe Ġinvalid .")) ĊĊĉ ĉ // ĠWhen Ġthe Ġlambda Ġbelow Ġruns , Ġit 's Ġgenerating Ġcode Ġat Ġthe Ġpoint Ġwhere Ċĉ ĉ // Ġcontinuation Reg Ġwill Ġhave Ġthe Ġnew Ġcontinuation . Ċĉ ĉ re ify ( null , ĠChunk EntryPoint . TO _ RE SU ME ) Ċĉ ĉ generator . jump To ( merge ) Ċĉ ĉ // ĠMerge Ġthe Ġflow Ġ( re ified Ġand Ġcontinued , Ġvers us Ġnot Ġre ified ). Ċĉ ĉ generator . start Block ( merge ) Ċĉ ĉ // ĠAnd Ġnow ... Ġeither Ġwe 're Ġback Ġor Ġwe Ġnever Ġleft . Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠEmit Ġthe Ġspecified Ġvariable - reading Ġinstruction , Ġand Ġan Ġoff - ramp Ġto Ġdeal Ċĉ Ġ* Ġwith Ġthe Ġcase Ġthat Ġthe Ġvariable Ġis Ġun assigned . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġget Operation Ċĉ Ġ* ĠĠ ĠThe Ġ[ variable Ġreading ][ L 2 Operation . is Variable Get ] Ċĉ Ġ* ĠĠ Ġ[ operation ][ L 2 Operation ]. Ċĉ Ġ* Ġ@ param Ġvariable Ċĉ Ġ* ĠĠ ĠThe Ġlocation Ġof Ġthe Ġ[ variable ][ A _ Variable ]. Ċĉ Ġ* Ġ@ param Ġmake Immutable Ċĉ Ġ* ĠĠ Ġ` true ` Ġif Ġthe Ġextracted Ġvalue Ġshould Ġbe Ġmade Ġimmutable , Ġotherwise Ċĉ Ġ* ĠĠ Ġ` false `. Ċĉ Ġ* Ġ@ return Ċĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġinto Ġwhich Ġthe Ġvariable 's Ġvalue Ġwill Ġbe Ċĉ Ġ* ĠĠ Ġwritten , Ġincluding Ġhaving Ġmade Ġit Ġimmutable Ġif Ġrequested . Ċĉ Ġ*/ Ċ ĉ fun Ġemit Get Variable Off R amp ( Ċĉ ĉ get Operation : ĠL 2 Operation , Ċĉ ĉ variable : ĠL 2 Read Boxed Operand , Ċĉ ĉ target Semantic Value : ĠL 2 Semantic Value , Ċĉ ĉ make Immutable : ĠBoolean ): ĠL 2 Read Boxed Operand Ċ ĉ { Ċĉ ĉ assert ( get Operation . is Variable Get ) Ċĉ ĉ val Ġsuccess Ġ= Ġgenerator . create BasicBlock (" successfully Ġread Ġvariable ") Ċĉ ĉ val Ġfailure Ġ= Ġgenerator . create BasicBlock (" failed Ġto Ġread Ġvariable ") ĊĊĉ ĉ // ĠEmit Ġthe Ġspecified Ġget - variable Ġinstruction Ġvariant . Ċĉ ĉ val Ġvalue Write Ġ= Ġgenerator . boxed Write ( Ċĉĉ ĉ target Semantic Value , Ċĉĉ ĉ restriction ForType ( variable . type (). read Type , ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ get Operation , Ċĉĉ ĉ variable , Ċĉĉ ĉ value Write , Ċĉĉ ĉ edge To ( success ), Ċĉĉ ĉ edge To ( failure )) ĊĊĉ ĉ // ĠEmit Ġthe Ġfailure Ġpath . ĠU nb ind Ġthe Ġdestination Ġof Ġthe Ġvariable - get Ġin Ċĉ ĉ // Ġthis Ġcase , Ġsince Ġit Ġwon 't Ġhave Ġbeen Ġpopulated Ġ( by Ġdefinition , Ċĉ ĉ // Ġotherwise Ġwe Ġwouldn 't Ġhave Ġfailed ). Ċĉ ĉ generator . start Block ( failure ) Ċĉ ĉ generator . add Instruction ( Ċĉĉ ĉ L 2 _ IN VOKE _ UN ASS IGNED _ VARIABLE _ READ _ FUNCTION , Ċĉĉ ĉ L 2 Int Immediate Operand ( pc ), Ċĉĉ ĉ L 2 Int Immediate Operand ( stack p ), Ċĉĉ ĉ L 2 Read Boxed Vector Operand (( 1 .. num Slots ). map ( this :: read Slot ))) Ċĉ ĉ assert (! generator . currently Reach able ()) ĊĊĉ ĉ // ĠEnd Ġwith Ġthe Ġsuccess Ġpath . Ċĉ ĉ generator . start Block ( success ) Ċĉ ĉ return Ġif Ġ( make Immutable ) Ċĉ ĉ { Ċĉĉ ĉ generator . make Immutable ( read Boxed ( value Write )) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ read Boxed ( value Write ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠEmit Ġthe Ġspecified Ġvariable - writing Ġinstruction , Ġand Ġan Ġoff - ramp Ġto Ġdeal Ċĉ Ġ* Ġwith Ġthe Ġcase Ġthat Ġthe Ġvariable Ġhas Ċĉ Ġ* Ġ[ write - react ors ][ Variable Access Reactor ] Ġbut Ġvariable Ġwrite Ċĉ Ġ* Ġ[ tracing ][ Interpreter . trace Variable Writes ] Ġis Ġdisabled . Ċĉ Ġ* Ċĉ Ġ* Ġ@ param Ġset Operation Ċĉ Ġ* ĠĠ ĠThe Ġ[ variable Ġreading ][ L 2 Operation . is Variable Set ] Ċĉ Ġ* ĠĠ Ġ[ operation ][ L 2 Operation ]. Ċĉ Ġ* Ġ@ param Ġvariable Ċĉ Ġ* ĠĠ ĠThe Ġlocation Ġof Ġthe Ġ[ variable ][ A _ Variable ]. Ċĉ Ġ* Ġ@ param ĠnewValue Ċĉ Ġ* ĠĠ ĠThe Ġlocation Ġof Ġthe Ġnew Ġvalue . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġemit Set Variable Off R amp ( Ċĉ ĉ set Operation : ĠL 2 Operation , Ċĉ ĉ variable : ĠL 2 Read Boxed Operand , Ċĉ ĉ newValue : ĠL 2 Read Boxed Operand ) Ċ ĉ { Ċĉ ĉ assert ( set Operation . is Variable Set ) Ċĉ ĉ val Ġsuccess Ġ= Ġgenerator . create BasicBlock (" set Ġlocal Ġsuccess ") Ċĉ ĉ val Ġfailure Ġ= Ġgenerator . create BasicBlock (" set Ġlocal Ġfailure ") Ċĉ ĉ val Ġon Re ification During Failure Ġ= Ġgenerator . create BasicBlock ( Ċĉĉ ĉ " re ify Ġduring Ġset Ġlocal Ġfailure ", Ċĉĉ ĉ Zone Type . PROP AG ATE _ RE IFICATION _ FOR _ IN VOKE . create Zone ( Ċĉĉĉ ĉ " Continue Ġre ification Ġfor Ġset - variable Ġfailure Ġhandler ")) Ċĉ ĉ // ĠEmit Ġthe Ġset - variable Ġinstruction . Ċĉ ĉ add Instruction ( Ċĉĉ ĉ set Operation , Ċĉĉ ĉ variable , Ċĉĉ ĉ newValue , Ċĉĉ ĉ edge To ( success ), Ċĉĉ ĉ edge To ( failure )) ĊĊĉ ĉ // ĠEmit Ġthe Ġfailure Ġpath . Ċĉ ĉ generator . start Block ( failure ) Ċĉ ĉ val Ġobserve Function Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( Ċĉĉĉ ĉ Hook Type . IMP LICIT _ OB SER VE . function Type , ĠBO X ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ GET _ IMP LICIT _ OB SER VE _ FUNCTION , Ċĉĉ ĉ observe Function ) Ċĉ ĉ val Ġvariable And Value Tuple Reg Ġ= Ġgenerator . boxed Write Temp ( Ċĉĉ ĉ restriction ForType ( Ċĉĉĉ ĉ tuple Type For Types ( variable . type (), ĠnewValue . type ()), Ċĉĉĉ ĉ BOX ED _ FLAG )) Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ CREATE _ T UP LE , Ċĉĉ ĉ L 2 Read Boxed Vector Operand ( listOf ( variable , ĠnewValue )), Ċĉĉ ĉ variable And Value Tuple Reg ) Ċĉ ĉ // ĠNote : Ġthe Ġhandler Ġblock 's Ġvalue Ġis Ġdiscarded ; Ġalso , Ġsince Ġit 's Ġnot Ġa Ċĉ ĉ // Ġmethod Ġdefinition , Ġit Ġcan 't Ġhave Ġa Ġsemantic Ġrestriction . Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ IN VOKE , Ċĉĉ ĉ read Boxed ( observe Function ), Ċĉĉ ĉ L 2 Read Boxed Vector Operand ( Ċĉĉĉ ĉ listOf ( Ċĉĉĉĉ ĉ generator Ċĉĉĉĉĉ ĉ . boxed Constant ( assignment Function ()), Ċĉĉĉĉ ĉ read Boxed ( variable And Value Tuple Reg ))), Ċĉĉ ĉ // ĠUn reachable : Ċĉĉ ĉ generator . boxed Write Temp ( Type Restriction . any Restriction ), Ċĉĉ ĉ edge To ( success ), Ċĉĉ ĉ edge To ( on Re ification During Failure )) Ċĉ ĉ generator . start Block ( on Re ification During Failure ) Ċĉ ĉ generator . add Instruction ( Ċĉĉ ĉ L 2 _ ENTER _ L 2 _ CHUNK , Ċĉĉ ĉ L 2 Int Immediate Operand ( Ċĉĉĉ ĉ Chunk EntryPoint . TRAN SI ENT . offset In Default Chunk ), Ċĉĉ ĉ L 2 Comment Operand ( Ċĉĉĉ ĉ " Transient Ġ- Ġcannot Ġbe Ġinvalid .")) Ċĉ ĉ re ify ( Types . TOP . o , ĠChunk EntryPoint . TO _ RETURN _ IN TO ) Ċĉ ĉ generator . jump To ( success ) ĊĊĉ ĉ // ĠEnd Ġwith Ġthe Ġsuccess Ġblock . Ġ ĠNote Ġthat Ġthe Ġfailure Ġpath Ġcan Ġlead Ġhere Ċĉ ĉ // Ġif Ġthe Ġimplicit - observe Ġfunction Ġreturns . Ċĉ ĉ generator . start Block ( success ) Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠFor Ġeach Ġlevel Ġone Ġinstruction , Ġwrite Ġa Ġsuitable Ġtrans l iteration Ġinto Ċĉ Ġ* Ġlevel Ġtwo Ġinstructions . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġtranslate L 1 Instructions () Ċ ĉ { Ċĉ ĉ val Ġtime At Start Of Translation Ġ= ĠAv ail Runtime Support . capture Nan os () ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠThe Ġ[ L 2 BasicBlock ] Ġwhich Ġis Ġthe Ġentry Ġpoint Ġfor Ġa Ġfunction Ġthat Ġhas Ġjust Ċĉĉ Ġ* Ġbeen Ġinvoked . Ċĉĉ Ġ*/ Ċĉ ĉ val Ġstart Block : ĠL 2 BasicBlock Ġ= Ċĉĉ ĉ generator . create BasicBlock (" START Ġfor Ġ${ generator . code Name }") Ċĉ ĉ start Block . make Ir re mov able () Ċĉ ĉ generator . special Blocks [ START ] Ġ= Ġstart Block Ċĉ ĉ generator . start Block ( start Block ) Ċĉ ĉ val Ġprimitive Ġ= Ġcode . code Primitive () Ċĉ ĉ if Ġ( primitive Ġ!== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ // ĠTry Ġthe Ġprimitive , Ġautomatically Ġreturning Ġif Ġsuccessful . Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ TRY _ PR IMIT IVE , Ċĉĉĉ ĉ L 2 Primitive Operand ( primitive )) Ċĉĉ ĉ if Ġ( primitive . has Flag ( Flag . Cannot Fail )) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠInf al lib le Ġprimitives Ġdon 't Ġneed Ġany Ġother ĠL 2 Ġcode . Ċĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ val Ġafter Primitive Ġ= Ċĉĉ ĉ generator . create Loop Head Block (" After Ġoptional Ġprimitive ") Ċĉ ĉ after Primitive . make Ir re mov able () Ċĉ ĉ generator . special Blocks [ AFTER _ OPTIONAL _ PR IMIT IVE ] Ġ= Ġafter Primitive Ċĉ ĉ generator . jump To ( after Primitive ) Ċĉ ĉ generator . start Block ( after Primitive ) Ċĉ ĉ current Manifest (). clear () Ċĉ ĉ // ĠWhile Ġit 's Ġtrue Ġthat Ġinvalid ation Ġmay Ġonly Ġtake Ġplace Ġwhen Ġno ĠAv ail Ċĉ ĉ // Ġcode Ġis Ġrunning Ġ( even Ġwhen Ġev ict ing Ġold Ġchunks ), Ġand Ġit 's Ġalso Ġthe Ċĉ ĉ // Ġcase Ġthat Ġinvalid ation Ġcauses Ġthe Ġchunk Ġto Ġbe Ġdisconnected Ġfrom Ġits Ċĉ ĉ // Ġcompiled Ġcode , Ġit 's Ġstill Ġthe Ġcase Ġthat Ġa Ġcontinuation Ġ( a Ġlabel , Ġsay ) Ċĉ ĉ // Ġcreated Ġat Ġan Ġearlier Ġtime Ġstill Ġrefers Ġto Ġthe Ġinvalid Ġchunk . Ġ ĠEnsure Ċĉ ĉ // Ġit Ġcan Ġfall Ġback Ġgrace fully Ġto ĠL 1 Ġ( the Ġdefault Ġchunk ) Ġby Ġentering Ġit Ċĉ ĉ // Ġat Ġthe ĠTO _ RE START Ġentry Ġpoint . Ġ ĠNote Ġthat Ġthere Ġcan 't Ġbe Ġa Ġprimitive Ċĉ ĉ // Ġfor Ġsuch Ġcontinu ations . Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ ENTER _ L 2 _ CHUNK , Ċĉĉ ĉ L 2 Int Immediate Operand ( Ċĉĉĉ ĉ Chunk EntryPoint . TO _ RE START . offset In Default Chunk ), Ċĉĉ ĉ L 2 Comment Operand ( Ċĉĉĉ ĉ " If Ġinvalid , Ġre enter ĠÂ« default Â» Ġat Ġthe Ġbeginning .")) ĊĊĉ ĉ // ĠDo Ġany Ġre optimization Ġbefore Ġcapturing Ġarguments . Ċĉ ĉ if Ġ( generator . optimization Level Ġ== ĠOptimization Level . UN OPTIMI Z ED ) Ċĉ ĉ { Ċĉĉ ĉ // ĠOpt imize Ġit Ġagain Ġif Ġit 's Ġcalled Ġfrequently Ġenough . Ċĉĉ ĉ code . countdown To Re optimize ( countdown For New ly Optim ized Code ) Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ DECRE MENT _ COUNTER _ AND _ RE OPTIMI ZE _ ON _ ZERO , Ċĉĉĉ ĉ L 2 Int Immediate Operand ( Ċĉĉĉĉ ĉ Optimization Level . FIRST _ TRANSL ATION . ordinal ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( 0 )) Ċĉĉ ĉ // ĠIf Ġit Ġwas Ġre optimized , Ġit Ġwould Ġhave Ġjump ed Ġto Ġthe Ċĉĉ ĉ // Ġafter Optional Initial Primitive Block Ġin Ġthe Ġnew Ġchunk . Ċĉ ĉ } ĊĊĉ ĉ // ĠCapture Ġthe Ġarguments . Ċĉ ĉ val Ġnum Args Ġ= Ġcode . num Args () Ċĉ ĉ if Ġ( num Args Ġ> Ġ 0 ) Ċĉ ĉ { Ċĉĉ ĉ val Ġtuple Type Ġ= Ġcode . function Type (). args Tuple Type Ċĉĉ ĉ for Ġ( i Ġin Ġ 1 Ġ.. Ġnum Args ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠCreate Ġa Ġnew Ġsemantic Ġslot Ġat Ġthe Ġcurrent Ġpc , Ġrepresenting Ċĉĉĉ ĉ // Ġthis Ġnewly Ġwritten Ġvalue . Ċĉĉĉ ĉ val Ġarg Reg Ġ= Ġgenerator . boxed Write ( Ċĉĉĉĉ ĉ semantic Slot ( i ), Ċĉĉĉĉ ĉ restriction ForType ( tuple Type . type AtIndex ( i ), ĠBO X ED _ FLAG )) Ċĉĉĉ ĉ add Instruction ( Ċĉĉĉĉ ĉ L 2 _ GET _ ARGUMENT , Ċĉĉĉĉ ĉ L 2 Int Immediate Operand ( i Ġ- Ġ 1 ), Ċĉĉĉĉ ĉ arg Reg ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // ĠHere 's Ġwhere Ġa Ġlocal ĠP _ Restart Continuation With Arguments Ġis Ġoptimized Ċĉ ĉ // Ġto Ġjump Ġto . ĠIt 's Ġexpected Ġto Ġplace Ġthe Ġreplacement Ġarguments Ġinto Ċĉ ĉ // Ġsemantic Ġslots Ġn @ 1 . Ċĉ ĉ val Ġloop Head Ġ= Ġgenerator . create Loop Head Block ( Ċĉĉ ĉ " Loop Ġhead Ġfor Ġ" Ġ+ Ġcode . methodName . as Native String ()) Ċĉ ĉ generator . special Blocks [ RE START _ LOOP _ HEAD ] Ġ= Ġloop Head Ċĉ ĉ generator . jump To ( loop Head ) Ċĉ ĉ generator . start Block ( loop Head ) ĊĊĉ ĉ // ĠCreate Ġthe Ġlocals . Ċĉ ĉ val Ġnum Local s Ġ= Ġcode . num Local s Ċĉ ĉ for Ġ( local Ġin Ġ 1 Ġ.. Ġnum Local s ) Ċĉ ĉ { Ċĉĉ ĉ val Ġlocal Type Ġ= Ġcode . local Type At ( local ) Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ CREATE _ VARIABLE , Ċĉĉĉ ĉ L 2 Constant Operand ( local Type ), Ċĉĉĉ ĉ write Slot ( Ċĉĉĉĉ ĉ num Args Ġ+ Ġlocal , Ċĉĉĉĉ ĉ pc , Ċĉĉĉĉ ĉ restriction ForType ( local Type , ĠBO X ED _ FLAG ))) Ċĉ ĉ } ĊĊĉ ĉ // ĠCapture Ġthe Ġprimitive Ġfailure Ġvalue Ġin Ġthe Ġfirst Ġlocal Ġif Ġapplicable . Ċĉ ĉ if Ġ( primitive Ġ!== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ assert (! primitive . has Flag ( Flag . Cannot Fail )) Ċĉĉ ĉ // ĠMove Ġthe Ġprimitive Ġfailure Ġvalue Ġinto Ġthe Ġfirst Ġlocal . Ġ ĠThis Ċĉĉ ĉ // Ġdoesn 't Ġneed Ġto Ġsupport Ġimplicit Ġobservation , Ġso Ġno Ġoff - ramp Ċĉĉ ĉ // Ġis Ġgenerated . Ċĉĉ ĉ val Ġsuccess Ġ= Ġgenerator . create BasicBlock (" success ") Ċĉĉ ĉ val Ġunreachable Ġ= ĠL 2 BasicBlock (" unreachable ") Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ SET _ VARIABLE _ NO _ CHECK , Ċĉĉĉ ĉ read Slot ( num Args Ġ+ Ġ 1 ), Ċĉĉĉ ĉ get Latest ReturnValue ( code . local Type At ( 1 ). write Type ), Ċĉĉĉ ĉ edge To ( success ), Ċĉĉĉ ĉ edge To ( unreachable )) ĊĊĉĉ ĉ generator . start Block ( unreachable ) Ċĉĉ ĉ generator . add Instruction ( L 2 _ UN RE ACH ABLE _ CODE ) ĊĊĉĉ ĉ generator . start Block ( success ) Ċĉ ĉ } ĊĊĉ ĉ // ĠNil Ġthe Ġrest Ġof Ġthe Ġstack Ġslots . Ċĉ ĉ for Ġ( i Ġin Ġnum Args Ġ+ Ġnum Local s Ġ+ Ġ 1 Ġ.. Ġnum Slots ) Ċĉ ĉ { Ċĉĉ ĉ nil Slot ( i ) Ċĉ ĉ } ĊĊĉ ĉ // ĠCheck Ġfor Ġinterrupts . ĠIf Ġan Ġinterrupt Ġis Ġdiscovered , Ġthen Ġre ify Ġand Ċĉ ĉ // Ġprocess Ġthe Ġinterrupt . Ġ ĠWhen Ġthe Ġchunk Ġresume s , Ġit Ġwill Ġexplode Ġthe Ċĉ ĉ // Ġcontinuation Ġagain . Ċĉ ĉ emit Interrupt Off R amp () ĊĊĉ ĉ // ĠCapture Ġthe Ġtime Ġit Ġtook Ġto Ġgenerate Ġthe Ġwhole Ġp reamble . Ċĉ ĉ val Ġinterpreter Index Ġ= Ġinterpreter . interpreter Index Ċĉ ĉ pre amble Generation Stat . record ( Ċĉĉ ĉ Avail Runtime Support . capture Nan os () Ġ- Ġtime At Start Of Translation , Ċĉĉ ĉ interpreter Index ) ĊĊĉ ĉ // ĠTrans l iterate Ġeach Ġlevel Ġone Ġny bble code Ġinto ĠL 2 Instructions . Ċĉ ĉ while Ġ(! instruction Decoder . at End () Ġ&& Ġgenerator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ val Ġbefore Ġ= ĠAv ail Runtime Support . capture Nan os () Ċĉĉ ĉ val Ġoperation Ġ= Ġinstruction Decoder . get Operation () Ċĉĉ ĉ operation . dispatch ( this ) Ċĉĉ ĉ level One Generation Stats [ operation . ordinal ]. record ( Ċĉĉĉ ĉ Avail Runtime Support . capture Nan os () Ġ- Ġbefore , Ċĉĉĉ ĉ interpreter Index ) Ċĉ ĉ } ĊĊĉ ĉ // ĠGenerate Ġthe Ġimplicit Ġreturn Ġafter Ġthe Ġinstruction Ġsequence . Ċĉ ĉ if Ġ( generator . currently Reach able ()) Ċĉ ĉ { Ċĉĉ ĉ val Ġread Result Ġ= Ġread Slot ( stack p ) Ċĉĉ ĉ add Instruction ( L 2 _ RETURN , Ġread Result ) Ċĉĉ ĉ assert ( stack p Ġ== Ġnum Slots ) Ċĉĉ ĉ stack p Ġ= ĠInt . MIN _ VALUE Ċĉ ĉ } Ċĉ ĉ val Ġunreachable Block Ġ= Ġgenerator . special Blocks [ UN RE ACH ABLE ] Ċĉ ĉ if Ġ( unreachable Block Ġ!== Ġnull Ċĉĉ ĉ && Ġunreachable Block . pre decessor Edges (). isNotEmpty ()) Ċĉ ĉ { Ċĉĉ ĉ // ĠGenerate Ġthe Ġunreachable Ġblock . Ċĉĉ ĉ generator . start Block ( unreachable Block ) Ċĉĉ ĉ add Instruction ( L 2 _ UN RE ACH ABLE _ CODE ) Ċĉĉ ĉ // ĠNow Ġmake Ġit Ġa Ġloop Ġhead , Ġjust Ġso Ġcode Ġgenerated Ġlater Ġfrom Ċĉĉ ĉ // Ġplaceholders Ġ( L 2 Operation # is Placeholder ()) Ġcan Ġstill Ġconnect Ġto Ċĉĉ ĉ // Ġit , Ġas Ġlong Ġas Ġit Ġuses Ġa Ġback - edge . Ċĉĉ ĉ unreachable Block . is Loop Head Ġ= Ġtrue Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠTranslate Ġthe Ġsupplied Ġ[ A _ Raw Function ] Ġinto Ġa Ġsequence Ġof Ċĉ Ġ* Ġ[ L 2 Instruction ] s . Ġ ĠThe Ġoptimization Ġlevel Ġspecifies Ġhow Ġhard Ġto Ġtry Ġto Ċĉ Ġ* Ġoptimize Ġthis Ġmethod . Ġ ĠIt Ġis Ġroughly Ġequivalent Ġto Ġthe Ġlevel Ġof Ġin lining Ċĉ Ġ* Ġto Ġattempt , Ġor Ġthe Ġratio Ġof Ġcode Ġexpansion Ġthat Ġis Ġpermitted . ĠAn Ċĉ Ġ* Ġoptimization Ġlevel Ġof Ġzero Ġis Ġthe Ġbare Ġminimum , Ġwhich Ġproduces Ġa Ġna Ã¯ ve Ċĉ Ġ* Ġtranslation Ġto Ġ[ Level &# 3 2 ; Two &# 3 2 ; code ][ L 2 Chunk ]. Ġ ĠThe Ġtranslation Ġmay Ċĉ Ġ* Ġinclude Ġcode Ġto Ġdecrement Ġa Ġcounter Ġand Ġre optimize Ġwith Ġgreater Ġeffort Ċĉ Ġ* Ġwhen Ġthe Ġcounter Ġreaches Ġzero . Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġtranslate () Ċ ĉ { Ċĉ ĉ val Ġbefore L 1 Na ive Ġ= ĠAv ail Runtime Support . capture Nan os () Ċĉ ĉ translate L 1 Instructions () Ċĉ ĉ translate L 1 Stat . record ( Ċĉĉ ĉ Avail Runtime Support . capture Nan os () Ġ- Ġbefore L 1 Na ive , Ċĉĉ ĉ interpreter . interpreter Index ) Ċĉ ĉ val Ġoptimizer Ġ= ĠL 2 Optimizer ( generator ) Ċĉ ĉ optimizer . optimize ( interpreter ) Ċĉ ĉ val Ġbefore Chunk Generation Ġ= ĠAv ail Runtime Support . capture Nan os () Ċĉ ĉ generator . create Chunk ( code ) Ċĉ ĉ assert ( code . starting Chunk Ġ== Ġgenerator . chunk ()) ĊĊĉ ĉ optimizer . post Optimization Cleanup () Ġ Ġ// ĠRemove Ġto Ġdebug . ĊĊĉ ĉ L 2 Generator . final Generation Stat . record ( Ċĉĉ ĉ Avail Runtime Support . capture Nan os () Ġ- Ġbefore Chunk Generation , Ċĉĉ ĉ interpreter . interpreter Index ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Call () Ċ ĉ { Ċĉ ĉ val Ġbundle : ĠA _ Bundle Ġ= Ċĉĉ ĉ code . literal At ( instruction Decoder . getOperand ()) Ċĉ ĉ val Ġexpected Type : ĠA _ Type Ġ= Ċĉĉ ĉ code . literal At ( instruction Decoder . getOperand ()) Ċĉ ĉ generate Call ( bundle , Ġexpected Type , Ġbottom ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Push Literal () Ċ ĉ { Ċĉ ĉ val Ġconstant Ġ= Ċĉĉ ĉ code . literal At ( instruction Decoder . getOperand ()) Ċĉ ĉ stack p -- Ċĉ ĉ move Constant To Slot ( constant , Ġstack p ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Push Last Local () Ċ ĉ { Ċĉ ĉ val Ġlocal Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ stack p -- Ċĉ ĉ val Ġsource Register Ġ= Ġread Slot ( local Index ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġsource Register ) Ċĉ ĉ nil Slot ( local Index ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Push Local () Ċ ĉ { Ċĉ ĉ val Ġlocal Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ stack p -- Ċĉ ĉ val Ġsource Register Ġ= Ċĉĉ ĉ generator . make Immutable ( read Slot ( local Index )) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġsource Register ) Ċĉ ĉ force Slot Register ( local Index , Ġpc , Ġsource Register ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Push Last Outer () Ċ ĉ { Ċĉ ĉ val Ġouter Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ val Ġouter Type Ġ= Ġcode . outer Type At ( outer Index ) Ċĉ ĉ stack p -- Ċĉ ĉ // ĠFor Ġnow , Ġsimplify Ġthe Ġlogic Ġrelated Ġto ĠL 1 's Ġn illing Ġof Ġmutable Ġout ers Ċĉ ĉ // Ġupon Ġtheir Ġfinal Ġuse . Ġ ĠJust Ġmake Ġit Ġimmutable Ġinstead . Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ pc , Ċĉĉ ĉ generator . make Immutable ( get Outer Register ( outer Index , Ġouter Type ))) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Close () Ċ ĉ { Ċĉ ĉ val Ġcount Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ val Ġcode Literal : ĠA _ Raw Function Ġ= Ġcode . literal At ( Ċĉĉ ĉ instruction Decoder . getOperand ()) Ċĉ ĉ val Ġout ers Ġ= Ġmutable ListOf < L 2 Read Boxed Operand >() Ċĉ ĉ for Ġ( i Ġin Ġ 1 Ġ.. Ġcount ) Ċĉ ĉ { Ċĉĉ ĉ out ers . add ( read Slot ( stack p Ġ+ Ġcount Ġ- Ġi )) Ċĉ ĉ } Ċĉ ĉ // ĠPop Ġthe Ġout ers , Ġbut Ġreserve Ġroom Ġfor Ġthe Ġpushed Ġfunction . Ċĉ ĉ stack p Ġ+= Ġcount Ġ- Ġ 1 Ċĉ ĉ add Instruction ( Ċĉĉ ĉ L 2 _ CREATE _ FUNCTION , Ċĉĉ ĉ L 2 Constant Operand ( code Literal ), Ċĉĉ ĉ L 2 Read Boxed Vector Operand ( out ers ), Ċĉĉ ĉ write Slot ( Ċĉĉĉ ĉ stack p , Ċĉĉĉ ĉ pc , Ċĉĉĉ ĉ restriction ForType ( code Literal . function Type (), ĠBO X ED _ FLAG ))) ĊĊĉ ĉ // ĠNow Ġthat Ġthe Ġfunction Ġhas Ġbeen Ġconstructed , Ġclear Ġthe Ġslots Ġthat Ċĉ ĉ // Ġwere Ġused Ġfor Ġouter Ġvalues Ġ-- Ġexcept Ġthe Ġdestination Ġslot , Ġwhich Ċĉ ĉ // Ġis Ġbeing Ġoverwritten Ġwith Ġthe Ġresulting Ġfunction Ġany how . Ċĉ ĉ for Ġ( i Ġin Ġstack p Ġ+ Ġ 1 Ġ- Ġcount Ġuntil Ġstack p ) Ċĉ ĉ { Ċĉĉ ĉ nil Slot ( i ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Set Local () Ċ ĉ { Ċĉ ĉ val Ġlocal Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ emit Set Variable Off R amp ( Ċĉĉ ĉ L 2 _ SET _ VARIABLE _ NO _ CHECK , Ċĉĉ ĉ read Slot ( local Index ), Ċĉĉ ĉ read Slot ( stack p )) Ċĉ ĉ // ĠNow Ġwe Ġhave Ġto Ġnil Ġthe Ġstack Ġslot Ġwhich Ġheld Ġthe Ġvalue Ġthat Ġwe Ċĉ ĉ // Ġassigned . Ġ ĠThis Ġsame Ġslot Ġpotentially Ġcaptured Ġthe Ġexpected Type Ġin Ġa Ċĉ ĉ // Ġcontinuation Ġif Ġwe Ġneeded Ġto Ġre ify Ġduring Ġthe Ġfailure Ġpath . Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ pc , Ċĉĉ ĉ generator . boxed Constant ( nil )) Ċĉ ĉ stack p ++ Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Get Local Clear ing () Ċ ĉ { Ċĉ ĉ val Ġindex Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ stack p -- Ċĉ ĉ val Ġvalue Reg Ġ= Ġemit Get Variable Off R amp ( Ċĉĉ ĉ L 2 _ GET _ VARIABLE _ CLEAR ING , Ċĉĉ ĉ read Slot ( index ), Ċĉĉ ĉ generator . new Temp (), Ċĉĉ ĉ false ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġvalue Reg ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Push Outer () Ċ ĉ { Ċĉ ĉ val Ġouter Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ val Ġouter Type Ġ= Ġcode . outer Type At ( outer Index ) Ċĉ ĉ stack p -- Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ pc , Ċĉĉ ĉ generator . make Immutable ( get Outer Register ( outer Index , Ġouter Type ))) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Pop () Ċ ĉ { Ċĉ ĉ nil Slot ( stack p ) Ċĉ ĉ stack p ++ Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Get Outer Clear ing () Ċ ĉ { Ċĉ ĉ val Ġouter Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ stack p -- Ċĉ ĉ val Ġouter Type Ġ= Ġcode . outer Type At ( outer Index ) Ċĉ ĉ val Ġvalue Reg Ġ= Ġemit Get Variable Off R amp ( Ċĉĉ ĉ L 2 _ GET _ VARIABLE _ CLEAR ING , Ċĉĉ ĉ get Outer Register ( outer Index , Ġouter Type ), Ċĉĉ ĉ generator . new Temp (), Ċĉĉ ĉ false ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġvalue Reg ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Set Outer () Ċ ĉ { Ċĉ ĉ val Ġouter Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ val Ġouter Type Ġ= Ġcode . outer Type At ( outer Index ) Ċĉ ĉ val Ġtemp Var Reg Ġ= Ċĉĉ ĉ get Outer Register ( outer Index , Ġouter Type ) Ċĉ ĉ emit Set Variable Off R amp ( Ċĉĉ ĉ L 2 _ SET _ VARIABLE _ NO _ CHECK , Ċĉĉ ĉ temp Var Reg , Ċĉĉ ĉ read Slot ( stack p )) Ċĉ ĉ // ĠNow Ġwe Ġhave Ġto Ġnil Ġthe Ġstack Ġslot Ġwhich Ġheld Ġthe Ġvalue Ġthat Ġwe Ċĉ ĉ // Ġassigned . Ġ ĠThis Ġsame Ġslot Ġpotentially Ġcaptured Ġthe Ġexpected Type Ġin Ġa Ċĉ ĉ // Ġcontinuation Ġif Ġwe Ġneeded Ġto Ġre ify Ġduring Ġthe Ġfailure Ġpath . Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ pc , Ċĉĉ ĉ generator . boxed Constant ( nil )) Ċĉ ĉ stack p ++ Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Get Local () Ċ ĉ { Ċĉ ĉ val Ġindex Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ stack p -- Ċĉ ĉ val Ġvalue Reg Ġ= Ġemit Get Variable Off R amp ( Ċĉĉ ĉ L 2 _ GET _ VARIABLE , Ċĉĉ ĉ read Slot ( index ), Ċĉĉ ĉ generator . new Temp (), Ċĉĉ ĉ true ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġvalue Reg ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Make Tuple () Ċ ĉ { Ċĉ ĉ val Ġcount Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ val Ġelements Ġ= Ġmutable ListOf < L 2 Read Boxed Operand >() Ċĉ ĉ for Ġ( i Ġin Ġ 1 Ġ.. Ġcount ) Ċĉ ĉ { Ċĉĉ ĉ elements . add ( read Slot ( stack p Ġ+ Ġcount Ġ- Ġi )) Ċĉĉ ĉ // ĠClear Ġall Ġbut Ġthe Ġfirst Ġpushed Ġslot . Ċĉĉ ĉ if Ġ( i Ġ!= Ġ 1 ) Ċĉĉ ĉ { Ċĉĉĉ ĉ nil Slot ( stack p Ġ+ Ġcount Ġ- Ġi ) Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ stack p Ġ+= Ġcount Ġ- Ġ 1 Ċĉ ĉ // ĠFold Ġinto Ġa Ġconstant Ġtuple Ġif Ġpossible Ċĉ ĉ val Ġtuple Read Ġ= Ġgenerator . create Tuple ( elements ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġtuple Read ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Get Outer () Ċ ĉ { Ċĉ ĉ val Ġouter Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ stack p -- Ċĉ ĉ val Ġouter Type Ġ= Ġcode . outer Type At ( outer Index ) Ċĉ ĉ val Ġvalue Reg Ġ= Ġemit Get Variable Off R amp ( Ċĉĉ ĉ L 2 _ GET _ VARIABLE , Ċĉĉ ĉ get Outer Register ( outer Index , Ġouter Type ), Ċĉĉ ĉ generator . new Temp (), Ċĉĉ ĉ false ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġvalue Reg ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 _ do Extension () Ċ ĉ { Ċĉ ĉ assert ( false ) Ġ{ Ġ" Illegal Ġdispatch Ġny bble code " Ġ} Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Push Label () Ċ ĉ { Ċĉ ĉ // ĠUse ĠL 2 _ VIRTUAL _ CREATE _ LABEL Ġto Ġsimplify Ġcode Ġmotion Ġin Ġthe Ġcommon Ċĉ ĉ // Ġcase Ġthat Ġlabel Ġcreation Ġcan Ġbe Ġpost p oned Ġinto Ġan Ġoff - ramp Ġ( which Ġis Ċĉ ĉ // Ġrare ly Ġinvoked ). Ġ ĠSince Ġa Ġlabel Ġrequires Ġits Ġcaller Ġto Ġbe Ġre ified , Ċĉ ĉ // Ġcreating Ġit Ġin Ġan Ġoff - ramp Ġis Ġtrivial , Ġsince Ġthe Ġcaller Ġwill Ġalready Ċĉ ĉ // Ġhave Ġbeen Ġre ified Ġby Ġthe ĠStack Re ifier Ġm achinery . Ċĉ ĉ // Ċĉ ĉ // ĠAfter Ġcode Ġmotion , Ġthe ĠL 2 _ VIRTUAL _ CREATE _ LABEL Ġinstruction Ġwill Ġbe Ċĉ ĉ // Ġreplaced Ġby Ġcode Ġto Ġforce Ġre ification Ġof Ġthe Ġcaller Ġ( or Ġdo Ġnothing Ġif Ċĉ ĉ // Ġit Ġhas Ġmigrated Ġinto Ġan Ġoff - ramp ), Ġand Ġthen Ġcreate Ġthe Ġlabel Ġusing Ċĉ ĉ // Ġthe Ġup - to - date Ġcaller . Ġ ĠSince Ġlabel Ġbuilding Ġonly Ġpre serves Ġthe Ċĉ ĉ // Ġframe 's Ġfunction Ġand Ġarguments , Ġonly Ġthose Ġare Ġused Ġby Ġthe Ġvirtual Ċĉ ĉ // Ġinstruction . Ġ ĠThe Ġlabel Ġcontinuation 's Ġpc Ġwill Ġbe Ġ 0 , Ġand Ġits Ġstack Ċĉ ĉ // Ġwill Ġbe Ġempty . Ċĉ ĉ assert ( code . code Primitive () Ġ=== Ġnull ) Ċĉ ĉ val Ġsemantic Label Ġ= Ġtop Frame (). label () Ċĉ ĉ if Ġ( generator . current Manifest . has Semantic Value ( semantic Label )) Ċĉ ĉ { Ċĉĉ ĉ // ĠRe use Ġa Ġlabel Ġthat Ġwas Ġcomputed Ġfor Ġan Ġearlier ĠL 1 Ġpush Label . Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ val Ġnum Args Ġ= Ġcode . num Args () Ċĉĉ ĉ val Ġarguments For Label Ġ= Ġmutable ListOf < L 2 Read Boxed Operand >() Ċĉĉ ĉ for Ġ( i Ġin Ġ 1 .. num Args ) Ċĉĉ ĉ { Ċĉĉĉ ĉ arguments For Label . add ( generator . make Immutable ( read Slot ( i ))) Ċĉĉ ĉ } Ċĉĉ ĉ val Ġcontinuation Type Ġ= Ċĉĉĉ ĉ continu ation Type For FunctionType ( code . function Type ()) Ċĉĉ ĉ val Ġdestination Register Ġ= Ġgenerator . boxed Write ( Ċĉĉĉ ĉ semantic Label , Ġrestriction ( continu ation Type , Ġnull )) Ċĉĉ ĉ add Instruction ( Ċĉĉĉ ĉ L 2 _ VIRTUAL _ CREATE _ LABEL , Ċĉĉĉ ĉ destination Register , Ċĉĉĉ ĉ current Function , Ċĉĉĉ ĉ L 2 Read Boxed Vector Operand ( arguments For Label ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( code . num Slots )) Ċĉ ĉ } Ċĉ ĉ // ĠNow Ġpush Ġthe Ġlabel . Ċĉ ĉ stack p -- Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ pc , Ċĉĉ ĉ current Manifest (). read Boxed ( semantic Label )) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Get Literal () Ċ ĉ { Ċĉ ĉ val Ġliteral Variable : ĠA _ Variable Ġ= Ġcode . literal At ( Ċĉĉ ĉ instruction Decoder . getOperand ()) Ċĉ ĉ stack p -- Ċĉ ĉ if Ġ( literal Variable . isInitialized Write Once Variable Ċĉĉ ĉ && Ġliteral Variable . value Was St ably Computed ()) Ċĉ ĉ { Ċĉĉ ĉ // ĠIt 's Ġan Ġinitialized Ġmodule Ġconstant , Ġso Ġit Ġcan Ġnever Ġchange , Ċĉĉ ĉ // Ġ* and * Ġthe Ġvalue Ġwas Ġcomputed Ġonly Ġvia Ġstable Ġsteps Ġfrom Ġother Ċĉĉ ĉ // Ġstable Ġvalues . Ġ ĠUse Ġthe Ġvariable 's Ġet ern al Ġvalue . Ġ ĠIf Ġwe Ġallowed Ċĉĉ ĉ // Ġan Ġun stable Ġconstant Ġvalue Ġto Ġavoid Ġtriggering Ġa Ġget , Ġwe Ġwouldn 't Ċĉĉ ĉ // Ġproperly Ġdetect Ġthe Ġaccess Ġto Ġan Ġun stable Ġvalue , Ġso Ġa Ġnew Ġmodule Ċĉĉ ĉ // Ġconstant Ġmight Ġnot Ġnotice Ġthat Ġits Ġvalue Ġwas Ġactually Ġcomputed Ċĉĉ ĉ // Ġfrom Ġun stable Ġvalues , Ġand Ġaccidentally Ġmark Ġitself Ġas Ġst ably Ċĉĉ ĉ // Ġcomputed . Ġ ĠThat Ġwould Ġbreak Ġthe Ġfast - loader Ġoptimization . Ċĉĉ ĉ move Constant To Slot ( literal Variable . value (), Ġstack p ) Ċĉ ĉ } Ċĉ ĉ else Ċĉ ĉ { Ċĉĉ ĉ val Ġvalue Reg Ġ= Ġemit Get Variable Off R amp ( Ċĉĉĉ ĉ L 2 _ GET _ VARIABLE , Ċĉĉĉ ĉ generator . boxed Constant ( literal Variable ), Ċĉĉĉ ĉ generator . new Temp (), Ċĉĉĉ ĉ false ) Ċĉĉ ĉ force Slot Register ( stack p , Ġpc , Ġvalue Reg ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Set Literal () Ċ ĉ { Ċĉ ĉ val Ġliteral Variable : ĠA _ Variable Ġ= Ġcode . literal At ( Ċĉĉ ĉ instruction Decoder . getOperand ()) Ċĉ ĉ emit Set Variable Off R amp ( Ċĉĉ ĉ L 2 _ SET _ VARIABLE _ NO _ CHECK , Ċĉĉ ĉ generator . boxed Constant ( literal Variable ), Ċĉĉ ĉ read Slot ( stack p )) Ċĉ ĉ // ĠNow Ġwe Ġhave Ġto Ġnil Ġthe Ġstack Ġslot Ġwhich Ġheld Ġthe Ġvalue Ġthat Ġwe Ċĉ ĉ // Ġassigned . Ġ ĠThis Ġsame Ġslot Ġpotentially Ġcaptured Ġthe Ġexpected Type Ġin Ġa Ċĉ ĉ // Ġcontinuation Ġif Ġwe Ġneeded Ġto Ġre ify Ġduring Ġthe Ġfailure Ġpath . Ċĉ ĉ force Slot Register ( Ċĉĉ ĉ stack p , Ċĉĉ ĉ pc , Ċĉĉ ĉ generator . boxed Constant ( nil )) Ċĉ ĉ stack p ++ Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Duplicate () Ċ ĉ { Ċĉ ĉ val Ġsource Ġ= Ġread Slot ( stack p ) Ċĉ ĉ stack p -- Ċĉ ĉ val Ġimmutable Read Ġ= Ġgenerator . make Immutable ( source ) Ċĉ ĉ force Slot Register ( stack p Ġ+ Ġ 1 , Ġpc , Ġimmutable Read ) Ċĉ ĉ force Slot Register ( stack p , Ġpc , Ġimmutable Read ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Perm ute () Ċ ĉ { Ċĉ ĉ // ĠMove Ġinto Ġthe Ġper muted Ġtemps , Ġthen Ġback Ġto Ġthe Ġstack . Ġ ĠThis Ġputs Ġthe Ċĉ ĉ // Ġresponsibility Ġfor Ġoptim izing Ġaway Ġextra Ġmoves Ġ( by Ġcolor ing Ġthe Ċĉ ĉ // Ġregisters ) Ġon Ġthe Ġoptimizer . Ċĉ ĉ val Ġpermutation : ĠA _ Tuple Ġ= Ġcode . literal At ( Ċĉĉ ĉ instruction Decoder . getOperand ()) Ċĉ ĉ val Ġsize Ġ= Ġpermutation . tuple Size Ċĉ ĉ val Ġtemps Ġ= ĠarrayOf Null s < L 2 Semantic Value >( size ) Ċĉ ĉ for Ġ( i Ġin Ġsize Ġdown To Ġ 1 ) Ċĉ ĉ { Ċĉĉ ĉ val Ġsource Ġ= Ġsemantic Slot ( stack p Ġ+ Ġsize Ġ- Ġi ) Ċĉĉ ĉ val Ġtemp Ġ= Ġgenerator . new Temp () Ċĉĉ ĉ generator . move Register ( L 2 _ MOVE . boxed , Ġsource , Ġtemp ) Ċĉĉ ĉ temp s [ permutation . tuple Int At ( i ) Ġ- Ġ 1 ] Ġ= Ġtemp Ċĉ ĉ } Ċĉ ĉ for Ġ( i Ġin Ġsize Ġdown To Ġ 1 ) Ċĉ ĉ { Ċĉĉ ĉ force Slot Register ( Ċĉĉĉ ĉ stack p Ġ+ Ġsize Ġ- Ġi , Ċĉĉĉ ĉ pc , Ċĉĉĉ ĉ current Manifest (). read Boxed ( temp s [ i Ġ- Ġ 1 ] !! )) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Super Call () Ċ ĉ { Ċĉ ĉ val Ġbundle : ĠA _ Bundle Ġ= Ċĉĉ ĉ code . literal At ( instruction Decoder . getOperand ()) Ċĉ ĉ val Ġexpected Type Ġ= Ċĉĉ ĉ code . literal At ( instruction Decoder . getOperand ()) Ċĉ ĉ val Ġsuper Union Type Ġ= Ċĉĉ ĉ code . literal At ( instruction Decoder . getOperand ()) Ċĉ ĉ generate Call ( bundle , Ġexpected Type , Ġsuper Union Type ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠL 1 Ext _ do Set Slot () Ċ ĉ { Ċĉ ĉ val Ġdestination Index Ġ= Ġinstruction Decoder . getOperand () Ċĉ ĉ val Ġsource Ġ= Ġread Slot ( stack p ) Ċĉ ĉ force Slot Register ( destination Index , Ġpc , Ġsource ) Ċĉ ĉ nil Slot ( stack p ) Ċĉ ĉ stack p ++ Ċ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠCreate Ġa Ġsemantic Ġslot Ġfor Ġthe Ġgiven Ġone - based Ġ[ index ], Ġrepresenting Ġthe Ċĉ Ġ* Ġstate Ġjust Ġbefore Ġre aching Ġthe Ġspecified Ġ[ after Pc ]. Ċĉ Ġ*/ Ċ ĉ fun Ġcreate Semantic Slot ( index : ĠInt , Ġafter Pc : ĠInt ): ĠL 2 Semantic Value Ġ= Ċĉ ĉ generator . top Frame . slot ( Ċĉĉ ĉ index , Ċĉĉ ĉ after Pc , Ċĉĉ ĉ if Ġ( index Ġ<= Ġslot Names . size ) Ġslot Names [ index Ġ- Ġ 1 ] Ġelse Ġnull ) ĊĊ ĉ comp anion Ġobject Ċ ĉ { Ċĉ ĉ /** Ċĉĉ Ġ* ĠDetermine Ġif Ġthe Ġgiven Ġ[ A _ Raw Function ]' s Ġinstanti ations Ġas Ċĉĉ Ġ* Ġ[ A _ Function ] s Ġmust Ġbe Ġmut ually Ġequal . Ċĉĉ Ġ* Ċĉĉ Ġ* Ġ@ param Ġthe Code Ċĉĉ Ġ* ĠĠ ĠThe Ġ[ A _ Raw Function ]. Ċĉĉ Ġ* Ġ@ return Ċĉĉ Ġ* ĠĠ ĠEither Ġa Ġcanonical Ġ[ A _ Function ] Ġor Ġ` null `. Ċĉĉ Ġ*/ Ċĉ ĉ private Ġfun Ġcompute Exact Function OrNull For Code ( Ċĉĉ ĉ the Code : ĠA _ Raw Function ): ĠA _ Function ? Ċĉ ĉ { Ċĉĉ ĉ val Ġnum Out ers Ġ= Ġthe Code . num Out ers Ċĉĉ ĉ val Ġouter Constants Ġ= Ġmutable ListOf < Avail Object >() Ċĉĉ ĉ for Ġ( i Ġin Ġ 1 Ġ.. Ġnum Out ers ) Ċĉĉ ĉ { Ċĉĉĉ ĉ val Ġouter Type Ġ= Ġthe Code . outer Type At ( i ) Ċĉĉĉ ĉ if Ġ(! outer Type . instance Count . equals Int ( 1 ) Ċĉĉĉĉ ĉ || Ġouter Type . is Instance Meta ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ return Ġnull Ċĉĉĉ ĉ } Ċĉĉĉ ĉ outer Constants . add ( outer Type . instance ) Ċĉĉ ĉ } Ċĉĉ ĉ // ĠThis Ġincludes Ġthe Ġcase Ġof Ġthere Ġbeing Ġno Ġout ers . Ċĉĉ ĉ return Ġcreate Function ( the Code , Ġtuple From List ( outer Constants )) Ċĉ ĉ } ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠGiven Ġa Ġregister Ġthat Ġholds Ġthe Ġfunction Ġto Ġinvoke , Ġanswer Ġeither Ġthe Ċĉĉ Ġ* Ġ[ A _ Raw Function ] Ġit Ġwill Ġbe Ġknown Ġto Ġrun , Ġor Ġ` null `. Ċĉĉ Ġ* Ċĉĉ Ġ* Ġ@ param Ġfunction To Call Reg Ċĉĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Read Boxed Operand ] Ġcontaining Ġthe Ġfunction Ġto Ġinvoke . Ċĉĉ Ġ* Ġ@ return Ċĉĉ Ġ* ĠĠ ĠEither Ġ` null ` Ġor Ġthe Ġfunction 's Ġ[ A _ Raw Function ]. Ċĉĉ Ġ*/ Ċĉ ĉ private Ġfun Ġdetermine Raw Function ( Ċĉĉ ĉ function To Call Reg : ĠL 2 Read Boxed Operand ): ĠA _ Raw Function ? Ċĉ ĉ { Ċĉĉ ĉ val Ġfunction If Known : ĠA _ Function ? Ġ= Ċĉĉĉ ĉ function To Call Reg . constant OrNull () Ċĉĉ ĉ if Ġ( function If Known Ġ!== Ġnull ) Ċĉĉ ĉ { Ċĉĉĉ ĉ // ĠThe Ġexact Ġfunction Ġis Ġknown . Ċĉĉĉ ĉ return Ġfunction If Known . code () Ċĉĉ ĉ } Ċĉĉ ĉ // ĠSee Ġif Ġwe Ġcan Ġat Ġleast Ġfind Ġout Ġthe Ġraw Ġfunction Ġthat Ġthe Ġfunction Ċĉĉ ĉ // Ġwas Ġcreated Ġfrom . Ċĉĉ ĉ val Ġfunction Definition Ġ= Ċĉĉĉ ĉ function To Call Reg . definition Skipping Moves ( true ) Ċĉĉ ĉ return Ġfunction Definition . operation (). get Constant Code From ( Ċĉĉĉ ĉ function Definition ) Ċĉ ĉ } ĊĊĉ ĉ /** ĠStat istic Ġfor Ġgenerating Ġan ĠL 2 Chunk 's Ġp reamble . Ġ*/ Ċĉ ĉ private Ġval Ġp reamble Generation Stat Ġ= ĠStat istic ( Ċĉĉ ĉ L 1 _ NA IVE _ TRANSL ATION _ TIME , Ġ"( generate Ġp reamble )") ĊĊĉ ĉ /** ĠStatistics Ġfor Ġtiming Ġthe Ġtranslation Ġper ĠL 1 Operation . Ġ*/ Ċĉ ĉ private Ġval Ġlevel One Generation Stats : ĠArray < Statistic > Ġ= Ċĉĉ ĉ L 1 Operation . values (). map Ġ{ Ċĉĉĉ ĉ Statistic ( L 1 _ NA IVE _ TRANSL ATION _ TIME , Ġit . name ) Ċĉĉ ĉ }. to Typed Array () ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠGenerate Ġthe Ġ[ L 2 Control Flow Graph ] Ġof Ġ[ L 2 Instruction ] s Ġfor Ġthe Ċĉĉ Ġ* Ġ[ L 2 Chunk . un optimized Chunk ]. Ċĉĉ Ġ* Ċĉĉ Ġ* Ġ@ param Ġinitial Block Ċĉĉ Ġ* ĠĠ ĠThe Ġblock Ġto Ġinitially Ġentry Ġthe Ġdefault Ġchunk Ġfor Ġa Ġcall . Ċĉĉ Ġ* Ġ@ param Ġre enter From Restart Block Ċĉĉ Ġ* ĠĠ ĠThe Ġblock Ġto Ġre enter Ġto Ġ[ P _ Restart Continuation ] Ġan Ġ[ A _ Continuation ]. Ċĉĉ Ġ* Ġ@ param Ġloop Block Ċĉĉ Ġ* ĠĠ ĠThe Ġmain Ġloop Ġof Ġthe Ġinterpreter . Ċĉĉ Ġ* Ġ@ param Ġre enter From Call Block Ċĉĉ Ġ* ĠĠ ĠThe Ġentry Ġpoint Ġfor Ġreturning Ġinto Ġa Ġre ified Ġcontinuation . Ċĉĉ Ġ* Ġ@ param Ġre enter From Interrupt Block Ċĉĉ Ġ* ĠĠ ĠThe Ġentry Ġpoint Ġfor Ġres uming Ġfrom Ġan Ġinterrupt . Ċĉĉ Ġ* Ġ@ param Ġunreachable Block Ċĉĉ Ġ* ĠĠ ĠA Ġbasic Ġblock Ġthat Ġshould Ġbe Ġdynamically Ġunreachable . Ċĉĉ Ġ* Ġ@ return Ċĉĉ Ġ* ĠĠ ĠThe Ġ[ L 2 Control Flow Graph ] Ġfor Ġthe Ġdefault Ġchunk . Ċĉĉ Ġ*/ Ċĉ ĉ fun Ġgenerate Default Chunk Control Flow Graph ( Ċĉĉ ĉ initial Block : ĠL 2 BasicBlock , Ċĉĉ ĉ re enter From Restart Block : ĠL 2 BasicBlock , Ċĉĉ ĉ loop Block : ĠL 2 BasicBlock , Ċĉĉ ĉ re enter From Call Block : ĠL 2 BasicBlock , Ċĉĉ ĉ re enter From Interrupt Block : ĠL 2 BasicBlock , Ċĉĉ ĉ unreachable Block : ĠL 2 BasicBlock ): ĠL 2 Control Flow Graph Ċĉ ĉ { Ċĉĉ ĉ initial Block . make Ir re mov able () Ċĉĉ ĉ loop Block . make Ir re mov able () Ċĉĉ ĉ re enter From Restart Block . make Ir re mov able () Ċĉĉ ĉ re enter From Call Block . make Ir re mov able () Ċĉĉ ĉ re enter From Interrupt Block . make Ir re mov able () Ċĉĉ ĉ unreachable Block . make Ir re mov able () Ċĉĉ ĉ val Ġgenerator Ġ= ĠL 2 Generator ( Ċĉĉĉ ĉ Optimization Level . UN OPTIMI Z ED , Ċĉĉĉ ĉ Frame ( null , Ġnil , Ġ" top Ġframe "), Ċĉĉĉ ĉ " default Ġchunk ") ĊĊĉĉ ĉ // Ġ 0 . ĠFirst Ġtry Ġto Ġrun Ġit Ġas Ġa Ġprimitive . Ċĉĉ ĉ generator . start Block ( initial Block ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ TRY _ OPTIONAL _ PR IMIT IVE ) Ċĉĉ ĉ generator . jump To ( re enter From Restart Block ) Ċĉĉ ĉ // ĠOnly Ġif Ġthe Ġprimitive Ġfails Ġshould Ġwe Ġeven Ġconsider Ġoptim izing Ġthe Ċĉĉ ĉ // Ġfallback Ġcode . ĊĊĉĉ ĉ // Ġ 1 . ĠUpdate Ġcounter Ġand Ġmaybe Ġoptimize Ġ* before * Ġextracting Ġarguments . Ċĉĉ ĉ generator . start Block ( re enter From Restart Block ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ DECRE MENT _ COUNTER _ AND _ RE OPTIMI ZE _ ON _ ZERO , Ċĉĉĉ ĉ L 2 Int Immediate Operand ( Ċĉĉĉĉ ĉ Optimization Level . FIRST _ TRANSL ATION . ordinal ), Ċĉĉĉ ĉ L 2 Int Immediate Operand ( 1 )) Ċĉĉ ĉ // Ġ 2 . ĠBuild Ġregisters , Ġget Ġarguments , Ġcreate Ġlocals , Ġcapture Ġprimitive Ċĉĉ ĉ // Ġfailure Ġvalue , Ġif Ġany . Ċĉĉ ĉ generator . add Instruction ( L 2 _ PRE PARE _ NEW _ FRAME _ FOR _ L 1 ) Ċĉĉ ĉ generator . jump To ( loop Block ) ĊĊĉĉ ĉ // Ġ 3 . ĠThe Ġmain ĠL 1 Ġinterpreter Ġloop . Ċĉĉ ĉ generator . start Block ( loop Block ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ INTER PRE T _ LEVEL _ ONE , Ċĉĉĉ ĉ edge To ( re enter From Call Block ), Ċĉĉĉ ĉ edge To ( re enter From Interrupt Block )) ĊĊĉĉ ĉ // Ġ 4 , 5 . ĠIf Ġre ified , Ġcalls Ġreturn Ġhere . Ċĉĉ ĉ generator . start Block ( re enter From Call Block ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ RE ENTER _ L 1 _ CHUNK _ FROM _ CALL ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ JUMP , Ċĉĉĉ ĉ back Edge To ( loop Block )) ĊĊĉĉ ĉ // Ġ 6 , 7 . ĠIf Ġre ified , Ġinterrupts Ġreturn Ġhere . Ċĉĉ ĉ generator . start Block ( re enter From Interrupt Block ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ RE ENTER _ L 1 _ CHUNK _ FROM _ INTERRUPT ) Ċĉĉ ĉ generator . add Instruction ( Ċĉĉĉ ĉ L 2 _ JUMP , Ċĉĉĉ ĉ back Edge To ( loop Block )) ĊĊĉĉ ĉ // Ġ 8 . ĠUn reachable . Ċĉĉ ĉ generator . start Block ( unreachable Block ) Ċĉĉ ĉ generator . add Instruction ( L 2 _ UN RE ACH ABLE _ CODE ) Ċĉĉ ĉ return Ġgenerator . control Flow Graph Ċĉ ĉ } ĊĊĉ ĉ /** ĠStat istic Ġfor Ġnumber Ġof Ġinstructions Ġin ĠL 2 Ġtranslations . Ġ*/ Ċĉ ĉ private Ġval Ġtranslation Size Stat Ġ= ĠStat istic ( Ċĉĉ ĉ L 2 _ TRANSL ATION _ VALUES , Ġ" L 2 Ġinstruction Ġcount ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠAn Ġarray Ġof Ġstatistics Ġfor Ġtracking Ġthe Ġdistribution Ġof Ġthe Ġnumber Ġof Ċĉĉ Ġ* Ġmethods Ġde pended Ġon Ġby ĠL 2 Ġtranslations . Ġ ĠThe Ġindex Ġinto Ġthe Ġarray Ġis Ċĉĉ Ġ* Ġthe Ġnumber Ġof Ġmethods Ġde pended Ġupon , Ġand Ġthe Ġcount Ġ( the Ġonly Ġpart Ġof Ċĉĉ Ġ* Ġthe Ġ[ Statistic ] Ġthat Ġis Ġmeaningful ) Ġis Ġhow Ġmany Ġ[ L 2 Chunk ] s Ġhad Ċĉĉ Ġ* Ġexactly Ġthat Ġnumber Ġof Ġdependencies . Ċĉĉ Ġ*/ Ċĉ ĉ private Ġval Ġtranslation Dependencies Stat Ġ= Ċĉĉ ĉ Atomic Reference ( array Of < Statistic >()) ĊĊĉ ĉ /** ĠStatistics Ġabout Ġthe Ġna ive ĠL 1 Ġto ĠL 2 Ġtranslation . Ġ*/ Ċĉ ĉ private Ġval Ġtranslate L 1 Stat Ġ= ĠStat istic ( Ċĉĉ ĉ L 2 _ OPTIMI Z ATION _ TIME , Ġ" L 1 Ġna ive Ġtranslation ") ĊĊĉ ĉ /** Ċĉĉ Ġ* ĠTranslate Ġthe Ġprovided Ġ[ A _ Raw Function ] Ġto Ġproduce Ġan Ġoptimized Ċĉĉ Ġ* Ġ[ L 2 Chunk ] Ġthat Ġis Ġthen Ġwritten Ġback Ġinto Ġthe Ġcode Ġfor Ġsubsequent Ċĉĉ Ġ* Ġexecution s . Ġ ĠAlso Ġupdate Ġthe Ġ[ Interpreter ]' s Ġchunk Ġand Ġoffset Ġto Ġuse Ċĉĉ Ġ* Ġthis Ġnew Ġchunk Ġright Ġaway . Ġ ĠIf Ġthe Ġcode Ġwas Ġa Ġprimitive , Ġmake Ġsure Ġto Ċĉĉ Ġ* Ġadjust Ġthe Ġoffset Ġto Ġjust Ġbeyond Ġits Ġ[ L 2 _ TRY _ PR IMIT IVE ] Ġinstruction , Ċĉĉ Ġ* Ġwhich Ġmust Ġhave Ġ* already * Ġbeen Ġattempted Ġand Ġfailed Ġfor Ġus Ġto Ġhave Ċĉĉ Ġ* Ġreached Ġthe Ġ[ L 2 _ DECRE MENT _ COUNTER _ AND _ RE OPTIMI ZE _ ON _ ZERO ] Ġthat Ġcaused Ċĉĉ Ġ* Ġthis Ġoptimization Ġto Ġhappen . Ċĉĉ Ġ* Ċĉĉ Ġ* Ġ@ param Ġcode Ċĉĉ Ġ* ĠĠ ĠThe Ġ[ A _ Raw Function ] Ġto Ġoptimize . Ċĉĉ Ġ* Ġ@ param Ġoptimization Level Ċĉĉ Ġ* ĠĠ ĠHow Ġmuch Ġoptimization Ġto Ġattempt . Ċĉĉ Ġ* Ġ@ param Ġinterpreter Ċĉĉ Ġ* ĠĠ ĠThe Ġ[ Interpreter ] Ġused Ġfor Ġfold ing Ġexpressions , Ġand Ġto Ġbe Ġupdated Ċĉĉ Ġ* ĠĠ Ġwith Ġthe Ġnew Ġchunk Ġand Ġpost - primitive Ġoffset . Ċĉĉ Ġ*/ Ċĉ ĉ fun Ġtranslate To Level Two ( Ċĉĉ ĉ code : ĠA _ Raw Function , Ċĉĉ ĉ optimization Level : ĠOptimization Level , Ċĉĉ ĉ interpreter : ĠInterpreter ) Ċĉ ĉ { Ċĉĉ ĉ val Ġsaved Function Ġ= Ġinterpreter . function Ċĉĉ ĉ val Ġsaved Arguments Ġ= Ġinterpreter . args Buffer . toList () Ċĉĉ ĉ val Ġsaved Failure Value Ġ= Ġinterpreter . latest Result OrNull () Ċĉĉ ĉ val Ġcode Name Ġ= Ġbuild String Ġ{ Ċĉĉĉ ĉ append ( code . methodName . as Native String ()) Ċĉĉĉ ĉ val Ġmodule Ġ= Ġcode . module Ċĉĉĉ ĉ if Ġ( module . not Nil ) Ċĉĉĉ ĉ { Ċĉĉĉĉ ĉ append ("\ n ") Ċĉĉĉĉ ĉ append ( module . moduleName ) Ċĉĉĉĉ ĉ val Ġline Ġ= Ġcode . code Starting LineNumber Ċĉĉĉĉ ĉ if Ġ( line Ġ!= Ġ 0 ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ append (" :$ line ") Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ val Ġgenerator Ġ= ĠL 2 Generator ( Ċĉĉĉ ĉ optimization Level , Ċĉĉĉ ĉ Frame ( null , Ġcode , Ġ" top Ġframe "), Ċĉĉĉ ĉ code Name ) Ċĉĉ ĉ val Ġtranslator Ġ= ĠL 1 Translator ( generator , Ġinterpreter , Ġcode ) Ċĉĉ ĉ translator . translate () Ċĉĉ ĉ val Ġchunk Ġ= Ġgenerator . chunk () Ċĉĉ ĉ interpreter . function Ġ= Ġsaved Function Ċĉĉ ĉ interpreter . args Buffer . clear () Ċĉĉ ĉ interpreter . args Buffer . addAll ( saved Arguments ) Ċĉĉ ĉ interpreter . set Latest Result ( saved Failure Value ) Ċĉĉ ĉ translation Size Stat . record ( Ċĉĉĉ ĉ chunk . instructions . size . to Long (), Ċĉĉĉ ĉ interpreter . interpreter Index ) Ċĉĉ ĉ val Ġdependency Count Ġ= Ġgenerator . cont ing ent Values . setSize Ċĉĉ ĉ var Ġarray Ġ= Ġtranslation Dependencies Stat . get () Ċĉĉ ĉ if Ġ( dependency Count Ġ>= Ġarray . size ) Ċĉĉ ĉ { Ċĉĉĉ ĉ array Ġ= Ġtranslation Dependencies Stat . update AndGet Ġ{ Ġold Ġ-> Ċĉĉĉĉ ĉ if Ġ( dependency Count Ġ>= Ġold . size Ġ) Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠAllocate Ġa Ġsp are Ġas Ġwell . Ċĉĉĉĉĉ ĉ Array ( dependency Count Ġ+ Ġ 2 ) Ġ{ Ċĉĉĉĉĉĉ ĉ if Ġ( it Ġ< Ġold . size ) Ġold [ it ] Ċĉĉĉĉĉĉ ĉ else ĠStat istic ( Ċĉĉĉĉĉĉĉ ĉ L 2 _ TRANSL ATION _ VALUES , Ġ" Dependency Ġcount Ġ= Ġ$ it ") Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ else Ċĉĉĉĉ ĉ { Ċĉĉĉĉĉ ĉ // ĠIt Ġwas Ġalready Ġupdated Ġby Ġanother Ġthread . Ċĉĉĉĉĉ ĉ old Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ assert ( dependency Count Ġ< Ġarray . size ) Ċĉĉ ĉ array [ dependency Count ]. record ( 1 ) Ċĉ ĉ } Ċ ĉ } ĊĊĊ ĉ init Ċ ĉ { Ċĉ ĉ stack p Ġ= Ġnum Slots Ġ+ Ġ 1 Ċĉ ĉ exact Function OrNull Ġ= Ġcompute Exact Function OrNull For Code ( code ) Ċĉ ĉ semantic Slots Ġ= ĠArray ( num Slots ) Ċĉ ĉ { Ċĉĉ ĉ create Semantic Slot ( it Ġ+ Ġ 1 , Ġ 1 ) Ċĉ ĉ } Ċĉ ĉ code . setUp Instruction Decoder ( instruction Decoder ) Ċĉ ĉ instruction Decoder . pc ( 1 ) Ċ ĉ } Ċ } Ċ