Repository navigation
Commit 350878c
committed
Reduce String ref/deref churn in JSC by 60% on JetStream2
https://bugs.webkit.org/show_bug.cgi?id=274046
rdar://127946516
Reviewed by Yusuke Suzuki.
This patch reduces the number of refs in JSC on JetStream2 by ~60% from 407831951 to 168560273,
which seems to be ~.3% speedup on that benchmark.
Mostly this is done by introducing a new class `GCOwnedDataScope` this class holds some data
owned by a GCed object and ensures that GCed object is retained by the C++ compiler at least
as long as the scope. This makes it easy to provide access to GC object owned data safely.
The only requirement is that people **DO NOT** do `Data&/* data = gcType->getData()`. However,
this is the problem with the current accessors used throughout JSC anyway. Over time we should
start migrating more and more JSC accessor member functions to `GCOwnedDataScope`.
The main functions updated in this patch are `JSString::value` and
`JSString::viewWithUnderlyingString` the latter of which is now JSString::view. These now
return a `GCOwnedDataScope<const String&>` and `GCOwnedDataScope<StringView>`, respectively.
Additionally, PropertyName now takes a CacheableIdentifier for the various `operationGetBy<Op>`
JIT operations instead of converting to a true Identifier (incurring a ref/deref).
Also, add some extra logging to our scope checking code.
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/bytecode/Repatch.cpp:
(JSC::tryCacheGetBy):
(JSC::tryCacheArrayGetByVal):
(JSC::tryCachePutBy):
(JSC::tryCacheArrayPutByVal):
(JSC::tryCacheDeleteBy):
(JSC::repatchDeleteBy):
(JSC::tryCacheInBy):
(JSC::repatchInBy):
(JSC::tryCacheHasPrivateBrand):
(JSC::tryCacheCheckPrivateBrand):
(JSC::tryCacheSetPrivateBrand):
(JSC::tryCacheInstanceOf):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/ftl/FTLOperations.cpp:
(JSC::FTL::JSC_DEFINE_NOEXCEPT_JIT_OPERATION):
* Source/JavaScriptCore/heap/GCOwnedDataScope.h: Added.
(JSC::GCOwnedDataScope::GCOwnedDataScope):
(JSC::GCOwnedDataScope::~GCOwnedDataScope):
(JSC::GCOwnedDataScope::operator const T const):
(JSC::GCOwnedDataScope::operator T):
(JSC::GCOwnedDataScope::requires):
(JSC::GCOwnedDataScope::operator[] const):
* Source/JavaScriptCore/inspector/InjectedScriptBase.cpp:
(Inspector::jsToInspectorValue):
* Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
* Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp:
(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
* Source/JavaScriptCore/interpreter/Interpreter.cpp:
(JSC::eval):
* Source/JavaScriptCore/jit/ICStats.h:
(JSC::ICEvent::ICEvent):
* Source/JavaScriptCore/jit/JITArithmetic.cpp:
(JSC::JIT::emit_compareImpl):
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::JSC_DEFINE_JIT_OPERATION):
(JSC::setPrivateField):
(JSC::definePrivateField):
(JSC::getPrivateName):
(JSC::deleteById):
(JSC::deleteByIdOptimize):
* Source/JavaScriptCore/jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
(printInternal):
(JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/CachedTypes.cpp:
(JSC::CachedJSValue::encode):
* Source/JavaScriptCore/runtime/CommonSlowPaths.cpp:
(JSC::JSC_DEFINE_COMMON_SLOW_PATH):
* Source/JavaScriptCore/runtime/DateConstructor.cpp:
(JSC::constructDate):
* Source/JavaScriptCore/runtime/ExceptionHelpers.cpp:
(JSC::errorDescriptionForValue):
* Source/JavaScriptCore/runtime/FunctionConstructor.cpp:
(JSC::stringifyFunction):
* Source/JavaScriptCore/runtime/HashMapImplInlines.h:
(JSC::jsMapHashImpl):
* Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h:
(JSC::toIntlMathematicalValue):
* Source/JavaScriptCore/runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::segment const):
* Source/JavaScriptCore/runtime/JSBoundFunction.cpp:
(JSC::JSBoundFunction::nameSlow):
* Source/JavaScriptCore/runtime/JSCJSValue.cpp:
(JSC::JSValue::toWTFStringForConsole const):
* Source/JavaScriptCore/runtime/JSCJSValueInlines.h:
(JSC::toPreferredPrimitiveType):
(JSC::JSValue::equalSlowCaseInline):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
(JSC::genericTypedArrayViewProtoFuncJoin):
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSImmutableButterfly.cpp:
(JSC::JSImmutableButterfly::createFromString):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::importModule):
* Source/JavaScriptCore/runtime/JSONObject.cpp:
(JSC::Stringifier::appendStringifiedValue):
(JSC::FastStringifier<CharType>::append):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSObject.cpp:
(JSC::JSObject::calculatedClassName):
* Source/JavaScriptCore/runtime/JSString.cpp:
(JSC::JSString::toNumber const):
* Source/JavaScriptCore/runtime/JSString.h:
(JSC:: const):
(JSC::JSString::getIndex):
(JSC::JSRopeString::view const):
(JSC::JSString::view const):
(JSC::JSString::value const): Deleted.
(JSC::JSString::tryGetValue const): Deleted.
(JSC::JSRopeString::unsafeView const): Deleted.
(JSC::JSRopeString::viewWithUnderlyingString const): Deleted.
(JSC::JSString::unsafeView const): Deleted.
(JSC::JSString::viewWithUnderlyingString const): Deleted.
* Source/JavaScriptCore/runtime/JSStringInlines.h:
(JSC::JSString::equalInline const):
* Source/JavaScriptCore/runtime/JSStringJoiner.h:
(JSC::JSStringJoiner::appendWithoutSideEffects):
(JSC::JSStringJoiner::append):
* Source/JavaScriptCore/runtime/NumberPrototype.cpp:
(JSC::throwVMToThisNumberError):
* Source/JavaScriptCore/runtime/Operations.h:
(JSC::jsString):
(JSC::compareBigIntToOtherPrimitive):
(JSC::compareBigInt32ToOtherPrimitive):
(JSC::jsLess):
(JSC::jsLessEq):
* Source/JavaScriptCore/runtime/ParseInt.h:
(JSC::toStringView):
* Source/JavaScriptCore/runtime/PropertyName.h:
(JSC::PropertyName::PropertyName):
* Source/JavaScriptCore/runtime/RegExpConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/RegExpMatchesArray.h:
(JSC::createRegExpMatchesArray):
* Source/JavaScriptCore/runtime/RegExpObject.cpp:
(JSC::RegExpObject::matchGlobal):
* Source/JavaScriptCore/runtime/RegExpObjectInlines.h:
(JSC::RegExpObject::execInline):
(JSC::RegExpObject::matchInline):
* Source/JavaScriptCore/runtime/RegExpPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/ShadowRealmPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/StringPrototype.cpp:
(JSC::replaceUsingRegExpSearch):
(JSC::JSC_DEFINE_JIT_OPERATION):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::replace):
(JSC::stringIndexOfImpl):
(JSC::toLocaleCase):
(JSC::normalize):
* Source/JavaScriptCore/runtime/StringPrototypeInlines.h:
(JSC::stringReplaceStringString):
(JSC::replaceUsingStringSearch):
* Source/JavaScriptCore/runtime/SymbolConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/TemporalCalendarPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/TemporalPlainTime.cpp:
(JSC::TemporalPlainTime::from):
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/WTF/wtf/HashMap.h:
* Source/WTF/wtf/text/WTFString.h:
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpIfTerminal):
* Source/WebCore/bridge/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
* Source/WebKitLegacy/mac/WebView/WebView.mm:
(aeDescFromJSValue):
Canonical link: https://commits.webkit.org/278691@main1 parent ac508ff commit 350878c
62 files changed
Lines changed: 536 additions & 441 deletions
File tree
- Source
- JavaScriptCore
- JavaScriptCore.xcodeproj
- bytecode
- dfg
- ftl
- heap
- inspector
- interpreter
- jit
- llint
- runtime
- tools
- WTF/wtf
- text
- WebCore
- bindings/js
- bridge/objc
- WebKitLegacy/mac/WebView
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
740 | 740 | | |
741 | 741 | | |
742 | 742 | | |
| 743 | + | |
743 | 744 | | |
744 | 745 | | |
745 | 746 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1212 | 1212 | | |
1213 | 1213 | | |
1214 | 1214 | | |
| 1215 | + | |
1215 | 1216 | | |
1216 | 1217 | | |
1217 | 1218 | | |
| |||
2152 | 2153 | | |
2153 | 2154 | | |
2154 | 2155 | | |
2155 | | - | |
2156 | | - | |
| 2156 | + | |
| 2157 | + | |
2157 | 2158 | | |
2158 | 2159 | | |
2159 | 2160 | | |
| |||
4292 | 4293 | | |
4293 | 4294 | | |
4294 | 4295 | | |
| 4296 | + | |
4295 | 4297 | | |
4296 | 4298 | | |
4297 | 4299 | | |
| |||
7026 | 7028 | | |
7027 | 7029 | | |
7028 | 7030 | | |
| 7031 | + | |
7029 | 7032 | | |
7030 | 7033 | | |
7031 | 7034 | | |
| |||
10892 | 10895 | | |
10893 | 10896 | | |
10894 | 10897 | | |
| 10898 | + | |
10895 | 10899 | | |
10896 | 10900 | | |
10897 | 10901 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
| 516 | + | |
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | | - | |
| 688 | + | |
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
| |||
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
861 | | - | |
| 861 | + | |
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
| 1017 | + | |
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
1021 | 1021 | | |
1022 | | - | |
| 1022 | + | |
1023 | 1023 | | |
1024 | 1024 | | |
1025 | 1025 | | |
| |||
1145 | 1145 | | |
1146 | 1146 | | |
1147 | 1147 | | |
1148 | | - | |
| 1148 | + | |
1149 | 1149 | | |
1150 | 1150 | | |
1151 | 1151 | | |
| |||
1218 | 1218 | | |
1219 | 1219 | | |
1220 | 1220 | | |
1221 | | - | |
| 1221 | + | |
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| |||
1231 | 1231 | | |
1232 | 1232 | | |
1233 | 1233 | | |
1234 | | - | |
| 1234 | + | |
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
| |||
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
1325 | | - | |
| 1325 | + | |
1326 | 1326 | | |
1327 | 1327 | | |
1328 | 1328 | | |
| |||
1372 | 1372 | | |
1373 | 1373 | | |
1374 | 1374 | | |
1375 | | - | |
| 1375 | + | |
1376 | 1376 | | |
1377 | 1377 | | |
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
1381 | 1381 | | |
1382 | 1382 | | |
1383 | | - | |
| 1383 | + | |
1384 | 1384 | | |
1385 | 1385 | | |
1386 | 1386 | | |
| |||
1411 | 1411 | | |
1412 | 1412 | | |
1413 | 1413 | | |
1414 | | - | |
| 1414 | + | |
1415 | 1415 | | |
1416 | 1416 | | |
1417 | 1417 | | |
| |||
1438 | 1438 | | |
1439 | 1439 | | |
1440 | 1440 | | |
1441 | | - | |
| 1441 | + | |
1442 | 1442 | | |
1443 | 1443 | | |
1444 | 1444 | | |
1445 | 1445 | | |
1446 | 1446 | | |
1447 | 1447 | | |
1448 | | - | |
| 1448 | + | |
1449 | 1449 | | |
1450 | 1450 | | |
1451 | 1451 | | |
| |||
1481 | 1481 | | |
1482 | 1482 | | |
1483 | 1483 | | |
1484 | | - | |
| 1484 | + | |
1485 | 1485 | | |
1486 | 1486 | | |
1487 | 1487 | | |
1488 | 1488 | | |
1489 | 1489 | | |
1490 | 1490 | | |
1491 | | - | |
| 1491 | + | |
1492 | 1492 | | |
1493 | 1493 | | |
1494 | 1494 | | |
| |||
1536 | 1536 | | |
1537 | 1537 | | |
1538 | 1538 | | |
1539 | | - | |
| 1539 | + | |
1540 | 1540 | | |
1541 | 1541 | | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | 1544 | | |
1545 | 1545 | | |
1546 | | - | |
| 1546 | + | |
1547 | 1547 | | |
1548 | 1548 | | |
1549 | 1549 | | |
| |||
1602 | 1602 | | |
1603 | 1603 | | |
1604 | 1604 | | |
1605 | | - | |
| 1605 | + | |
1606 | 1606 | | |
1607 | 1607 | | |
1608 | 1608 | | |
1609 | 1609 | | |
1610 | | - | |
| 1610 | + | |
1611 | 1611 | | |
1612 | 1612 | | |
1613 | 1613 | | |
| |||
0 commit comments