aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-27 22:30:12 -0500
committerAlon Zakai <alonzakai@gmail.com>2012-12-27 22:30:12 -0500
commit0833e5bbfe9d550714733447fa13a07546574be0 (patch)
treef06b89dd080cd8878d1698eecfd853900081ef15 /src
parent0bf4db93ed9f57809c75739430bb619a693aed96 (diff)
option to provide raw ll to compiler.js
Diffstat (limited to 'src')
-rw-r--r--src/compiler.js83
1 files changed, 45 insertions, 38 deletions
diff --git a/src/compiler.js b/src/compiler.js
index e4bd8964..31d033b4 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -215,55 +215,62 @@ NECESSARY_BLOCKADDRS = temp;
// Read llvm
-var raw = read(ll_file);
-if (FAKE_X86_FP80) {
- raw = raw.replace(/x86_fp80/g, 'double');
-}
-if (raw.search('\r\n') >= 0) {
- raw = raw.replace(/\r\n/g, '\n'); // fix windows line endings
-}
-var lines = raw.split('\n');
-raw = null;
+function compile(raw) {
+ if (FAKE_X86_FP80) {
+ raw = raw.replace(/x86_fp80/g, 'double');
+ }
+ if (raw.search('\r\n') >= 0) {
+ raw = raw.replace(/\r\n/g, '\n'); // fix windows line endings
+ }
+ var lines = raw.split('\n');
+ raw = null;
-// Pre-process the LLVM assembly
+ // Pre-process the LLVM assembly
-Debugging.handleMetadata(lines);
+ Debugging.handleMetadata(lines);
-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));
+ 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);
+ if (singlePhase) 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;
+ // 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');
+ }
+}
-if (singlePhase) {
- runPhase(phase);
+if (ll_file.indexOf('\n') == -1) {
+ compile(read(ll_file));
} else {
- runPhase('pre');
- runPhase('funcs');
- runPhase('post');
+ compile(ll_file); // we are given raw .ll
}