Skip to content

Commit 3cc41af

Browse files
Revert "Don't include mem init loading code when it is inside the wasm anyhow (emscripten-core#5844)"
This reverts commit b1acff2.
1 parent a53ddec commit 3cc41af

File tree

6 files changed

+3
-59
lines changed

6 files changed

+3
-59
lines changed

emcc.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,6 @@ def check(input_file):
12201220
if shared.Settings.BINARYEN_PASSES:
12211221
shared.Settings.BINARYEN_PASSES += ','
12221222
shared.Settings.BINARYEN_PASSES += 'safe-heap'
1223-
# we will include the mem init data in the wasm, when we don't need the
1224-
# mem init file to be loadable by itself
1225-
shared.Settings.MEM_INIT_IN_WASM = 'asmjs' not in shared.Settings.BINARYEN_METHOD and \
1226-
'interpret-asm2wasm' not in shared.Settings.BINARYEN_METHOD and \
1227-
not shared.Settings.USE_PTHREADS
12281223

12291224
# wasm outputs are only possible with a side wasm
12301225
if target.endswith(WASM_ENDINGS):
@@ -1723,7 +1718,7 @@ def repl(m):
17231718
if not shared.Settings.BINARYEN or 'asmjs' in shared.Settings.BINARYEN_METHOD or 'interpret-asm2wasm' in shared.Settings.BINARYEN_METHOD:
17241719
return 'memoryInitializer = "%s";' % shared.JS.get_subresource_location(memfile, embed_memfile(options))
17251720
else:
1726-
return ''
1721+
return 'memoryInitializer = null;'
17271722
src = re.sub(shared.JS.memory_initializer_pattern, repl, open(final).read(), count=1)
17281723
open(final + '.mem.js', 'w').write(src)
17291724
final += '.mem.js'
@@ -2310,7 +2305,8 @@ def do_binaryen(target, asm_target, options, memfile, wasm_binary_target,
23102305
cmd.append(shared.Building.opt_level_to_str(options.opt_level, options.shrink_level))
23112306
# import mem init file if it exists, and if we will not be using asm.js as a binaryen method (as it needs the mem init file, of course)
23122307
mem_file_exists = options.memory_init_file and os.path.exists(memfile)
2313-
import_mem_init = mem_file_exists and shared.Settings.MEM_INIT_IN_WASM
2308+
ok_binaryen_method = 'asmjs' not in shared.Settings.BINARYEN_METHOD and 'interpret-asm2wasm' not in shared.Settings.BINARYEN_METHOD
2309+
import_mem_init = mem_file_exists and ok_binaryen_method
23142310
if import_mem_init:
23152311
cmd += ['--mem-init=' + memfile]
23162312
if not shared.Settings.RELOCATABLE:

src/postamble.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Module['asm'] = asm;
55

66
{{{ exportRuntime() }}}
77

8-
#if MEM_INIT_IN_WASM == 0
98
#if MEM_INIT_METHOD == 2
109
#if USE_PTHREADS
1110
if (memoryInitializer && !ENVIRONMENT_IS_PTHREAD) (function(s) {
@@ -112,7 +111,6 @@ if (memoryInitializer) {
112111
}
113112
}
114113
#endif
115-
#endif // MEM_INIT_IN_WASM == 0
116114

117115
#if CYBERDWARF
118116
Module['cyberdwarf'] = _cyberdwarf_Debugger(cyberDWARFFile);

src/preamble.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,12 +2065,10 @@ function integrateWasmJS() {
20652065
var oldView = new Int8Array(oldBuffer);
20662066
var newView = new Int8Array(newBuffer);
20672067

2068-
#if MEM_INIT_IN_WASM == 0
20692068
// If we have a mem init file, do not trample it
20702069
if (!memoryInitializer) {
20712070
oldView.set(newView.subarray(Module['STATIC_BASE'], Module['STATIC_BASE'] + Module['STATIC_BUMP']), Module['STATIC_BASE']);
20722071
}
2073-
#endif
20742072

20752073
newView.set(oldView);
20762074
updateGlobalBuffer(newBuffer);

src/settings.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,5 @@ var WASM_BINARY_FILE = ''; // name of the file containing wasm binary, if releva
881881
var ASMJS_CODE_FILE = ''; // name of the file containing asm.js, if relevant
882882
var SOURCE_MAP_BASE = ''; // Base URL the source mapfile, if relevant
883883

884-
var MEM_INIT_IN_WASM = 0; // for internal use only
885-
886884
var SUPPORT_BASE64_EMBEDDING = 0; // If set to 1, src/base64Utils.js will be included in the bundle.
887885
// This is set internally when needed (SINGLE_FILE)

tests/pthread/test_pthread_global_data_initialization.c

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/test_browser.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,16 +3458,6 @@ def test_pthread_call_async_on_main_thread(self):
34583458
self.btest(path_from_root('tests', 'pthread', 'call_async_on_main_thread.c'), expected='7', args=['-O3', '-s', 'USE_PTHREADS=1', '-DPROXY_TO_PTHREAD=0', '--js-library', path_from_root('tests', 'pthread', 'call_async_on_main_thread.js')])
34593459
self.btest(path_from_root('tests', 'pthread', 'call_async_on_main_thread.c'), expected='7', args=['-Oz', '-DPROXY_TO_PTHREAD=0', '--js-library', path_from_root('tests', 'pthread', 'call_async_on_main_thread.js')])
34603460

3461-
# Tests that spawning a new thread does not cause a reinitialization of the global data section of the application memory area.
3462-
def test_pthread_global_data_initialization(self):
3463-
for mem_init_mode in [[], ['--memory-init-file', '0'], ['--memory-init-file', '1'], ['-s', 'MEM_INIT_METHOD=2']]:
3464-
for args in [[], ['-O3']]:
3465-
self.btest(path_from_root('tests', 'pthread', 'test_pthread_global_data_initialization.c'), expected='20', args=args+mem_init_mode+['-s', 'USE_PTHREADS=1', '-s', 'PROXY_TO_PTHREAD=1'])
3466-
3467-
# Test that emscripten_get_now() reports coherent wallclock times across all pthreads, instead of each pthread independently reporting wallclock times since the launch of that pthread.
3468-
def test_pthread_clock_drift(self):
3469-
self.btest(path_from_root('tests', 'pthread', 'test_pthread_clock_drift.cpp'), expected='1', args=['-O3', '-s', 'USE_PTHREADS=1', '-s', 'PROXY_TO_PTHREAD=1'])
3470-
34713461
# test atomicrmw i64
34723462
def test_atomicrmw_i64(self):
34733463
Popen([PYTHON, EMCC, path_from_root('tests', 'atomicrmw_i64.ll'), '-s', 'USE_PTHREADS=1', '-s', 'IN_TEST_HARNESS=1', '-o', 'test.html']).communicate()

0 commit comments

Comments
 (0)