[commit: ghc] wip/oneShot: Add GHC.Prim.oneShot (955d9f5)

Simon Peyton Jones simonpj at microsoft.com
Sun Oct 26 21:02:41 UTC 2014


Is all this one-shot stuff carefully documented somewhere?  I think it's basically a good plan, but I see no Notes, alas.

Simon

| -----Original Message-----
| From: ghc-commits [mailto:ghc-commits-bounces at haskell.org] On Behalf Of
| git at git.haskell.org
| Sent: 25 October 2014 11:27
| To: ghc-commits at haskell.org
| Subject: [commit: ghc] wip/oneShot: Add GHC.Prim.oneShot (955d9f5)
| 
| Repository : ssh://git@git.haskell.org/ghc
| 
| On branch  : wip/oneShot
| Link       :
| http://ghc.haskell.org/trac/ghc/changeset/955d9f53b6c934585a90423dfc95d86
| d8a129908/ghc
| 
| >---------------------------------------------------------------
| 
| commit 955d9f53b6c934585a90423dfc95d86d8a129908
| Author: Joachim Breitner <mail at joachim-breitner.de>
| Date:   Sun Jan 26 11:36:23 2014 +0000
| 
|     Add GHC.Prim.oneShot
| 
|     Conflicts:
|     	compiler/basicTypes/MkId.lhs
| 
| 
| >---------------------------------------------------------------
| 
| 955d9f53b6c934585a90423dfc95d86d8a129908
|  compiler/basicTypes/MkId.lhs   | 17 +++++++++++++++--
|  compiler/prelude/PrelNames.lhs |  3 ++-
|  2 files changed, 17 insertions(+), 3 deletions(-)
| 
| diff --git a/compiler/basicTypes/MkId.lhs b/compiler/basicTypes/MkId.lhs
| index bf1c199..05dcdd5 100644
| --- a/compiler/basicTypes/MkId.lhs
| +++ b/compiler/basicTypes/MkId.lhs
| @@ -135,7 +135,8 @@ ghcPrimIds
|      seqId,
|      magicDictId,
|      coerceId,
| -    proxyHashId
| +    proxyHashId,
| +    oneShotId
|      ]
|  \end{code}
| 
| @@ -1016,7 +1017,7 @@ another gun with which to shoot yourself in the
| foot.
|  \begin{code}
|  lazyIdName, unsafeCoerceName, nullAddrName, seqName,
|     realWorldName, voidPrimIdName, coercionTokenName,
| -   magicDictName, coerceName, proxyName, dollarName :: Name
| +   magicDictName, coerceName, proxyName, dollarName, oneShotName :: Name
|  unsafeCoerceName  = mkWiredInIdName gHC_PRIM  (fsLit "unsafeCoerce#")
| unsafeCoerceIdKey  unsafeCoerceId
|  nullAddrName      = mkWiredInIdName gHC_PRIM  (fsLit "nullAddr#")
| nullAddrIdKey      nullAddrId
|  seqName           = mkWiredInIdName gHC_PRIM  (fsLit "seq")
| seqIdKey           seqId
| @@ -1028,6 +1029,7 @@ magicDictName     = mkWiredInIdName gHC_PRIM
| (fsLit "magicDict")      magicDict
|  coerceName        = mkWiredInIdName gHC_PRIM  (fsLit "coerce")
| coerceKey          coerceId
|  proxyName         = mkWiredInIdName gHC_PRIM  (fsLit "proxy#")
| proxyHashKey       proxyHashId
|  dollarName        = mkWiredInIdName gHC_BASE  (fsLit "$")
| dollarIdKey        dollarId
| +oneShotName       = mkWiredInIdName gHC_PRIM (fsLit "oneShot")
| oneShotKey         oneShotId
|  \end{code}
| 
|  \begin{code}
| @@ -1119,6 +1121,17 @@ lazyId = pcMiscPrelId lazyIdName ty info
|      info = noCafIdInfo
|      ty  = mkForAllTys [alphaTyVar] (mkFunTy alphaTy alphaTy)
| 
| +oneShotId :: Id
| +oneShotId = pcMiscPrelId oneShotName ty info
| +  where
| +    info = noCafIdInfo `setInlinePragInfo` alwaysInlinePragma
| +                       `setUnfoldingInfo`  mkCompulsoryUnfolding rhs
| +    ty  = mkForAllTys [alphaTyVar, betaTyVar] (mkFunTy fun_ty fun_ty)
| +    fun_ty = mkFunTy alphaTy betaTy
| +    [body, x] = mkTemplateLocals [fun_ty, alphaTy]
| +    x' = setOneShotLambda x
| +    rhs = mkLams [alphaTyVar, betaTyVar, body, x'] $ Var body `App` Var
| x
| +
| 
|  ------------------------------------------------------------------------
| --------
|  magicDictId :: Id  -- See Note [magicDictId magic]
| diff --git a/compiler/prelude/PrelNames.lhs
| b/compiler/prelude/PrelNames.lhs
| index e053b11..e2ade33 100644
| --- a/compiler/prelude/PrelNames.lhs
| +++ b/compiler/prelude/PrelNames.lhs
| @@ -1682,10 +1682,11 @@ rootMainKey, runMainKey :: Unique
|  rootMainKey                   = mkPreludeMiscIdUnique 101
|  runMainKey                    = mkPreludeMiscIdUnique 102
| 
| -thenIOIdKey, lazyIdKey, assertErrorIdKey :: Unique
| +thenIOIdKey, lazyIdKey, assertErrorIdKey, oneShotKey :: Unique
|  thenIOIdKey                   = mkPreludeMiscIdUnique 103
|  lazyIdKey                     = mkPreludeMiscIdUnique 104
|  assertErrorIdKey              = mkPreludeMiscIdUnique 105
| +oneShotKey                    = mkPreludeMiscIdUnique 106
| 
|  breakpointIdKey, breakpointCondIdKey, breakpointAutoIdKey,
|      breakpointJumpIdKey, breakpointCondJumpIdKey,
| 
| _______________________________________________
| ghc-commits mailing list
| ghc-commits at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-commits


More information about the ghc-devs mailing list