(options)
| 340 | |
| 341 | |
| 342 | def get_binaryen_passes(options): |
| 343 | passes = get_binaryen_lowering_passes() |
| 344 | optimizing = should_run_binaryen_optimizer() |
| 345 | |
| 346 | # safe heap must run before post-emscripten, so post-emscripten can apply the sbrk ptr |
| 347 | if settings.SAFE_HEAP: |
| 348 | passes += ['--safe-heap'] |
| 349 | if settings.EMULATE_FUNCTION_POINTER_CASTS: |
| 350 | # fpcast-emu must run before -Ox so that directize (inside -Ox) sees |
| 351 | # the rewritten table entries with matching types. It must also run |
| 352 | # before asyncify so the byn$fpcast-emu thunks get instrumented. |
| 353 | passes += ['--fpcast-emu'] |
| 354 | if optimizing: |
| 355 | # wasm-emscripten-finalize will strip the features section for us |
| 356 | # automatically, but if we did not modify the wasm then we didn't run it, |
| 357 | # and in an optimized build we strip it manually here. (note that in an |
| 358 | # unoptimized build we might end up with the features section, if we neither |
| 359 | # optimize nor run wasm-emscripten-finalize, but a few extra bytes in the |
| 360 | # binary don't matter in an unoptimized build) |
| 361 | passes += ['--strip-target-features'] |
| 362 | passes += ['--post-emscripten'] |
| 363 | if settings.SIDE_MODULE: |
| 364 | passes += ['--pass-arg=post-emscripten-side-module'] |
| 365 | passes += [building.opt_level_to_str(settings.OPT_LEVEL, settings.SHRINK_LEVEL)] |
| 366 | # when optimizing, use the fact that low memory is never used (1024 is a |
| 367 | # hardcoded value in the binaryen pass). we also cannot do it when the stack |
| 368 | # is first, as then the stack is in the low memory that should be unused. |
| 369 | if settings.GLOBAL_BASE >= 1024 and not settings.STACK_FIRST: |
| 370 | passes += ['--low-memory-unused'] |
| 371 | if options.fast_math: |
| 372 | passes += ['--fast-math'] |
| 373 | if settings.AUTODEBUG: |
| 374 | # adding '--flatten' here may make these even more effective |
| 375 | passes += ['--instrument-locals'] |
| 376 | passes += ['--log-execution'] |
| 377 | passes += ['--instrument-memory'] |
| 378 | if settings.LEGALIZE_JS_FFI: |
| 379 | # legalize it again now, as the instrumentation may need it |
| 380 | passes += ['--legalize-js-interface'] |
| 381 | passes += building.js_legalization_pass_flags() |
| 382 | if settings.ASYNCIFY == 1: |
| 383 | passes += ['--asyncify'] |
| 384 | if settings.MAIN_MODULE: |
| 385 | passes += ['--pass-arg=asyncify-export-globals'] |
| 386 | elif settings.SIDE_MODULE: |
| 387 | passes += ['--pass-arg=asyncify-import-globals'] |
| 388 | if settings.ASSERTIONS: |
| 389 | passes += ['--pass-arg=asyncify-asserts'] |
| 390 | if settings.ASYNCIFY_ADVISE: |
| 391 | passes += ['--pass-arg=asyncify-verbose'] |
| 392 | if settings.ASYNCIFY_IGNORE_INDIRECT: |
| 393 | passes += ['--pass-arg=asyncify-ignore-indirect'] |
| 394 | if settings.ASYNCIFY_PROPAGATE_ADD: |
| 395 | passes += ['--pass-arg=asyncify-propagate-addlist'] |
| 396 | passes += ['--pass-arg=asyncify-imports@%s' % ','.join(settings.ASYNCIFY_IMPORTS)] |
| 397 | |
| 398 | # shell escaping can be confusing; try to emit useful warnings |
| 399 | def check_human_readable_list(items): |
no test coverage detected