Skip to content

Commit

Permalink
Remove use of MEM_INIT_METHOD == 2 (#12325)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbc100 authored Sep 24, 2020
1 parent 27a6786 commit 101bac9
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 74 deletions.
29 changes: 0 additions & 29 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,6 @@
{{{ exportRuntime() }}}

#if MEM_INIT_IN_WASM == 0
#if MEM_INIT_METHOD == 2
#if USE_PTHREADS
if (memoryInitializer && !ENVIRONMENT_IS_PTHREAD) (function(s) {
#else
if (memoryInitializer) (function(s) {
#endif
var i, n = s.length;
#if ASSERTIONS
n -= 4;
var crc, bit, table = new Int32Array(256);
for (i = 0; i < 256; ++i) {
for (crc = i, bit = 0; bit < 8; ++bit)
crc = (crc >>> 1) ^ ((crc & 1) * 0xedb88320);
table[i] = crc >>> 0;
}
crc = -1;
crc = table[(crc ^ n) & 0xff] ^ (crc >>> 8);
crc = table[(crc ^ (n >>> 8)) & 0xff] ^ (crc >>> 8);
for (i = 0; i < s.length; ++i) {
crc = table[(crc ^ s.charCodeAt(i)) & 0xff] ^ (crc >>> 8);
}
assert(crc === 0, "memory initializer checksum");
#endif
for (i = 0; i < n; ++i) {
HEAPU8[GLOBAL_BASE + i] = s.charCodeAt(i);
}
})(memoryInitializer);
#else
#if USE_PTHREADS
if (memoryInitializer && !ENVIRONMENT_IS_PTHREAD) {
#else
Expand Down Expand Up @@ -115,7 +87,6 @@ if (memoryInitializer) {
}
}
}
#endif
#endif // MEM_INIT_IN_WASM == 0

var calledRun;
Expand Down
1 change: 0 additions & 1 deletion src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ var EXIT_RUNTIME = 0;
// 1: create a *.mem file containing the binary data of the initial memory;

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

// The total stack size. There is no way to enlarge the stack, so this
Expand Down
2 changes: 0 additions & 2 deletions tests/fuzz/csmith_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ def try_js(args=[]):
js_args += ['-s', 'MAIN_MODULE=1']
if random.random() < 0.25:
js_args += ['-s', 'INLINING_LIMIT=1'] # inline nothing, for more call interaction
if random.random() < 0.5:
js_args += ["--memory-init-file", "0", "-s", "MEM_INIT_METHOD=2"]
if random.random() < 0.5:
js_args += ['-s', 'ASSERTIONS=1']
print('(compile)', ' '.join(js_args))
Expand Down
25 changes: 0 additions & 25 deletions tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3998,31 +3998,6 @@ def test_atomicrmw_i64(self):
def test_sigalrm(self):
self.btest(path_from_root('tests', 'sigalrm.cpp'), expected='0', args=['-O3'])

@no_wasm_backend('mem init file')
def test_meminit_pairs(self):
d = 'const char *data[] = {\n "'
d += '",\n "'.join(''.join('\\x{:02x}\\x{:02x}'.format(i, j)
for j in range(256)) for i in range(256))
with open(path_from_root('tests', 'meminit_pairs.c')) as f:
d += '"\n};\n' + f.read()
args = ["-O2", "--memory-init-file", "0", "-s", "MEM_INIT_METHOD=2", "-s", "ASSERTIONS=1", '-s', 'WASM=0']
self.btest(d, expected='0', args=args + ["--closure", "0"])
self.btest(d, expected='0', args=args + ["--closure", "0", "-g"])
self.btest(d, expected='0', args=args + ["--closure", "1"])

@no_wasm_backend('mem init file')
def test_meminit_big(self):
d = 'const char *data[] = {\n "'
d += '",\n "'.join([''.join('\\x{:02x}\\x{:02x}'.format(i, j)
for j in range(256)) for i in range(256)] * 256)
with open(path_from_root('tests', 'meminit_pairs.c')) as f:
d += '"\n};\n' + f.read()
assert len(d) > (1 << 27) # more than 32M memory initializer
args = ["-O2", "--memory-init-file", "0", "-s", "MEM_INIT_METHOD=2", "-s", "ASSERTIONS=1", '-s', 'WASM=0']
self.btest(d, expected='0', args=args + ["--closure", "0"])
self.btest(d, expected='0', args=args + ["--closure", "0", "-g"])
self.btest(d, expected='0', args=args + ["--closure", "1"])

def test_canvas_style_proxy(self):
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')])

Expand Down
17 changes: 0 additions & 17 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -5801,23 +5801,6 @@ def test_debug_asmLastOpts(self):
self.run_process([EMCC, 'src.c', '-s', 'EXPORTED_FUNCTIONS=["_main", "_treecount"]', '--minify', '0', '-g4', '-Oz'])
self.assertContained('hello, world!', self.run_js('a.out.js'))

@no_wasm_backend('MEM_INIT_METHOD not supported under wasm')
def test_meminit_crc(self):
create_test_file('src.c', r'''
#include <stdio.h>
int main() { printf("Mary had a little lamb.\n"); }
''')

self.run_process([EMCC, 'src.c', '--memory-init-file', '0', '-s', 'MEM_INIT_METHOD=2', '-s', 'ASSERTIONS=1', '-s', 'WASM=0'])
with open('a.out.js') as f:
d = f.read()
return
self.assertContained('Mary had', d)
d = d.replace('Mary had', 'Paul had')
create_test_file('a.out.js', d)
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
self.assertContained('Assertion failed: memory initializer checksum', out)

def test_emscripten_print_double(self):
create_test_file('src.c', r'''
#include <stdio.h>
Expand Down

0 comments on commit 101bac9

Please sign in to comment.