Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

Commit

Permalink
CoreRun backend running works now with/without Core whole program lin…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
atzedijkstra committed Oct 13, 2015
1 parent a1a85e5 commit c64f179
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 50 deletions.
1 change: 1 addition & 0 deletions EHC/changelog.md.editthis
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- [guarantees] This is a pre-release as far as below extensions is concerned.
- [backend] Core/CoreRun backend now better supported (e.g. via uhcl/uhcr) to allow CoreRun modules to be run, without requiring -Operwholecore (Core whole program linking).
- [extension] Local instances have been resurrected, paper submitted to flops2016 describes what can be done. Still bugs and design issues to be sorted out.
- [extension] Generic deriving now by default off, can be turned on via deriving Generic addition to datatype def.
- [compatibility] Compatibility with ghc <7.10 versions no longer guaranteed.
Expand Down
33 changes: 21 additions & 12 deletions EHC/src/ehc/EHC/BuildFunction/Run.chs
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,19 @@ bcall bfun = do
cpTrPP TraceOn_BldFlow ["ASTSemFlowStage_BetweenModule astpMbSrcCachedCore" >#< modSearchKey, pp p]
bcall $ FoldCoreModPlMb modSearchKey pl
) (return id) $ \_ (coreChkSem, _, _, _, _, _) -> do
-- 20151008 AD: TBD: dataGam needs independent passing around
return $ \crsi ->
let cenv = cenvDataGam ^$= (`gamUnion` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreChkSem) $ crsi ^. crsiCEnv
in ( ( crsiCEnv ^= cenv )
%%[[(50 grin)
{-
. ( crsiCoreInh ^$= \coreInh ->
coreInh
-- { Core2GrSem.dataGam_Inh_CodeAGItf = Core2GrSem.dataGam_Inh_CodeAGItf coreInh `gamUnion` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreChkSem }
{Core2GrSem.dataGam_Inh_CodeAGItf = cenv ^. cenvDataGam}
)
-}
%%]]
) )
$ crsi
) $ crsi
%%][50
let updCoreSrc = id
%%]]
Expand Down Expand Up @@ -280,13 +281,15 @@ bcall bfun = do
return $ \crsi ->
let cenv = cenvLamMp ^$= (Core2GrSem.gathLamMp_Syn_CodeAGItf core2GrinSem `lamMpUnionBindAspMp`) $ crsi ^. crsiCEnv
in ( ( crsiCEnv ^= cenv )
{-
. ( crsiCoreInh ^$= \coreInh ->
coreInh
-- assumption: old info can safely be overridden, otherwise merge should be done here
-- { Core2GrSem.lamMp_Inh_CodeAGItf = Core2GrSem.gathLamMp_Syn_CodeAGItf core2GrinSem `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh }
{ Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp }
) )
$ crsi
)
-}
) $ crsi

%%][50
let updCoreGrin = id
Expand Down Expand Up @@ -415,14 +418,15 @@ bcall bfun = do
) (return ()) $ \_ ehSem -> do
cpUpdSI $ \crsi ->
let ehInh = crsi ^. crsiEHInh
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
cenv = crsi ^. crsiCEnv
lm = EHSem.gathLamMp_Syn_AGItf ehSem
cenv' = ( cenvDataGam ^$= (EHSem.gathDataGam_Syn_AGItf ehSem `gamUnion`) )
%%[[(8 core)
. ( cenvLamMp ^$= (EHSem.gathLamMp_Syn_AGItf ehSem `lamMpUnionBindAspMp`) ) -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
$ cenv
{-
coreInh' = coreInh
%%[[8
{ Core2GrSem.dataGam_Inh_CodeAGItf = cenv' ^. cenvDataGam -- EHSem.gathDataGam_Syn_AGItf ehSem
Expand All @@ -432,8 +436,9 @@ bcall bfun = do
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp -- lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
}
-}
in crsi -- From: cpFlowEHSem1
{ _crsiCoreInh = coreInh', _crsiCEnv = cenv' }
{ {- _crsiCoreInh = coreInh', -} _crsiCEnv = cenv' }
%%]]

brefto bfun BRef_CRSI
Expand Down Expand Up @@ -1211,15 +1216,19 @@ ecuIsHSNewerThanHI ecu
ecu <- bcall $ EcuOfPrevNameAndPath modSearchKey
opts <- bcall $ EHCOptsOf modSearchKey
crsi <- bcall $ CRSIOfNamePl bglob modSearchKey astplan
let coreInh = _crsiCoreInh crsi
let -- coreInh = _crsiCoreInh crsi
cenv = crsi ^. crsiCEnv
coreSem = Core2GrSem.wrap_CodeAGItf
(Core2GrSem.sem_CodeAGItf (Core.CodeAGItf_AGItf core))
(coreInh { Core2GrSem.gUniq_Inh_CodeAGItf = crsi ^. crsiHereUID
, Core2GrSem.opts_Inh_CodeAGItf = opts
(Core2GrSem.Inh_CodeAGItf -- coreInh
{ Core2GrSem.gUniq_Inh_CodeAGItf = crsi ^. crsiHereUID
, Core2GrSem.opts_Inh_CodeAGItf = opts
, Core2GrSem.dataGam_Inh_CodeAGItf = cenv ^. cenvDataGam
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp
%%[[50
, Core2GrSem.importUsedModules_Inh_CodeAGItf = ecuImportUsedModules ecu
, Core2GrSem.importUsedModules_Inh_CodeAGItf = ecuImportUsedModules ecu
%%]]
})
})
bUpdECU modNm $ ecuStoreCoreSem coreSem
breturn $ Just coreSem
%%]]
Expand Down
39 changes: 24 additions & 15 deletions EHC/src/ehc/EHC/CompilePhase/FlowBetweenPhase.chs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ cpFlowEHSem1 modNm
ehInh = crsi ^. crsiEHInh
cenv = crsi ^. crsiCEnv
%%[[(8 core grin)
coreInh = _crsiCoreInh crsi
-- coreInh = _crsiCoreInh crsi
%%]]
dg = prepFlow $! EHSem.gathDataGam_Syn_AGItf ehSem
%%[[(50 hmtyinfer)
Expand All @@ -168,6 +168,11 @@ cpFlowEHSem1 modNm
%%[[(8 core)
lm = prepFlow $! EHSem.gathLamMp_Syn_AGItf ehSem
%%]]
cenv' = ( cenvDataGam ^$= (dg `gamUnionFlow`) )
%%[[(8 core)
. ( cenvLamMp ^$= (lm `lamMpUnionBindAspMp`) ) -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
$ cenv
%%[[50
mmi = panicJust "cpFlowEHSem1.crsiModMp" $ Map.lookup modNm $ crsiModMp crsi
hii = ecu ^. ecuHIInfo
Expand All @@ -178,11 +183,6 @@ cpFlowEHSem1 modNm
= mentrelToFilterMp' False [modNm] (mmiExps mmi)
%%]]
usedImpS = mentrelFilterMpModuleNames mentrelFilterMp
cenv' = ( cenvDataGam ^$= (dg `gamUnionFlow`) )
%%[[(8 core)
. ( cenvLamMp ^$= (lm `lamMpUnionBindAspMp`) ) -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
$ cenv
ehInh' = ehInh
%%[[(50 hmtyinfer)
{ -- EHSem.dataGam_Inh_AGItf = dg `gamUnionFlow` EHSem.dataGam_Inh_AGItf ehInh
Expand Down Expand Up @@ -217,6 +217,7 @@ cpFlowEHSem1 modNm
}
%%]]
%%[[(8 core grin)
{-
coreInh' = coreInh
%%[[8
{ Core2GrSem.dataGam_Inh_CodeAGItf = cenv' ^. cenvDataGam -- EHSem.gathDataGam_Syn_AGItf ehSem
Expand All @@ -226,14 +227,15 @@ cpFlowEHSem1 modNm
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp -- lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
}
-}
%%]]
; when (isJust (_ecuMbEHSem ecu))
(do { cpUpdSI
(\crsi -> crsi
%%[[(8 core grin)
{ _crsiCoreInh = coreInh', _crsiCEnv = cenv' }
{ {- _crsiCoreInh = coreInh', -} _crsiCEnv = cenv' }
%%][(50 core grin)
{ _crsiCoreInh = coreInh', _crsiCEnv = cenv', _crsiEHInh = ehInh' }
{ {- _crsiCoreInh = coreInh', -} _crsiCEnv = cenv', _crsiEHInh = ehInh' }
%%][50
{ _crsiEHInh = ehInh', _crsiCEnv = cenv' }
%%]]
Expand Down Expand Up @@ -293,11 +295,13 @@ cpFlowHISem modNm
, HSSem.idGam_Inh_AGItf = (HI.hiiIdDefOccGam hiInfo) `gamUnionFlow` HSSem.idGam_Inh_AGItf hsInh
}
%%[[(50 core grin)
{-
coreInh = crsi ^. crsiCoreInh
coreInh' = coreInh
{ -- Core2GrSem.lamMp_Inh_CodeAGItf = (HI.hiiLamMp hiInfo) `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh
Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp
}
-}
%%]]
optim = crsiOptim crsi
optim' = optim
Expand All @@ -310,7 +314,7 @@ cpFlowHISem modNm
, _crsiHSInh = hsInh'
, _crsiCEnv = cenv'
%%[[(50 core grin)
, _crsiCoreInh = coreInh'
-- , _crsiCoreInh = coreInh'
%%]]
, crsiOptim = optim'
})
Expand All @@ -325,23 +329,24 @@ cpFlowCoreModSem modNm
= do { cr <- get
; let (ecu,crsi,opts,_) = crBaseInfo modNm cr
%%[[(50 grin)
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
%%]]
mbCoreModSem = _ecuMbCoreSemMod ecu
-- 20151008 AD: TBD: dataGam should be passed independently of Core etc.
; when (isJust mbCoreModSem) $ do
{ let coreModSem = fromJust mbCoreModSem
cenv = cenvDataGam ^$= (`gamUnionFlow` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreModSem) $ crsi ^. crsiCEnv
%%[[(50 grin)
{-
coreInh' = coreInh
{ -- Core2GrSem.dataGam_Inh_CodeAGItf = Core2GrSem.dataGam_Inh_CodeAGItf coreInh `gamUnionFlow` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreModSem
Core2GrSem.dataGam_Inh_CodeAGItf = cenv ^. cenvDataGam
}
-}
%%]]
; cpUpdSI $
( crsiCEnv ^= cenv )
%%[[(50 grin)
. ( crsiCoreInh ^= coreInh' )
-- . ( crsiCoreInh ^= coreInh' )
%%]]
}
}
Expand All @@ -358,12 +363,14 @@ cpFlowCoreSemAfterFold modNm
lm = prepFlow $! Core2GrSem.gathLamMp_Syn_CodeAGItf coreSem
cenv = cenvLamMp ^$= (lm `lamMpUnionBindAspMp`) $ crsi ^. crsiCEnv -- assumption: old info can be overridden, otherwise merge should be done here
%%[[50
{-
coreInh = crsi ^. crsiCoreInh
hii = ecu ^. ecuHIInfo
coreInh' = coreInh
{ -- Core2GrSem.lamMp_Inh_CodeAGItf = lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: old info can be overridden, otherwise merge should be done here
Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp
}
-}
hii = ecu ^. ecuHIInfo
hii' = hii
{ HI.hiiLamMp = lm
}
Expand All @@ -372,7 +379,7 @@ cpFlowCoreSemAfterFold modNm
(do { cpUpdSI $
( crsiCEnv ^= cenv )
%%[[50
. ( crsiCoreInh ^= coreInh')
-- . ( crsiCoreInh ^= coreInh')
; cpUpdCU modNm ( ecuStoreHIInfo hii'
)
%%]]
Expand Down Expand Up @@ -418,7 +425,7 @@ cpFlowHILamMp modNm
= do { cr <- get
; let (ecu,crsi,opts,_) = crBaseInfo modNm cr
%%[[(50 grin)
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
%%]]
cenv = cenvLamMp ^$= (HI.hiiLamMp hii `lamMpUnionBindAspMp`) $ crsi ^. crsiCEnv -- assumption: old info can be overridden, otherwise merge should be done here
hii = ecu ^. ecuHIInfo
Expand All @@ -427,10 +434,12 @@ cpFlowHILamMp modNm
; cpUpdSI $
( crsiCEnv ^= cenv )
%%[[(50 grin)
{-
. ( crsiCoreInh ^= coreInh
-- { Core2GrSem.lamMp_Inh_CodeAGItf = HI.hiiLamMp hii `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh }
{ Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp }
)
-}
%%]]
}
%%]
Expand Down
14 changes: 9 additions & 5 deletions EHC/src/ehc/EHC/CompilePhase/Semantics.chs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ cpFoldCore2Grin modNm
; let (ecu,crsi,opts,_) = crBaseInfo modNm cr
mbCore = _ecuMbCore ecu
core = panicJust "cpFoldCore2Grin" mbCore
coreInh = crsi ^. crsiCoreInh
cenv = crsi ^. crsiCEnv
-- coreInh = crsi ^. crsiCoreInh
coreSem = Core2GrSem.wrap_CodeAGItf
(Core2GrSem.sem_CodeAGItf (Core.CodeAGItf_AGItf core))
(coreInh { Core2GrSem.gUniq_Inh_CodeAGItf = crsi ^. crsiHereUID
, Core2GrSem.opts_Inh_CodeAGItf = opts
(Core2GrSem.Inh_CodeAGItf -- coreInh
{ Core2GrSem.gUniq_Inh_CodeAGItf = crsi ^. crsiHereUID
, Core2GrSem.opts_Inh_CodeAGItf = opts
, Core2GrSem.dataGam_Inh_CodeAGItf = cenv ^. cenvDataGam
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp
%%[[50
, Core2GrSem.importUsedModules_Inh_CodeAGItf = ecuImportUsedModules ecu
, Core2GrSem.importUsedModules_Inh_CodeAGItf = ecuImportUsedModules ecu
%%]]
})
})
; when (isJust mbCore)
(cpUpdCU modNm ( ecuStoreCoreSem coreSem
))
Expand Down
7 changes: 6 additions & 1 deletion EHC/src/ehc/EHC/CompilePhase/TopLevelPhases.chs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ cpEhcCorePerModulePart2 modNm
}
%%]

%%[(8 codegen corerunin)
%%[(8888 codegen corerunin)
-- | Part 2 CoreRun processing, part2 is done either for per individual module compilation or after full program analysis
cpEhcCoreRunPerModulePart2 :: EHCCompileRunner m => HsName -> EHCompilePhaseT m ()
cpEhcCoreRunPerModulePart2 = cpProcessCoreRunRest
Expand Down Expand Up @@ -1298,9 +1298,11 @@ cpProcessCoreBasic modNm
%%]]
, cpProcessCoreFold modNm
%%[[(50 corerun)
{-
, when (targetIsCoreVariation (ehcOptTarget opts)) $
void $ -- cpOutputCoreRun ASTFileContent_Binary "" Cfg.suffixDotlessBinaryCoreRun modNm
cpOutputSomeModule (^. ecuCoreRun) astHandler'_CoreRun ASTFileContent_Binary "" Cfg.suffixDotlessBinaryCoreRun modNm
-}
%%]]
]
}
Expand Down Expand Up @@ -1405,6 +1407,9 @@ cpProcessCoreRunRest modNm
-- [cpRunCoreRun2 modNm]
-- [cpRunCoreRun3 modNm]
else [])
++ (if targetIsCoreVariation (ehcOptTarget opts)
then [void $ cpOutputSomeModule (^. ecuCoreRun) astHandler'_CoreRun ASTFileContent_Binary "" Cfg.suffixDotlessInputOutputBinaryCoreRun modNm]
else [])
)
}

Expand Down
2 changes: 1 addition & 1 deletion EHC/src/ehc/EHC/CompilePhase/Transformations.chs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cpTransformCore optimScope modNm
-- transform
; let mbCore = _ecuMbCore ecu
%%[[(8 grin)
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
%%]]
trfcoreIn = emptyTrfCore
{ trfstMod = panicJust "cpTransformCore" mbCore
Expand Down
8 changes: 4 additions & 4 deletions EHC/src/ehc/EHC/CompilePhase/Translations.chs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ cpTranslateCore2JavaScript modNm
= do { cr <- get
; let (ecu,crsi,opts,fp) = crBaseInfo modNm cr
mbCore = _ecuMbCore ecu
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
; when (isJust mbCore)
$ cpUpdCU modNm
$ ecuStoreJavaScript
Expand Down Expand Up @@ -302,7 +302,7 @@ cpTranslateGrin2Cmm modNm
= do { cr <- get
; let (ecu,crsi,opts,fp) = crBaseInfo modNm cr
mbGrin = _ecuMbGrin ecu
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
%%[[50
; (lamMp, allImpNmL, impNmFldMpMp, expNmFldMp) <- cpGenGrinGenInfo modNm
%%]]
Expand All @@ -327,7 +327,7 @@ cpTranslateCmm2JavaScript modNm
= do { cr <- get
; let (ecu,crsi,opts,fp) = crBaseInfo modNm cr
mbCmm = _ecuMbCmm ecu
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
; when (isJust mbCmm) $ do
let (jsmod,errs) =
cmmMod2JavaScript opts
Expand Down Expand Up @@ -404,7 +404,7 @@ cpTranslateByteCode modNm
grinbcCmm = Cmm.Module_Mod modNm cmmMod Nothing Const.emptyConstSt
%%]]
%%][50
coreInh = crsi ^. crsiCoreInh
-- coreInh = crsi ^. crsiCoreInh
( grinbcPP
%%[[(50 cmm cmmbc)
,grinbcCmm
Expand Down
6 changes: 3 additions & 3 deletions EHC/src/ehc/EHC/CompileRun/Base.chs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ data EHCompileRunStateInfo (m :: * -> *)
, _crsiCEnv :: CEnv -- globally required codegen info
-- 20151009 AD: TBD, for now non strict field
%%[[(8 core grin)
, _crsiCoreInh :: !AST_Core_Inh_ToGrin -- current inh attrs for Core2Grin sem
-- , _crsiCoreInh :: !AST_Core_Inh_ToGrin -- current inh attrs for Core2Grin sem
%%]]
%%[[(8 corerun)
, _crsiCoreRunState :: !EHCompileRunCoreRunStateInfo -- corerun compilation specific state
Expand Down Expand Up @@ -1013,7 +1013,7 @@ emptyEHCompileRunStateInfo
, _crsiFileSuffMp = emptyFileSuffMp
, _crsiCEnv = emptyCEnv
%%[[(8 core grin)
, _crsiCoreInh = panic "emptyEHCompileRunStateInfo.crsiCoreInh"
-- , _crsiCoreInh = panic "emptyEHCompileRunStateInfo.crsiCoreInh"
%%]]
%%[[(8 corerun)
, _crsiCoreRunState = emptyEHCompileRunCoreRunStateInfo
Expand Down Expand Up @@ -1170,7 +1170,7 @@ mkLabel ''EHCompileRunStateInfo
%%[8 export(crsiCEnv)
%%]

%%[(8 core grin) export(crsiCoreInh)
%%[(8888 core grin) export(crsiCoreInh)
%%]

%%[(8888 corerun) export(crsiCore2RunInh)
Expand Down
2 changes: 1 addition & 1 deletion EHC/src/ehc/EHC/InitialSetup.chs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ initialEHSem opts fp
}
%%]

%%[(8 codegen) export(initialCore2GrSem)
%%[(8888 codegen) export(initialCore2GrSem)
initialCore2GrSem :: EHCOpts -> Core2GrSem.Inh_CodeAGItf
initialCore2GrSem opts
= Core2GrSem.Inh_CodeAGItf
Expand Down
Loading

0 comments on commit c64f179

Please sign in to comment.