Skip to content

Commit 101bac9

Browse files
authored
Remove use of MEM_INIT_METHOD == 2 (#12325)
These is no way to set MEM_INIT_METHOD to 2 these days. It cannot be used on the comment line (we error out if it is), and the only place it gets set in the source code we set it to 1.
1 parent 27a6786 commit 101bac9

File tree

5 files changed

+0
-74
lines changed

5 files changed

+0
-74
lines changed

src/postamble.js

-29
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,6 @@
99
{{{ exportRuntime() }}}
1010

1111
#if MEM_INIT_IN_WASM == 0
12-
#if MEM_INIT_METHOD == 2
13-
#if USE_PTHREADS
14-
if (memoryInitializer && !ENVIRONMENT_IS_PTHREAD) (function(s) {
15-
#else
16-
if (memoryInitializer) (function(s) {
17-
#endif
18-
var i, n = s.length;
19-
#if ASSERTIONS
20-
n -= 4;
21-
var crc, bit, table = new Int32Array(256);
22-
for (i = 0; i < 256; ++i) {
23-
for (crc = i, bit = 0; bit < 8; ++bit)
24-
crc = (crc >>> 1) ^ ((crc & 1) * 0xedb88320);
25-
table[i] = crc >>> 0;
26-
}
27-
crc = -1;
28-
crc = table[(crc ^ n) & 0xff] ^ (crc >>> 8);
29-
crc = table[(crc ^ (n >>> 8)) & 0xff] ^ (crc >>> 8);
30-
for (i = 0; i < s.length; ++i) {
31-
crc = table[(crc ^ s.charCodeAt(i)) & 0xff] ^ (crc >>> 8);
32-
}
33-
assert(crc === 0, "memory initializer checksum");
34-
#endif
35-
for (i = 0; i < n; ++i) {
36-
HEAPU8[GLOBAL_BASE + i] = s.charCodeAt(i);
37-
}
38-
})(memoryInitializer);
39-
#else
4012
#if USE_PTHREADS
4113
if (memoryInitializer && !ENVIRONMENT_IS_PTHREAD) {
4214
#else
@@ -115,7 +87,6 @@ if (memoryInitializer) {
11587
}
11688
}
11789
}
118-
#endif
11990
#endif // MEM_INIT_IN_WASM == 0
12091

12192
var calledRun;

src/settings.js

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ var EXIT_RUNTIME = 0;
9797
// 1: create a *.mem file containing the binary data of the initial memory;
9898

9999
// use the --memory-init-file command line switch to select this method
100-
// 2: embed a string literal representing that initial memory data
101100
var MEM_INIT_METHOD = 0;
102101

103102
// The total stack size. There is no way to enlarge the stack, so this

tests/fuzz/csmith_driver.py

-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ def try_js(args=[]):
151151
js_args += ['-s', 'MAIN_MODULE=1']
152152
if random.random() < 0.25:
153153
js_args += ['-s', 'INLINING_LIMIT=1'] # inline nothing, for more call interaction
154-
if random.random() < 0.5:
155-
js_args += ["--memory-init-file", "0", "-s", "MEM_INIT_METHOD=2"]
156154
if random.random() < 0.5:
157155
js_args += ['-s', 'ASSERTIONS=1']
158156
print('(compile)', ' '.join(js_args))

tests/test_browser.py

-25
Original file line numberDiff line numberDiff line change
@@ -3998,31 +3998,6 @@ def test_atomicrmw_i64(self):
39983998
def test_sigalrm(self):
39993999
self.btest(path_from_root('tests', 'sigalrm.cpp'), expected='0', args=['-O3'])
40004000

4001-
@no_wasm_backend('mem init file')
4002-
def test_meminit_pairs(self):
4003-
d = 'const char *data[] = {\n "'
4004-
d += '",\n "'.join(''.join('\\x{:02x}\\x{:02x}'.format(i, j)
4005-
for j in range(256)) for i in range(256))
4006-
with open(path_from_root('tests', 'meminit_pairs.c')) as f:
4007-
d += '"\n};\n' + f.read()
4008-
args = ["-O2", "--memory-init-file", "0", "-s", "MEM_INIT_METHOD=2", "-s", "ASSERTIONS=1", '-s', 'WASM=0']
4009-
self.btest(d, expected='0', args=args + ["--closure", "0"])
4010-
self.btest(d, expected='0', args=args + ["--closure", "0", "-g"])
4011-
self.btest(d, expected='0', args=args + ["--closure", "1"])
4012-
4013-
@no_wasm_backend('mem init file')
4014-
def test_meminit_big(self):
4015-
d = 'const char *data[] = {\n "'
4016-
d += '",\n "'.join([''.join('\\x{:02x}\\x{:02x}'.format(i, j)
4017-
for j in range(256)) for i in range(256)] * 256)
4018-
with open(path_from_root('tests', 'meminit_pairs.c')) as f:
4019-
d += '"\n};\n' + f.read()
4020-
assert len(d) > (1 << 27) # more than 32M memory initializer
4021-
args = ["-O2", "--memory-init-file", "0", "-s", "MEM_INIT_METHOD=2", "-s", "ASSERTIONS=1", '-s', 'WASM=0']
4022-
self.btest(d, expected='0', args=args + ["--closure", "0"])
4023-
self.btest(d, expected='0', args=args + ["--closure", "0", "-g"])
4024-
self.btest(d, expected='0', args=args + ["--closure", "1"])
4025-
40264001
def test_canvas_style_proxy(self):
40274002
self.btest('canvas_style_proxy.c', expected='1', args=['--proxy-to-worker', '--shell-file', path_from_root('tests/canvas_style_proxy_shell.html'), '--pre-js', path_from_root('tests/canvas_style_proxy_pre.js')])
40284003

tests/test_other.py

-17
Original file line numberDiff line numberDiff line change
@@ -5801,23 +5801,6 @@ def test_debug_asmLastOpts(self):
58015801
self.run_process([EMCC, 'src.c', '-s', 'EXPORTED_FUNCTIONS=["_main", "_treecount"]', '--minify', '0', '-g4', '-Oz'])
58025802
self.assertContained('hello, world!', self.run_js('a.out.js'))
58035803

5804-
@no_wasm_backend('MEM_INIT_METHOD not supported under wasm')
5805-
def test_meminit_crc(self):
5806-
create_test_file('src.c', r'''
5807-
#include <stdio.h>
5808-
int main() { printf("Mary had a little lamb.\n"); }
5809-
''')
5810-
5811-
self.run_process([EMCC, 'src.c', '--memory-init-file', '0', '-s', 'MEM_INIT_METHOD=2', '-s', 'ASSERTIONS=1', '-s', 'WASM=0'])
5812-
with open('a.out.js') as f:
5813-
d = f.read()
5814-
return
5815-
self.assertContained('Mary had', d)
5816-
d = d.replace('Mary had', 'Paul had')
5817-
create_test_file('a.out.js', d)
5818-
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
5819-
self.assertContained('Assertion failed: memory initializer checksum', out)
5820-
58215804
def test_emscripten_print_double(self):
58225805
create_test_file('src.c', r'''
58235806
#include <stdio.h>

0 commit comments

Comments
 (0)