diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-27 15:25:31 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-27 15:25:31 -0500 |
commit | 275adcf5ce7729295d0fa706cbb2f45ac0a875ef (patch) | |
tree | 2d0067ee1f647a132448aac0469f07a874ffd196 /src/compiler.js | |
parent | 66021ae3aba2f532610efda849f8dbabc8f94783 (diff) |
allow (unoptimal) single-phase compiler.js invocation
Diffstat (limited to 'src/compiler.js')
-rw-r--r-- | src/compiler.js | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/compiler.js b/src/compiler.js index 3ce53b1e..e87ff760 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -225,30 +225,43 @@ raw = null; // Pre-process the LLVM assembly -//printErr('JS compiler in action, phase ' + phase); - Debugging.handleMetadata(lines); -if (phase != 'pre') { - PassManager.load(read(forwardedDataFile)); +function runPhase(currPhase) { + //printErr('// JS compiler in action, phase ' + currPhase + typeof lines + (lines === null)); + phase = currPhase; + if (phase != 'pre') { + if (singlePhase) PassManager.load(read(forwardedDataFile)); - if (phase == 'funcs') { - PreProcessor.eliminateUnneededIntrinsics(lines); + if (phase == 'funcs') { + PreProcessor.eliminateUnneededIntrinsics(lines); + } } -} -// Do it + // Do it + + var intertyped = intertyper(lines); + if (singlePhase) lines = null; + var analyzed = analyzer(intertyped); + intertyped = null; + JSify(analyzed); -var intertyped = intertyper(lines); -lines = null; -var analyzed = analyzer(intertyped); -intertyped = null; -JSify(analyzed); + if (DEBUG_MEMORY) { + print('zzz. last gc: ' + gc()); + MemoryDebugger.dump(); + print('zzz. hanging now!'); + while(1){}; + } +} -if (DEBUG_MEMORY) { - print('zzz. last gc: ' + gc()); - MemoryDebugger.dump(); - print('zzz. hanging now!'); - while(1){}; +// Normal operation is for each execution of compiler.js to run a single phase. The calling script sends us exactly the information we need, and it is easy to parallelize operation that way. However, it is also possible to run in an unoptimal multiphase mode, where a single invocation goes from ll to js directly. This is not recommended and will likely do a lot of duplicate processing. +singlePhase = !!phase; + +if (singlePhase) { + runPhase(phase); +} else { + runPhase('pre'); + runPhase('funcs'); + runPhase('post'); } |