Optimize interpreter hot paths for arithmetic, comparisons, and control flow#2345
Merged
Conversation
…ol flow Add double fast paths to arithmetic operators (Plus, Minus, Times, Divide) that skip ToPrimitive/ToNumeric overhead for JsNumber operands. Simplify CompareNumber to check integer type first and handle NaN directly instead of falling back to CompareComplex. Move Remainder's integer check before ToNumeric conversion. Add GetBooleanValue virtual method to JintExpression with overrides on 7 comparison operators, and use it in for-loop, while-loop, and if-statement conditions to avoid JsBoolean wrapper allocation and ToBoolean virtual dispatch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lahma
force-pushed
the
perf-improvements
branch
from
March 22, 2026 09:58
bdb30cf to
aeee8bf
Compare
This was referenced Mar 23, 2026
This was referenced Jun 8, 2026
This was referenced Jun 29, 2026
This was referenced Jul 7, 2026
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.
Summary
+,-,*,/) that skipToPrimitive/ToNumericoverhead forJsNumberoperandsCompareNumberto check integer type first with directAsInteger(), handle NaN directly instead of falling back to expensiveCompareComplex, remove unnecessary infinity checkRemainder's integer check beforeToNumericconversion to skip redundant type conversion for integer operandsGetBooleanValue()virtual method onJintExpressionwith overrides on comparison operators (<,>,<=,>=,==,!=,===,!==), used infor-loop,while-loop, andif-statement conditions to avoidJsBooleanwrapper andToBooleanvirtual dispatchEngineComparison Benchmark Results
Measured with
EngineComparisonBenchmark.Jint_ParsedScripton .NET 10.0.5, AMD Ryzen 9 5950X.SunSpider Benchmark Results (main vs perf-improvements)
*Within noise floor — both suites ran concurrently on the same machine.
Dromaeo Benchmark Results (main vs perf-improvements, Prepared=True)
*Within noise — benchmarks ran concurrently; main's CoreEval had exceptionally high StdDev.
No performance regressions detected across all three benchmark suites (52 benchmarks total).
Test plan
dotnet test -c Release Jint.Tests/Jint.Tests.csproj— 2764 passed, 0 failed🤖 Generated with Claude Code