From 5e68c85806e5a31c8e5ec903f916eebdc3fccaf6 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 10 Sep 2015 14:08:17 -0700 Subject: [PATCH] suggest use of EMTERPRETIFY_FILE when emterpreter bitcode is large --- tests/test_other.py | 13 +++++++++++++ tools/emterpretify.py | 3 +++ 2 files changed, 16 insertions(+) diff --git a/tests/test_other.py b/tests/test_other.py index 737fce8e7..b48cc6e1a 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -5166,3 +5166,16 @@ main(int argc, char **argv) out, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_libcxx.cpp')], stderr=PIPE).communicate() assert err == '', err + def test_emterpreter_file_suggestion(self): + for linkable in [0, 1]: + for to_file in [0, 1]: + self.clear() + cmd = [PYTHON, EMCC, '-s', 'EMTERPRETIFY=1', path_from_root('tests', 'hello_libcxx.cpp'), '-s', 'LINKABLE=' + str(linkable), '-O1', '-s', 'USE_ZLIB=1'] + if to_file: + cmd += ['-s', 'EMTERPRETIFY_FILE="code.dat"'] + print cmd + stdout, stderr = Popen(cmd, stderr=PIPE).communicate() + need_warning = linkable and not to_file + assert ('''warning: emterpreter bytecode is fairly large''' in stderr) == need_warning, stderr + assert ('''It is recommended to use -s EMTERPRETIFY_FILE=..''' in stderr) == need_warning, stderr + diff --git a/tools/emterpretify.py b/tools/emterpretify.py index 0184ecfe7..1c6a0f311 100755 --- a/tools/emterpretify.py +++ b/tools/emterpretify.py @@ -1044,6 +1044,9 @@ __ATPRERUN__.push(function() { ''' % (len(all_code), all_code[0], all_code[1], all_code[2], all_code[3], len(relocations), relocations[0])] else: + if len(all_code) > 1024*1024: + shared.logging.warning('warning: emterpreter bytecode is fairly large, %.2f MB. It is recommended to use -s EMTERPRETIFY_FILE=.. so that it is saved as a binary file, instead of the default behavior which is to embed it as text (as text, it can cause very slow compile and startup times)' % (len(all_code) / (1024*1024.))) + CHUNK_SIZE = 10240 i = 0