Move re-initialization logic into Rust/wasm-bindgen#947
Move re-initialization logic into Rust/wasm-bindgen#947logan-gatlin wants to merge 24 commits intomainfrom
Conversation
Merging this PR will not alter performance
|
guybedford
left a comment
There was a problem hiding this comment.
Would be nice to see how this integrates with the upstream branch of supporting StaleError and if that is sufficient to support the instance checks.
We also need to ensure unwind test coverage here.
cef1a38 to
62f9763
Compare
7ad45cd to
11ef7cc
Compare
|
This PR broke doctests somehow, probably because I bumped the versions of a lot of things. Had to go in and add |
|
I updated this to use the new fork of reinit-hooks wasm-bindgen/wasm-bindgen#5059 |
This PR moves (most of) the responsibility for re-initializing Rust workers away from our custom JS shim, and into Rust/wasm-bindgen.
Latest wasm-bindgen handles re-initialization automatically when building for the panic=unwind target. This means that most of the shim we provide for WASM modules is unnecessary. This PR creates a new minimal shim for panic=unwind builds.
Durable objects require slightly more work since their state must be reset on an abort. Previously, durable objects were heap allocated Rust structs managed by JS objects which kept pointers into Rust's memory. This is problematic when the instance resets, as these pointers become dangling.
The new design is to keep a global
HashMapin Rust containing all live DO instances, keyed by a uniqueu32. In our JS shim, we maintain a list of live DO ids and the arguments used to construct them. When re-initialization happens, every entry in this list is re-initialized.Notes:
This requires a new feature in
wasm-bindgenallowing for a post-reinitialization hook, right now I am just pointing the submodule to my feature branch. Both Rust andwasm-bindgenneeded to be bumped to their latest version so I could write panic=unwind tests. This makes the diff messy because many doc tests subsequently failed to build, and CI had to be modified to support this new setup. When the wasm-bindgen reinit hook is merged I will probably split this up into two PRs