Skip to content
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

[test] Cleanup test_async_compile. NFC #21259

Merged
merged 1 commit into from
Feb 6, 2024
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
1 change: 1 addition & 0 deletions test/browser/test_async_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ int main() {
int result = EM_ASM_INT({
return Module.sawAsyncCompilation | 0;
});
printf("sawAsyncCompilation => %d\n", result);
return result;
}

29 changes: 14 additions & 15 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4469,7 +4469,16 @@ def test_in_flight_memfile_request(self, args, expected):
# should happen when there is a mem init file (-O2+)
self.btest('in_flight_memfile_request.c', expected=expected)

def test_async_compile(self):
@parameterized({
'': ([], 1),
'O1': (['-O1'], 1),
'O2': (['-O2'], 1),
'O3': (['-O3'], 1),
# force it on
'force': (['-sWASM_ASYNC_COMPILATION'], 1),
'off': (['-sWASM_ASYNC_COMPILATION=0'], 0),
})
def test_async_compile(self, opts, returncode):
# notice when we use async compilation
script = '''
<script>
Expand All @@ -4478,11 +4487,13 @@ def test_async_compile(self):
var real_wasm_instantiateStreaming = WebAssembly.instantiateStreaming;
if (typeof real_wasm_instantiateStreaming === 'function') {
WebAssembly.instantiateStreaming = (a, b) => {
console.log('instantiateStreaming called');
Module.sawAsyncCompilation = true;
return real_wasm_instantiateStreaming(a, b);
};
} else {
WebAssembly.instantiate = (a, b) => {
console.log('instantiate called');
Module.sawAsyncCompilation = true;
return real_wasm_instantiate(a, b);
};
Expand All @@ -4497,21 +4508,9 @@ def test_async_compile(self):
'''
shell_with_script('shell.html', 'shell.html', script)
common_args = ['--shell-file', 'shell.html']
for opts, returncode in [
([], 1),
(['-O1'], 1),
(['-O2'], 1),
(['-O3'], 1),
# force it on
(['-sWASM_ASYNC_COMPILATION'], 1),
# force it off. note that we use -O3 here to make the binary small enough
# for chrome to allow compiling it synchronously
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess the increase in this limit last year allows this to work even without -O3 now, nice...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

(['-O3', '-sWASM_ASYNC_COMPILATION=0'], 0),
]:
print(opts, returncode)
self.btest_exit('test_async_compile.c', assert_returncode=returncode, args=common_args + opts)
self.btest_exit('test_async_compile.c', assert_returncode=returncode, args=common_args + opts)
# Ensure that compilation still works and is async without instantiateStreaming available
no_streaming = ' <script> WebAssembly.instantiateStreaming = undefined;</script>'
no_streaming = '<script>WebAssembly.instantiateStreaming = undefined;</script>'
shell_with_script('shell.html', 'shell.html', no_streaming + script)
self.btest_exit('test_async_compile.c', assert_returncode=1, args=common_args)

Expand Down
Loading