Description: wasi
This file as text.
(active) Revisions in this set:
a0e88efa6a73f044718f233cff76cee983a96dc2,711efc3e3aa0e87dddf71663036337434065bdcd,93fea6de3a0252bee42d8fb20f38960907994184
87111246ca24629d15385f9ec00fc9ee57421ea5,45620b11c0cca007cb38c94fc201cd8eef7875da,390be44cce0d32775bf1e24756f0535a1e55d1c5
27ff471ff4f9c54bed5df5e04fbdf654a8bdb5dd,08520e032a7dfdb7cf01c355d5a2a451ae4f91fc,d0b3a599a300945a46abd020fae9878c97d75c4c
1e34f047291dcf6140f89250d85a7b5fa5f907fe,a7dfbf012441cd54a960c7c1c153ca1a4f77582e,2a688eb948ac869dbf4165d2315e563b9d790e17
47b664ba92ac1e129b9401d7c0b1a0265f68c4a0,cf857a22eec513f3d131912a7d53c4239fc8924b,d6fc3129b390702dc0ebf94a07ef44032402a343
3d56f75ba7ac99a0bb6527b860209dda548a287d,9bebe9bcb7cc581f700600cfd0f3b9b100154bd0,84b3036574bfcc4acb20b211afd2ae9df63f8f50
c69649782a27d9234c3c9d4f6f066fdb67a1e0e4,fa7444a0d81bea369311fbc3b353bd5ffcdd993a,de7ebe219c562ddc18e07c9f437d25cd42c3e1d6
e830ed6cbc39f0b8899447a1e9f732aaccd49eba,e00dca144860bb2c8d5e25d4d57f54853700ddde,14ec15be7b0f91cc2892928e38380f8f98b16308
7c09f0be9673f9b95326ed2a442e496f011b50a4,56aa1e1bbe51ecf1143700e03119cfcccfd834a1,0a384b09058aab280c58752a46916d8e53cd71e2
d3ce008cd3c8069b1b9cfae5f989c52c756a89ee,ba3383f7e350afb3ca07b3ed50941edbd4170604,bc08af99b04772a62fdae261eeb9ddfa8c147fed
144d7ed97896b31ce9c18cddbeb3ffb998aec35d,0af333bd0f04010aa86fca053d29b8c53bb01796,a7b3747b7beac97be48a3d868355c6dd564853f9
5ee902800cf318036eb74044e4e87ecc542b080f,5718b33dd868a8266c933a51547e168a301a7ca0,17fac45ddce93a1769433e72688eddea046cd597
539ea53babd8f10c5e1b2a2404bf2e2639a6ceeb,125dbdc21cd23fe9f4184d3c2444b1291439b154,ba1dcfc6a4136c6b8154ba16d05d977553b30160
953893267bb45dc8179f55da4c4c203468b2777c,25a9843ea4488a7fcd462ba7a20964c20933e96f,c48f27225e0ca6dccbcba86f3000f48f374df7a4
827f543289dd3f8ff80c09d36cad489b583c3410,720068360ea09dac6fcd35dd47e763baa5805c6b,a5309a5d0cdeb9791a4ac59f666aca5628ed6f0a
3fd6704582a29832f9aa518bd7a178cff083aef7,9efcd4e5548637e8c970dd693bd52b4c859ceeee,67c152092835268be95e6e35f1f31b50d6546bbd
90eb1351dcf77267e4a02a699b6f21ad2995ab2b,5ff2af5176ecef0e9f0deda6a007089f82d5840f,ca3f1d7b6d507c5f4f3e4d681b85cb9ad51b659d
4240279a848b8cc4dffb4dba278d3c1c1be60bb7,c275c3c7f2df5eaaaf1080d5685280062db1d246,afb9c2ae94e020a1061aaeaaf8d44bff2b95e797
433050a2c41069ba5dd519058e47166aba1adfc5,5eac35664fa0a3df98a3fa7b6bbe8c129e5fe7c0,0219b4018cc400bb18f8ea3a924a5a0775186408
f0543ad8d523e40068359ddc096ad120c55cb5db,be90ad1672cec33b15f8faa09715190f6279e75f,a01a6021409f83d80ec80d95e73a66912d7d1211
c0cec218d64e082c373a6f973d4cf2f5798f84fa,e19fcd2b8b826c69b9ca97ab19eb9d9b49a4cf16,b93998c17c7b2eb81e13fbb93bc987f0258a645c
fe903f2ae413631591528c2ea9b33fcc05eac4e3,e091d263c84890f64ca8353fa837c4fd7eb94c37,68cd1c39732449efc0e83adfc3d66dce80f1f9eb
163d2ab344b7ef739f501d79b7a0de9b2bda0666,497dd20a088a67a950c7c61f0a365f170c547f18,1b22a68fc6be4fb51c57a5f01b5193abacab4cf1
a8b789d183513c381c0dc60c0cd50700e8909dfe,585d0cf5746ab85b5dc5a202606f8426d4a282ab,f4964691b0ae2590ddd9a530f78ad9a378898098
f12752372f5e2544e5c4a9d60794c037b55df546,7cac9d2f02bfc1d207b28974340503afbe68d00c,4765d885dfacf93db8202c3b6217a806c09d0dcc
e5ac0b26891f1d5934e8023204f6574195a709cb,9e70f49745836204da6e132ae0822e832a521261,65d8c3d7ebef6ea5a893314b4a3267d3f1d6bcd6
e3139fea211474f8b31ac880c259ae68b8278c6f,d05bcd846ea9f296e9acb855de4810e2c24448a0,fa278564786c5ec7fee45d7bd3b3f4f2d253be6e
f2d5deb26d396c86b9ff636540464d065647a91c,1a714d688a6365ae970c5b63d8ef74d7a9bb9e8d,2fb300c5c0ef04ab2832d7f6e32a5cd57811838b
038ecaef929dda1588b181c3058bad1ed56bb537,5de7084d35492e6ec6d4e3c4cf0cfac3d881195d,c6794dd7d73cd099ad0688483d8f215ba05c4821
8413c2b0732714300db387b1faacd8f1d9149fcc,b9a6b01c97afca09b44ebdf5bac8f91dfe7ff35e,1a93cad4f3db9fb747d23d9b16a75642c4ecc0ad
04b9bc77024bdfb7da727fe7648b1a3534c34072,6d45fd09a23252a391f48f1775747e0816e76674,a21dfc0245ff29ae5f23bc0a334c05aa43e9c4d3
a179ca8cf8c9e1a62bdff1e9693e55b9a1453ba3,692bd6235922a3c84f329e0fc8117d7e9b656151,41ead20bfb32f03c1b36bd4e98bdcb569345dba1
6a1eb520e961845b4a0e277fa57df4c6f138ea9d,e61240156247fac15c854294ec2a0d7dad1d2868,c2fcb1a8336cb9b40a43667c6489ebca7081da14
694341aa789e1bc5d3653e5a816cf102179ab554,bb93b918a5bae47027d01ab5dcf79d01147835f0,31bb06ac876543a509dc04d7af53b55db145d84c
7681c192dbb6d74b6944061863445a55825506a1,aaf536ae109a4797c13d4c6a0655c3103596d5c8,801f902efed9527bcf5ee2cc44aa5d2262a9637d
6be3a42a2f18a349402d18241c83d68c492c7bd5,74a4550ff01a1cee4fff5c5a5a7361729608613c,a417b0db9b9c8f19141be552e6e01da1e4057893
3c027b0ba03df25a95ff94cb18f15aa1dbac2272,60bb6c19d9a3fafd600b3f8de50fd2e9fc7c9184,68f41911192f5e8b63fbaf02badfdb5f85952df2
da597114427645ef37f4d1ad10c9c19d5d4ce23e,9d771396ff829f3fde3dae0ffb6ed5cef1064ddb,9e0b2869a3ecbb35eb9244db4352fe33a1513166
f23cc9ec6d5a89bc61619e53c9eac8a57ef1dfbe,77d592221ac120ece3ab60730de6a00eb826761d,e03389c6a85ad2aa2ae11be193f3a95e1483cc31
fcfce9f2d582c9adb1435161d27a73a86381a6ad,a0e1dce1fded5e40a6a060a5e946503c3eb11a18,5d058258fc3fb182a42e750ad8ab09962bd2f4c5
af5c2d66c2337316c85d8541149ce3baab650cd3,37c32a9eb76ca90f6d984f52e0293cbd79cf6bfa,02867fe9184d95890305bf5450d9b68171afd55d
200fbf64a11ef6df7276c50b9e7b3daa2dad87de,edf7b26f52d05ca09fb69043148acfa4785f4414,db1d903a119e29849948ba8cff90c6569ffe373b
017b41de89da93c848470f2f2140b6df019ac1aa,df26a02d9d6d3b000c185496259896d10835a3bf,c8b9eb3c5c693ab31bcd408f1015dbc14dbffbb0
4abbd82135800a4c79414bf252e153b76940b988,6dfd2de1882096019b27c144ffc2db2636b5d466,492e38069c9ca4eb6132fac300532840e4880a02
7fe6438d4483f66d347dbbe4205123743bd36ea1,a0ac317aae017c1bf828084410210324448661c9,919f8f383d208f340520a34a8ef2ea958474d1ae
Clicking a revision will expand files
+ compile the sysconst unit for wasm32-wasi
+ started working on the SysUtils unit for the WASI platform
+ enabled compilation of unit SysUtils for the WASI target. Note that WASI
snapshot building fails, when compiler is built with -CR, because of a
use-after-free bug in the compiler, related to generics. A fix for this bug
is currently being worked on.
+ enabled compilation of unit sortbase for the WASI target
+ enabled compilation of unit math for the WASI target
+ enable compilation of unit rtlconsts for the WASI target
+ enabled compilation of unit types for the WASI target
+ enabled compilation of unit typinfo for the WASI target
+ enabled compilation of unit fgl for the WASI target
+ enabled compilation of unit macpas for the WASI target
+ enabled compilation of unit iso7185 for the WASI target
+ enabled compilation of unit getopts for the WASI target
+ enabled compilation of unit charset for the WASI target
+ enabled compilation of unit cpall for the WASI target
+ enabled compilation of unit character for the WASI target
+ enabled compilation of units unicodedata and unicodenumtable for the WASI target
* fixed the dependencies of unit character
+ enabled compilation of unit fpwidestring for the WASI target
+ added classes unit for the WASI target (not yet enabled in the makefiles)
+ added tthread.inc rtl include file for WASI
+ enabled compilation of unit classes for the WASI target
+ enabled compilation of unit uuchar for the WASI platform
+ compile the unit dos (OS-specific functions are dummies for now) for the WASI target
+ enabled compilation of unit extpas for the WASI target
+ enabled the fcl-xml package for the WASI target
+ enabled the fcl-sound package for the WASI target
+ enabled the regexpr package for the WASI target
* enumerate preopened dirs on startup and store them in a list, accessible via global vars in the system unit
+ initial implementation of GetDir() for WASI
+ keep also the fds for the current dirs
+ initial implementation of resolving relative paths
+ implemented MkDir for the WASI target
+ implemented RmDir for the WASI target
+ implemented Erase() for the WASI target
+ implemented do_truncate for the WASI target
+ implemented Do_FilePos for the WASI target
+ implemented Do_FileSize for the WASI target
+ implemented Do_Seek and Do_Seekend for the WASI target
+ implemented Do_Rename for the WASI target
+ also resolve absolute paths in ConvertToFdRelativePath
+ initial WASI implementation of DOS.GetFTime. Not working yet, due to a
compiler bug, related to the import of fd_filestat_get from the wasiapi unit.
* also set doserror to 5 for access denied in dos.getfattr
+ request the FD_FILESTAT_GET capability when opening files
* fixed date calculation in WasiDateToDT
+ workaround for newer wasmtime versions that don't report the fd type of
stdin/stdout/stderr. Always assume handles 0..2 are a device, so that
standard input and output are flushed.
+ request fd_seek and fd_tell rights when opening a file
+ request the rights to set size (truncate) and set times, when a file is opened for writing
+ request fd_allocate rights when opening a file for writing
* changed the formatting of the setting of fs_rights_base in Do_Open. No functional changes.
+ request FD_DATASYNC and FD_SYNC rights when a file is opened for writing
+ always request FD_FDSTAT_SET_FLAGS rights
+ always request FD_ADVISE rights, when opening a file
+ always request pollfd_readwrite rights, when opening a file
+ implemented environment variables support in the DOS unit for the WASI target
* set EXEEXT to .wasm for the WASI target in fpcmake
+ started working on DOS.FindFirst
+ initial working implementation of FindFirst/FindNext
* use -1 instead of 0 for indicating empty DirFD
+ enabled compilation of unit heaptrc for the WASI target
- removed commented out code from the WASI startup code
+ added unhandled exception handling code for the branchful exceptions mode
+ implemented GetMsCount in the DOS unit for WASI
Disable utils for wasi target, because paszlib cannot be compiled due to use of goto labels
* fixed range check error in HasDriveLetter when path is 1 character long
+ define USE_NOTHREADMANAGER in the WASI system unit
Unicode' unicodenumtable.pas removed : update Makefile.fpc.
Regenerate Makefile's with trunk fpcmake
* Export wasiAlloc and wasiFree
* patch from Pierre for working around the exitcode <= 125 limitation in wasmtime
+ added unit WebAssembly for WebAssembly-specific stuff. Currently contains
the AtomicFence intrinsic, which emits the atomic.fence instruction.
Add implicit units to wasi rtl
Regenerate Makefile after: Add implicit units to wasi rtl
+ added AtomicStore() to the WebAssembly unit
* Export wasiAlloc, wasiFree
* anonymous method overloads for synchronize/queue.
* fix missing ifdef for the non win32/64/unix targets.
* also do watcom.
* refactored duplicated code for epoch to datetime and vice versa conversion
between the dos and sysutils units for the WASI platform
+ setup a thread manager (functions are still not yet implemented), when the WASI RTL is compiled with multithreading support
* Dotted filenames for package winunits-jedi
+ added promising _start and _initialize exports
* Adjust wasmtime interface to latest version
* fixed WasiRTLCreateEvent to actually return the result
* fixes to WebAssembly RTLEventWaitFor:
* correct conversion from milliseconds to nanoseconds (multiply by 1000000,
instead of 1000)
* use a negative timeout value, instead of 0, to indicate infinite wait
timeout. Using 0 with the 'wait' instruction indicates no wait at all.
* fixed WasiRTLEventWaitFor_WaitAllowed: second parameter is expected value to wait on (0), not wait to wait for (1)
* WasiRTLEventWaitFor_WaitNotAllowed: treat timeout of 0 as zero wait time,
instead of infinite time, for consistency with WasiRTLEventWaitFor_WaitAllowed
(and other platforms, such as Windows)
* fixed WebAssembly InitMutex() and DoneMutex() - pass the parameter by reference
* optimization in WebAssembly's MutexKind() function - mark the first parameter
as const, to avoid making a copy on the stack
* WebAssembly threads: set M.Locked to 0 on UnLockMutex
* fixed conversion between milliseconds and nanoseconds in LockMutexTimeoutNoWait and LockMutexTimeoutWait
* WebAssembly mutex: treat all negative values of aTimeoutMS as infinite, instead of just -1
* WebAssembly mutex: changed the aTimeoutMS parameters of LockMutexTimeoutNoWait
and LockMutexTimeoutWait to int64, instead of longint, since they're called
from LockMutexTimeout, which takes an int64 parameter
* WebAssembly mutex: changed the timeout parameter to be in nanoseconds (these
functions are only used internally, so this doesn't break compatibility)
* WebAssembly threads: bug fixes in LockMutexTimeoutWait
* WebAssembly threads: fixed race condition LockMutex in the check where Locked
is 1, but Owner still holds the current thread id, even though another thread
has just acquired a lock, but still haven't updated the owner thread ID. We
avoid this problem by setting Owner to nil before unlocking the mutex. And in
InitMutex/DoneMutex, we store the creator thread ID in a different field -
Creator, instead of Owner.
* WebAssembly threads: use atomic loads and stores for accessing TRTLCriticalSection.Locked
* WebAssembly threads: also access TRTLCriticalSection.Owner using atomic loads and stores
* WebAssembly threads: reformat code in LockMutexTimeoutNoWait for better
readability by removing begin..end blocks and replacing it with an 'else if'
chain. No functional changes.
* WebAssembly threads: fixed bug in LockMutexTimeoutNoWait, caused by the use of
Result instead of Res. This stupid bug broke WebAssembly critical sections,
causing random spurious hangs and it took me quite a lot of time to find it!
* WebAssembly threads: don't check for GetThreadState(MyThread)<>tsRunning in
LockMutexTimeoutWait and LockMutexTimeoutNoWait
+ WebAssembly threads: initial implementation of the WASI threads proposal:
https://github.com/WebAssembly/wasi-threads
Note that the WASI folk have already declared this proposal 'obsolete' and
only intended to be used for engines that support WASI v0.1. On the other
hand, the WASI v0.2 threads proposal is an early draft and not implemented
anywhere, so we have no choice, but to stay with v0.1 at this time, or give up
on multithreading for who knows how long it would take for the v0.2 spec to be
completed.
Regarding the WASI v0.1 engines that implement WASI threads correctly and can
be used with Free Pascal, I've discovered only one that works:
https://github.com/bytecodealliance/wasm-micro-runtime/tree/main
Wasmtime claims to support multithreading since version 15, however it doesn't
seem to work. I tested all versions until the 23.0.1, and none of them works.
Caveat: using the internal linker is not yet supported with WebAssembly and
multithreading. Please use the external linker (the -Xe option), if you want
to give this new feature a try.
* WebAssembly threads: protect SysOSAlloc against race conditions via a critical section
* WebAssembly: allow specifying the initial and max memory size via the $M
directive
* WebAssembly threads: fix threadvars with the new WASI-threads implementation
* WebAssembly: optimized SysOSAlloc to use memory area left at the end of the
page (64kb). This reduces memory use, when SysOSAlloc is called with sizes,
smaller than 64kb.
* WebAssembly threads: fix TThread.WaitFor (use -1 instead of 0 to signal infinite timeout)
* WebAssembly threads: simplified (optimized) the implementation of
TWasmRTLEvent, so it doesn't use a Mutex. Use atomic operations instead.
* WebAssembly threads: use the stack size, specified for the main thread (via
the $M directive, or the '-Cs' compiler option) as the default stack size for
other spawned threads
+ WASI: set StackLength on startup
+ WASI: set StackBottom on startup
* WebAssembly threads: pass the stack size to InitThread when starting a new thread
+ WebAssembly threads: init StackBottom (used for stack checking) more precisely
when starting a new thread. Precision is not that important for the stack
checking itself, because it uses a stack margin of 16kb, so the previous
value, set by InitThread is good enough, however it's easy to do it precisely,
since we allocate the stack and pass a pointer to it in TWasmThread, so why
not?
* WebAssembly threads: disable stack checking for the FPCWasmThreadStartPascal procedure
* WebAssembly threads: free the stack block and TLS block in case wasi_thread_spawn fails
* WebAssembly threads: use New and Dispose instead of GetMem/FreeMem for allocating/freeing TWasmThread
* WebAssembly threads: destroy the event and mutex in WasiBeginThread in case wasi_thread_spawn fails
* WebAssembly threads: implement WasiEndThread using exceptions. There's no
other way to end a thread in WebAssembly, except by ending the thread
procedure. Therefore, the only way to implement WasiEndThread is to have it
raise an exception and handle it at the outermost level. This, of course,
requires one of the WebAssembly exception modes to be turned on, in order for
this to work.
* WebAssembly threads: call fpc_wasm32_init_tls from inline asm code to avoid
race condition in branchful exceptions mode
+ added some more comments in wasi_thread_start
* removed TODO comment from WasiThreadSwitch
* Explicitly specify path to include files
+ WebAssembly threads: initialize the ThreadId threadvar for the main thread
+ WebAssembly threads: set IsMultiThread to true in WasiBeginThread
+ WebAssembly threads: implemented basic events (both manual and auto reset)
* WebAssembly threads: use high(uint32) as MaxThreadSignal
* WebAssembly threads: RTLEvents rewritten to implement an auto reset event.
Previous implementation did a manual reset event. However, at least on Windows
and Linux, an auto reset event is used.
+ WebAssembly threads: set FThreadReaped to true in TThread.WaitFor, to avoid
hang in TThread.SysDestroy after .WaitFor
* WebAssembly threads: moved the thread stack and TLS block free code to a new
procedure: FreeStackAndTlsBlock. No functional changes.
* WebAssembly threads: made FreeStackAndTlsBlock set the StackBlock and
TlsPointers to nil
+ WebAssembly threads: call FreeStackAndTlsBlock in WasiWaitForThreadTerminate
+ WebAssembly threads: introduced TWasmThread.ThreadHasFinished boolean
+ WebAssembly threads: initialize TWasmThread.ThreadHasFinished to false in WasiBeginThread
+ WebAssembly threads: spinwait until ThreadHasFinished becomes true in
WasiWaitForThreadTerminate, before freeing the thread TLS and stack block, to
avoid race condition with a thread that is finishing (i.e. the main threadproc
is done), but still executing internal Pascal code inside
FPCWasmThreadStartPascal.
* fixed compilation error, introduced in a0ac317aae017c1bf828084410210324448661c9