diff options
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 66 |
1 files changed, 7 insertions, 59 deletions
diff --git a/emscripten.py b/emscripten.py index 8758df52..ad770b19 100755 --- a/emscripten.py +++ b/emscripten.py @@ -727,15 +727,14 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, compiler = path_from_root('src', 'compiler.js') - # Parallelization: We run 3 phases: - # 1 aka 'pre' : Process types and metadata and so forth, and generate the preamble. - # 2 aka 'funcs': Process functions. We can parallelize this, working on each function independently. - # 3 aka 'post' : Process globals, generate postamble and finishing touches. + # Overview: + # * Run LLVM backend to emit JS. JS includes function bodies, memory initializer, + # and various metadata + # * Run compiler.js on the metadata to emit the shell js code, pre/post-ambles, + # JS library dependencies, etc. if DEBUG: logging.debug('emscript: ll=>js') - if jcache: jcache.ensure() - # Pre-scan ll and alter settings as necessary if DEBUG: t = time.time() ll = open(infile).read() @@ -806,34 +805,12 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, pre_file = temp_files.get('.pre.ll').name pre_input = ''.join(pre) + '\n' + meta out = None - if jcache: - keys = [pre_input, settings_text, ','.join(libraries)] - shortkey = jcache.get_shortkey(keys) - if DEBUG_CACHE: logging.debug('shortkey', shortkey) - - out = jcache.get(shortkey, keys) - - if DEBUG_CACHE and not out: - dfpath = os.path.join(get_configuration().TEMP_DIR, "ems_" + shortkey) - dfp = open(dfpath, 'w') - dfp.write(pre_input) - dfp.write("\n\n========================== settings_text\n\n") - dfp.write(settings_text) - dfp.write("\n\n========================== libraries\n\n") - dfp.write("\n".join(libraries)) - dfp.close() - logging.debug(' cache miss, key data dumped to %s' % dfpath) - - if out and DEBUG: logging.debug(' loading pre from jcache') if not out: open(pre_file, 'w').write(pre_input) #print >> sys.stderr, 'running', str([settings_file, pre_file, 'pre'] + libraries).replace("'/", "'") # see funcs out = jsrun.run_js(compiler, compiler_engine, [settings_file, pre_file, 'pre'] + libraries, stdout=subprocess.PIPE, stderr=STDERR_FILE, cwd=path_from_root('src')) assert '//FORWARDED_DATA:' in out, 'Did not receive forwarded data in pre output - process failed?' - if jcache: - if DEBUG: logging.debug(' saving pre to jcache') - jcache.set(shortkey, keys, out) pre, forwarded_data = out.split('//FORWARDED_DATA:') forwarded_file = temp_files.get('.json').name pre_input = None @@ -864,30 +841,13 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, chunks = cache_module.chunkify( funcs, chunk_size, - jcache.get_cachename('emscript_files') if jcache else None) + None) #sys.exit(1) #chunks = [chunks[0]] # pick specific chunks for debugging/profiling funcs = None - if jcache: - # load chunks from cache where we can # TODO: ignore small chunks - cached_outputs = [] - def load_from_cache(chunk): - keys = [settings_text, forwarded_data, chunk] - shortkey = jcache.get_shortkey(keys) # TODO: share shortkeys with later code - out = jcache.get(shortkey, keys) # this is relatively expensive (pickling?) - if out: - cached_outputs.append(out) - return False - return True - chunks = filter(load_from_cache, chunks) - if len(cached_outputs) > 0: - if out and DEBUG: logging.debug(' loading %d funcchunks from jcache' % len(cached_outputs)) - else: - cached_outputs = [] - # TODO: minimize size of forwarded data from funcs to what we actually need if len(chunks) > 0: @@ -901,8 +861,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, funcs_file = temp_files.get('.func_%d.ll' % i).name f = open(funcs_file, 'w') f.write(chunks[i]) - if not jcache: - chunks[i] = None # leave chunks array alive (need its length later) + chunks[i] = None # leave chunks array alive (need its length later) f.write('\n') f.write(meta) f.close() @@ -922,19 +881,8 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, else: outputs = [] - if jcache: - # save chunks to cache - for i in range(len(chunks)): - chunk = chunks[i] - keys = [settings_text, forwarded_data, chunk] - shortkey = jcache.get_shortkey(keys) - jcache.set(shortkey, keys, outputs[i]) - if out and DEBUG and len(chunks) > 0: logging.debug(' saving %d funcchunks to jcache' % len(chunks)) - chunks = None - if jcache: outputs += cached_outputs # TODO: preserve order - outputs = [output.split('//FORWARDED_DATA:') for output in outputs] for output in outputs: assert len(output) == 2, 'Did not receive forwarded data in an output - process failed? We only got: ' + output[0][-3000:] |