WebAssembly / WebAssembly/component-model
Optimization: Shorter option binary representation via invalid value (e.g. -1 == None of option<resource>)
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 1.4k
- Forks
- 130
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 15
Description
Today I realized that option<my-resource> or option<borrow<my-resource>> could have the same size and representation as the resource itself, because (at least in the current bindings) -1 is used as an invalid value for the resource index.
As I didn't find the invalid value nor the optimization documented in the canonical ABI, I wonder whether this would be a reasonable addition to the spec. Similarly string and vector could have defined invalid representations which could optimize the representation of an option.
See https://doc.rust-lang.org/std/option/index.html#representation for the documentation of the Null Pointer Optimization on Rust.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the canonical ABI’s option and resource representation rules, then compare them with the linked Rust Option representation documentation. Determine whether invalid representations for resources, strings, and vectors can be specified without ambiguity; done means a concrete ABI proposal and its implications are documented for review.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100