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