@@ -9178,16 +9178,15 @@ def test_unoptimized_code_size(self):
9178
9178
test_file('other/test_unoptimized_code_size_strict.js.size'),
9179
9179
os.path.getsize('strict.js'))
9180
9180
9181
- def run_codesize_test(self, filename, args=[], expected_exists=[], expected_not_exists=[], # noqa
9182
- check_funcs=True):
9181
+ def run_codesize_test(self, filename, emcc_args, check_funcs=True):
9183
9182
9184
9183
# in -Os, -Oz, we remove imports wasm doesn't need
9185
- print('Running metadce test: %s:' % filename, args, expected_exists, expected_not_exists , check_funcs)
9184
+ print('Running codesize test: %s:' % filename, emcc_args , check_funcs)
9186
9185
filename = test_file('other/codesize', filename)
9187
9186
expected_basename = test_file('other/codesize', self.id().split('.')[-1])
9188
9187
9189
9188
# Run once without closure and parse output to find wasmImports
9190
- build_cmd = [compiler_for(filename), filename, '--output-eol=linux', '--emit-minification-map=minify.map'] + args + self.get_emcc_args()
9189
+ build_cmd = [compiler_for(filename), filename, '--output-eol=linux', '--emit-minification-map=minify.map'] + emcc_args + self.get_emcc_args()
9191
9190
self.run_process(build_cmd + ['-g2'])
9192
9191
# find the imports we send from JS
9193
9192
# TODO(sbc): Find a way to do that that doesn't depend on internal details of
@@ -9213,19 +9212,14 @@ def run_codesize_test(self, filename, args=[], expected_exists=[], expected_not_
9213
9212
9214
9213
self.run_process(build_cmd + ['--profiling-funcs', '--closure=1'])
9215
9214
9216
- for exists in expected_exists:
9217
- self.assertIn(exists, sent)
9218
- for not_exists in expected_not_exists:
9219
- self.assertNotIn(not_exists, sent)
9220
-
9221
9215
js_size = os.path.getsize('a.out.js')
9222
9216
gz_size = get_file_gzipped_size('a.out.js')
9223
9217
js_size_file = expected_basename + '.jssize'
9224
9218
gz_size_file = expected_basename + '.gzsize'
9225
9219
self.check_expected_size_in_file('js', js_size_file, js_size)
9226
9220
self.check_expected_size_in_file('gz', gz_size_file, gz_size)
9227
9221
9228
- if '-sSINGLE_FILE' in args :
9222
+ if '-sSINGLE_FILE' in emcc_args :
9229
9223
# No wasm file in the final output so we skip the rest of the
9230
9224
# testing
9231
9225
return
@@ -9277,25 +9271,25 @@ def strip_numeric_suffixes(funcname):
9277
9271
self.assertFileContents(filename, data)
9278
9272
9279
9273
@parameterized({
9280
- 'O0': ([], [], ['waka']), # noqa
9281
- 'O1': (['-O1'], [], ['waka']), # noqa
9282
- 'O2': (['-O2'], [], ['waka']), # noqa
9274
+ 'O0': ([],),
9275
+ 'O1': (['-O1'],),
9276
+ 'O2': (['-O2'],),
9283
9277
# in -O3, -Os and -Oz we metadce, and they shrink it down to the minimal output we want
9284
- 'O3': (['-O3'], [], [] ), # noqa
9285
- 'Os': (['-Os'], [], [] ), # noqa
9286
- 'Oz': (['-Oz'], [], [] ), # noqa
9287
- 'Os_mr': (['-Os', '-sMINIMAL_RUNTIME'], [], [], 74), # noqa
9278
+ 'O3': (['-O3'],), # noqa
9279
+ 'Os': (['-Os'],), # noqa
9280
+ 'Oz': (['-Oz'],), # noqa
9281
+ 'Os_mr': (['-Os', '-sMINIMAL_RUNTIME'],),
9288
9282
# EVAL_CTORS also removes the __wasm_call_ctors function
9289
- 'Oz-ctors': (['-Oz', '-sEVAL_CTORS'], [], []), # noqa
9290
- '64': (['-Oz', '-sMEMORY64'], [], []), # noqa
9283
+ 'Oz-ctors': (['-Oz', '-sEVAL_CTORS'],),
9284
+ '64': (['-Oz', '-sMEMORY64'],),
9291
9285
# WasmFS should not be fully linked into a minimal program.
9292
- 'wasmfs': (['-Oz', '-sWASMFS'], [], []), # noqa
9293
- 'esm': (['-Oz', '-sEXPORT_ES6'], [], []), # noqa
9286
+ 'wasmfs': (['-Oz', '-sWASMFS'],),
9287
+ 'esm': (['-Oz', '-sEXPORT_ES6'],),
9294
9288
})
9295
- def test_codesize_minimal(self, * args):
9289
+ def test_codesize_minimal(self, args):
9296
9290
self.set_setting('STRICT')
9297
9291
self.emcc_args.append('--no-entry')
9298
- self.run_codesize_test('minimal.c', * args)
9292
+ self.run_codesize_test('minimal.c', args)
9299
9293
9300
9294
@node_pthreads
9301
9295
@parameterized({
@@ -9306,88 +9300,80 @@ def test_codesize_minimal_pthreads(self, args):
9306
9300
self.run_codesize_test('minimal_main.c', ['-Oz', '-pthread', '-sPROXY_TO_PTHREAD', '-sSTRICT'] + args)
9307
9301
9308
9302
@parameterized({
9309
- 'noexcept': (['-O2'], [], ['waka'] ), # noqa
9303
+ 'noexcept': (['-O2'],), # noqa
9310
9304
# exceptions increases code size significantly
9311
- 'except': (['-O2', '-fexceptions'], [], ['waka'] ), # noqa
9305
+ 'except': (['-O2', '-fexceptions'],), # noqa
9312
9306
# exceptions does not pull in demangling by default, which increases code size
9313
- 'mangle': (['-O2', '-fexceptions',
9314
- '-sEXPORTED_FUNCTIONS=_main,_free,___cxa_demangle', '-Wno-deprecated'], [], ['waka']), # noqa
9307
+ 'mangle': (['-O2', '-fexceptions', '-sEXPORTED_FUNCTIONS=_main,_free,___cxa_demangle', '-Wno-deprecated'],), # noqa
9315
9308
# Wasm EH's code size increase is smaller than that of Emscripten EH
9316
- 'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'], [], ['waka'] ),
9317
- 'except_wasm_legacy': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'], [], ['waka'] ),
9309
+ 'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'],),
9310
+ 'except_wasm_legacy': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],),
9318
9311
# eval_ctors 1 can partially optimize, but runs into getenv() for locale
9319
9312
# code. mode 2 ignores those and fully optimizes out the ctors
9320
- 'ctors1': (['-O2', '-sEVAL_CTORS'], [], ['waka'] ),
9321
- 'ctors2': (['-O2', '-sEVAL_CTORS=2'], [], ['waka'] ),
9322
- 'wasmfs': (['-O2', '-sWASMFS'], [], ['waka'] ),
9323
- 'lto': (['-Oz', '-flto'], [], ['waka'] ),
9313
+ 'ctors1': (['-O2', '-sEVAL_CTORS'],),
9314
+ 'ctors2': (['-O2', '-sEVAL_CTORS=2'],),
9315
+ 'wasmfs': (['-O2', '-sWASMFS'],),
9316
+ 'lto': (['-Oz', '-flto'],),
9324
9317
})
9325
- def test_codesize_cxx(self, * args):
9318
+ def test_codesize_cxx(self, args):
9326
9319
# do not check functions in this test as there are a lot of libc++ functions
9327
9320
# pulled in here, and small LLVM backend changes can affect their size and
9328
9321
# lead to different inlining decisions which add or remove a function
9329
- self.run_codesize_test('hello_libcxx.cpp', * args, check_funcs=False)
9322
+ self.run_codesize_test('hello_libcxx.cpp', args, check_funcs=False)
9330
9323
9331
9324
@parameterized({
9332
- 'O0': ([], [], ['waka'] ),
9333
- 'O1': (['-O1'], [], ['waka'] ),
9334
- 'O2': (['-O2'], [], ['waka'] ),
9335
- 'O3': (['-O3'], [], [] ), # in -O3, -Os and -Oz we metadce
9336
- 'Os': (['-Os'], [], [] ),
9337
- 'Oz': (['-Oz'], [], [] ),
9325
+ 'O0': ([],),
9326
+ 'O1': (['-O1'],),
9327
+ 'O2': (['-O2'],),
9328
+ 'O3': (['-O3'],), # in -O3, -Os and -Oz we metadce
9329
+ 'Os': (['-Os'],),
9330
+ 'Oz': (['-Oz'],),
9338
9331
# finally, check what happens when we export nothing. wasm should be almost empty
9339
- 'export_nothing': (['-Os', '-sEXPORTED_FUNCTIONS=[]'], [], [] ),
9332
+ 'export_nothing': (['-Os', '-sEXPORTED_FUNCTIONS=[]'],),
9340
9333
# we don't metadce with linkable code! other modules may want stuff
9341
9334
# TODO(sbc): Investivate why the number of exports is order of magnitude
9342
9335
# larger for wasm backend.
9343
- 'dylink': (['-O3', '-sMAIN_MODULE=2'], [], [] ),
9336
+ 'dylink': (['-O3', '-sMAIN_MODULE=2'],),
9344
9337
# WasmFS should not be fully linked into a hello world program.
9345
- 'wasmfs': (['-O3', '-sWASMFS'], [], [] ),
9346
- 'single_file': (['-O3', '-sSINGLE_FILE'], [], [] ), # noqa
9338
+ 'wasmfs': (['-O3', '-sWASMFS'],),
9339
+ 'single_file': (['-O3', '-sSINGLE_FILE'],), # noqa
9347
9340
})
9348
- def test_codesize_hello(self, * args):
9349
- self.run_codesize_test('hello_world.c', * args)
9341
+ def test_codesize_hello(self, args):
9342
+ self.run_codesize_test('hello_world.c', args)
9350
9343
9351
9344
@parameterized({
9352
- 'O3': ('mem.c', ['-O3'],
9353
- [], []), # noqa
9345
+ 'O3': ('mem.c', ['-O3']),
9354
9346
# argc/argv support code etc. is in the wasm
9355
- 'O3_standalone': ('mem.c', ['-O3', '-sSTANDALONE_WASM'],
9356
- [], []), # noqa
9347
+ 'O3_standalone': ('mem.c', ['-O3', '-sSTANDALONE_WASM']),
9357
9348
# without argc/argv, no support code for them is emitted
9358
- 'O3_standalone_narg': ('mem_no_argv.c', ['-O3', '-sSTANDALONE_WASM'],
9359
- [], []), # noqa
9349
+ 'O3_standalone_narg': ('mem_no_argv.c', ['-O3', '-sSTANDALONE_WASM']),
9360
9350
# without main, no support code for argc/argv is emitted either
9361
- 'O3_standalone_lib': ('mem_no_main.c', ['-O3', '-sSTANDALONE_WASM', '--no-entry'],
9362
- [], []), # noqa
9351
+ 'O3_standalone_lib': ('mem_no_main.c', ['-O3', '-sSTANDALONE_WASM', '--no-entry']),
9363
9352
# Growth support code is in JS, no significant change in the wasm
9364
- 'O3_grow': ('mem.c', ['-O3', '-sALLOW_MEMORY_GROWTH'],
9365
- [], []), # noqa
9353
+ 'O3_grow': ('mem.c', ['-O3', '-sALLOW_MEMORY_GROWTH']),
9366
9354
# Growth support code is in the wasm
9367
- 'O3_grow_standalone': ('mem.c', ['-O3', '-sALLOW_MEMORY_GROWTH', '-sSTANDALONE_WASM'],
9368
- [], []), # noqa
9355
+ 'O3_grow_standalone': ('mem.c', ['-O3', '-sALLOW_MEMORY_GROWTH', '-sSTANDALONE_WASM']),
9369
9356
# without argc/argv, no support code for them is emitted, even with lto
9370
9357
'O3_standalone_narg_flto':
9371
- ('mem_no_argv.c', ['-O3', '-sSTANDALONE_WASM', '-flto'],
9372
- [], []), # noqa
9358
+ ('mem_no_argv.c', ['-O3', '-sSTANDALONE_WASM', '-flto']), # noqa
9373
9359
})
9374
- def test_codesize_mem(self, filename, * args):
9375
- self.run_codesize_test(filename, * args)
9360
+ def test_codesize_mem(self, filename, args):
9361
+ self.run_codesize_test(filename, args)
9376
9362
9377
9363
@parameterized({
9378
- 'O3': (['-O3'], [], []), # noqa
9364
+ 'O3': (['-O3'],),
9379
9365
# argc/argv support code etc. is in the wasm
9380
- 'O3_standalone': (['-O3', '-sSTANDALONE_WASM'], [], []), # noqa
9366
+ 'O3_standalone': (['-O3', '-sSTANDALONE_WASM'],),
9381
9367
})
9382
- def test_codesize_libcxxabi_message(self, * args):
9383
- self.run_codesize_test('libcxxabi_message.cpp', * args)
9368
+ def test_codesize_libcxxabi_message(self, args):
9369
+ self.run_codesize_test('libcxxabi_message.cpp', args)
9384
9370
9385
9371
@parameterized({
9386
- 'js_fs': (['-O3', '-sNO_WASMFS'], [], [] ), # noqa
9387
- 'wasmfs': (['-O3', '-sWASMFS'], [], [] ), # noqa
9372
+ 'js_fs': (['-O3', '-sNO_WASMFS'],), # noqa
9373
+ 'wasmfs': (['-O3', '-sWASMFS'],), # noqa
9388
9374
})
9389
- def test_codesize_files(self, * args):
9390
- self.run_codesize_test('files.cpp', * args)
9375
+ def test_codesize_files(self, args):
9376
+ self.run_codesize_test('files.cpp', args)
9391
9377
9392
9378
def test_exported_runtime_methods_metadce(self):
9393
9379
exports = ['stackSave', 'stackRestore', 'stackAlloc', 'FS']
0 commit comments