Changeset 7851

Show
Ignore:
Timestamp:
11/05/05 15:06:37 (3 years ago)
Author:
autrijus
Message:

* Repair PIR codegen; use "new .Continuation" instead of

the old style "newsub" op. Suggested by Leo.

Location:
src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Emit/PIR.hs

    r7277 r7851  
    8787    = PerlScalar | PerlArray | PerlHash 
    8888    | PerlInt | PerlPair | PerlRef | PerlEnv 
     89    | Closure | Continuation 
    8990    | BareType String 
    9091    deriving (Show, Eq, Typeable) 
     
    587588                -> PrimName    -- ^ PIR opcode to use for branching 
    588589                -> Decl        -- ^ Final declaration of the sub 
    589 stmtControlCond name comp = sub ("&statement_control:" ++ name) [arg0, arg1, arg2] ( 
    590     [ "newsub" .- [funPMC, bare ".Continuation", bare postL] 
    591     , comp .- [arg0, bare altL] 
    592     ] ++ callThunkCC arg1 ++ 
    593     [ InsLabel altL 
    594     ] ++ callThunkCC arg2 ++ collectCC postL) --> [tempPMC] 
     590stmtControlCond name comp = 
     591    sub ("&statement_control:" ++ name) [arg0, arg1, arg2] body --> [tempPMC] 
    595592    where 
    596593    altL = ("sc_" ++ name ++ "_alt") 
    597594    postL = ("sc_" ++ name ++ "_post") 
     595    body = concat 
     596        [ newCont postL 
     597        , [ comp .- [arg0, bare altL] ] 
     598        , callThunkCC arg1 
     599        , [ InsLabel altL ] 
     600        , callThunkCC arg2, 
     601        collectCC postL 
     602        ] 
     603 
     604newCont :: VarName -> [Ins] 
     605newCont label = 
     606    [ InsNew funPMC Continuation 
     607    , "set_addr" .- [funPMC, bare label] 
     608    ] 
    598609 
    599610{-| Creates appropriate @&infix:foo@ subs for logical operators (@||@, @&&@, 
     
    602613           -> PrimName         -- ^ PIR opcode to use (@if@, @unless@) 
    603614           -> Decl             -- ^ Final declaration of the sub 
    604 op2Logical name comp = sub ("&infix:" ++ name) [arg0, arg1] ( 
    605     [ "newsub" .- [funPMC, bare ".Continuation", bare postL] 
    606     , comp .- [arg0, bare altL] 
    607     , "set_returns" .- retSigList [arg0] 
    608     , "returncc" .- [] 
    609     , InsLabel altL 
    610     ] ++ callThunkCC arg1 ++ collectCC postL) --> [tempPMC] 
     615op2Logical name comp = sub ("&infix:" ++ name) [arg0, arg1] body --> [tempPMC] 
    611616    where 
    612617    altL = ("sc_" ++ escaped name ++ "_alt") 
    613618    postL = ("sc_" ++ escaped name ++ "_post") 
     619    body = newCont postL ++ 
     620        [ comp .- [arg0, bare altL] 
     621        , "set_returns" .- retSigList [arg0] 
     622        , "returncc" .- [] 
     623        , InsLabel altL 
     624        ] ++ callThunkCC arg1 ++ collectCC postL 
    614625 
    615626{-| Escapes characters which have a special meaning in PIR. -} 
  • src/Pugs/CodeGen/PIR.hs

    r7579 r7851  
    8989        [begL, sndL, retL, endL] <- genLabel ["thunkBegin", "thunkAgain", "thunkReturn", "thunkEnd"] 
    9090        this    <- genPMC "block" 
    91         tellIns $ "newsub" .- [reg this, bare ".Continuation", bare begL] 
     91        tellIns $ InsNew (reg this) Continuation 
     92        tellIns $ "set_addr" .- [reg this, bare begL] 
    9293        tellIns $ "goto" .- [bare endL] 
    9394        tellLabel begL 
     
    109110        [begL, endL] <- genLabel ["blockBegin", "blockEnd"] 
    110111        this    <- genPMC "block" 
    111         tellIns $ "newsub" .- [reg this, bare ".Closure", bare begL] 
     112        tellIns $ InsNew (reg this) Closure 
     113        tellIns $ "set_addr" .- [reg this, bare begL] 
    112114        tellIns $ "goto" .- [bare endL] 
    113115        tellLabel begL