stage2: Wasm - Integrate lifeness analysis for locals reusal #13193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This uses a combination of lifeness analysis and reference counting to 'free' locals virtually so they can be reused for new temporaries and variables. Although Wasm has an infinite amount of locals available to itself, by reducing the number of locals we generate we decrease the binary size as well as the load time when loading the Wasm binary into the runtime. Currently, we only decrease a reference if an operand dies within the same branch it was created. Operands dying inside of a branch is an exercise for later, which won't require any major refactoring as all of the ground has already been done now.
The binary size for the behavior test suite (1074 passing tests), resulted in a decrease of 8259 bytes (1.4%). While not a substantial change, there are a lot of operands dying within other branches, so this could be shaved off more in the future. I still think this was a worthwhile change, regardless of the increased complexity.
Other changes I did also:
valtype
was off by 2 and therefore stored locals into free-lists that had a different type. Causing the Wasm-validator to not pass.self
to a self-explanatory name.