-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Asyncify: Add an "add list", rename old lists (#2910)
Asyncify does a whole-program analysis to figure out the list of functions to instrument. In emscripten-core/emscripten#10746 (comment) we realized that we need another type of list there, an "add list" which is a list of functions to add to the instrumented functions list, that is, that we should definitely instrument. The use case in that link is that we disable indirect calls, but there is one special indirect call that we do need to instrument. Being able to add just that one can be much more efficient than assuming all indirect calls in a big codebase need instrumentation. Similar issues can come up if we add a profile-guided option to asyncify, which we've discussed. The existing lists were not good enough to allow that, so a new option is needed. I took the opportunity to rename the old ones to something better and more consistent, so after this PR we have 3 lists as follows: * The old "remove list" (previously "blacklist") which removes functions from the list of functions to be instrumented. * The new "add list" which adds to that list (note how add/remove are clearly parallel). * The old "only list" (previously "whitelist") which simply replaces the entire list, and so only those functions are instrumented and no other. This PR temporarily still supports the old names in the commandline arguments, to avoid immediate breakage for our CI.
- Loading branch information
Showing
9 changed files
with
291 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
(module | ||
(type $none_=>_none (func)) | ||
(type $i32_=>_none (func (param i32))) | ||
(type $none_=>_i32 (func (result i32))) | ||
(import "env" "import" (func $import)) | ||
(memory $0 1 2) | ||
(global $__asyncify_state (mut i32) (i32.const 0)) | ||
(global $__asyncify_data (mut i32) (i32.const 0)) | ||
(export "asyncify_start_unwind" (func $asyncify_start_unwind)) | ||
(export "asyncify_stop_unwind" (func $asyncify_stop_unwind)) | ||
(export "asyncify_start_rewind" (func $asyncify_start_rewind)) | ||
(export "asyncify_stop_rewind" (func $asyncify_stop_rewind)) | ||
(export "asyncify_get_state" (func $asyncify_get_state)) | ||
(func $foo | ||
(local $0 i32) | ||
(local $1 i32) | ||
(if | ||
(i32.eq | ||
(global.get $__asyncify_state) | ||
(i32.const 2) | ||
) | ||
(nop) | ||
) | ||
(local.tee $0 | ||
(block $__asyncify_unwind | ||
(block | ||
(block | ||
(if | ||
(i32.eq | ||
(global.get $__asyncify_state) | ||
(i32.const 2) | ||
) | ||
(block | ||
(i32.store | ||
(global.get $__asyncify_data) | ||
(i32.add | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(i32.const -4) | ||
) | ||
) | ||
(local.set $1 | ||
(i32.load | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
(if | ||
(i32.eq | ||
(global.get $__asyncify_state) | ||
(i32.const 0) | ||
) | ||
(call $nothing) | ||
) | ||
) | ||
(return) | ||
) | ||
) | ||
) | ||
(block | ||
(i32.store | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(local.get $0) | ||
) | ||
(i32.store | ||
(global.get $__asyncify_data) | ||
(i32.add | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(i32.const 4) | ||
) | ||
) | ||
) | ||
(nop) | ||
) | ||
(func $bar | ||
(call $nothing) | ||
) | ||
(func $nothing | ||
(nop) | ||
) | ||
(func $asyncify_start_unwind (param $0 i32) | ||
(global.set $__asyncify_state | ||
(i32.const 1) | ||
) | ||
(global.set $__asyncify_data | ||
(local.get $0) | ||
) | ||
(if | ||
(i32.gt_u | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(i32.load offset=4 | ||
(global.get $__asyncify_data) | ||
) | ||
) | ||
(unreachable) | ||
) | ||
) | ||
(func $asyncify_stop_unwind | ||
(global.set $__asyncify_state | ||
(i32.const 0) | ||
) | ||
(if | ||
(i32.gt_u | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(i32.load offset=4 | ||
(global.get $__asyncify_data) | ||
) | ||
) | ||
(unreachable) | ||
) | ||
) | ||
(func $asyncify_start_rewind (param $0 i32) | ||
(global.set $__asyncify_state | ||
(i32.const 2) | ||
) | ||
(global.set $__asyncify_data | ||
(local.get $0) | ||
) | ||
(if | ||
(i32.gt_u | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(i32.load offset=4 | ||
(global.get $__asyncify_data) | ||
) | ||
) | ||
(unreachable) | ||
) | ||
) | ||
(func $asyncify_stop_rewind | ||
(global.set $__asyncify_state | ||
(i32.const 0) | ||
) | ||
(if | ||
(i32.gt_u | ||
(i32.load | ||
(global.get $__asyncify_data) | ||
) | ||
(i32.load offset=4 | ||
(global.get $__asyncify_data) | ||
) | ||
) | ||
(unreachable) | ||
) | ||
) | ||
(func $asyncify_get_state (result i32) | ||
(global.get $__asyncify_state) | ||
) | ||
) |
Oops, something went wrong.