next.js
a683d06f - [tubopack] migrate rcstr! to use scattered collect (#94498)

Commit
59 days ago
[tubopack] migrate rcstr! to use scattered collect (#94498) ### What? Adopt `[scattered_collect`](https://docs.rs/scattered-collect/latest/scattered_collect/) for collecting static rcstr values. ### Why? Built by our good friend @mmastrac to solve some of our problems. Replaces inventory with a simpler linker driver approach. Basically inventory works using constructor functions to build a linked list, then iterating follows the list. `scattered_collect` on the otherhand uses a linker section for the data, so it all gets moved to a dedicated part of the binary and bingo, a slice!. This means we don't need `init` time logic. This is preparation for migrating other uses of `inventory` just to prove it out. Which was a good idea because we found and fixed a bug! See https://github.com/mmastrac/linktime/releases/tag/link-section-0.18.2 ## Wasm scatter_collect supports wasm, but requires us to register a 'section reader' function with the runtime, see https://docs.rs/link-section/latest/link_section/#wasm. The instructions are staightforward but a little tricky since we rely on `wasm-bindgen` to constrct the `Wasm.Module` instance and it is encapsulated. So to 'inject' that function we would need to patch some of the bootstrapping. Given that this registry is only an optimization for deserialization which never happens in a wasm build i just flagged it all off.
Author
Parents
Loading