Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JSC] Expand existing property names caching onto Reflect.ownKeys() /…
… Object.getOwnPropertySymbols() https://bugs.webkit.org/show_bug.cgi?id=255935 <rdar://problem/108512520> Reviewed by Yusuke Suzuki. This change expands existing Object.keys() / Object.getOwnPropertyNames() StructureRareData-based property names caching onto Reflect.ownKeys() / Object.getOwnPropertySymbols(). Vue.js v3 traps "ownKeys" on all reactive objects (except Map / Set) to merely forward the call to Reflect.ownKeys(), while web developers often destructure / call Object.assign() on those Proxy objects. Also, this change enables a follow-up optimization of Proxy objects without "ownKeys" traps, hence the renaming of CachedPropertyNamesKind that unties enumerators from ObjectConstructor methods. As for Object.getOwnPropertySymbols(), some older code on the web uses it conditionally instead of polyfilling Reflect.ownKeys(), and optimizing it along with Reflect.ownKeys() brought convenience of removing std::optional and a few conditions. The downside of this patch is sizeof(StructureRareData) increase from 80 to 96. ToT patch reflect-own-keys-proxy 18.8444+-0.1230 ? 18.9896+-0.1170 ? reflect-own-keys-proxy-2 23.4113+-0.1775 ^ 21.2813+-0.1835 ^ definitely 1.1001x faster reflect-own-keys-function 8.3105+-0.0650 ^ 6.4431+-0.0452 ^ definitely 1.2898x faster reflect-own-keys 31.3966+-0.1861 ^ 0.9040+-0.0209 ^ definitely 34.7312x faster object-get-own-property-symbols 18.6633+-0.1597 ^ 1.0756+-0.0218 ^ definitely 17.3512x faster <geometric> 18.4640+-0.0749 ^ 4.7893+-0.0312 ^ definitely 3.8553x faster * JSTests/microbenchmarks/object-get-own-property-symbols.js: * JSTests/microbenchmarks/reflect-own-keys.js: Makes the property keys count way more real-world. * Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsicCall): * Source/JavaScriptCore/dfg/DFGClobberize.h: (JSC::DFG::clobberize): * Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * Source/JavaScriptCore/dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * Source/JavaScriptCore/dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * Source/JavaScriptCore/dfg/DFGNode.h: (JSC::DFG::Node::cachedPropertyNamesKind const): * Source/JavaScriptCore/dfg/DFGNodeType.h: * Source/JavaScriptCore/dfg/DFGOperations.cpp: (JSC::DFG::JSC_DEFINE_JIT_OPERATION): * Source/JavaScriptCore/dfg/DFGOperations.h: (JSC::DFG::operationOwnPropertyKeysVariant): (JSC::DFG::operationOwnPropertyKeysVariantObject): * Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp: * Source/JavaScriptCore/dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp: * Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h: * Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h: * Source/JavaScriptCore/ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::abstractHeapForOwnPropertyKeysCache): (JSC::FTL::DFG::LowerDFGToB3::compileOwnPropertyKeysVariant): (JSC::FTL::DFG::LowerDFGToB3::compileObjectKeysOrObjectGetOwnPropertyNames): Deleted. * Source/JavaScriptCore/runtime/Intrinsic.h: * Source/JavaScriptCore/runtime/ObjectConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): (JSC::inferCachedPropertyNamesKind): (JSC::ownPropertyKeys): Merely removes PropertyNameMode check, de-indents, and extracts copyPropertiesToBuffer() helper. * Source/JavaScriptCore/runtime/ObjectConstructor.h: * Source/JavaScriptCore/runtime/ReflectObject.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/StructureRareData.h: Canonical link: https://commits.webkit.org/263441@main
- Loading branch information
Alexey Shvayka
committed
Apr 26, 2023
1 parent
9c5f7b8
commit d126a37
Showing
27 changed files
with
275 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
var obj = {}, i; | ||
for (i = 0; i < 100; ++i) | ||
for (i = 0; i < 10; ++i) | ||
obj[`k${i}`] = i; | ||
for (i = 0; i < 100; ++i) | ||
for (i = 0; i < 10; ++i) | ||
obj[Symbol(i)] = i; | ||
|
||
noInline(Reflect.ownKeys); | ||
|
||
for (i = 0; i < 1e4; ++i) | ||
for (i = 0; i < 1e5; ++i) | ||
Reflect.ownKeys(obj); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.