Skip to content

Fix wasteful allocations and minor perf improvements#2369

Merged
lahma merged 3 commits into
sebastienros:mainfrom
lahma:fix/perf-set-prototype-typeconverter
Mar 26, 2026
Merged

Fix wasteful allocations and minor perf improvements#2369
lahma merged 3 commits into
sebastienros:mainfrom
lahma:fix/perf-set-prototype-typeconverter

Conversation

@lahma

@lahma lahma commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • SetPrototype: Remove unnecessary JsSet/HashSet copies in IsDisjointFrom, IsSubsetOf, and IsSupersetOf that were allocating full set copies for read-only or boolean-returning operations
  • SetPrototype.IsSubsetOf: Remove redundant always-true condition guard
  • TypeConverter: Cache BigInteger.Pow(2, 64) and BigInteger.Pow(2, 63) as static readonly fields instead of recomputing on every ToBigInt64/ToBigUint64 call
  • JintBinaryExpression: Cache Math.Abs(baseValue) in exponentiation instead of calling it 4 times

Test plan

  • Jint.Tests — 2,807 passed, 0 failed
  • Jint.Tests.Test262 — 95,985 passed, 0 failed

🤖 Generated with Claude Code

lahma and others added 3 commits March 26, 2026 18:17
- SetPrototype: Remove unnecessary JsSet/HashSet copies in IsDisjointFrom,
  IsSubsetOf, and IsSupersetOf that were allocating full set copies for
  read-only or boolean-returning operations
- SetPrototype.IsSubsetOf: Remove redundant always-true condition guard
- TypeConverter: Cache BigInteger.Pow(2, 64) and BigInteger.Pow(2, 63)
  as static readonly fields instead of recomputing on every call
- JintBinaryExpression: Cache Math.Abs(baseValue) in exponentiation
  instead of calling it 4 times
- HybridDictionary: Replace Enumerable.Empty<T>().GetEnumerator() with
  Array.Empty<T>() cast to avoid LINQ enumerator allocation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both Enumerable.Empty<T>().GetEnumerator() and Array.Empty<T>() cast
produce the same SZGenericArrayEnumerator allocation. The original code
is cleaner and callers already null-check before iterating, so this
path is rarely hit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rted features

- Add TaskInterop section under Asynchronous Execution explaining automatic
  .NET Task/ValueTask to JavaScript Promise conversion with usage examples
- Add Decorators to ECMAScript proposals (no version yet) feature list

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lahma
lahma enabled auto-merge (squash) March 26, 2026 16:30
@lahma
lahma merged commit 378cead into sebastienros:main Mar 26, 2026
4 checks passed
@lahma
lahma deleted the fix/perf-set-prototype-typeconverter branch March 27, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant