Skip to content

Commit

Permalink
MINIMAL_RUNTIME memory growth tests working in Wasm backend. (emscrip…
Browse files Browse the repository at this point in the history
…ten-core#10112)

* MINIMAL_RUNTIME memory growth tests working in Wasm backend.

* Add explicit NO_FILESYSTEM option to MINIMAL_RUNTIME code size, needed because WASI does not automatically DCE away when not used.

* Enable WASI imports for MINIMAL_RUNTIME for a +0.56%-6.37% size regression in JS code size

* Update test
  • Loading branch information
juj authored Jan 13, 2020
1 parent cc22864 commit 506c2cd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/postamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function initRuntime(asm) {

var imports = {
'env': asmLibraryArg
// TODO: Fix size bloat coming from WASI properly. The -s FILESYSTEM=1 check is too weak to properly DCE WASI linkage away.
// (Emscripten now unconditionally uses WASI for stdio, perhaps replace that with web-friendly stdio)
, '{{{ WASI_MODULE_NAME }}}': asmLibraryArg
#if WASM_BACKEND == 0
, 'global': {
'NaN': NaN,
Expand Down
2 changes: 2 additions & 0 deletions src/runtime_stack_check.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#if STACK_OVERFLOW_CHECK
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
function writeStackCookie() {
#if ASSERTIONS
assert((STACK_MAX & 3) == 0);
#endif
#if WASM_BACKEND
// The stack grows downwards
HEAPU32[(STACK_MAX >> 2)+1] = 0x2135467;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ def test_runtime_stacksave(self):
self.do_run(src, 'success')

# Tests that -s MINIMAL_RUNTIME=1 builds can utilize -s ALLOW_MEMORY_GROWTH=1 option.
@no_wasm_backend('MINIMAL_RUNTIME not yet for wasm backend')
@no_wasm2js('MINIMAL_RUNTIME not yet working with WASM2JS')
def test_minimal_runtime_memorygrowth(self):
if self.has_changed_setting('ALLOW_MEMORY_GROWTH'):
self.skipTest('test needs to modify memory growth')
Expand Down
13 changes: 7 additions & 6 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -9566,6 +9566,7 @@ def test_minimal_runtime_code_size(self):
'-s', 'GL_POOL_TEMP_BUFFERS=0',
'-s', 'FAST_UNROLLED_MEMCPY_AND_MEMSET=0',
'-s', 'MIN_CHROME_VERSION=58',
'-s', 'NO_FILESYSTEM=1',
'--output_eol', 'linux']

asmjs = ['-s', 'WASM=0', '--separate-asm', '-s', 'ELIMINATE_DUPLICATE_FUNCTIONS=1', '--memory-init-file', '1']
Expand All @@ -9585,17 +9586,17 @@ def test_minimal_runtime_code_size(self):

if self.is_wasm_backend():
test_cases = [
(opts, hello_world_sources, {'a.html': 1445, 'a.js': 455, 'a.wasm': 176}),
(opts, hello_webgl_sources, {'a.html': 1565, 'a.js': 4636, 'a.wasm': 11809}),
(opts, hello_webgl2_sources, {'a.html': 1565, 'a.js': 5143, 'a.wasm': 11809}) # Compare how WebGL2 sizes stack up with WebGL 1
(opts, hello_world_sources, {'a.html': 1445, 'a.js': 484, 'a.wasm': 176}),
(opts, hello_webgl_sources, {'a.html': 1565, 'a.js': 4663, 'a.wasm': 11809}),
(opts, hello_webgl2_sources, {'a.html': 1565, 'a.js': 5172, 'a.wasm': 11809}) # Compare how WebGL2 sizes stack up with WebGL 1
]
else:
test_cases = [
(asmjs + opts, hello_world_sources, {'a.html': 1481, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
(opts, hello_world_sources, {'a.html': 1445, 'a.js': 604, 'a.wasm': 86}),
(opts, hello_world_sources, {'a.html': 1445, 'a.js': 633, 'a.wasm': 86}),
(asmjs + opts, hello_webgl_sources, {'a.html': 1605, 'a.js': 4921, 'a.asm.js': 11129, 'a.mem': 321}),
(opts, hello_webgl_sources, {'a.html': 1565, 'a.js': 4844, 'a.wasm': 8932}),
(opts, hello_webgl2_sources, {'a.html': 1565, 'a.js': 5331, 'a.wasm': 8932}) # Compare how WebGL2 sizes stack up with WebGL 1
(opts, hello_webgl_sources, {'a.html': 1565, 'a.js': 4874, 'a.wasm': 8932}),
(opts, hello_webgl2_sources, {'a.html': 1565, 'a.js': 5361, 'a.wasm': 8932}) # Compare how WebGL2 sizes stack up with WebGL 1
]

success = True
Expand Down

0 comments on commit 506c2cd

Please sign in to comment.