diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 15:47:29 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 15:47:29 -0800 |
commit | ac5209f8f4bcceabd68e127b73996890715c596e (patch) | |
tree | 103240a165f9bbcbd2fd9a02e4d7fd153693a88b /src/jsifier.js | |
parent | cb88b99fc40e27ba503ba6f29f9f15d3d7f15f63 (diff) |
do global indexing up front
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 714bd33c..591dccc4 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1293,7 +1293,18 @@ function JSify(data, functionsOnly, givenFunctions) { // Print out global variables and postsets TODO: batching if (phase == 'pre') { legalizedI64s = false; - JSify(analyzer(intertyper(data.unparsedGlobalss[0].lines, true), true), true, Functions); + + var globalsData = analyzer(intertyper(data.unparsedGlobalss[0].lines, true), true); + + if (!NAMED_GLOBALS) { + for (var ident in Variables.globals) { + Variables.indexedGlobals[ident] = Variables.nextIndexedOffset; + Variables.nextIndexedOffset += Runtime.alignMemory(calcAllocatedSize(Variables.globals[ident].type)); + } + } + + JSify(globalsData, true, Functions); + globalsData = null; data.unparsedGlobalss = null; var generated = itemsDict.functionStub.concat(itemsDict.GlobalVariablePostSet); |