@@ -4469,7 +4469,16 @@ def test_in_flight_memfile_request(self, args, expected):
4469
4469
# should happen when there is a mem init file (-O2+)
4470
4470
self .btest ('in_flight_memfile_request.c' , expected = expected )
4471
4471
4472
- def test_async_compile (self ):
4472
+ @parameterized ({
4473
+ '' : ([], 1 ),
4474
+ 'O1' : (['-O1' ], 1 ),
4475
+ 'O2' : (['-O2' ], 1 ),
4476
+ 'O3' : (['-O3' ], 1 ),
4477
+ # force it on
4478
+ 'force' : (['-sWASM_ASYNC_COMPILATION' ], 1 ),
4479
+ 'off' : (['-sWASM_ASYNC_COMPILATION=0' ], 0 ),
4480
+ })
4481
+ def test_async_compile (self , opts , returncode ):
4473
4482
# notice when we use async compilation
4474
4483
script = '''
4475
4484
<script>
@@ -4478,11 +4487,13 @@ def test_async_compile(self):
4478
4487
var real_wasm_instantiateStreaming = WebAssembly.instantiateStreaming;
4479
4488
if (typeof real_wasm_instantiateStreaming === 'function') {
4480
4489
WebAssembly.instantiateStreaming = (a, b) => {
4490
+ console.log('instantiateStreaming called');
4481
4491
Module.sawAsyncCompilation = true;
4482
4492
return real_wasm_instantiateStreaming(a, b);
4483
4493
};
4484
4494
} else {
4485
4495
WebAssembly.instantiate = (a, b) => {
4496
+ console.log('instantiate called');
4486
4497
Module.sawAsyncCompilation = true;
4487
4498
return real_wasm_instantiate(a, b);
4488
4499
};
@@ -4497,21 +4508,9 @@ def test_async_compile(self):
4497
4508
'''
4498
4509
shell_with_script ('shell.html' , 'shell.html' , script )
4499
4510
common_args = ['--shell-file' , 'shell.html' ]
4500
- for opts , returncode in [
4501
- ([], 1 ),
4502
- (['-O1' ], 1 ),
4503
- (['-O2' ], 1 ),
4504
- (['-O3' ], 1 ),
4505
- # force it on
4506
- (['-sWASM_ASYNC_COMPILATION' ], 1 ),
4507
- # force it off. note that we use -O3 here to make the binary small enough
4508
- # for chrome to allow compiling it synchronously
4509
- (['-O3' , '-sWASM_ASYNC_COMPILATION=0' ], 0 ),
4510
- ]:
4511
- print (opts , returncode )
4512
- self .btest_exit ('test_async_compile.c' , assert_returncode = returncode , args = common_args + opts )
4511
+ self .btest_exit ('test_async_compile.c' , assert_returncode = returncode , args = common_args + opts )
4513
4512
# Ensure that compilation still works and is async without instantiateStreaming available
4514
- no_streaming = ' <script> WebAssembly.instantiateStreaming = undefined;</script>'
4513
+ no_streaming = '<script>WebAssembly.instantiateStreaming = undefined;</script>'
4515
4514
shell_with_script ('shell.html' , 'shell.html' , no_streaming + script )
4516
4515
self .btest_exit ('test_async_compile.c' , assert_returncode = 1 , args = common_args )
4517
4516
0 commit comments