1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-23 23:30:22 +00:00

Single threaded mode

This commit is contained in:
Karol Stasiak 2018-03-06 01:01:22 +01:00
parent 1909fd7154
commit 53245eb1e2
5 changed files with 14 additions and 3 deletions

View File

@ -126,6 +126,8 @@ object CompilationFlag extends Enumeration {
VariableOverlap, CompactReturnDispatchParams,
// runtime check options
CheckIndexOutOfBounds,
// special options
SingleThreaded,
// warning options
ExtraComparisonWarnings,
RorWarning,

View File

@ -301,6 +301,10 @@ object Main {
fluff("", "Other options:", "")
flag("--single-threaded").action(c =>
c.changeFlag(CompilationFlag.SingleThreaded, true)
).description("Run the compiler in a single thread.")
flag("--help").action(c => {
printHelp(20).foreach(println(_))
assumeStatus(CliStatus.Quit)

View File

@ -52,7 +52,8 @@ object SuperOptimizer extends AssemblyOptimization {
while(queue.nonEmpty) {
val (optsSoFar, codeSoFar) = queue.dequeue()
var isLeaf = true
allOptimizers.par.foreach { o =>
(if (options.flag(CompilationFlag.SingleThreaded)) allOptimizers
else allOptimizers.par).foreach { o =>
val optimized = o.optimize(m, codeSoFar, options)
val view = viewCode(optimized)
seenSoFar.synchronized{

View File

@ -194,7 +194,7 @@ object VariableToRegisterOptimization extends AssemblyOptimization {
val aCandidateSets = NonOverlappingIntervals.apply[(String, Range, Int)](aCandidates, _._2.start, _._2.end)
val variants = for {
vx <- xCandidateSets.par
vx <- if (options.flag(CompilationFlag.SingleThreaded)) xCandidateSets else xCandidateSets.par
nx = vx.map(_._1)
vy <- yCandidateSets

View File

@ -30,7 +30,11 @@ class SourceLoadingQueue(val initialFilenames: List[String], val includePath: Li
moduleQueue.enqueue(() => parseModule("zp_reg", includePath, Left(None), options))
}
while (moduleQueue.nonEmpty) {
moduleQueue.dequeueAll(_ => true).par.foreach(_())
if (options.flag(CompilationFlag.SingleThreaded)) {
moduleQueue.dequeueAll(_ => true).foreach(_())
} else {
moduleQueue.dequeueAll(_ => true).par.foreach(_())
}
}
ErrorReporting.assertNoErrors("Parse failed")
parsedModules.values.reduce(_ + _)