fix and enable minifyNames in native optimizer

This commit is contained in:
Alon Zakai 2014-11-13 15:38:39 -08:00
Родитель e6ff252953
Коммит f8750120dc
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -9,7 +9,7 @@ __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
NATIVE_PASSES = set(['asm', 'asmPreciseF32', 'receiveJSON', 'emitJSON', 'eliminate', 'eliminateMemSafe', 'simplifyExpressions', 'simplifyIfs', 'optimizeFrounds', 'registerize'])
NATIVE_PASSES = set(['asm', 'asmPreciseF32', 'receiveJSON', 'emitJSON', 'eliminate', 'eliminateMemSafe', 'simplifyExpressions', 'simplifyIfs', 'optimizeFrounds', 'registerize', 'minifyNames', 'minifyLocals'])
JS_OPTIMIZER = path_from_root('tools', 'js-optimizer.js')
@ -106,8 +106,10 @@ def run_on_chunk(command):
filename = command[index + 1]
else:
filename = command[1]
#print >> sys.stderr, 'running js optimizer command', ' '.join(map(lambda c: c if c != filename else 'input.txt', command))
#shutil.copyfile(filename, '/tmp/emscripten_temp/input.txt')
#saved = 'save_' + os.path.basename(filename)
#while os.path.exists(saved): saved = 'input' + str(int(saved.replace('input', '').replace('.txt', ''))+1) + '.txt'
#print >> sys.stderr, 'running js optimizer command', ' '.join(map(lambda c: c if c != filename else saved, command))
#shutil.copyfile(filename, os.path.join('/tmp/emscripten_temp', saved))
output = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + output
filename = temp_files.get(os.path.basename(filename) + '.jo.js').name

Просмотреть файл

@ -2657,8 +2657,9 @@ void minifyLocals(Ref ast) {
if (node[0] == NAME) {
IString name = node[1]->getIString();
if (!asmData.isLocal(name)) {
IString minified = globals[name]->getIString();
if (!!minified) {
if (globals->has(name)) {
IString minified = globals[name]->getIString();
assert(!!minified);
newNames[name] = minified;
usedNames.insert(minified);
}