Bug 1715759 - Add a pref to control allocation site based pretrening r=jandem

This doesn't change the state of this feature which currently enabled, but will
allow us to disable it easily if necessary.

Differential Revision: https://phabricator.services.mozilla.com/D117441
This commit is contained in:
Jon Coppeard 2021-06-14 14:22:57 +00:00
Родитель 7c8d046c02
Коммит e436a16c30
4 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -913,6 +913,12 @@ class JS_PUBLIC_API AutoDisableGenerationalGC {
*/
extern JS_PUBLIC_API bool IsGenerationalGCEnabled(JSRuntime* rt);
/**
* Enable or disable support for pretenuring allocations based on their
* allocation site.
*/
extern JS_PUBLIC_API void SetSiteBasedPretenuringEnabled(bool enable);
/**
* Pass a subclass of this "abstract" class to callees to require that they
* never GC. Subclasses can use assertions or the hazard analysis to ensure no

Просмотреть файл

@ -55,9 +55,16 @@ static constexpr size_t HighNurserySurvivalCountBeforeRecovery = 2;
AllocSite* const AllocSite::EndSentinel = reinterpret_cast<AllocSite*>(1);
static bool SiteBasedPretenuringEnabled = true;
JS_PUBLIC_API void JS::SetSiteBasedPretenuringEnabled(bool enable) {
SiteBasedPretenuringEnabled = enable;
}
bool PretenuringNursery::canCreateAllocSite() {
MOZ_ASSERT(allocSitesCreated <= MaxAllocSitesPerMinorGC);
return allocSitesCreated < MaxAllocSitesPerMinorGC;
return SiteBasedPretenuringEnabled &&
allocSitesCreated < MaxAllocSitesPerMinorGC;
}
size_t PretenuringNursery::doPretenuring(GCRuntime* gc, bool validPromotionRate,

Просмотреть файл

@ -910,6 +910,10 @@ static void LoadStartupJSPrefs(XPCJSContext* xpccx) {
JS::SetLargeArrayBuffersEnabled(
StaticPrefs::javascript_options_large_arraybuffers_DoNotUseDirectly());
JS::SetSiteBasedPretenuringEnabled(
StaticPrefs::
javascript_options_site_based_pretenuring_DoNotUseDirectly());
}
static void ReloadPrefsCallback(const char* pref, void* aXpccx) {

Просмотреть файл

@ -5969,6 +5969,13 @@
mirror: always # LoadStartupJSPrefs
do_not_use_directly: true
# Support for pretenuring allocations based on their allocation site.
- name: javascript.options.site_based_pretenuring
type: bool
value: true
mirror: always # LoadStartupJSPrefs
do_not_use_directly: true
#if !defined(JS_CODEGEN_MIPS32) && !defined(JS_CODEGEN_MIPS64)
# Spectre security vulnerability mitigations for the JS JITs.
#