Skip to content

Commit 1b2914e

Browse files
committed
Remove emterpreter support.
Emterpreter has largerly been replaces by asyncify and is fastcomp only so due for removing in the near future anyway. The reason I'm pulling this forward ahead of fastcomp deprecation is that it unblocks some other refactoring I'm working on.
1 parent 257c33e commit 1b2914e

36 files changed

+41
-4905
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Current Trunk
3939
- Remove `BINARYEN_PASSES` settings. We still have `BINARYEN_EXTRA_PASSES`, but
4040
completely overriding the set of passes from the command line didn't make much
4141
sense.
42+
- Remove emterpreter and ``EMTERPRETIFY`` settings. Emterpreter has largerly
43+
been replaces by asyncify and is fastcomp only so due for removing in
44+
the near future anyway.
4245

4346
v1.39.13: 04/17/2020
4447
--------------------

emcc.py

Lines changed: 6 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
import emscripten
4343
from tools import shared, system_libs, client_mods, js_optimizer, jsrun, colored_logger, diagnostics
44-
from tools.shared import unsuffixed, unsuffixed_basename, WINDOWS, safe_copy, safe_move, run_process, asbytes, read_and_preprocess, exit_with_error, DEBUG
44+
from tools.shared import unsuffixed, unsuffixed_basename, WINDOWS, safe_move, run_process, asbytes, read_and_preprocess, exit_with_error, DEBUG
4545
from tools.response_file import substitute_response_files
4646
from tools.minimal_runtime_shell import generate_minimal_runtime_html
4747
import tools.line_endings
@@ -96,8 +96,6 @@
9696

9797
LIB_PREFIXES = ('', 'lib')
9898

99-
DEFERRED_RESPONSE_FILES = ('EMTERPRETIFY_BLACKLIST', 'EMTERPRETIFY_WHITELIST', 'EMTERPRETIFY_SYNCLIST')
100-
10199
DEFAULT_ASYNCIFY_IMPORTS = [
102100
'emscripten_sleep', 'emscripten_wget', 'emscripten_wget_data', 'emscripten_idb_load',
103101
'emscripten_idb_store', 'emscripten_idb_delete', 'emscripten_idb_exists',
@@ -407,11 +405,10 @@ def standardize_setting_change(key, value):
407405
value = str(shared.expand_byte_size_suffixes(value))
408406

409407
if value[0] == '@':
410-
if key not in DEFERRED_RESPONSE_FILES:
411-
filename = value[1:]
412-
if not os.path.exists(filename):
413-
exit_with_error('%s: file not found parsing argument: %s' % (filename, change))
414-
value = open(filename).read()
408+
filename = value[1:]
409+
if not os.path.exists(filename):
410+
exit_with_error('%s: file not found parsing argument: %s' % (filename, change))
411+
value = open(filename).read()
415412
else:
416413
value = value.replace('\\', '\\\\')
417414
try:
@@ -1189,9 +1186,6 @@ def check(input_file):
11891186
diagnostics.warning('emcc', 'disabling closure because debug info was requested')
11901187
options.use_closure_compiler = False
11911188

1192-
if shared.Settings.EMTERPRETIFY_FILE and shared.Settings.SINGLE_FILE:
1193-
exit_with_error('cannot have both EMTERPRETIFY_FILE and SINGLE_FILE enabled at the same time')
1194-
11951189
if shared.Settings.WASM == 2 and shared.Settings.SINGLE_FILE:
11961190
exit_with_error('cannot have both WASM=2 and SINGLE_FILE enabled at the same time (pick either JS to target with -s WASM=0 or Wasm to target with -s WASM=1)')
11971191

@@ -1422,19 +1416,6 @@ def has_c_source(args):
14221416
if not shared.Settings.WASM_BACKEND:
14231417
exit_with_error('ASYNCIFY has been removed from fastcomp. There is a new implementation which can be used in the upstream wasm backend.')
14241418

1425-
if shared.Settings.EMTERPRETIFY:
1426-
diagnostics.warning('emterpreter', 'emterpreter is soon to be removed. If you depend on this feature please reach out on github for help transitioning.')
1427-
shared.Settings.FINALIZE_ASM_JS = 0
1428-
shared.Settings.SIMPLIFY_IFS = 0 # this is just harmful for emterpreting
1429-
shared.Settings.EXPORTED_FUNCTIONS += ['emterpret']
1430-
if not options.js_opts:
1431-
logger.debug('enabling js opts for EMTERPRETIFY')
1432-
options.js_opts = True
1433-
options.force_js_opts = True
1434-
if options.use_closure_compiler == 2:
1435-
exit_with_error('EMTERPRETIFY requires valid asm.js, and is incompatible with closure 2 which disables that')
1436-
assert not use_source_map(options), 'EMTERPRETIFY is not compatible with source maps (maps are not useful in emterpreted code, and splitting out non-emterpreted source maps is not yet implemented)'
1437-
14381419
if shared.Settings.DISABLE_EXCEPTION_THROWING and not shared.Settings.DISABLE_EXCEPTION_CATCHING:
14391420
exit_with_error("DISABLE_EXCEPTION_THROWING was set (probably from -fno-exceptions) but is not compatible with enabling exception catching (DISABLE_EXCEPTION_CATCHING=0). If you don't want exceptions, set DISABLE_EXCEPTION_CATCHING to 1; if you do want exceptions, don't link with -fno-exceptions")
14401421

@@ -1590,8 +1571,6 @@ def include_and_export(name):
15901571
exit_with_error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS>0!')
15911572
if shared.Settings.MAIN_MODULE:
15921573
exit_with_error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1593-
if shared.Settings.EMTERPRETIFY:
1594-
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s USE_PTHREADS>0!')
15951574
if shared.Settings.PROXY_TO_WORKER:
15961575
exit_with_error('--proxy-to-worker is not supported with -s USE_PTHREADS>0! Use the option -s PROXY_TO_PTHREAD=1 if you want to run the main thread of a multithreaded application in a web worker.')
15971576
else:
@@ -1940,9 +1919,6 @@ def check_human_readable_list(items):
19401919
exit_with_error('memory growth is not supported with shared asm.js modules')
19411920

19421921
if shared.Settings.MINIMAL_RUNTIME:
1943-
if shared.Settings.EMTERPRETIFY:
1944-
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s MINIMAL_RUNTIME=1')
1945-
19461922
if shared.Settings.PRECISE_F32 == 2:
19471923
exit_with_error('-s PRECISE_F32=2 is not supported with -s MINIMAL_RUNTIME=1')
19481924

@@ -2617,14 +2593,6 @@ def get_eliminate():
26172593

26182594
optimizer.queue += ['simplifyExpressions']
26192595

2620-
if shared.Settings.EMTERPRETIFY:
2621-
# emterpreter code will not run through a JS optimizing JIT, do more work ourselves
2622-
optimizer.queue += ['localCSE']
2623-
2624-
if shared.Settings.EMTERPRETIFY:
2625-
# add explicit label setting, as we will run aggressiveVariableElimination late, *after* 'label' is no longer notable by name
2626-
optimizer.queue += ['safeLabelSetting']
2627-
26282596
if shared.Settings.OPT_LEVEL >= 1 and options.js_opts:
26292597
if shared.Settings.OPT_LEVEL >= 2:
26302598
# simplify ifs if it is ok to make the code somewhat unreadable,
@@ -2660,7 +2628,7 @@ def get_eliminate():
26602628

26612629
if options.js_opts:
26622630
# some compilation modes require us to minify later or not at all
2663-
if not shared.Settings.EMTERPRETIFY and not shared.Settings.WASM:
2631+
if not shared.Settings.WASM:
26642632
optimizer.do_minify()
26652633

26662634
if shared.Settings.OPT_LEVEL >= 2:
@@ -2684,9 +2652,6 @@ def get_eliminate():
26842652
log_time('js opts')
26852653

26862654
with ToolchainProfiler.profile_block('final emitting'):
2687-
if shared.Settings.EMTERPRETIFY:
2688-
emterpretify(js_target, optimizer, options)
2689-
26902655
# Remove some trivial whitespace
26912656
# TODO: do not run when compress has already been done on all parts of the code
26922657
# src = open(final).read()
@@ -3048,78 +3013,6 @@ def consume_arg():
30483013
return options, settings_changes, newargs
30493014

30503015

3051-
def emterpretify(js_target, optimizer, options):
3052-
global final
3053-
optimizer.flush('pre-emterpretify')
3054-
logger.debug('emterpretifying')
3055-
blacklist = shared.Settings.EMTERPRETIFY_BLACKLIST
3056-
whitelist = shared.Settings.EMTERPRETIFY_WHITELIST
3057-
synclist = shared.Settings.EMTERPRETIFY_SYNCLIST
3058-
if type(blacklist) == list:
3059-
blacklist = json.dumps(blacklist)
3060-
if type(whitelist) == list:
3061-
whitelist = json.dumps(whitelist)
3062-
if type(synclist) == list:
3063-
synclist = json.dumps(synclist)
3064-
3065-
args = [shared.PYTHON,
3066-
shared.path_from_root('tools', 'emterpretify.py'),
3067-
js_target,
3068-
final + '.em.js',
3069-
blacklist,
3070-
whitelist,
3071-
synclist,
3072-
str(shared.Settings.SWAPPABLE_ASM_MODULE)]
3073-
if shared.Settings.EMTERPRETIFY_ASYNC:
3074-
args += ['ASYNC=1']
3075-
if shared.Settings.EMTERPRETIFY_ADVISE:
3076-
args += ['ADVISE=1']
3077-
if options.profiling or options.profiling_funcs:
3078-
args += ['PROFILING=1']
3079-
if shared.Settings.ASSERTIONS:
3080-
args += ['ASSERTIONS=1']
3081-
if shared.Settings.PRECISE_F32:
3082-
args += ['FROUND=1']
3083-
if shared.Settings.ALLOW_MEMORY_GROWTH:
3084-
args += ['MEMORY_SAFE=1']
3085-
if shared.Settings.EMTERPRETIFY_FILE:
3086-
args += ['FILE="' + shared.Settings.EMTERPRETIFY_FILE + '"']
3087-
3088-
try:
3089-
# move temp js to final position, alongside its mem init file
3090-
shutil.move(final, js_target)
3091-
shared.check_call(args)
3092-
finally:
3093-
shared.try_delete(js_target)
3094-
3095-
final = final + '.em.js'
3096-
3097-
if shared.Settings.EMTERPRETIFY_ADVISE:
3098-
logger.warning('halting compilation due to EMTERPRETIFY_ADVISE')
3099-
sys.exit(0)
3100-
3101-
# minify (if requested) after emterpreter processing, and finalize output
3102-
logger.debug('finalizing emterpreted code')
3103-
shared.Settings.FINALIZE_ASM_JS = 1
3104-
if not shared.Settings.WASM:
3105-
optimizer.do_minify()
3106-
optimizer.queue += ['last']
3107-
optimizer.flush('finalizing-emterpreted-code')
3108-
3109-
# finalize the original as well, if we will be swapping it in (TODO: add specific option for this)
3110-
if shared.Settings.SWAPPABLE_ASM_MODULE:
3111-
real = final
3112-
original = js_target + '.orig.js' # the emterpretify tool saves the original here
3113-
final = original
3114-
logger.debug('finalizing original (non-emterpreted) code at ' + final)
3115-
if not shared.Settings.WASM:
3116-
optimizer.do_minify()
3117-
optimizer.queue += ['last']
3118-
optimizer.flush('finalizing-original-code')
3119-
safe_copy(final, original)
3120-
final = real
3121-
3122-
31233016
def emit_js_source_maps(target, js_transform_tempfiles):
31243017
logger.debug('generating source maps')
31253018
jsrun.run_js_tool(shared.path_from_root('tools', 'source-maps', 'sourcemapper.js'),
@@ -3527,28 +3420,6 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
35273420
separate_asm=options.separate_asm)
35283421

35293422
if not shared.Settings.SINGLE_FILE:
3530-
if shared.Settings.EMTERPRETIFY_FILE:
3531-
# We need to load the emterpreter file before anything else, it has to be synchronously ready
3532-
script.un_src()
3533-
script.inline = '''
3534-
var emterpretURL = '%s';
3535-
var emterpretXHR = new XMLHttpRequest();
3536-
emterpretXHR.open('GET', emterpretURL, true);
3537-
emterpretXHR.responseType = 'arraybuffer';
3538-
emterpretXHR.onload = function() {
3539-
if (emterpretXHR.status === 200 || emterpretXHR.status === 0) {
3540-
Module.emterpreterFile = emterpretXHR.response;
3541-
} else {
3542-
var emterpretURLBytes = tryParseAsDataURI(emterpretURL);
3543-
if (emterpretURLBytes) {
3544-
Module.emterpreterFile = emterpretURLBytes.buffer;
3545-
}
3546-
}
3547-
%s
3548-
};
3549-
emterpretXHR.send(null);
3550-
''' % (shared.JS.get_subresource_location(shared.Settings.EMTERPRETIFY_FILE), script.inline)
3551-
35523423
if options.memory_init_file and not shared.Settings.MEM_INIT_IN_WASM:
35533424
# start to load the memory init file in the HTML, in parallel with the JS
35543425
script.un_src()

emscripten.py

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ def create_module_asmjs(function_table_sigs, metadata,
521521
temp_float = ' var tempFloat = %s;\n' % ('Math_fround(0)' if provide_fround() else '0.0')
522522
else:
523523
temp_float = ''
524-
async_state = ' var asyncState = 0;\n' if shared.Settings.EMTERPRETIFY_ASYNC else ''
525524
f0_fround = ' const f0 = Math_fround(0);\n' if provide_fround() else ''
526525

527526
replace_memory = create_replace_memory(metadata)
@@ -530,7 +529,7 @@ def create_module_asmjs(function_table_sigs, metadata,
530529

531530
asm_end = create_asm_end(exports)
532531

533-
asm_variables = collapse_redundant_vars(memory_views + asm_global_vars + asm_temp_vars + asm_runtime_thread_local_vars + '\n' + asm_global_funcs + stack + temp_float + async_state + f0_fround)
532+
asm_variables = collapse_redundant_vars(memory_views + asm_global_vars + asm_temp_vars + asm_runtime_thread_local_vars + '\n' + asm_global_funcs + stack + temp_float + f0_fround)
534533
asm_global_initializer = create_global_initializer(metadata['initializers'])
535534

536535
module = [
@@ -954,11 +953,6 @@ def get_exported_implemented_functions(all_exported_functions, all_implemented,
954953
if shared.Settings.USE_PTHREADS:
955954
funcs += ['asmJsEstablishStackFrame']
956955

957-
if shared.Settings.EMTERPRETIFY:
958-
funcs += ['emterpret']
959-
if shared.Settings.EMTERPRETIFY_ASYNC:
960-
funcs += ['setAsyncState', 'emtStackSave', 'emtStackRestore', 'getEmtStackMax', 'setEmtStackMax']
961-
962956
return sorted(set(funcs))
963957

964958

@@ -1005,10 +999,6 @@ def include_asm_consts(pre, forwarded_json, metadata):
1005999
proxy_args = ['-1 - code', str(int(sync_proxy))] + args
10061000
pre_asm_const += ' if (ENVIRONMENT_IS_PTHREAD) { ' + proxy_debug_print(sync_proxy) + 'return _emscripten_proxy_to_main_thread_js(' + ', '.join(proxy_args) + '); }\n'
10071001

1008-
if shared.Settings.EMTERPRETIFY_ASYNC and shared.Settings.ASSERTIONS:
1009-
# we cannot have an EM_ASM on the stack when saving/loading
1010-
pre_asm_const += " assert(typeof EmterpreterAsync !== 'object' || EmterpreterAsync.state !== 2, 'cannot have an EM_ASM on the stack when emterpreter pauses/resumes - the JS is not emterpreted, so we would end up running it again from the start');\n"
1011-
10121002
asm_const_funcs.append(r'''
10131003
function _emscripten_asm_const_%s(%s) {
10141004
%s return ASM_CONSTS[code](%s);
@@ -1352,7 +1342,7 @@ def closure(other):
13521342
def asm_backend_uses(metadata, symbol):
13531343
# If doing dynamic linking, we should generate full set of runtime primitives, since we cannot know up front ahead
13541344
# of time what the dynamically linked in modules will need. Also with SAFE_HEAP and Emterpretify, generate full set of views.
1355-
if shared.Settings.MAIN_MODULE or shared.Settings.SIDE_MODULE or shared.Settings.SAFE_HEAP or shared.Settings.EMTERPRETIFY:
1345+
if shared.Settings.MAIN_MODULE or shared.Settings.SIDE_MODULE or shared.Settings.SAFE_HEAP:
13561346
return True
13571347

13581348
# Allow querying asm_backend_uses(metadata, 'Math.') to find if any of the Math objects are used
@@ -1609,8 +1599,6 @@ def create_basic_funcs(function_table_sigs, invoke_function_names):
16091599
basic_funcs = shared.Settings.RUNTIME_FUNCS_TO_IMPORT
16101600
if shared.Settings.STACK_OVERFLOW_CHECK and not shared.Settings.MINIMAL_RUNTIME:
16111601
basic_funcs += ['abortStackOverflow']
1612-
if shared.Settings.EMTERPRETIFY:
1613-
basic_funcs += ['abortStackOverflowEmterpreter']
16141602
if shared.Settings.SAFE_HEAP:
16151603
if asm_safe_heap():
16161604
basic_funcs += ['segfault', 'alignfault', 'ftfault']
@@ -1646,9 +1634,6 @@ def create_basic_vars(exported_implemented_functions, forwarded_json, metadata):
16461634
# wasm side modules have a specific convention for these
16471635
basic_vars += ['__memory_base', '__table_base']
16481636

1649-
if shared.Settings.EMTERPRETIFY:
1650-
basic_vars += ['EMTSTACKTOP', 'EMT_STACK_MAX', 'eb']
1651-
16521637
return basic_vars
16531638

16541639

@@ -1915,35 +1900,6 @@ def create_runtime_funcs_asmjs(exports, metadata):
19151900
tempDoublePtr = STACKTOP;
19161901
STACKTOP = (STACKTOP + 16)|0;
19171902
}
1918-
''')
1919-
1920-
if shared.Settings.EMTERPRETIFY:
1921-
funcs.append('''
1922-
function emterpret(pc) { // this will be replaced when the emterpreter code is generated; adding it here allows validation until then
1923-
pc = pc | 0;
1924-
assert(0);
1925-
}''')
1926-
1927-
if shared.Settings.EMTERPRETIFY_ASYNC:
1928-
funcs.append('''
1929-
function setAsyncState(x) {
1930-
x = x | 0;
1931-
asyncState = x;
1932-
}
1933-
function emtStackSave() {
1934-
return EMTSTACKTOP|0;
1935-
}
1936-
function emtStackRestore(x) {
1937-
x = x | 0;
1938-
EMTSTACKTOP = x;
1939-
}
1940-
function getEmtStackMax() {
1941-
return EMT_STACK_MAX | 0;
1942-
}
1943-
function setEmtStackMax(x) {
1944-
x = x | 0;
1945-
EMT_STACK_MAX = x;
1946-
}
19471903
''')
19481904

19491905
if asm_safe_heap():

site/build/text/docs/tools_reference/emcc.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ Options that are modified or new in *emcc* are listed below:
184184
You normally don't need to specify this option, as "-O" with an
185185
optimization level will set a good value.
186186

187-
Note: Some options might override this flag (e.g. "EMTERPRETIFY",
188-
"DEAD_FUNCTIONS", "SAFE_HEAP" and "SPLIT_MEMORY" override the
189-
value with "js-opts=1"), because they depend on the js-optimizer.
187+
Note: Some options might override this flag (e.g. "DEAD_FUNCTIONS",
188+
"SAFE_HEAP" and "SPLIT_MEMORY" override the value with "js-opts=1"),
189+
because they depend on the js-optimizer.
190190

191191
"--llvm-opts <level>"
192192
Enables LLVM optimizations, relevant when we call the LLVM

site/source/docs/api_reference/emscripten.h.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ Functions
10391039
Returns whether pseudo-synchronous functions can be used.
10401040
10411041
:rtype: int
1042-
:returns: 1 if program was compiled with ASYNCIFY=1 or EMTERPRETER_ASYNC=1, 0 otherwise.
1042+
:returns: 1 if program was compiled with ASYNCIFY=1, 0 otherwise.
10431043
10441044
10451045
.. c:function:: void emscripten_debugger()
@@ -1252,7 +1252,7 @@ Typedefs
12521252
Pseudo-synchronous functions
12531253
============================
12541254
1255-
These functions require Asyncify (``-s ASYNCIFY=1``) with the wasm backend, or Emterpreter-async with fastcomp (``-s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1``). These functions are asynchronous but appear synchronous in C. See `Asyncify <https://emscripten.org/docs/porting/asyncify.html>`_ and `Emterpreter <https://emscripten.org/docs/porting/emterpreter.html>`_ for more details.
1255+
These functions require Asyncify (``-s ASYNCIFY=1``). These functions are asynchronous but appear synchronous in C. See `Asyncify <https://emscripten.org/docs/porting/asyncify.html>`_ for more details.
12561256
12571257
Sleeping
12581258
--------

0 commit comments

Comments
 (0)