aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-24 18:36:17 +0100
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 14:23:18 -0800
commit887ef685cd7e6d9af9e45016dc6c714feaf281d3 (patch)
tree5d69d24f1cb7cb58aa8fc71ed95fca3524e4b47a /tools
parenteac1c0b2bf7f6c01553bfe1117592bc285878464 (diff)
notice function indentation in js_optimizer.py so that we properly scan indented code in asm.js
Diffstat (limited to 'tools')
-rw-r--r--tools/js_optimizer.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py
index 622ceec2..744e068a 100644
--- a/tools/js_optimizer.py
+++ b/tools/js_optimizer.py
@@ -53,7 +53,7 @@ def run(filename, passes, js_engine, jcache):
jcache = False
# If we process only generated code, find that and save the rest on the side
- func_sig = re.compile('function (_[\w$]+)\(')
+ func_sig = re.compile('( *)function (_[\w$]+)\(')
if suffix:
pos = 0
gen_start = 0
@@ -62,12 +62,13 @@ def run(filename, passes, js_engine, jcache):
m = func_sig.search(js, pos)
if not m: break
pos = m.end()
- ident = m.group(1)
+ indent = m.group(1)
+ ident = m.group(2)
if ident in generated:
if not gen_start:
gen_start = m.start()
assert gen_start
- gen_end = js.find('\n}\n', m.end()) + 3
+ gen_end = js.find('\n%s}\n' % indent, m.end()) + (3 + len(indent))
assert gen_end > gen_start
pre = js[:gen_start]
post = js[gen_end:]
@@ -128,6 +129,7 @@ def run(filename, passes, js_engine, jcache):
if len(filenames) > 0:
# XXX Use '--nocrankshaft' to disable crankshaft to work around v8 bug 1895, needed for older v8/node (node 0.6.8+ should be ok)
commands = map(lambda filename: [js_engine, JS_OPTIMIZER, filename, 'noPrintMetadata'] + passes, filenames)
+ #print [' '.join(command) for command in commands]
cores = min(multiprocessing.cpu_count(), filenames)
if len(chunks) > 1 and cores >= 2: