From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/base/nsJSEnvironment.cpp | 67 ++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'dom/base/nsJSEnvironment.cpp') diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 1397bd25b5..a14a22bcf0 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1707,38 +1707,38 @@ void nsJSContext::MaybeRunNextCollectorSlice(nsIDocShell* aDocShell, return; } - if (!sScheduler->IsUserActive()) { - if (sScheduler->InIncrementalGC() || sScheduler->IsCollectingCycles()) { - Maybe next = nsRefreshDriver::GetNextTickHint(); - if (next.isSome()) { - // Try to not delay the next RefreshDriver tick, so give a reasonable - // deadline for collectors. - sScheduler->RunNextCollectorTimer(aReason, next.value()); - } - } else { - nsCOMPtr shell = aDocShell; - NS_DispatchToCurrentThreadQueue( - NS_NewRunnableFunction( - "nsJSContext::MaybeRunNextCollectorSlice", - [shell] { - nsIDocShell::BusyFlags busyFlags = nsIDocShell::BUSY_FLAGS_NONE; - shell->GetBusyFlags(&busyFlags); - if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) { - return; - } - - // In order to improve performance on the next page, run a minor - // GC. The 16ms limit ensures it isn't called all the time if - // there are for example multiple iframes loading at the same - // time. - JS::RunNurseryCollection( - CycleCollectedJSRuntime::Get()->Runtime(), - JS::GCReason::PREPARE_FOR_PAGELOAD, - mozilla::TimeDuration::FromMilliseconds(16)); - }), - EventQueuePriority::Idle); + if (!sScheduler->IsUserActive() && + (sScheduler->InIncrementalGC() || sScheduler->IsCollectingCycles())) { + Maybe next = nsRefreshDriver::GetNextTickHint(); + if (next.isSome()) { + // Try to not delay the next RefreshDriver tick, so give a reasonable + // deadline for collectors. + sScheduler->RunNextCollectorTimer(aReason, next.value()); } } + + nsCOMPtr shell = aDocShell; + NS_DispatchToCurrentThreadQueue( + NS_NewRunnableFunction("nsJSContext::MaybeRunNextCollectorSlice", + [shell] { + nsIDocShell::BusyFlags busyFlags = + nsIDocShell::BUSY_FLAGS_NONE; + shell->GetBusyFlags(&busyFlags); + if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) { + return; + } + + // In order to improve performance on the next + // page, run a minor GC. The 16ms limit ensures + // it isn't called all the time if there are for + // example multiple iframes loading at the same + // time. + JS::RunNurseryCollection( + CycleCollectedJSRuntime::Get()->Runtime(), + JS::GCReason::PREPARE_FOR_PAGELOAD, + mozilla::TimeDuration::FromMilliseconds(16)); + }), + EventQueuePriority::Idle); } // static @@ -2121,6 +2121,13 @@ void nsJSContext::EnsureStatics() { "javascript.options.mem.gc_compacting", (void*)JSGC_COMPACTING_ENABLED); +#ifdef NIGHTLY_BUILD + Preferences::RegisterCallbackAndCall( + SetMemoryPrefChangedCallbackBool, + "javascript.options.mem.gc_experimental_semispace_nursery", + (void*)JSGC_SEMISPACE_NURSERY_ENABLED); +#endif + Preferences::RegisterCallbackAndCall( SetMemoryPrefChangedCallbackBool, "javascript.options.mem.gc_parallel_marking", -- cgit v1.2.3