diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-08 10:17:44 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-08 10:17:44 -0800 |
commit | 82ddb0715d1aa655841223cff314a5377fe10aa5 (patch) | |
tree | 99908b418c6234544f033abc00ad7dbed6adba93 /tools | |
parent | 1836357e38f7a13c3ac3810ed0e82a8d393c5a3c (diff) |
send only a marker of generated functions to js-optimizer.js; we either know the generated functions and send only them, or we don't know them and send all the code, in either case js-optimizer.js does not need a list of generated functions
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 7 | ||||
-rw-r--r-- | tools/eliminator/eliminator-test.js | 7 | ||||
-rw-r--r-- | tools/js-optimizer.js | 19 | ||||
-rw-r--r-- | tools/js_optimizer.py | 2 | ||||
-rw-r--r-- | tools/test-js-optimizer-output.js | 6 | ||||
-rw-r--r-- | tools/test-js-optimizer.js | 6 |
6 files changed, 6 insertions, 41 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index 32b7ddcf..69539e91 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -192,13 +192,6 @@ function strtok_part(b, j, f) { function py() { HEAP[HEAP[HEAP[__PyThreadState_Current] + 12] + 1 + 12] = 99; } -function otherPy() { - var $4 = HEAP[__PyThreadState_Current]; - var $5 = $4 + 12; - var $7 = HEAP[$5] + 1; - var $8 = $4 + 12; - HEAP[$8] = $7; -} var anon = (function(x) { var $4 = HEAP[__PyThreadState_Current]; var $5 = $4 + 12; diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index 13ecab59..3edd61ac 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -230,13 +230,6 @@ function py() { var $8 = $7 + 12; HEAP[$8] = 99; } -function otherPy() { - var $4 = HEAP[__PyThreadState_Current]; - var $5 = $4 + 12; - var $7 = HEAP[$5] + 1; - var $8 = $4 + 12; - HEAP[$8] = $7; -} var anon = function(x) { var $4 = HEAP[__PyThreadState_Current]; var $5 = $4 + 12; diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index f2dc516a..9c744fa3 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -140,15 +140,8 @@ var UNDEFINED_NODE = ['unary-prefix', 'void', ['num', 0]]; var TRUE_NODE = ['unary-prefix', '!', ['num', 0]]; var FALSE_NODE = ['unary-prefix', '!', ['num', 1]]; -var GENERATED_FUNCTIONS_MARKER = '// EMSCRIPTEN_GENERATED_FUNCTIONS:'; -var generatedFunctions = null; -function setGeneratedFunctions(metadata) { - var start = metadata.indexOf(GENERATED_FUNCTIONS_MARKER); - generatedFunctions = set(eval(metadata.substr(start + GENERATED_FUNCTIONS_MARKER.length))); -} -function isGenerated(ident) { - return ident in generatedFunctions; -} +var GENERATED_FUNCTIONS_MARKER = '// EMSCRIPTEN_GENERATED_FUNCTIONS'; +var generatedFunctions = false; // whether we have received only generated functions function srcToAst(src) { return uglify.parser.parse(src); @@ -216,7 +209,7 @@ function traverse(node, pre, post, stack) { function traverseGenerated(ast, pre, post, stack) { assert(generatedFunctions); traverse(ast, function(node) { - if (node[0] == 'defun' && isGenerated(node[1])) { + if (node[0] == 'defun') { traverse(node, pre, post, stack); return null; } @@ -226,7 +219,7 @@ function traverseGenerated(ast, pre, post, stack) { function traverseGeneratedFunctions(ast, callback) { assert(generatedFunctions); traverse(ast, function(node) { - if (node[0] == 'defun' && isGenerated(node[1])) { + if (node[0] == 'defun') { callback(node); return null; } @@ -2218,9 +2211,7 @@ var passes = { var src = read(arguments_[0]); var ast = srcToAst(src); //printErr(JSON.stringify(ast)); throw 1; -var metadata = src.split('\n').filter(function(line) { return line.indexOf(GENERATED_FUNCTIONS_MARKER) >= 0 })[0]; -//assert(metadata, 'Must have EMSCRIPTEN_GENERATED_FUNCTIONS metadata'); -if (metadata) setGeneratedFunctions(metadata); +generatedFunctions = src.indexOf(GENERATED_FUNCTIONS_MARKER) >= 0; arguments_.slice(1).forEach(function(arg) { passes[arg](ast); diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index 2fd2211b..13e6e4f6 100644 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -131,7 +131,7 @@ def run_on_js(filename, passes, js_engine, jcache): temp_file = temp_files.get('.jsfunc_%d.js' % i).name f = open(temp_file, 'w') f.write(chunk) - f.write(suffix) + f.write(suffix_marker) f.close() return temp_file filenames = [write_chunk(chunks[i], i) for i in range(len(chunks))] diff --git a/tools/test-js-optimizer-output.js b/tools/test-js-optimizer-output.js index 5c06475e..13f927de 100644 --- a/tools/test-js-optimizer-output.js +++ b/tools/test-js-optimizer-output.js @@ -35,12 +35,6 @@ function loopy() { next(); something(); } -function ignoreLoopy() { - b$for_cond$4 : while (1) { - if ($ok) break b$for_cond$4; - var $inc = $ok + 1; - } -} function bits() { print(($s & 65535) + ((($f & 65535) << 16 >> 16) * (($f & 65535) << 16 >> 16) | 0) % 256 & 65535); z(HEAP32[$id + 40 >> 2]); diff --git a/tools/test-js-optimizer.js b/tools/test-js-optimizer.js index 982e3230..bd3be281 100644 --- a/tools/test-js-optimizer.js +++ b/tools/test-js-optimizer.js @@ -37,12 +37,6 @@ function loopy() { something(); } while(0); } -function ignoreLoopy() { - b$for_cond$4: while(1) { - if ($ok) break b$for_cond$4; - var $inc=$ok+1; - } -} function bits() { print((($s & 65535) + ((($f & 65535) << 16 >> 16) * (($f & 65535) << 16 >> 16) | 0 | 0) % 256 | 0) & 65535); z(HEAP32[($id + 40 | 0) >> 2]); |