finalize saved original code when it will be swapped in
This commit is contained in:
Родитель
e9e1a4354a
Коммит
a8c8fadea6
13
emcc
13
emcc
|
@ -1498,11 +1498,24 @@ try:
|
|||
shared.try_delete(js_target)
|
||||
|
||||
# minify (if requested) after emterpreter processing, and finalize output
|
||||
logging.debug('finalizing emterpreted code')
|
||||
shared.Settings.FINALIZE_ASM_JS = 1
|
||||
do_minify()
|
||||
js_optimizer_queue += ['last']
|
||||
flush_js_optimizer_queue()
|
||||
|
||||
# finalize the original as well, if we will be swapping it in (TODO: add specific option for this)
|
||||
if shared.Settings.SWAPPABLE_ASM_MODULE:
|
||||
real = final
|
||||
original = js_target + '.orig.js' # the emterpretify tool saves the original here
|
||||
final = original
|
||||
logging.debug('finalizing original (non-emterpreted) code at ' + final)
|
||||
do_minify()
|
||||
js_optimizer_queue += ['last']
|
||||
flush_js_optimizer_queue()
|
||||
safe_move(final, original)
|
||||
final = real
|
||||
|
||||
# Remove some trivial whitespace # TODO: do not run when compress has already been done on all parts of the code
|
||||
#src = open(final).read()
|
||||
#src = re.sub(r'\n+[ \n]*\n+', '\n', src)
|
||||
|
|
|
@ -2060,5 +2060,9 @@ Module['_main'] = function() {
|
|||
Popen([PYTHON, EMCC, 'second.cpp'] + opts).communicate()
|
||||
Popen([PYTHON, path_from_root('tools', 'distill_asm.py'), 'a.out.js', 'second.js', 'swap-in']).communicate()
|
||||
assert os.path.exists('second.js')
|
||||
|
||||
out = run_js('second.js', engine=SPIDERMONKEY_ENGINE, stderr=PIPE, full_output=True, assert_returncode=None)
|
||||
self.validate_asmjs(out)
|
||||
|
||||
self.btest(path_from_root('tests', 'asm_swap.cpp'), args=['-s', 'SWAPPABLE_ASM_MODULE=1', '-s', 'NO_EXIT_RUNTIME=1', '--pre-js', 'run.js'] + opts, expected='999')
|
||||
|
||||
|
|
|
@ -4303,3 +4303,10 @@ function _main() {
|
|||
do_log_test(path_from_root('tests', 'primes.cpp'), 86, 'main')
|
||||
do_log_test(path_from_root('tests', 'fannkuch.cpp'), 234, 'fannkuch_worker')
|
||||
|
||||
def test_emterpreter_swap_orig(self):
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'fasta.cpp'), '-s', 'EMTERPRETIFY=1', '-s', 'SWAPPABLE_ASM_MODULE=1', '-O2']).communicate()
|
||||
Popen([PYTHON, path_from_root('tools', 'distill_asm.py'), 'a.out.js.orig.js', 'second.js', 'swap-in']).communicate()
|
||||
assert os.path.exists('second.js')
|
||||
out = run_js('second.js', engine=SPIDERMONKEY_ENGINE, stderr=PIPE, full_output=True, assert_returncode=None)
|
||||
self.validate_asmjs(out)
|
||||
|
||||
|
|
|
@ -561,8 +561,7 @@ force_memfile = sys.argv[3] if len(sys.argv) >= 4 else None
|
|||
if len(sys.argv) >= 5:
|
||||
BLACKLIST = set(list(BLACKLIST) + json.loads(sys.argv[4]))
|
||||
|
||||
#print 'emterpretifying %s to %s' % (infile, outfile)
|
||||
|
||||
shared.logging.debug('saving original (non-emterpreted) code to ' + infile + '.orig.js')
|
||||
shutil.copyfile(infile, infile + '.orig.js')
|
||||
|
||||
# final global functions
|
||||
|
|
Загрузка…
Ссылка в новой задаче