diff options
-rwxr-xr-x | emscripten.py | 1 | ||||
-rw-r--r-- | src/jsifier.js | 7 | ||||
-rw-r--r-- | src/parseTools.js | 3 |
3 files changed, 5 insertions, 6 deletions
diff --git a/emscripten.py b/emscripten.py index e845aef2..790b8674 100755 --- a/emscripten.py +++ b/emscripten.py @@ -308,7 +308,6 @@ def emscript(infile, settings, outfile, libraries=[]): fundamentals = ['buffer', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array'] basic_funcs = ['abort', 'assert'] + [m.replace('.', '_') for m in maths] basic_vars = ['STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT'] - if not settings['NAMED_GLOBALS']: basic_vars += ['GLOBAL_BASE'] if forwarded_json['Types']['preciseI64MathUsed']: basic_funcs += ['i64Math_' + op for op in ['add', 'subtract', 'multiply', 'divide', 'modulo']] asm_setup += ''' diff --git a/src/jsifier.js b/src/jsifier.js index 5cea1dfa..7568c088 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1353,12 +1353,11 @@ function JSify(data, functionsOnly, givenFunctions) { if (phase == 'pre' && !Variables.generatedGlobalBase) { Variables.generatedGlobalBase = true; if (Variables.nextIndexedOffset > 0) { - // Variables have been calculated, get to base generation before we print them - print('var GLOBAL_BASE = STATICTOP; assert(GLOBAL_BASE == STACK_MAX); \n'); + // Variables have been calculated, get to base stuff before we print them + // GLOBAL_BASE is statically known to be equal to STACK_MAX and to TOTAL_STACK, assert on this + print('assert(STATICTOP == STACK_MAX); assert(STACK_MAX == TOTAL_STACK);\n'); print('STATICTOP += ' + Variables.nextIndexedOffset + ';\n'); print('assert(STATICTOP < TOTAL_MEMORY);\n'); - } else { - print('var GLOBAL_BASE = 0;\n'); } } var generated = itemsDict.function.concat(itemsDict.type).concat(itemsDict.GlobalVariableStub).concat(itemsDict.GlobalVariable).concat(itemsDict.GlobalVariablePostSet); diff --git a/src/parseTools.js b/src/parseTools.js index 1a7746e7..8bd8b796 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -414,7 +414,8 @@ function makeGlobalDef(ident) { } function makeGlobalUse(ident) { - if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return '(' + getFastValue('GLOBAL_BASE', '+', Variables.indexedGlobals[ident]) + ')'; + // We assert on TOTAL_STACK being equal to GLOBAL_BASE + if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return (TOTAL_STACK + Variables.indexedGlobals[ident]).toString(); return ident; } |