WebAssembly / WebAssembly/spec
Semi-implicit dropping of initialization should be explicited
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 3.5k
- Forks
- 539
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 13
Description
(Based on WebAssembly/stack-switching#118)
The current specification prevents initialization information to be propagated through blocks by simply not having variable lists in the rules:
C |- blocktype : [t1*] -> [t2*] C, labels[t2*] |- instr* : [t1*] -> [t2*]
----------------------------------------------------------------------------
C |- block blocktype instr* end : [t1*] -> [t2*]
C |- blocktype : [t1*] -> [t2*] C, labels[t1*] |- instr* : [t1*] -> [t2*]
---------------------------------------------------------------------------
C |- loop blocktype instr* end : [t1*] -> [t2*]
I understand the rationale behind this decision, and I agree that this is the simplest way that is also future-compatible. However, someone reading through this specification may not notice this as this is too implicit, and I think this decision should be explicited in a note as this is an important caveat.
The note would not have to be long; it could for example be:
This instruction never initializes locals.
EDIT: Another possibility is to add a note similar to the select instruction, such as:
In future versions of WebAssembly, this instruction may specify locals that become initialized.
On a related note, why are block types valid as instruction types when they cannot describe locals indices? Shouldn't they be valid as function types instead?
Contributor guide
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 block and loop typing rules quoted in the issue, then compare them with the existing note for the select instruction. Decide how initialization behavior should be stated and whether the question about block types belongs in the same change. Done means the specification explicitly communicates the initialization caveat and the chosen wording is consistent with related rules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100