Skip to content

Commit 2e94ce5

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 bab3f12 commit 2e94ce5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+68
-4888
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Current Trunk
6969
this might result in slightly slower link times with the old fastcomp
7070
backend. In order to exclude these libraries build with `-nostdlib` and/or
7171
`-nostdlib++`.
72+
- Remove emterpreter and ``EMTERPRETIFY`` settings. Emterpreter has largerly
73+
been replaced by asyncify and is fastcomp only so due for removing in
74+
the near future anyway.
7275

7376
1.39.15: 05/06/2020
7477
-------------------

docs/emcc.txt

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

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

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

emcc.py

Lines changed: 5 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@
104104

105105
LIB_PREFIXES = ('', 'lib')
106106

107-
DEFERRED_RESPONSE_FILES = ('EMTERPRETIFY_BLACKLIST', 'EMTERPRETIFY_WHITELIST', 'EMTERPRETIFY_SYNCLIST')
108-
109107
DEFAULT_ASYNCIFY_IMPORTS = [
110108
'emscripten_sleep', 'emscripten_wget', 'emscripten_wget_data', 'emscripten_idb_load',
111109
'emscripten_idb_store', 'emscripten_idb_delete', 'emscripten_idb_exists',
@@ -417,11 +415,10 @@ def standardize_setting_change(key, value):
417415
value = str(shared.expand_byte_size_suffixes(value))
418416

419417
if value[0] == '@':
420-
if key not in DEFERRED_RESPONSE_FILES:
421-
filename = value[1:]
422-
if not os.path.exists(filename):
423-
exit_with_error('%s: file not found parsing argument: %s' % (filename, change))
424-
value = open(filename).read()
418+
filename = value[1:]
419+
if not os.path.exists(filename):
420+
exit_with_error('%s: file not found parsing argument: %s' % (filename, change))
421+
value = open(filename).read()
425422
else:
426423
value = value.replace('\\', '\\\\')
427424
try:
@@ -1219,9 +1216,6 @@ def check(input_file):
12191216
diagnostics.warning('emcc', 'disabling closure because debug info was requested')
12201217
options.use_closure_compiler = False
12211218

1222-
if shared.Settings.EMTERPRETIFY_FILE and shared.Settings.SINGLE_FILE:
1223-
exit_with_error('cannot have both EMTERPRETIFY_FILE and SINGLE_FILE enabled at the same time')
1224-
12251219
if shared.Settings.WASM == 2 and shared.Settings.SINGLE_FILE:
12261220
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)')
12271221

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

1462-
if shared.Settings.EMTERPRETIFY:
1463-
diagnostics.warning('emterpreter', 'emterpreter is soon to be removed. If you depend on this feature please reach out on github for help transitioning.')
1464-
shared.Settings.FINALIZE_ASM_JS = 0
1465-
shared.Settings.SIMPLIFY_IFS = 0 # this is just harmful for emterpreting
1466-
shared.Settings.EXPORTED_FUNCTIONS += ['emterpret']
1467-
if not options.js_opts:
1468-
logger.debug('enabling js opts for EMTERPRETIFY')
1469-
options.js_opts = True
1470-
options.force_js_opts = True
1471-
if options.use_closure_compiler == 2:
1472-
exit_with_error('EMTERPRETIFY requires valid asm.js, and is incompatible with closure 2 which disables that')
1473-
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)'
1474-
14751456
if shared.Settings.DISABLE_EXCEPTION_THROWING and not shared.Settings.DISABLE_EXCEPTION_CATCHING:
14761457
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")
14771458

@@ -1635,8 +1616,6 @@ def include_and_export(name):
16351616
exit_with_error('-s SIDE_MODULE=1 is not supported with -s USE_PTHREADS>0!')
16361617
if shared.Settings.MAIN_MODULE:
16371618
exit_with_error('-s MAIN_MODULE=1 is not supported with -s USE_PTHREADS>0!')
1638-
if shared.Settings.EMTERPRETIFY:
1639-
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s USE_PTHREADS>0!')
16401619
if shared.Settings.PROXY_TO_WORKER:
16411620
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.')
16421621
else:
@@ -1991,9 +1970,6 @@ def check_human_readable_list(items):
19911970
exit_with_error('memory growth is not supported with shared asm.js modules')
19921971

19931972
if shared.Settings.MINIMAL_RUNTIME:
1994-
if shared.Settings.EMTERPRETIFY:
1995-
exit_with_error('-s EMTERPRETIFY=1 is not supported with -s MINIMAL_RUNTIME=1')
1996-
19971973
if shared.Settings.PRECISE_F32 == 2:
19981974
exit_with_error('-s PRECISE_F32=2 is not supported with -s MINIMAL_RUNTIME=1')
19991975

@@ -2680,14 +2656,6 @@ def get_eliminate():
26802656

26812657
optimizer.queue += ['simplifyExpressions']
26822658

2683-
if shared.Settings.EMTERPRETIFY:
2684-
# emterpreter code will not run through a JS optimizing JIT, do more work ourselves
2685-
optimizer.queue += ['localCSE']
2686-
2687-
if shared.Settings.EMTERPRETIFY:
2688-
# add explicit label setting, as we will run aggressiveVariableElimination late, *after* 'label' is no longer notable by name
2689-
optimizer.queue += ['safeLabelSetting']
2690-
26912659
if shared.Settings.OPT_LEVEL >= 1 and options.js_opts:
26922660
if shared.Settings.OPT_LEVEL >= 2:
26932661
# simplify ifs if it is ok to make the code somewhat unreadable,
@@ -2723,7 +2691,7 @@ def get_eliminate():
27232691

27242692
if options.js_opts:
27252693
# some compilation modes require us to minify later or not at all
2726-
if not shared.Settings.EMTERPRETIFY and not shared.Settings.WASM:
2694+
if not shared.Settings.WASM:
27272695
optimizer.do_minify()
27282696

27292697
if shared.Settings.OPT_LEVEL >= 2:
@@ -2747,9 +2715,6 @@ def get_eliminate():
27472715
log_time('js opts')
27482716

27492717
with ToolchainProfiler.profile_block('final emitting'):
2750-
if shared.Settings.EMTERPRETIFY:
2751-
emterpretify(js_target, optimizer, options)
2752-
27532718
# Remove some trivial whitespace
27542719
# TODO: do not run when compress has already been done on all parts of the code
27552720
# src = open(final).read()
@@ -3123,64 +3088,6 @@ def consume_arg():
31233088
return options, settings_changes, newargs
31243089

31253090

3126-
def emterpretify(js_target, optimizer, options):
3127-
global final
3128-
optimizer.flush('pre-emterpretify')
3129-
logger.debug('emterpretifying')
3130-
blacklist = shared.Settings.EMTERPRETIFY_BLACKLIST
3131-
whitelist = shared.Settings.EMTERPRETIFY_WHITELIST
3132-
synclist = shared.Settings.EMTERPRETIFY_SYNCLIST
3133-
if type(blacklist) == list:
3134-
blacklist = json.dumps(blacklist)
3135-
if type(whitelist) == list:
3136-
whitelist = json.dumps(whitelist)
3137-
if type(synclist) == list:
3138-
synclist = json.dumps(synclist)
3139-
3140-
args = [shared.PYTHON,
3141-
shared.path_from_root('tools', 'emterpretify.py'),
3142-
js_target,
3143-
final + '.em.js',
3144-
blacklist,
3145-
whitelist,
3146-
synclist]
3147-
if shared.Settings.EMTERPRETIFY_ASYNC:
3148-
args += ['ASYNC=1']
3149-
if shared.Settings.EMTERPRETIFY_ADVISE:
3150-
args += ['ADVISE=1']
3151-
if options.profiling or options.profiling_funcs:
3152-
args += ['PROFILING=1']
3153-
if shared.Settings.ASSERTIONS:
3154-
args += ['ASSERTIONS=1']
3155-
if shared.Settings.PRECISE_F32:
3156-
args += ['FROUND=1']
3157-
if shared.Settings.ALLOW_MEMORY_GROWTH:
3158-
args += ['MEMORY_SAFE=1']
3159-
if shared.Settings.EMTERPRETIFY_FILE:
3160-
args += ['FILE="' + shared.Settings.EMTERPRETIFY_FILE + '"']
3161-
3162-
try:
3163-
# move temp js to final position, alongside its mem init file
3164-
shutil.move(final, js_target)
3165-
shared.check_call(args)
3166-
finally:
3167-
shared.try_delete(js_target)
3168-
3169-
final = final + '.em.js'
3170-
3171-
if shared.Settings.EMTERPRETIFY_ADVISE:
3172-
logger.warning('halting compilation due to EMTERPRETIFY_ADVISE')
3173-
sys.exit(0)
3174-
3175-
# minify (if requested) after emterpreter processing, and finalize output
3176-
logger.debug('finalizing emterpreted code')
3177-
shared.Settings.FINALIZE_ASM_JS = 1
3178-
if not shared.Settings.WASM:
3179-
optimizer.do_minify()
3180-
optimizer.queue += ['last']
3181-
optimizer.flush('finalizing-emterpreted-code')
3182-
3183-
31843091
def emit_js_source_maps(target, js_transform_tempfiles):
31853092
logger.debug('generating source maps')
31863093
jsrun.run_js_tool(shared.path_from_root('tools', 'source-maps', 'sourcemapper.js'),
@@ -3581,28 +3488,6 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
35813488
separate_asm=options.separate_asm)
35823489

35833490
if not shared.Settings.SINGLE_FILE:
3584-
if shared.Settings.EMTERPRETIFY_FILE:
3585-
# We need to load the emterpreter file before anything else, it has to be synchronously ready
3586-
script.un_src()
3587-
script.inline = '''
3588-
var emterpretURL = '%s';
3589-
var emterpretXHR = new XMLHttpRequest();
3590-
emterpretXHR.open('GET', emterpretURL, true);
3591-
emterpretXHR.responseType = 'arraybuffer';
3592-
emterpretXHR.onload = function() {
3593-
if (emterpretXHR.status === 200 || emterpretXHR.status === 0) {
3594-
Module.emterpreterFile = emterpretXHR.response;
3595-
} else {
3596-
var emterpretURLBytes = tryParseAsDataURI(emterpretURL);
3597-
if (emterpretURLBytes) {
3598-
Module.emterpreterFile = emterpretURLBytes.buffer;
3599-
}
3600-
}
3601-
%s
3602-
};
3603-
emterpretXHR.send(null);
3604-
''' % (shared.JS.get_subresource_location(shared.Settings.EMTERPRETIFY_FILE), script.inline)
3605-
36063491
if options.memory_init_file and not shared.Settings.MEM_INIT_IN_WASM:
36073492
# start to load the memory init file in the HTML, in parallel with the JS
36083493
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

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

19521908
if asm_safe_heap():

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

site/source/docs/api_reference/preamble.js.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Calling compiled C functions from JavaScript
7070
:returns: The result of the function call as a native JavaScript value (as in ``returnType``) or, if the ``async`` option is set, a JavaScript Promise of the result.
7171
:opts: An optional options object. It can contain the following properties:
7272

73-
- ``async``: If ``true``, implies that the ccall will perform an async operation. This assumes you are using the Emterpreter-Async option for your code.
73+
- ``async``: If ``true``, implies that the ccall will perform an async operation. This assumes you are build with asyncify support.
7474

7575
.. note:: Async calls currently don't support promise error handling.
7676

site/source/docs/optimizing/Optimizing-Code.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ In addition to the above, the following tips can help to reduce code size:
8080
- Use :ref:`the closure compiler <emcc-closure>` on the non-compiled code: ``--closure 1``. This can hugely reduce the size of the support JavaScript code, and is highly recommended. However, if you add your own additional JavaScript code (in a ``--pre-js``, for example) then you need to make sure it uses `closure annotations properly <https://developers.google.com/closure/compiler/docs/api-tutorial3>`_.
8181
- `Floh's blogpost on this topic <http://floooh.github.io/2016/08/27/asmjs-diet.html>`_ is very helpful.
8282
- Make sure to use gzip compression on your webserver, which all browsers now support.
83-
- You can move some of your code into the `Emterpreter <https://github.com/emscripten-core/emscripten/wiki/Emterpreter>`_, which will then run much slower (as it is interpreted), but it will transfer all that code into a smaller amount of data.
8483

8584
The following compiler settings can help (see ``src/settings.js`` for more details):
8685

site/source/docs/porting/asyncify.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ later callback, when nothing else is on the stack.
303303
Migrating from older APIs
304304
#########################
305305

306-
If you have code using the Emterpreter-Async API, or the old Asyncify, then the
307-
new API is somewhat different, and you may need some minor changes:
306+
If you have code uses the old Emterpreter-Async API, or the old Asyncify, then
307+
the new API is somewhat different, and you may need some minor changes:
308308

309-
* The Emterpreter has "yielding" as a concept, but it isn't needed in Asyncify.
309+
* The Emterpreter had "yielding" as a concept, but it isn't needed in Asyncify.
310310
You can replace ``emscripten_sleep_with_yield()`` calls with ``emscripten_sleep()``.
311311
* The JS API is different. See notes above on ``Asyncify.handleSleep()``, and
312312
see ``src/library_async.js`` for more examples.

0 commit comments

Comments
 (0)