diff options
-rw-r--r-- | src/intertyper.js | 11 | ||||
-rw-r--r-- | src/jsifier.js | 4 |
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) { |