diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 14 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 17 | ||||
-rw-r--r-- | tools/js-optimizer.js | 12 |
3 files changed, 40 insertions, 3 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index 52c91ce1..2ce77b78 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -5094,4 +5094,18 @@ function multiloop2($n_0, $35) { } } } +function tempDouble2($46, $14, $28, $42, $20, $32, $45) { + $46 = $46 | 0; + $14 = $14 | 0; + $28 = $28 | 0; + $42 = $42 | 0; + $20 = $20 | 0; + $32 = $32 | 0; + $45 = $45 | 0; + var $_sroa_06_0_insert_insert$1 = 0; + $_sroa_06_0_insert_insert$1 = (HEAPF32[tempDoublePtr >> 2] = ($20 < $32 ? $20 : $32) - $42, HEAP32[tempDoublePtr >> 2] | 0) | 0; + HEAP32[$45 >> 2] = 0 | (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0); + HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1; + HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1; +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index e01a89ea..f45f082b 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -6823,5 +6823,20 @@ function multiloop2($n_0, $35) { } } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "multiloop", "multiloop2"] +function tempDouble2($46, $14, $28, $42, $20, $32, $45) { + $46 = $46 | 0; + $14 = $14 | 0; + $28 = $28 | 0; + $42 = $42 | 0; + $20 = $20 | 0; + $32 = $32 | 0; + $45 = $45 | 0; + var $46 = 0, $_sroa_06_0_insert_insert$1 = 0; + $46 = (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0); + $_sroa_06_0_insert_insert$1 = (HEAPF32[tempDoublePtr >> 2] = ($20 < $32 ? $20 : $32) - $42, HEAP32[tempDoublePtr >> 2] | 0) | 0; + HEAP32[$45 >> 2] = 0 | $46; + HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1; + HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "multiloop", "multiloop2", "tempDouble2"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 7e1d374f..5a202de9 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1850,6 +1850,13 @@ var NODES_WITHOUT_ELIMINATION_SIDE_EFFECTS = set('name', 'num', 'string', 'binar var IGNORABLE_ELIMINATOR_SCAN_NODES = set('num', 'toplevel', 'string', 'break', 'continue', 'dot'); // dot can only be STRING_TABLE.* var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'for', 'while', 'array', 'throw'); // we could handle some of these, TODO, but nontrivial (e.g. for while, the condition is hit multiple times after the body) +function isTempDoublePtrAccess(node) { // these are used in bitcasts; they are not really affecting memory, and should cause no invalidation + assert(node[0] == 'sub'); + return (node[2][0] == 'name' && node[2][1] == 'tempDoublePtr') || + (node[2][0] == 'binary' && ((node[2][2][0] == 'name' && node[2][2][1] == 'tempDoublePtr') || + (node[2][3][0] == 'name' && node[2][3][1] == 'tempDoublePtr'))); +} + function eliminate(ast, memSafe) { // Find variables that have a single use, and if they can be eliminated, do so traverseGeneratedFunctions(ast, function(func, type) { @@ -2134,7 +2141,7 @@ function eliminate(ast, memSafe) { if (allowTracking) track(name, node[3], node); } } else if (target[0] == 'sub') { - if (!memoryInvalidated) { + if (!isTempDoublePtrAccess(target) && !memoryInvalidated) { invalidateMemory(); memoryInvalidated = true; } @@ -2142,7 +2149,8 @@ function eliminate(ast, memSafe) { } else if (type == 'sub') { traverseInOrder(node[1], false, !memSafe); // evaluate inner traverseInOrder(node[2]); // evaluate outer - if (!ignoreSub) { // ignoreSub means we are a write (happening later), not a read + // ignoreSub means we are a write (happening later), not a read + if (!ignoreSub && !isTempDoublePtrAccess(node)) { // do the memory access if (!callsInvalidated) { invalidateCalls(); |