diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-08 13:04:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-08 13:04:13 -0700 |
commit | 649f00422986e1e41551bcb49568adcb7897faa6 (patch) | |
tree | 87879d2c9803e9024f009e0d59429d38509066e8 | |
parent | 458567779b54a321ee65c30a80b8a1b0d984d359 (diff) |
track if there is inline js, and if so do not mark as valid asm.js
-rwxr-xr-x | emscripten.py | 5 | ||||
-rw-r--r-- | src/intertyper.js | 3 | ||||
-rw-r--r-- | src/modules.js | 7 |
3 files changed, 11 insertions, 4 deletions
diff --git a/emscripten.py b/emscripten.py index 257527fe..e05037b0 100755 --- a/emscripten.py +++ b/emscripten.py @@ -287,6 +287,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, exported_implemented_functions = set() for func_js, curr_forwarded_data in outputs: curr_forwarded_json = json.loads(curr_forwarded_data) + forwarded_json['Types']['hasInlineJS'] = forwarded_json['Types']['hasInlineJS'] or curr_forwarded_json['Types']['hasInlineJS'] forwarded_json['Types']['preciseI64MathUsed'] = forwarded_json['Types']['preciseI64MathUsed'] or curr_forwarded_json['Types']['preciseI64MathUsed'] for key, value in curr_forwarded_json['Functions']['blockAddresses'].iteritems(): forwarded_json['Functions']['blockAddresses'][key] = value @@ -543,7 +544,7 @@ function asmPrintFloat(x, y) { } // EMSCRIPTEN_START_ASM var asm = (function(global, env, buffer) { - 'use asm'; + %s var HEAP8 = new global.Int8Array(buffer); var HEAP16 = new global.Int16Array(buffer); var HEAP32 = new global.Int32Array(buffer); @@ -552,7 +553,7 @@ var asm = (function(global, env, buffer) { var HEAPU32 = new global.Uint32Array(buffer); var HEAPF32 = new global.Float32Array(buffer); var HEAPF64 = new global.Float64Array(buffer); -''' % (asm_setup,) + '\n' + asm_global_vars + ''' +''' % (asm_setup, "'use asm';" if not forwarded_json['Types']['hasInlineJS'] else "'almost asm, but inline js';") + '\n' + asm_global_vars + ''' var __THREW__ = 0; var threwValue = 0; var setjmpId = 0; diff --git a/src/intertyper.js b/src/intertyper.js index ddb93d71..f9633549 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -708,7 +708,8 @@ function intertyper(data, sidePass, baseLineNums) { item.ident = eatLLVMIdent(tokensLeft); if (item.ident == 'asm') { if (ASM_JS) { - warnOnce('inline JS in asm.js mode can cause the code to no longer fall in the asm.js subset of JavaScript'); + Types.hasInlineJS = true; + warnOnce('inline JavaScript (asm, EM_ASM) will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance'); } assert(TARGET_LE32, 'inline js is only supported in le32'); // Inline assembly is just JavaScript that we paste into the code diff --git a/src/modules.js b/src/modules.js index 373e60d9..1a931572 100644 --- a/src/modules.js +++ b/src/modules.js @@ -227,6 +227,8 @@ var Types = { needAnalysis: {}, // Types noticed during parsing, that need analysis + hasInlineJS: false, // whether the program has inline JS anywhere + // Set to true if we actually use precise i64 math: If PRECISE_I64_MATH is set, and also such math is actually // needed (+,-,*,/,% - we do not need it for bitops), or PRECISE_I64_MATH is 2 (forced) preciseI64MathUsed: (PRECISE_I64_MATH == 2) @@ -467,7 +469,10 @@ var PassManager = { })); } else if (phase == 'funcs') { print('\n//FORWARDED_DATA:' + JSON.stringify({ - Types: { preciseI64MathUsed: Types.preciseI64MathUsed }, + Types: { + hasInlineJS: Types.hasInlineJS, + preciseI64MathUsed: Types.preciseI64MathUsed + }, Functions: { blockAddresses: Functions.blockAddresses, indexedFunctions: Functions.indexedFunctions, |