Bug 1831072 - Part 3: Add a forceDiscardJitCode method and refactor GC callers r=jandem

I didn't update ReleaseAllJITCode out of an abundance of caution, but maybe
this should call forceDiscardJitCode too.

Differential Revision: https://phabricator.services.mozilla.com/D177038
This commit is contained in:
Jon Coppeard 2023-05-04 09:34:40 +00:00
parent 9375b42233
commit ce9fb10c21
5 changed files with 13 additions and 13 deletions

View file

@ -3291,10 +3291,7 @@ void GCRuntime::maybeStopPretenuring() {
double rate = double(zone->finalizedStrings) / double(numStrings);
if (rate > tunables.stopPretenureStringThreshold()) {
CancelOffThreadIonCompile(zone);
bool preserving = zone->isPreservingCode();
zone->setPreservingCode(false);
zone->discardJitCode(rt->gcContext());
zone->setPreservingCode(preserving);
zone->forceDiscardJitCode(rt->gcContext());
for (RealmsInZoneIter r(zone); !r.done(); r.next()) {
if (jit::JitRealm* jitRealm = r->jitRealm()) {
jitRealm->discardStubs();

View file

@ -95,8 +95,7 @@ void js::ReleaseAllJITCode(JS::GCContext* gcx) {
js::CancelOffThreadIonCompile(gcx->runtime());
for (ZonesIter zone(gcx->runtime(), SkipAtoms); !zone.done(); zone.next()) {
zone->setPreservingCode(false);
zone->discardJitCode(gcx);
zone->forceDiscardJitCode(gcx);
}
for (RealmsIter realm(gcx->runtime()); !realm.done(); realm.next()) {

View file

@ -1564,10 +1564,7 @@ size_t js::Nursery::doPretenuring(JSRuntime* rt, JS::GCReason reason,
zone->tenuredBigInts >= 30 * 1000;
if (disableNurseryStrings || disableNurseryBigInts) {
CancelOffThreadIonCompile(zone);
bool preserving = zone->isPreservingCode();
zone->setPreservingCode(false);
zone->discardJitCode(rt->gcContext());
zone->setPreservingCode(preserving);
zone->forceDiscardJitCode(rt->gcContext());
for (RealmsInZoneIter r(zone); !r.done(); r.next()) {
if (jit::JitRealm* jitRealm = r->jitRealm()) {
jitRealm->discardStubs();

View file

@ -385,11 +385,14 @@ void Zone::checkStringWrappersAfterMovingGC() {
#endif
void Zone::discardJitCode(JS::GCContext* gcx, const DiscardOptions& options) {
if (!jitZone()) {
return;
if (!isPreservingCode()) {
forceDiscardJitCode(gcx, options);
}
}
if (isPreservingCode()) {
void Zone::forceDiscardJitCode(JS::GCContext* gcx,
const DiscardOptions& options) {
if (!jitZone()) {
return;
}

View file

@ -327,6 +327,10 @@ class Zone : public js::ZoneAllocator, public js::gc::GraphNodeBase<JS::Zone> {
void discardJitCode(JS::GCContext* gcx,
const DiscardOptions& options = DiscardOptions());
// Discard JIT code regardless of isPreservingCode().
void forceDiscardJitCode(JS::GCContext* gcx,
const DiscardOptions& options = DiscardOptions());
void resetAllocSitesAndInvalidate(bool resetNurserySites,
bool resetPretenuredSites);