Verified Commit b9cd5ab1 authored by Camil Staps's avatar Camil Staps 🐨

Check bytecode version number and update if the bytecode generator has a newer version

parent 5fbd5168
Pipeline #22692 passed with stage
in 1 minute and 1 second
......@@ -118,7 +118,7 @@ GenAsmProjectModule imp_pathname project setproject ps
| DQuitCompilers ![!ModuleDirAndName] !DriverCompilingInfo !DriverStateRecord
| DGene ![!ModuleDirAndName] !DriverCodeGenerationInfo !DriverStateRecord
| DOptimiseABC ![!ModuleDirAndName] !DriverStateRecord
| DGenerateByteCode ![!ModuleDirAndName] !DriverStateRecord
| DGenerateByteCode !Int ![!ModuleDirAndName] !DriverStateRecord
| DLink !DriverStateRecord
| DDone
......@@ -756,7 +756,7 @@ step intr (DOptimiseABC [!mdn:rest] ds) ps
# cgo = PR_GetCodeGenOptions ds.project
| not cgo.optimise_abc
# (paths,ds) = ds!modpaths
= step intr (DGenerateByteCode paths ds) ps
= step intr (DGenerateByteCode -1 paths ds) ps
# (tp,ps) = getCurrentProc ps
# ((modinfo,abccache,fileinfo),ps) = FI_GetFileInfo tp mdn ds.abccache ds.fileinfo ps
# (ok,ps) = OptimiseABC mdn modinfo.abcpath modinfo.abcdate ps
......@@ -764,19 +764,36 @@ step intr (DOptimiseABC [!mdn:rest] ds) ps
= cont (DOptimiseABC rest ds, ps)
step intr (DOptimiseABC [!] ds) ps
# (paths,ds) = ds!modpaths
= step intr (DGenerateByteCode paths ds) ps
= step intr (DGenerateByteCode -1 paths ds) ps
step intr (DGenerateByteCode [!mdn:rest] ds) ps
step intr (DGenerateByteCode -1 paths ds) ps
# cgo = PR_GetCodeGenOptions ds.project
| not cgo.generate_bytecode
#! ps = showInfo (Level1 "Linking...") ps
# ps = showInfo (Level1 "Linking...") ps
= step intr (DLink ds) ps
# (startupdir,ps) = getStup ps
(bcgen,ps) = getCurrentBCgen ps
bcgen = startupdir +++ DirSeparatorString +++ bcgen
# (exitcode,err,ps) = RunExternalCommand bcgen ["-V"] startupdir ps
# ok = exitcode == 0
# (ok,version) = case err of
[v] -> case toInt v of
0 -> (False,0)
v -> (ok,v)
_ -> (False,0)
# ps = if ok ps (updateErrorWindow ["Failed to get bytecode instruction set version"] ps)
| not ok
# ps = showInfo (Level1 "Linking...") ps
= step intr (DLink ds) ps
= step intr (DGenerateByteCode version paths ds) ps
step intr (DGenerateByteCode version [!mdn:rest] ds) ps
# cgo = PR_GetCodeGenOptions ds.project
# (tp,ps) = getCurrentProc ps
# ((modinfo,abccache,fileinfo),ps) = FI_GetFileInfo tp mdn ds.abccache ds.fileinfo ps
# (ok,ps) = ByteCodeGen cgo.optimise_abc mdn modinfo.abcpath ps
# (ok,ps) = ByteCodeGen version cgo.optimise_abc mdn modinfo.abcpath ps
# ds & abccache=abccache, fileinfo=fileinfo, ok=ok
= cont (DGenerateByteCode rest ds,ps)
step intr (DGenerateByteCode [!] ds) ps
= cont (DGenerateByteCode version rest ds,ps)
step intr (DGenerateByteCode _ [!] ds) ps
#! ps = showInfo (Level1 "Linking...") ps
= step intr (DLink ds) ps
......@@ -1719,8 +1736,8 @@ OptimiseABC mdn abc_path abc_date ps
# ps = updateErrorWindow err ps
= (exitcode == 0, ps)
ByteCodeGen :: !Bool !ModuleDirAndName !Pathname !*GeneralSt -> *(!Bool, !*GeneralSt)
ByteCodeGen use_optimised_abc mdn abc_path ps
ByteCodeGen :: !Int !Bool !ModuleDirAndName !Pathname !*GeneralSt -> *(!Bool, !*GeneralSt)
ByteCodeGen bcgen_version use_optimised_abc mdn abc_path ps
# (startupdir,ps) = getStup ps
(bcgen,ps) = getCurrentBCgen ps
bcgen = startupdir +++ DirSeparatorString +++ bcgen
......@@ -1729,8 +1746,9 @@ ByteCodeGen use_optimised_abc mdn abc_path ps
# (abc_date,ps) = accFiles (FModified abc_path) ps
(bc_date,ps) = accFiles (FModified bc_path) ps
| bc_date.exists && Older_Date abc_date bc_date
= (True, ps)
# (must_run,ps) = requires_codegen bc_path abc_date bc_date ps
| not must_run = (True,ps)
# ps = showInfo (Level2 ("Generating bytecode for '" +++ mdn.mdn_name +++ "'.")) ps
# (exitcode,err,ps) = RunExternalCommand bcgen [abc_path,"-o",bc_path] startupdir ps
......@@ -1739,6 +1757,19 @@ ByteCodeGen use_optimised_abc mdn abc_path ps
(err ++ ["Bytecode generator failed for " +++ mdn.mdn_name +++ " (exit code: " +++ toString exitcode +++ ")"])
# ps = updateErrorWindow err ps
= (exitcode == 0, ps)
where
requires_codegen bc_path abc_date bc_date ps
| not bc_date.exists = (True,ps)
| not (Older_Date abc_date bc_date) = (True,ps)
# ((ok,bytecode),ps) = accFiles (\fs -> let (ok,f,fs`) = fopen bc_path FReadData fs in ((ok,f),fs`)) ps
| not ok = (True,ps)
# (ok,bytecode) = fseek bytecode 8 FSeekSet
| not ok = (True,ps)
# (ok,version,bytecode) = freadi bytecode
| not ok = (True,ps)
# (ok,ps) = accFiles (fclose bytecode) ps
| not ok = abort "fclose failed during ByteCodeGen\n"
= (version <> bcgen_version,ps)
ByteCodeLink :: !FileInfoCache !Project !*GeneralSt -> *(!Bool, !*GeneralSt)
ByteCodeLink fileinfo project ps
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment