Skip to content

Commit edf2d4f

Browse files
Add ASYNCIFY_PROPAGATE_ADD setting, on by default (#21672)
This setting affects whether the ASYNCIFY_ADD list propagates, that is, whether it automatically leads to more things added based on the inference. It is on by default, which is safer, but may increase code size in some cases - to undo that, set it to 0. Fixes #13150
1 parent 1dd2c23 commit edf2d4f

File tree

6 files changed

+36
-6
lines changed

6 files changed

+36
-6
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ See docs/process.md for more on how version tagging works.
4444
- TypeScript definitions for Wasm exports, runtime exports, and embind bindings
4545
can now be generated with `--emit-tsd`. The option `--embind-emit-tsd` has been
4646
deprecated, use `--emit-tsd` instead.
47+
- Added the `ASYNCIFY_PROPAGATE_ADD` setting, to control whether the `ASYNCIFY_ADD`
48+
list propagates or not. By default this is enabled; as a result you may see larger
49+
ASYNCIFY builds as more of the function tree may be instrumented than you were
50+
previously manually specifying in `ASYNCIFY_ADD`. To stop propagation you can
51+
specify functions in the `ASYNCIFY_REMOVE` list, or to return to the previous
52+
behaviour, disable this setting (set `-sNO_ASYNCIFY_PROPAGATE_ADD`.) (#21672)
4753
- ports changes:
4854
- Fixed transitive link dependencies (#21602)
4955
- Enable use of options in ports dependencies (#21629)

site/source/docs/porting/asyncify.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,16 @@ If you know that some indirect calls matter and others do not, then you
355355
can provide a manual list of functions to Asyncify:
356356

357357
* ``ASYNCIFY_REMOVE`` is a list of functions that do not unwind the stack.
358-
Asyncify will do its normal whole-program analysis, then remove these
359-
functions from the list of instrumented functions.
360-
* ``ASYNCIFY_ADD`` is a list of functions that do unwind the stack, and
361-
are added after doing the normal whole-program analysis. This is mostly useful
358+
As Asyncify processes the call tree, functions in this list will be removed,
359+
and neither they nor their callers will be instrumented (unless their callers
360+
need to be instrumented for other reasons.)
361+
* ``ASYNCIFY_ADD`` is a list of functions that do unwind the stack, and will be
362+
processed like the imports. This is mostly useful
362363
if you use ``ASYNCIFY_IGNORE_INDIRECT`` but want to also mark some additional
363-
functions that need to unwind.
364+
functions that need to unwind. If the ``ASYNCIFY_PROPAGATE_ADD`` setting is
365+
disabled however, then this list will only be added after the whole-program
366+
analysis. If ``ASYNCIFY_PROPAGATE_ADD`` is disabled then you must also add
367+
their callers, their callers' callers, and so on.
364368
* ``ASYNCIFY_ONLY`` is a list of the **only** functions that can unwind
365369
the stack. Asyncify will instrument exactly those and no others.
366370

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,15 @@ instrumented.
11311131
See notes on ASYNCIFY_REMOVE about the names, including wildcard matching and
11321132
character substitutions.
11331133

1134+
.. _asyncify_propagate_add:
1135+
1136+
ASYNCIFY_PROPAGATE_ADD
1137+
======================
1138+
1139+
If enabled, instrumentation status will be propagated from the add-list, ie.
1140+
their callers, and their callers' callers, and so on. If disabled then all
1141+
callers must be manually added to the add-list (like the only-list).
1142+
11341143
.. _asyncify_only:
11351144

11361145
ASYNCIFY_ONLY

src/settings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,12 @@ var ASYNCIFY_REMOVE = [];
895895
// [link]
896896
var ASYNCIFY_ADD = [];
897897

898+
// If enabled, instrumentation status will be propagated from the add-list, ie.
899+
// their callers, and their callers' callers, and so on. If disabled then all
900+
// callers must be manually added to the add-list (like the only-list).
901+
// [link]
902+
var ASYNCIFY_PROPAGATE_ADD = true;
903+
898904
// If the Asyncify only-list is provided, then *only* the functions in the list
899905
// will be instrumented. Like the remove-list, getting this wrong will break
900906
// your application.

test/test_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8221,7 +8221,10 @@ def test_asyncify_lists(self, args, should_pass, response=None):
82218221
@parameterized({
82228222
'normal': ([], True),
82238223
'ignoreindirect': (['-sASYNCIFY_IGNORE_INDIRECT'], False),
8224-
'add': (['-sASYNCIFY_IGNORE_INDIRECT', '-sASYNCIFY_ADD=["__original_main","main","virt()"]'], True),
8224+
'add': (['-sASYNCIFY_IGNORE_INDIRECT', '-sASYNCIFY_ADD=["virt()"]'], True),
8225+
# If ASYNCIFY_PROPAGATE_ADD is disabled then we must specify the callers of
8226+
# virt() manually, rather than have them inferred automatically.
8227+
'add_no_prop': (['-sASYNCIFY_IGNORE_INDIRECT', '-sASYNCIFY_ADD=["__original_main","main","virt()"]', '-sASYNCIFY_PROPAGATE_ADD=0'], True),
82258228
})
82268229
def test_asyncify_indirect_lists(self, args, should_pass):
82278230
self.set_setting('ASYNCIFY')

tools/link.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ def get_binaryen_passes():
370370
passes += ['--pass-arg=asyncify-verbose']
371371
if settings.ASYNCIFY_IGNORE_INDIRECT:
372372
passes += ['--pass-arg=asyncify-ignore-indirect']
373+
if settings.ASYNCIFY_PROPAGATE_ADD:
374+
passes += ['--pass-arg=asyncify-propagate-addlist']
373375
passes += ['--pass-arg=asyncify-imports@%s' % ','.join(settings.ASYNCIFY_IMPORTS)]
374376

375377
# shell escaping can be confusing; try to emit useful warnings

0 commit comments

Comments
 (0)