Skip to content

Commit e754b97

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 7ef236c commit e754b97

36 files changed

+41
-4905
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ See docs/process.md for how version tagging works.
1717

1818
Current Trunk
1919
-------------
20+
- Remove emterpreter and ``EMTERPRETIFY`` settings. Emterpreter has largerly
21+
been replaced by asyncify and is fastcomp only so due for removing in
22+
the near future anyway.
2023

2124
1.39.15: 05/06/2020
2225
-------------------

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
@@ -99,8 +99,6 @@
9999

100100
LIB_PREFIXES = ('', 'lib')
101101

102-
DEFERRED_RESPONSE_FILES = ('EMTERPRETIFY_BLACKLIST', 'EMTERPRETIFY_WHITELIST', 'EMTERPRETIFY_SYNCLIST')
103-
104102
DEFAULT_ASYNCIFY_IMPORTS = [
105103
'emscripten_sleep', 'emscripten_wget', 'emscripten_wget_data', 'emscripten_idb_load',
106104
'emscripten_idb_store', 'emscripten_idb_delete', 'emscripten_idb_exists',
@@ -412,11 +410,10 @@ def standardize_setting_change(key, value):
412410
value = str(shared.expand_byte_size_suffixes(value))
413411

414412
if value[0] == '@':
415-
if key not in DEFERRED_RESPONSE_FILES:
416-
filename = value[1:]
417-
if not os.path.exists(filename):
418-
exit_with_error('%s: file not found parsing argument: %s' % (filename, change))
419-
value = open(filename).read()
413+
filename = value[1:]
414+
if not os.path.exists(filename):
415+
exit_with_error('%s: file not found parsing argument: %s' % (filename, change))
416+
value = open(filename).read()
420417
else:
421418
value = value.replace('\\', '\\\\')
422419
try:
@@ -1201,9 +1198,6 @@ def check(input_file):
12011198
diagnostics.warning('emcc', 'disabling closure because debug info was requested')
12021199
options.use_closure_compiler = False
12031200

1204-
if shared.Settings.EMTERPRETIFY_FILE and shared.Settings.SINGLE_FILE:
1205-
exit_with_error('cannot have both EMTERPRETIFY_FILE and SINGLE_FILE enabled at the same time')
1206-
12071201
if shared.Settings.WASM == 2 and shared.Settings.SINGLE_FILE:
12081202
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)')
12091203

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

1436-
if shared.Settings.EMTERPRETIFY:
1437-
diagnostics.warning('emterpreter', 'emterpreter is soon to be removed. If you depend on this feature please reach out on github for help transitioning.')
1438-
shared.Settings.FINALIZE_ASM_JS = 0
1439-
shared.Settings.SIMPLIFY_IFS = 0 # this is just harmful for emterpreting
1440-
shared.Settings.EXPORTED_FUNCTIONS += ['emterpret']
1441-
if not options.js_opts:
1442-
logger.debug('enabling js opts for EMTERPRETIFY')
1443-
options.js_opts = True
1444-
options.force_js_opts = True
1445-
if options.use_closure_compiler == 2:
1446-
exit_with_error('EMTERPRETIFY requires valid asm.js, and is incompatible with closure 2 which disables that')
1447-
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)'
1448-
14491430
if shared.Settings.DISABLE_EXCEPTION_THROWING and not shared.Settings.DISABLE_EXCEPTION_CATCHING:
14501431
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")
14511432

@@ -1601,8 +1582,6 @@ def include_and_export(name):
16011582
exit_with_error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS>0!')
16021583
if shared.Settings.MAIN_MODULE:
16031584
exit_with_error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1604-
if shared.Settings.EMTERPRETIFY:
1605-
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s USE_PTHREADS>0!')
16061585
if shared.Settings.PROXY_TO_WORKER:
16071586
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.')
16081587
else:
@@ -1951,9 +1930,6 @@ def check_human_readable_list(items):
19511930
exit_with_error('memory growth is not supported with shared asm.js modules')
19521931

19531932
if shared.Settings.MINIMAL_RUNTIME:
1954-
if shared.Settings.EMTERPRETIFY:
1955-
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s MINIMAL_RUNTIME=1')
1956-
19571933
if shared.Settings.PRECISE_F32 == 2:
19581934
exit_with_error('-s PRECISE_F32=2 is not supported with -s MINIMAL_RUNTIME=1')
19591935

@@ -2625,14 +2601,6 @@ def get_eliminate():
26252601

26262602
optimizer.queue += ['simplifyExpressions']
26272603

2628-
if shared.Settings.EMTERPRETIFY:
2629-
# emterpreter code will not run through a JS optimizing JIT, do more work ourselves
2630-
optimizer.queue += ['localCSE']
2631-
2632-
if shared.Settings.EMTERPRETIFY:
2633-
# add explicit label setting, as we will run aggressiveVariableElimination late, *after* 'label' is no longer notable by name
2634-
optimizer.queue += ['safeLabelSetting']
2635-
26362604
if shared.Settings.OPT_LEVEL >= 1 and options.js_opts:
26372605
if shared.Settings.OPT_LEVEL >= 2:
26382606
# simplify ifs if it is ok to make the code somewhat unreadable,
@@ -2668,7 +2636,7 @@ def get_eliminate():
26682636

26692637
if options.js_opts:
26702638
# some compilation modes require us to minify later or not at all
2671-
if not shared.Settings.EMTERPRETIFY and not shared.Settings.WASM:
2639+
if not shared.Settings.WASM:
26722640
optimizer.do_minify()
26732641

26742642
if shared.Settings.OPT_LEVEL >= 2:
@@ -2692,9 +2660,6 @@ def get_eliminate():
26922660
log_time('js opts')
26932661

26942662
with ToolchainProfiler.profile_block('final emitting'):
2695-
if shared.Settings.EMTERPRETIFY:
2696-
emterpretify(js_target, optimizer, options)
2697-
26982663
# Remove some trivial whitespace
26992664
# TODO: do not run when compress has already been done on all parts of the code
27002665
# src = open(final).read()
@@ -3071,78 +3036,6 @@ def consume_arg():
30713036
return options, settings_changes, newargs
30723037

30733038

3074-
def emterpretify(js_target, optimizer, options):
3075-
global final
3076-
optimizer.flush('pre-emterpretify')
3077-
logger.debug('emterpretifying')
3078-
blacklist = shared.Settings.EMTERPRETIFY_BLACKLIST
3079-
whitelist = shared.Settings.EMTERPRETIFY_WHITELIST
3080-
synclist = shared.Settings.EMTERPRETIFY_SYNCLIST
3081-
if type(blacklist) == list:
3082-
blacklist = json.dumps(blacklist)
3083-
if type(whitelist) == list:
3084-
whitelist = json.dumps(whitelist)
3085-
if type(synclist) == list:
3086-
synclist = json.dumps(synclist)
3087-
3088-
args = [shared.PYTHON,
3089-
shared.path_from_root('tools', 'emterpretify.py'),
3090-
js_target,
3091-
final + '.em.js',
3092-
blacklist,
3093-
whitelist,
3094-
synclist,
3095-
str(shared.Settings.SWAPPABLE_ASM_MODULE)]
3096-
if shared.Settings.EMTERPRETIFY_ASYNC:
3097-
args += ['ASYNC=1']
3098-
if shared.Settings.EMTERPRETIFY_ADVISE:
3099-
args += ['ADVISE=1']
3100-
if options.profiling or options.profiling_funcs:
3101-
args += ['PROFILING=1']
3102-
if shared.Settings.ASSERTIONS:
3103-
args += ['ASSERTIONS=1']
3104-
if shared.Settings.PRECISE_F32:
3105-
args += ['FROUND=1']
3106-
if shared.Settings.ALLOW_MEMORY_GROWTH:
3107-
args += ['MEMORY_SAFE=1']
3108-
if shared.Settings.EMTERPRETIFY_FILE:
3109-
args += ['FILE="' + shared.Settings.EMTERPRETIFY_FILE + '"']
3110-
3111-
try:
3112-
# move temp js to final position, alongside its mem init file
3113-
shutil.move(final, js_target)
3114-
shared.check_call(args)
3115-
finally:
3116-
shared.try_delete(js_target)
3117-
3118-
final = final + '.em.js'
3119-
3120-
if shared.Settings.EMTERPRETIFY_ADVISE:
3121-
logger.warning('halting compilation due to EMTERPRETIFY_ADVISE')
3122-
sys.exit(0)
3123-
3124-
# minify (if requested) after emterpreter processing, and finalize output
3125-
logger.debug('finalizing emterpreted code')
3126-
shared.Settings.FINALIZE_ASM_JS = 1
3127-
if not shared.Settings.WASM:
3128-
optimizer.do_minify()
3129-
optimizer.queue += ['last']
3130-
optimizer.flush('finalizing-emterpreted-code')
3131-
3132-
# finalize the original as well, if we will be swapping it in (TODO: add specific option for this)
3133-
if shared.Settings.SWAPPABLE_ASM_MODULE:
3134-
real = final
3135-
original = js_target + '.orig.js' # the emterpretify tool saves the original here
3136-
final = original
3137-
logger.debug('finalizing original (non-emterpreted) code at ' + final)
3138-
if not shared.Settings.WASM:
3139-
optimizer.do_minify()
3140-
optimizer.queue += ['last']
3141-
optimizer.flush('finalizing-original-code')
3142-
safe_copy(final, original)
3143-
final = real
3144-
3145-
31463039
def emit_js_source_maps(target, js_transform_tempfiles):
31473040
logger.debug('generating source maps')
31483041
jsrun.run_js_tool(shared.path_from_root('tools', 'source-maps', 'sourcemapper.js'),
@@ -3540,28 +3433,6 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
35403433
separate_asm=options.separate_asm)
35413434

35423435
if not shared.Settings.SINGLE_FILE:
3543-
if shared.Settings.EMTERPRETIFY_FILE:
3544-
# We need to load the emterpreter file before anything else, it has to be synchronously ready
3545-
script.un_src()
3546-
script.inline = '''
3547-
var emterpretURL = '%s';
3548-
var emterpretXHR = new XMLHttpRequest();
3549-
emterpretXHR.open('GET', emterpretURL, true);
3550-
emterpretXHR.responseType = 'arraybuffer';
3551-
emterpretXHR.onload = function() {
3552-
if (emterpretXHR.status === 200 || emterpretXHR.status === 0) {
3553-
Module.emterpreterFile = emterpretXHR.response;
3554-
} else {
3555-
var emterpretURLBytes = tryParseAsDataURI(emterpretURL);
3556-
if (emterpretURLBytes) {
3557-
Module.emterpreterFile = emterpretURLBytes.buffer;
3558-
}
3559-
}
3560-
%s
3561-
};
3562-
emterpretXHR.send(null);
3563-
''' % (shared.JS.get_subresource_location(shared.Settings.EMTERPRETIFY_FILE), script.inline)
3564-
35653436
if options.memory_init_file and not shared.Settings.MEM_INIT_IN_WASM:
35663437
# start to load the memory init file in the HTML, in parallel with the JS
35673438
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 = [
@@ -955,11 +954,6 @@ def get_exported_implemented_functions(all_exported_functions, all_implemented,
955954
if shared.Settings.USE_PTHREADS:
956955
funcs += ['asmJsEstablishStackFrame']
957956

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

965959

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

1009-
if shared.Settings.EMTERPRETIFY_ASYNC and shared.Settings.ASSERTIONS:
1010-
# we cannot have an EM_ASM on the stack when saving/loading
1011-
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"
1012-
10131003
asm_const_funcs.append(r'''
10141004
function _emscripten_asm_const_%s(%s) {
10151005
%s return ASM_CONSTS[code](%s);
@@ -1353,7 +1343,7 @@ def closure(other):
13531343
def asm_backend_uses(metadata, symbol):
13541344
# If doing dynamic linking, we should generate full set of runtime primitives, since we cannot know up front ahead
13551345
# of time what the dynamically linked in modules will need. Also with SAFE_HEAP and Emterpretify, generate full set of views.
1356-
if shared.Settings.MAIN_MODULE or shared.Settings.SIDE_MODULE or shared.Settings.SAFE_HEAP or shared.Settings.EMTERPRETIFY:
1346+
if shared.Settings.MAIN_MODULE or shared.Settings.SIDE_MODULE or shared.Settings.SAFE_HEAP:
13571347
return True
13581348

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

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

16551640

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

19501906
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)