Repository navigation
Add __async: 'proxy' for functions that block only when proxied from a pthread - #28094
guybedford wants to merge 3 commits into
Conversation
40e4684 to
23ff847
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces the "__async: 'proxy'" configuration for JS library functions, which are designed to block when called from a pthread but should not be treated as suspending imports under ASYNCIFY/JSPI. It updates jsifier.mjs to handle this new mode, ensures it requires "__proxy: 'sync'", and adds corresponding tests. A critical review comment points out that renaming isAsyncFunction to asyncMode in jsifier.mjs leaves isAsyncFunction undefined later in the scope, which would cause a runtime ReferenceError during compilation with ASYNCIFY.
|
A body that ignores What do you think of having the wrapper recover the value instead, now that #28083 has Separately, none of the AI-generated with Claude, reviewed by me before posting. |
…eads under ASYNCIFY/JSPI
23ff847 to
8d428da
Compare
|
Thanks @PedroRosalba for checking this, all three points taken. Under Also added the |
This adds
__async: 'proxy'for a JS library function that must block when called from a pthread but can never be a suspending import, replacing #28093.write()on a pipe is the case: a pthread writing to a full pipe has to wait for the reader, which the main thread can do on its behalf by returning a Promise from the sync-proxied call (#28083). Butfd_writesits behind everyprintf, so marking it__async: 'auto'would make it a suspending import underASYNCIFY/JSPI, instrumenting or trapping every caller. #28083 therefore guards the marker with#if PTHREADS && !ASYNCIFYand loses the pthread wait inASYNCIFY/JSPI builds.'proxy'is that contract spelled out: the function stays a plain import in every build, and itssyncargument (as for'auto', #28022) isfalseonly on behalf of a sync-proxied pthread caller.'proxy'function is never added to the suspending imports and never wrapped inhandleAsync; its proxied calls use the Promise-capable sync proxying mode, like'auto'.syncistrueunderASYNCIFY/JSPI too, since the import cannot suspend.__async: 'proxy'without__proxy: 'sync'is a build error, as the function would then have no asynchronous path.syncdescription in the "Marking JS library functions as async" section.Tests:
jslib.test_jslib_async_auto_syncgains'proxy'variants in plain,ASYNCIFY, JSPI andPROXY_TO_PTHREADbuilds, andjslib.test_jslib_async_proxy_requires_proxyingcovers the error.Made with AI assistance under my review