aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-11-29 17:38:59 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-11-29 17:38:59 -0800
commit3e0e413257761536b3e874d90b17d9df65591c2a (patch)
tree6200c15290b1df1c69111128206d97c292631e05 /src
parentff7d01a6a846dd9a976dc7e3c585b074def23497 (diff)
refactor unparsedFunctions a tiny bit
Diffstat (limited to 'src')
-rw-r--r--src/intertyper.js11
-rw-r--r--src/jsifier.js4
2 files changed, 8 insertions, 7 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 8e7187b6..d04c92b8 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -33,7 +33,10 @@ function intertyper(data, parseFunctions, baseLineNum) {
substrate = new Substrate('Intertyper');
- // Line splitter.
+ // Line splitter. We break off some bunches of lines into unparsedBundles, which are
+ // parsed in separate passes later. This helps to keep memory usage low - we can start
+ // from raw lines and end up with final JS for each function individually that way, instead
+ // of intertyping them all, then analyzing them all, etc.
substrate.addActor('LineSplitter', {
processItem: function(item) {
var lines = item.llvmLines;
@@ -42,7 +45,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
var inFunction = false;
var currFunctionLines;
var currFunctionLineNum;
- var unparsedFunctions = [];
+ var unparsedBundles = [];
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
lines[i] = null; // lines may be very very large. Allow GCing to occur in the loop by releasing refs here
@@ -79,7 +82,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
inFunction = false;
if (!parseFunctions) {
var func = funcHeader.processItem(tokenizer.processItem({ lineText: currFunctionLines[0], lineNum: currFunctionLineNum }, true))[0];
- unparsedFunctions.push({
+ unparsedBundles.push({
intertype: 'unparsedFunction',
// We need this early, to know basic function info - ident, params, varargs
ident: toNiceIdent(func.ident),
@@ -95,7 +98,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
// We need lines beginning with ';' inside functions, because older LLVM versions generated labels that way. But when not
// parsing functions, we can ignore all such lines and save some time that way.
this.forwardItems(ret.filter(function(item) { return item.lineText && (item.lineText[0] != ';' || parseFunctions); }), 'Tokenizer');
- return unparsedFunctions;
+ return unparsedBundles;
}
});
diff --git a/src/jsifier.js b/src/jsifier.js
index 099fa4c6..0d9f2ebd 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -32,10 +32,8 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
var pre = processMacros(preprocess(read(preFile).replace('{{RUNTIME}}', getRuntime()), CONSTANTS));
print(pre);
print('Runtime.QUANTUM_SIZE = ' + QUANTUM_SIZE);
- }
- // Add additional necessary items for the main pass
- if (mainPass) {
+ // Add additional necessary items for the main pass
LibraryManager.load();
var libFuncsToInclude;
if (INCLUDE_FULL_LIBRARY) {