Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WasmFS] Async proxied JS backend #16229

Merged
merged 65 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
36bb44f
start
kripken Feb 4, 2022
91326ec
work [ci skip]
kripken Feb 4, 2022
91bf512
work [ci skip]
kripken Feb 4, 2022
11f82c7
builds [ci skip]
kripken Feb 4, 2022
fabf251
test passes [ci skip]
kripken Feb 4, 2022
09aa942
fix
kripken Feb 4, 2022
0df35c1
fix
kripken Feb 4, 2022
5a0653a
comment
kripken Feb 4, 2022
17c041f
better
kripken Feb 4, 2022
cb4c42f
format
kripken Feb 4, 2022
5fa4f25
fix
kripken Feb 4, 2022
650efab
comments
kripken Feb 4, 2022
c80a891
comment [ci skip]
kripken Feb 7, 2022
a49a630
Merge remote-tracking branch 'origin/main' into wfjsbs
kripken Feb 8, 2022
6d9e223
Merge remote-tracking branch 'origin/main' into wfjsbs
kripken Feb 8, 2022
e3c9012
rename
kripken Feb 8, 2022
0e5429b
start [ci skip]
kripken Feb 8, 2022
dc20c8d
wip [ci skip]
kripken Feb 8, 2022
6210afa
[ci skip]
kripken Feb 8, 2022
af004a0
work [ci skip]
kripken Feb 8, 2022
19c0c9e
cpp builds [ci skip]
kripken Feb 8, 2022
9a4d052
rename
kripken Feb 8, 2022
8575f0b
Merge branch 'wfjsbs' into wfjsbs2
kripken Feb 8, 2022
4718c65
js 'compiles' [ci skip]
kripken Feb 8, 2022
8b28d20
node? [ci skip]
kripken Feb 8, 2022
3ec5f1f
work [ci skip]
kripken Feb 8, 2022
52bbb0e
work [ci skip]
kripken Feb 8, 2022
4c555bd
work
kripken Feb 8, 2022
9321fe6
format [ci skip]
kripken Feb 8, 2022
55928de
c++ builds again [ci skip]
kripken Feb 8, 2022
56240d7
progress [ci skip]
kripken Feb 8, 2022
3e71d34
progress [ci skip]
kripken Feb 8, 2022
736424f
progress [ci skip]
kripken Feb 8, 2022
e33e58b
progress [ci skip]
kripken Feb 8, 2022
2158d61
progress [ci skip]
kripken Feb 8, 2022
57714f4
progress [ci skip]
kripken Feb 8, 2022
337a777
progress [ci skip]
kripken Feb 8, 2022
85b5967
test passes [ci skip]
kripken Feb 9, 2022
cbe113b
work [ci skip]
kripken Feb 9, 2022
223485a
work [ci skip]
kripken Feb 9, 2022
0cb0560
work [ci skip]
kripken Feb 9, 2022
2819980
work [ci skip]
kripken Feb 9, 2022
5dc1455
work [ci skip]
kripken Feb 9, 2022
db018ca
proper [ci skip]
kripken Feb 9, 2022
b59cc11
proper [ci skip]
kripken Feb 9, 2022
b5b1e33
work [ci skip]
kripken Feb 9, 2022
82edc92
work [ci skip]
kripken Feb 9, 2022
320ad78
work [ci skip]
kripken Feb 9, 2022
0794ed1
work [ci skip]
kripken Feb 9, 2022
ec37827
work [ci skip]
kripken Feb 9, 2022
f2aa924
work [ci skip]
kripken Feb 9, 2022
5436d71
work [ci skip]
kripken Feb 9, 2022
a9f685b
work [ci skip]
kripken Feb 9, 2022
8ad69f2
work [ci skip]
kripken Feb 9, 2022
721acea
work [ci skip]
kripken Feb 9, 2022
329c114
work [ci skip]
kripken Feb 9, 2022
86ec770
format
kripken Feb 9, 2022
945cb46
Merge remote-tracking branch 'origin/main' into wfjsbs2
kripken Feb 9, 2022
771ad77
refactor to avoid creating a FetchBackend class that creates its own …
kripken Feb 9, 2022
621813a
format
kripken Feb 9, 2022
fa649e6
docs
kripken Feb 10, 2022
cacb8c2
update test
kripken Feb 10, 2022
cc77ca9
comment
kripken Feb 10, 2022
2b031d7
indent
kripken Feb 10, 2022
cd0d2ef
use arrow functions
kripken Feb 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions system/lib/wasmfs/js_impl_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
// To write a new backend in JS, you basically do the following:
//
// 1. Add a declaration of the C function to create the backend in the
// "backend creation" section of emscripten/wasmfs.h.
// "backend creation" section of emscripten/wasmfs.h. (One line.)
// 2. Add a cpp file for the new backend, and implement the C function from 1,
// which should create it on both the C++ (using JSImplBackend) and JS
// sides. (By convention, the C function should just call into C++ and JS
// which do the interesting work; the C is just a thin wrapper.)
// which do the interesting work; the C is just a thin wrapper.) (A few
// lines.)
// 3. Write a new JS library, and add the implementation of the JS method just
// mentioned, which should set up the mapping from the C++ backend object's
// address to the JS code containing the hooks to read and write etc.
// address to the JS code containing the hooks to read and write etc. (99%
// of the work happens here.)
//
// For a simple example, see js_file_backend.cpp and library_wasmfs_js_file.js
//
Expand Down
18 changes: 18 additions & 0 deletions system/lib/wasmfs/proxied_async_js_impl_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
// Similar to JSImplBackend, but proxies to another thread where the JS can be
// async.
//
// To write a new async backend in JS, you basically do the following:
//
// 1. Add a declaration of the C function to create the backend in the
// "backend creation" section of emscripten/wasmfs.h. (One line.)
// 2. Add a cpp file for the new backend, and implement the C function from 1,
// which should create a ProxiedAsyncJSBackend while passing it code to
// set up the JS side. (A few lines.)
// 3. Write a new JS library, and add the implementation of the JS method just
// mentioned, which should set up the mapping from the C++ backend object's
// address to the JS code containing the hooks to read and write etc. The
// hooks should each return a JS Promise. (99% of the work happens here.)
kripken marked this conversation as resolved.
Show resolved Hide resolved
//
// This is basically the same as JSImplBackend, except that the code in step #3
// is async (also, step #2 looks slightly different, but is similarly very
// short).
//
// For a simple example, see fetch_backend.cpp and library_wasmfs_fetch.js.
//

using js_index_t = uint32_t;

Expand Down