Optimize Date operations and object resolution#2288
Draft
lahma wants to merge 1 commit intosebastienros:mainfrom
Draft
Optimize Date operations and object resolution#2288lahma wants to merge 1 commit intosebastienros:mainfrom
lahma wants to merge 1 commit intosebastienros:mainfrom
Conversation
…watch benchmark improvement Three targeted optimizations for Date-heavy workloads: 1. TypeConverter.ToNumeric: Fast path for JsDate objects Bypasses the expensive ToPrimitive chain (Symbol.toPrimitive lookup -> exotic call -> OrdinaryToPrimitive -> valueOf -> ThisTimeValue) by directly returning the date's numeric value. Eliminates ~12 method calls per Date-to-number conversion. 2. DateConstructor.Construct: Skip OrdinaryCreateFromConstructor for new Date() When newTarget is the built-in DateConstructor (the common case), directly construct JsDate with the known prototype instead of going through GetPrototypeFromConstructor which does a property lookup. 3. Engine.GetValue: Direct ObjectInstance cast When baseValue.IsObject() is already confirmed, use a direct cast instead of TypeConverter.ToObject() which performs a redundant type check. StopwatchBenchmark results (ShortRun): | Variant | Before | After | Improvement | |----------------------|----------|----------|-------------| | Classic Execute | 251.4 ms | 225.3 ms | -10.4% | | Classic ParsedScript | 264.3 ms | 231.0 ms | -12.6% | | Modern Execute | 302.6 ms | 271.9 ms | -10.1% | | Modern ParsedScript | 320.2 ms | 277.8 ms | -13.2% | Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Three targeted optimizations for Date-heavy workloads:
TypeConverter.ToNumeric: Fast path for JsDate objects Bypasses the expensive ToPrimitive chain (Symbol.toPrimitive lookup -> exotic call -> OrdinaryToPrimitive -> valueOf -> ThisTimeValue) by directly returning the date's numeric value. Eliminates ~12 method calls per Date-to-number conversion.
DateConstructor.Construct: Skip OrdinaryCreateFromConstructor for new Date() When newTarget is the built-in DateConstructor (the common case), directly construct JsDate with the known prototype instead of going through GetPrototypeFromConstructor which does a property lookup.
Engine.GetValue: Direct ObjectInstance cast When baseValue.IsObject() is already confirmed, use a direct cast instead of TypeConverter.ToObject() which performs a redundant type check.
StopwatchBenchmark results (ShortRun):