Skip to content

Enable MINIMAL_RUNTIME code size tests for Wasm backend #10116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,11 @@ var LibraryJSEvents = {
// for all the messages, one of which is this GL-using one. This won't be
// called if GL is not linked in, but also make sure to not add a dep on
// GL unnecessarily from here, as that would cause a linker error.
emscripten_webgl_do_create_context__deps: maybeAddGLDep(['$JSEvents', '_emscripten_webgl_power_preferences', '_findEventTarget', '_findCanvasEventTarget']),
emscripten_webgl_do_create_context__deps: [
#if LibraryManager.has('library_webgl.js')
'$GL',
#endif
'$JSEvents', '_emscripten_webgl_power_preferences', '_findEventTarget', '_findCanvasEventTarget'],
// This function performs proxying manually, depending on the style of context that is to be created.
emscripten_webgl_do_create_context: function(target, attributes) {
#if ASSERTIONS
Expand Down
13 changes: 0 additions & 13 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,3 @@ var PassManager = {
*/
}
};

// Given a list of dependencies, maybe add GL to it, if it was linked in
// (note that the item with this list of dependencies should not call GL code
// if it is not; this just avoids even adding a dependency that would error).
// This only matters in strict mode (specifically AUTO_JS_LIBRARIES=0), as in
// non-strict mode the GL library is always linked in anyhow.
function maybeAddGLDep(deps) {
if (AUTO_JS_LIBRARIES ||
SYSTEM_JS_LIBRARIES.indexOf('library_webgl.js') >= 0) {
deps.push('$GL');
}
return deps;
}
24 changes: 15 additions & 9 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -9545,7 +9545,6 @@ def test(wasm, closure, opt):
test(['-s', 'WASM=0'], closure, opt)
test(['-s', 'WASM=1', '-s', 'WASM_ASYNC_COMPILATION=0'], closure, opt)

@no_wasm_backend('tests asmjs, sizes sensitive to fastcomp')
def test_minimal_runtime_code_size(self):
smallest_code_size_args = ['-s', 'MINIMAL_RUNTIME=2',
'-s', 'AGGRESSIVE_VARIABLE_ELIMINATION=1',
Expand Down Expand Up @@ -9577,17 +9576,24 @@ def test_minimal_runtime_code_size(self):
path_from_root('tests', 'minimal_webgl', 'webgl.c'),
'--js-library', path_from_root('tests', 'minimal_webgl', 'library_js.js'),
'-s', 'RUNTIME_FUNCS_TO_IMPORT=[]',
'-s', 'USES_DYNAMIC_ALLOC=2', '-lGL',
'-s', 'USES_DYNAMIC_ALLOC=2', '-lwebgl.js',
'-s', 'MODULARIZE=1']
hello_webgl2_sources = hello_webgl_sources + ['-s', 'MAX_WEBGL_VERSION=2']

test_cases = [
(asmjs + opts, hello_world_sources, {'a.html': 1483, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
(opts, hello_world_sources, {'a.html': 1440, 'a.js': 604, 'a.wasm': 86}),
(asmjs + opts, hello_webgl_sources, {'a.html': 1606, 'a.js': 4880, 'a.asm.js': 11139, 'a.mem': 321}),
(opts, hello_webgl_sources, {'a.html': 1557, 'a.js': 4837, 'a.wasm': 8841}),
(opts, hello_webgl2_sources, {'a.html': 1557, 'a.js': 5324, 'a.wasm': 8841}) # Compare how WebGL2 sizes stack up with WebGL 1
]
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': 11918}),
(opts, hello_webgl2_sources, {'a.html': 1565, 'a.js': 5143, 'a.wasm': 11918}) # Compare how WebGL2 sizes stack up with WebGL 1
]
else:
test_cases = [
(asmjs + opts, hello_world_sources, {'a.html': 1483, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
(opts, hello_world_sources, {'a.html': 1440, 'a.js': 604, 'a.wasm': 86}),
(asmjs + opts, hello_webgl_sources, {'a.html': 1606, 'a.js': 4880, 'a.asm.js': 11139, 'a.mem': 321}),
(opts, hello_webgl_sources, {'a.html': 1557, 'a.js': 4837, 'a.wasm': 8841}),
(opts, hello_webgl2_sources, {'a.html': 1557, 'a.js': 5324, 'a.wasm': 8841}) # Compare how WebGL2 sizes stack up with WebGL 1
]

success = True

Expand Down
4 changes: 3 additions & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2890,7 +2890,9 @@ def path_to_system_js_libraries(library_name):
library_files = []
if library_name in js_system_libraries:
if len(js_system_libraries[library_name]):
library_files += js_system_libraries[library_name] if isinstance(js_system_libraries[library_name], list) else [js_system_libraries[library_name]]
lib = js_system_libraries[library_name] if isinstance(js_system_libraries[library_name], list) else [js_system_libraries[library_name]]
library_files += lib
logger.debug('Linking in JS library ' + str(lib))

elif library_name.endswith('.js') and os.path.isfile(path_from_root('src', 'library_' + library_name)):
library_files += ['library_' + library_name]
Expand Down