Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adapter: eliminate State::with_mut (bytecodealliance#6973)
There is no need to get exclusive access to State: * All mutation of State and Descriptors is handled internally with cells. `descriptors_mut` does not need exclusive access to State, and eliminating that constraint means we can trivially shorten all uses of `with_mut` to `with`. * recursive access to State is required for implementing the cabi_realloc functions. These functions do not need exclusive access to State, but if another call has already taken an exclusive borrow, realloc will trap. I recently found a bug that would occur if `path_open` is the first call into the adapter, the State will be borrowed exclusively and `descriptors_mut` will initialize the descriptors by calling out to get the preopens. Because preopens are a list, the runtime needs to call cabi_realloc to return them, and that call will fail where cabi_import_realloc tries to borrow the exclusively- borrowed State.
- Loading branch information