Perf/array push pop dense fast path#5283
Closed
MayankRaj435 wants to merge 3 commits intoboa-dev:mainfrom
Closed
Conversation
added 3 commits
March 28, 2026 23:00
Introduce a dedicated ArrowFunction struct that implements a specialized __call__ handler, bypassing the constructor check and this-binding resolution that are unnecessary for arrow functions. Arrow functions: - Are never constructors (skip is_class_constructor check) - Always have lexical this (skip this-binding resolution) - Don't need [[Fields]] or [[PrivateMethods]] slots This reduces the per-call overhead for arrow functions by ~26% in microbenchmarks (100M calls: 21.0s -> 15.6s in release mode). The approach follows the maintainer-recommended strategy of specializing at the function object layer rather than adding new VM opcodes, keeping the Instruction enum lean (24 bytes) and avoiding dispatch sensitivity.
- Implement ScriptFunction trait for polymorphic ArrowFunction/OrdinaryFunction access - Refactor all downcast_ref sites (toString, function_call, get_function_realm, etc.) - Update GetHomeObject/SetHomeObject opcodes for ArrowFunction support - Fix perform_eval and has_super_binding for ArrowFunction - Apply cargo fmt formatting
Test262 conformance changes
Broken tests (4):Tested main commit: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5283 +/- ##
===========================================
+ Coverage 47.24% 59.68% +12.44%
===========================================
Files 476 589 +113
Lines 46892 63632 +16740
===========================================
+ Hits 22154 37981 +15827
- Misses 24738 25651 +913 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Author
|
Hey maintainers ,please review it and let me know if any changes required |
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
This PR implements fast-path optimizations for
Array.prototype.pushandArray.prototype.popwhen dealing with arrays that have contiguous, "dense" index storage. By bypassing the generic property map lookups and standard[[Get]]/[[Set]]internal methods, we significantly reduce the overhead for these fundamental operations.Related Issue
Fixes #5281
Key Changes
IndexedProperties(property_map.rs):pop_dense()method to natively remove elements from dense vectors (DenseI32,DenseF64, andDenseElement).len()andis_sparse()helper methods to facilitate fast check logic.Array.prototype.pop(array/mod.rs):lengthproperty, avoiding string conversion and map lookups.Array.prototype.push(array/mod.rs):push_dense.extensiblecheck to ensure strict compliance when adding new properties to non-extensible arrays.lengthproperty once at the end of the operation.Verification
cargo test arrayincore/engine(123 tests).cargo clippyandcargo fmtpassed (as seen in the command logs).Performance Impact
Initial microbenchmarks suggest a significant reduction in cycles for
pushandpopon dense arrays, as we now avoid: