[JSC] Implement Array.prototype.includes in C++#40613
Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom Feb 23, 2025
Merged
[JSC] Implement Array.prototype.includes in C++#40613webkit-commit-queue merged 1 commit intoWebKit:mainfrom
Array.prototype.includes in C++#40613webkit-commit-queue merged 1 commit intoWebKit:mainfrom
Conversation
Collaborator
|
EWS run on previous version of this PR (hash fe2384a) Details |
fe2384a to
71e9316
Compare
Collaborator
|
EWS run on previous version of this PR (hash 71e9316) Details |
71e9316 to
64f07ef
Compare
Collaborator
|
EWS run on previous version of this PR (hash 64f07ef) Details |
64f07ef to
afe4045
Compare
Collaborator
|
EWS run on previous version of this PR (hash afe4045) Details |
afe4045 to
7f8cc43
Compare
Collaborator
|
EWS run on previous version of this PR (hash 7f8cc43) Details |
Constellation
approved these changes
Feb 17, 2025
7f8cc43 to
b81a2fe
Compare
Collaborator
|
EWS run on current version of this PR (hash b81a2fe) Details |
https://bugs.webkit.org/show_bug.cgi?id=287693 Reviewed by Yusuke Suzuki. Currently, JSC’s `Array#includes` is implemented in JavaScript, whereas the similar `Array#indexOf` is implemented in C++ and benefits from DFG/FTL optimizations. This patch reimplements `Array#includes` in C++ in the same way as `Array#indexOf`, thereby enabling DFG/FTL support. In most cases, the patch shows performance improvements: ``` TipOfTree Patched array-prototype-includes-double 25.2368+-0.1405 ^ 20.9887+-3.0246 ^ definitely 1.2024x faster array-prototype-includes-int32-from-contiguous 22.4340+-0.4231 ^ 17.1624+-0.2591 ^ definitely 1.3072x faster array-prototype-includes-string 43.4965+-0.6154 ^ 30.8301+-0.7207 ^ definitely 1.4108x faster array-prototype-includes-string-16 73.3458+-0.8209 ^ 51.7629+-0.5639 ^ definitely 1.4170x faster array-prototype-includes-double-from-contiguous 73.3174+-0.9760 ^ 42.4634+-1.0352 ^ definitely 1.7266x faster array-prototype-includes-int32 205.9207+-0.2986 ^ 107.2346+-0.4414 ^ definitely 1.9203x faster array-prototype-includes-contiguous 27.8838+-2.6451 ^ 9.7461+-0.1414 ^ definitely 2.8610x faster array-prototype-includes-bigint 17.6066+-0.2040 ^ 12.2816+-0.1275 ^ definitely 1.4336x faster ``` However, benchmarks that use constant strings experience a performance regression. This is due to the loss of constant folding for the `===` operator that was effective in the JavaScript implementation: ``` TipOfTree Patched array-prototype-includes-string-const 17.8715+-0.0715 ! 24.9579+-0.2986 ! definitely 1.3965x slower array-prototype-includes-string-16-const 17.9026+-0.0907 ! 50.5343+-0.6068 ! definitely 2.8227x slower ``` * Source/JavaScriptCore/builtins/ArrayPrototype.js: (includes): Deleted. * Source/JavaScriptCore/runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::finishCreation): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/CommonIdentifiers.h: * Source/JavaScriptCore/runtime/JSCJSValueInlines.h: (JSC::sameValueZero): Canonical link: https://commits.webkit.org/290906@main
b81a2fe to
febcbad
Compare
Collaborator
|
Committed 290906@main (febcbad): https://commits.webkit.org/290906@main Reviewed commits have been landed. Closing PR #40613 and removing active labels. |
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.
febcbad
b81a2fe