Skip to content

Commit 80093ba

Browse files
authored
[jspi] - Use new -sJSPI flag to enable JSPI. (#21824)
1 parent e1381d5 commit 80093ba

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ See docs/process.md for more on how version tagging works.
2323
- Fix the location of the dummy `.worker.js` file that is now generated as part
2424
of pthread builds so that is generated alongside the main JavaScript file.
2525
See #21701. ()
26+
- `-sASYNCIFY=2` is setting now deprecated, use `-sJSPI` instead.
2627

2728
3.1.58 - 04/23/24
2829
-----------------

emcc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ def apply_user_settings():
298298
if key == 'WASM_OBJECT_FILES':
299299
settings.LTO = 0 if value else 'full'
300300

301+
if key == 'JSPI':
302+
settings.ASYNCIFY = 2
303+
301304

302305
def cxx_to_c_compiler(cxx):
303306
# Convert C++ compiler name into C compiler name

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,16 +1030,11 @@ ASYNCIFY
10301030
Whether to support async operations in the compiled code. This makes it
10311031
possible to call JS functions from synchronous-looking code in C/C++.
10321032

1033-
- Run binaryen's Asyncify pass to transform the code using asyncify. This
1034-
emits a normal wasm file in the end, so it works everywhere, but it has a
1035-
significant cost in terms of code size and speed.
1033+
- 1 (default): Run binaryen's Asyncify pass to transform the code using
1034+
asyncify. This emits a normal wasm file in the end, so it works everywhere,
1035+
but it has a significant cost in terms of code size and speed.
10361036
See https://emscripten.org/docs/porting/asyncify.html
1037-
- Depend on VM support for the wasm stack switching proposal. This allows
1038-
async operations to happen without the overhead of modifying the wasm.
1039-
This is experimental atm while spec discussion is ongoing, see
1040-
https://github.com/WebAssembly/js-promise-integration/
1041-
TODO: document which of the following flags are still relevant in this
1042-
mode (e.g. IGNORE_INDIRECT etc. are not needed)
1037+
- 2 (deprecated): Use ``-sJSPI`` instead.
10431038

10441039
.. _asyncify_imports:
10451040

@@ -1186,6 +1181,18 @@ Specify which of the exports will have JSPI applied to them and return a
11861181
promise.
11871182
Only supported for ASYNCIFY==2 mode.
11881183

1184+
.. _jspi:
1185+
1186+
JSPI
1187+
====
1188+
1189+
Use VM support for the JavaScript Promise Integration proposal. This allows
1190+
async operations to happen without the overhead of modifying the wasm. This
1191+
is experimental atm while spec discussion is ongoing, see
1192+
https://github.com/WebAssembly/js-promise-integration/ TODO: document which
1193+
of the following flags are still relevant in this mode (e.g. IGNORE_INDIRECT
1194+
etc. are not needed)
1195+
11891196
.. _exported_runtime_methods:
11901197

11911198
EXPORTED_RUNTIME_METHODS

src/settings.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -805,16 +805,11 @@ var NODEJS_CATCH_REJECTION = true;
805805
// Whether to support async operations in the compiled code. This makes it
806806
// possible to call JS functions from synchronous-looking code in C/C++.
807807
//
808-
// - Run binaryen's Asyncify pass to transform the code using asyncify. This
809-
// emits a normal wasm file in the end, so it works everywhere, but it has a
810-
// significant cost in terms of code size and speed.
808+
// - 1 (default): Run binaryen's Asyncify pass to transform the code using
809+
// asyncify. This emits a normal wasm file in the end, so it works everywhere,
810+
// but it has a significant cost in terms of code size and speed.
811811
// See https://emscripten.org/docs/porting/asyncify.html
812-
// - Depend on VM support for the wasm stack switching proposal. This allows
813-
// async operations to happen without the overhead of modifying the wasm.
814-
// This is experimental atm while spec discussion is ongoing, see
815-
// https://github.com/WebAssembly/js-promise-integration/
816-
// TODO: document which of the following flags are still relevant in this
817-
// mode (e.g. IGNORE_INDIRECT etc. are not needed)
812+
// - 2 (deprecated): Use ``-sJSPI`` instead.
818813
//
819814
// [link]
820815
var ASYNCIFY = 0;
@@ -933,6 +928,16 @@ var ASYNCIFY_DEBUG = 0;
933928
// [link]
934929
var ASYNCIFY_EXPORTS = [];
935930

931+
// Use VM support for the JavaScript Promise Integration proposal. This allows
932+
// async operations to happen without the overhead of modifying the wasm. This
933+
// is experimental atm while spec discussion is ongoing, see
934+
// https://github.com/WebAssembly/js-promise-integration/ TODO: document which
935+
// of the following flags are still relevant in this mode (e.g. IGNORE_INDIRECT
936+
// etc. are not needed)
937+
//
938+
// [link]
939+
var JSPI = 0;
940+
936941
// Runtime elements that are exported on Module by default. We used to export
937942
// quite a lot here, but have removed them all. You should use
938943
// EXPORTED_RUNTIME_METHODS for things you want to export from the runtime.

test/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ def require_jspi(self):
881881
# emcc warns about stack switching being experimental, and we build with
882882
# warnings-as-errors, so disable that warning
883883
self.emcc_args += ['-Wno-experimental']
884-
self.set_setting('ASYNCIFY', 2)
884+
self.set_setting('JSPI')
885885
if self.is_wasm2js():
886886
self.skipTest('JSPI is not currently supported for WASM2JS')
887887

0 commit comments

Comments
 (0)