aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc35
1 files changed, 32 insertions, 3 deletions
diff --git a/emcc b/emcc
index 48631d64..27b873c4 100755
--- a/emcc
+++ b/emcc
@@ -724,8 +724,6 @@ try:
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if llvm_lto is None: llvm_lto = llvm_opts > 0
if closure is None: closure = 1 if opt_level >= 2 else 0
- if minify_whitespace is None:
- minify_whitespace = closure # if closure is run, minify whitespace
if opt_level <= 0: keep_debug = True # always keep debug in -O0
if DEBUG: start_time = time.time() # done after parsing arguments, which might affect debug state
@@ -853,9 +851,23 @@ try:
exec('shared.Settings.' + key + ' = ' + value)
# Apply effects from settings
+ if shared.Settings.ASM_JS:
+ if closure:
+ print >> sys.stderr, 'emcc: warning: disabling closure because it is not compatible with asm.js code generation'
+ closure = False
+ if shared.Settings.CORRECT_SIGNS != 1:
+ print >> sys.stderr, 'emcc: warning: setting CORRECT_SIGNS to 1 for asm.js code generation'
+ shared.Settings.CORRECT_SIGNS = 1
+ if shared.Settings.CORRECT_OVERFLOWS != 1:
+ print >> sys.stderr, 'emcc: warning: setting CORRECT_OVERFLOWS to 1 for asm.js code generation'
+ shared.Settings.CORRECT_OVERFLOWS = 1
+
if shared.Settings.CORRECT_SIGNS >= 2 or shared.Settings.CORRECT_OVERFLOWS >= 2 or shared.Settings.CORRECT_ROUNDINGS >= 2:
keep_debug = True # must keep debug info to do line-by-line operations
+ if minify_whitespace is None:
+ minify_whitespace = closure # if closure is run, minify whitespace
+
## Compile source code to bitcode
if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode'
@@ -1137,6 +1149,16 @@ try:
execute(shlex.split(js_transform, posix=posix) + [os.path.abspath(final)])
if DEBUG: save_intermediate('transformed')
+ if shared.Settings.ASM_JS: # XXX temporary wrapping for testing purposes
+ unwrapped = open(final).read()
+ final += '.asmwrap.js'
+ open(final, 'w').write('''
+(function() { // prevent new Function from seeing the global scope
+%s
+}).apply(null, arguments);
+''' % unwrapped)
+ if DEBUG: save_intermediate('asmwrap')
+
# It is useful to run several js optimizer passes together, to save on unneeded unparsing/reparsing
js_optimizer_queue = []
def flush_js_optimizer_queue():
@@ -1162,7 +1184,12 @@ try:
if DEBUG: save_intermediate('pretty')
def get_eliminate():
- return 'eliminate' if not shared.Settings.ALLOW_MEMORY_GROWTH else 'eliminateMemSafe'
+ if shared.Settings.ASM_JS:
+ return 'eliminateAsm'
+ elif shared.Settings.ALLOW_MEMORY_GROWTH:
+ return 'eliminateMemSafe'
+ else:
+ return 'eliminate'
js_optimizer_queue += [get_eliminate()]
@@ -1176,6 +1203,8 @@ try:
if DEBUG: print >> sys.stderr, 'emcc: running closure'
final = shared.Building.closure_compiler(final)
if DEBUG: save_intermediate('closure')
+ elif shared.Settings.ASM_JS and shared.Settings.RELOOP:
+ js_optimizer_queue += ['registerizeAsm'] # we can't use closure in asm, but this does much of the same
if opt_level >= 1:
if DEBUG: print >> sys.stderr, 'emcc: running post-closure post-opts'