mirror of
https://github.com/KarolS/millfork.git
synced 2025-02-16 05:32:26 +00:00
Single threaded mode
This commit is contained in:
parent
1909fd7154
commit
53245eb1e2
@ -126,6 +126,8 @@ object CompilationFlag extends Enumeration {
|
|||||||
VariableOverlap, CompactReturnDispatchParams,
|
VariableOverlap, CompactReturnDispatchParams,
|
||||||
// runtime check options
|
// runtime check options
|
||||||
CheckIndexOutOfBounds,
|
CheckIndexOutOfBounds,
|
||||||
|
// special options
|
||||||
|
SingleThreaded,
|
||||||
// warning options
|
// warning options
|
||||||
ExtraComparisonWarnings,
|
ExtraComparisonWarnings,
|
||||||
RorWarning,
|
RorWarning,
|
||||||
|
@ -301,6 +301,10 @@ object Main {
|
|||||||
|
|
||||||
fluff("", "Other options:", "")
|
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 => {
|
flag("--help").action(c => {
|
||||||
printHelp(20).foreach(println(_))
|
printHelp(20).foreach(println(_))
|
||||||
assumeStatus(CliStatus.Quit)
|
assumeStatus(CliStatus.Quit)
|
||||||
|
@ -52,7 +52,8 @@ object SuperOptimizer extends AssemblyOptimization {
|
|||||||
while(queue.nonEmpty) {
|
while(queue.nonEmpty) {
|
||||||
val (optsSoFar, codeSoFar) = queue.dequeue()
|
val (optsSoFar, codeSoFar) = queue.dequeue()
|
||||||
var isLeaf = true
|
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 optimized = o.optimize(m, codeSoFar, options)
|
||||||
val view = viewCode(optimized)
|
val view = viewCode(optimized)
|
||||||
seenSoFar.synchronized{
|
seenSoFar.synchronized{
|
||||||
|
@ -194,7 +194,7 @@ object VariableToRegisterOptimization extends AssemblyOptimization {
|
|||||||
val aCandidateSets = NonOverlappingIntervals.apply[(String, Range, Int)](aCandidates, _._2.start, _._2.end)
|
val aCandidateSets = NonOverlappingIntervals.apply[(String, Range, Int)](aCandidates, _._2.start, _._2.end)
|
||||||
|
|
||||||
val variants = for {
|
val variants = for {
|
||||||
vx <- xCandidateSets.par
|
vx <- if (options.flag(CompilationFlag.SingleThreaded)) xCandidateSets else xCandidateSets.par
|
||||||
nx = vx.map(_._1)
|
nx = vx.map(_._1)
|
||||||
|
|
||||||
vy <- yCandidateSets
|
vy <- yCandidateSets
|
||||||
|
@ -30,8 +30,12 @@ class SourceLoadingQueue(val initialFilenames: List[String], val includePath: Li
|
|||||||
moduleQueue.enqueue(() => parseModule("zp_reg", includePath, Left(None), options))
|
moduleQueue.enqueue(() => parseModule("zp_reg", includePath, Left(None), options))
|
||||||
}
|
}
|
||||||
while (moduleQueue.nonEmpty) {
|
while (moduleQueue.nonEmpty) {
|
||||||
|
if (options.flag(CompilationFlag.SingleThreaded)) {
|
||||||
|
moduleQueue.dequeueAll(_ => true).foreach(_())
|
||||||
|
} else {
|
||||||
moduleQueue.dequeueAll(_ => true).par.foreach(_())
|
moduleQueue.dequeueAll(_ => true).par.foreach(_())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ErrorReporting.assertNoErrors("Parse failed")
|
ErrorReporting.assertNoErrors("Parse failed")
|
||||||
parsedModules.values.reduce(_ + _)
|
parsedModules.values.reduce(_ + _)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user