mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset ddfe7f3ad095 (bug 926678) for perma-orange linux crashtest failures
This commit is contained in:
parent
f35c378c80
commit
7ab0f220a1
@ -127,14 +127,7 @@ Zone::setGCMaxMallocBytes(size_t value)
|
||||
void
|
||||
Zone::onTooMuchMalloc()
|
||||
{
|
||||
if (TriggerZoneGC(this, gcreason::TOO_MUCH_MALLOC)) {
|
||||
/*
|
||||
* Set gcMallocBytes to stop updateMallocCounter() calling this method
|
||||
* again before the counter is reset by GC.
|
||||
*/
|
||||
gcMallocBytes = PTRDIFF_MAX;
|
||||
}
|
||||
|
||||
TriggerZoneGC(this, gcreason::TOO_MUCH_MALLOC);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -272,8 +272,10 @@ struct Zone : public JS::shadow::Zone,
|
||||
* Note: this code may be run from worker threads. We
|
||||
* tolerate any thread races when updating gcMallocBytes.
|
||||
*/
|
||||
gcMallocBytes -= ptrdiff_t(nbytes);
|
||||
if (JS_UNLIKELY(isTooMuchMalloc()))
|
||||
ptrdiff_t oldCount = gcMallocBytes;
|
||||
ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
|
||||
gcMallocBytes = newCount;
|
||||
if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
|
||||
onTooMuchMalloc();
|
||||
}
|
||||
|
||||
|
@ -1930,31 +1930,29 @@ TriggerOperationCallback(JSRuntime *rt, JS::gcreason::Reason reason)
|
||||
rt->triggerOperationCallback(JSRuntime::TriggerCallbackMainThread);
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
js::TriggerGC(JSRuntime *rt, JS::gcreason::Reason reason)
|
||||
{
|
||||
/* Wait till end of parallel section to trigger GC. */
|
||||
if (InParallelSection()) {
|
||||
ForkJoinSlice::Current()->requestGC(reason);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Don't trigger GCs when allocating under the operation callback lock. */
|
||||
if (rt->currentThreadOwnsOperationCallbackLock())
|
||||
return false;
|
||||
return;
|
||||
|
||||
JS_ASSERT(CurrentThreadCanAccessRuntime(rt));
|
||||
|
||||
/* GC is already running. */
|
||||
if (rt->isHeapCollecting())
|
||||
return true;
|
||||
if (rt->isHeapBusy())
|
||||
return;
|
||||
|
||||
JS::PrepareForFullGC(rt);
|
||||
TriggerOperationCallback(rt, reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
js::TriggerZoneGC(Zone *zone, JS::gcreason::Reason reason)
|
||||
{
|
||||
/*
|
||||
@ -1963,37 +1961,35 @@ js::TriggerZoneGC(Zone *zone, JS::gcreason::Reason reason)
|
||||
*/
|
||||
if (InParallelSection()) {
|
||||
ForkJoinSlice::Current()->requestZoneGC(zone, reason);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Zones in use by a thread with an exclusive context can't be collected. */
|
||||
if (zone->usedByExclusiveThread)
|
||||
return false;
|
||||
return;
|
||||
|
||||
JSRuntime *rt = zone->runtimeFromMainThread();
|
||||
|
||||
/* Don't trigger GCs when allocating under the operation callback lock. */
|
||||
if (rt->currentThreadOwnsOperationCallbackLock())
|
||||
return false;
|
||||
return;
|
||||
|
||||
/* GC is already running. */
|
||||
if (rt->isHeapCollecting())
|
||||
return true;
|
||||
if (rt->isHeapBusy())
|
||||
return;
|
||||
|
||||
if (rt->gcZeal() == ZealAllocValue) {
|
||||
TriggerGC(rt, reason);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (rt->isAtomsZone(zone)) {
|
||||
/* We can't do a zone GC of the atoms compartment. */
|
||||
TriggerGC(rt, reason);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
PrepareZoneForGC(zone);
|
||||
TriggerOperationCallback(rt, reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -687,11 +687,11 @@ extern void
|
||||
TraceRuntime(JSTracer *trc);
|
||||
|
||||
/* Must be called with GC lock taken. */
|
||||
extern bool
|
||||
extern void
|
||||
TriggerGC(JSRuntime *rt, JS::gcreason::Reason reason);
|
||||
|
||||
/* Must be called with GC lock taken. */
|
||||
extern bool
|
||||
extern void
|
||||
TriggerZoneGC(Zone *zone, JS::gcreason::Reason reason);
|
||||
|
||||
extern void
|
||||
|
@ -724,8 +724,10 @@ void
|
||||
JSRuntime::updateMallocCounter(JS::Zone *zone, size_t nbytes)
|
||||
{
|
||||
/* We tolerate any thread races when updating gcMallocBytes. */
|
||||
gcMallocBytes -= ptrdiff_t(nbytes);
|
||||
if (JS_UNLIKELY(gcMallocBytes <= 0))
|
||||
ptrdiff_t oldCount = gcMallocBytes;
|
||||
ptrdiff_t newCount = oldCount - ptrdiff_t(nbytes);
|
||||
gcMallocBytes = newCount;
|
||||
if (JS_UNLIKELY(newCount <= 0 && oldCount > 0))
|
||||
onTooMuchMalloc();
|
||||
else if (zone)
|
||||
zone->updateMallocCounter(nbytes);
|
||||
@ -734,16 +736,8 @@ JSRuntime::updateMallocCounter(JS::Zone *zone, size_t nbytes)
|
||||
JS_FRIEND_API(void)
|
||||
JSRuntime::onTooMuchMalloc()
|
||||
{
|
||||
if (!CurrentThreadCanAccessRuntime(this))
|
||||
return;
|
||||
|
||||
if (TriggerGC(this, JS::gcreason::TOO_MUCH_MALLOC)) {
|
||||
/*
|
||||
* Set gcMallocBytes to stop updateMallocCounter() calling this method
|
||||
* again before the counter is reset by GC.
|
||||
*/
|
||||
gcMallocBytes = PTRDIFF_MAX;
|
||||
}
|
||||
if (CurrentThreadCanAccessRuntime(this))
|
||||
TriggerGC(this, JS::gcreason::TOO_MUCH_MALLOC);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void *)
|
||||
|
Loading…
Reference in New Issue
Block a user