Repository navigation
perf(vm): step uncaptured number locals in place for i++; - #106
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A
i++;ori--;statement (including aforupdate clause) on an uncaptured, mutable local now compiles to a newINC_LOCALop in front of the usualGET_LOCAL/INC/PUT_LOCAL. If the local holds a number it steps by one in place and skips those three words. Anything else (BigInt, string,undefined, an object withvalueOf, a TDZ hole) runs them as before, so coercion, errors and their locations stay the same.const, captured locals, globals, upvalues, uses of the value (x = i++) andforceExtrabuilds don't get the op.Measured on a loaded machine (load average ~10), so numbers are noisy:
for (let i = 0; i < 1e6; i++) s += i, fresh process, best of 9script/bench.tsnumeric loop, best of 21, six alternating runsThe rest of
script/bench.tswas within noise.Bumps
COMPILER_VERSION5 → 6 and regeneratessrc/prelude/bytecode.json, so the build id changes and snapshots from older builds are refused. The Rust port has its own compiler and is unaffected.Tests: semantics and which locals get the op in
test/vm.test.ts, the verifier and disassembler know the op, and a newtest/snapshot.test.tsprogram round-trips loops that step numbers, BigInts, strings and objects.