mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1405274 - Always update runtime malloc counter too when malloc memory is associated with a zone r=sfink
This commit is contained in:
parent
6e03c7e15b
commit
df11828d61
@ -846,7 +846,7 @@ class GCRuntime
|
||||
bool isTooMuchMalloc() const { return mallocCounter.isTooMuchMalloc(); }
|
||||
void resetMallocBytes() { mallocCounter.reset(); }
|
||||
void setMaxMallocBytes(size_t value);
|
||||
void updateMallocCounter(JS::Zone* zone, size_t nbytes);
|
||||
bool updateMallocCounter(size_t nbytes) { return mallocCounter.update(this, nbytes); }
|
||||
|
||||
void setGCCallback(JSGCCallback callback, void* data);
|
||||
void callGCCallback(JSGCStatus status) const;
|
||||
|
@ -444,7 +444,10 @@ struct Zone : public JS::shadow::Zone,
|
||||
|
||||
void resetGCMallocBytes() { gcMallocCounter.reset(); }
|
||||
void setGCMaxMallocBytes(size_t value) { gcMallocCounter.setMax(value); }
|
||||
void updateMallocCounter(size_t nbytes) { gcMallocCounter.update(this, nbytes); }
|
||||
void updateMallocCounter(size_t nbytes) {
|
||||
if (!runtime_->gc.updateMallocCounter(nbytes))
|
||||
gcMallocCounter.update(this, nbytes);
|
||||
}
|
||||
size_t GCMaxMallocBytes() const { return gcMallocCounter.maxBytes(); }
|
||||
size_t GCMallocBytes() const { return gcMallocCounter.bytes(); }
|
||||
|
||||
|
@ -1609,6 +1609,17 @@ JSContext::findVersion()
|
||||
return runtime()->defaultVersion();
|
||||
}
|
||||
|
||||
void
|
||||
JSContext::updateMallocCounter(size_t nbytes)
|
||||
{
|
||||
if (!zone()) {
|
||||
runtime()->updateMallocCounter(nbytes);
|
||||
return;
|
||||
}
|
||||
|
||||
zone()->updateMallocCounter(nbytes);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
JS::AutoCheckRequestDepth::AutoCheckRequestDepth(JSContext* cxArg)
|
||||
|
@ -142,9 +142,7 @@ struct JSContext : public JS::RootingContext,
|
||||
/* Clear the pending exception (if any) due to OOM. */
|
||||
void recoverFromOutOfMemory();
|
||||
|
||||
inline void updateMallocCounter(size_t nbytes) {
|
||||
runtime()->updateMallocCounter(zone(), nbytes);
|
||||
}
|
||||
void updateMallocCounter(size_t nbytes);
|
||||
|
||||
void reportAllocationOverflow() {
|
||||
js::ReportAllocationOverflow(this);
|
||||
|
@ -1823,14 +1823,6 @@ GCRuntime::setMaxMallocBytes(size_t value)
|
||||
zone->setGCMaxMallocBytes(value);
|
||||
}
|
||||
|
||||
void
|
||||
GCRuntime::updateMallocCounter(JS::Zone* zone, size_t nbytes)
|
||||
{
|
||||
bool triggered = mallocCounter.update(this, nbytes);
|
||||
if (!triggered && zone)
|
||||
zone->updateMallocCounter(nbytes);
|
||||
}
|
||||
|
||||
double
|
||||
ZoneHeapThreshold::allocTrigger(bool highFrequencyGC) const
|
||||
{
|
||||
|
@ -756,7 +756,7 @@ ArrayBufferObject::createForWasm(JSContext* cx, uint32_t initialSize,
|
||||
|
||||
auto contents = BufferContents::create<WASM>(wasmBuf->dataPointer());
|
||||
buffer->initialize(initialSize, contents, OwnsData);
|
||||
cx->zone()->updateMallocCounter(wasmBuf->mappedSize());
|
||||
cx->updateMallocCounter(wasmBuf->mappedSize());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -801,7 +801,7 @@ ArrayBufferObject::prepareForAsmJS(JSContext* cx, Handle<ArrayBufferObject*> buf
|
||||
buffer->changeContents(cx, BufferContents::create<WASM>(data), OwnsData);
|
||||
buffer->setIsPreparedForAsmJS();
|
||||
MOZ_ASSERT(data == buffer->dataPointer());
|
||||
cx->zone()->updateMallocCounter(wasmBuf->mappedSize());
|
||||
cx->updateMallocCounter(wasmBuf->mappedSize());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1061,7 +1061,7 @@ ArrayBufferObject::create(JSContext* cx, uint32_t nbytes, BufferContents content
|
||||
nAllocated = JS_ROUNDUP(nbytes, js::gc::SystemPageSize());
|
||||
else if (contents.kind() == WASM)
|
||||
nAllocated = contents.wasmBuffer()->allocatedBytes();
|
||||
cx->zone()->updateMallocCounter(nAllocated);
|
||||
cx->updateMallocCounter(nAllocated);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(ownsState == OwnsData);
|
||||
|
@ -799,13 +799,7 @@ JSRuntime::forkRandomKeyGenerator()
|
||||
void
|
||||
JSRuntime::updateMallocCounter(size_t nbytes)
|
||||
{
|
||||
updateMallocCounter(nullptr, nbytes);
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::updateMallocCounter(JS::Zone* zone, size_t nbytes)
|
||||
{
|
||||
gc.updateMallocCounter(zone, nbytes);
|
||||
gc.updateMallocCounter(nbytes);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void*)
|
||||
|
@ -960,7 +960,6 @@ struct JSRuntime : public js::MallocProvider<JSRuntime>
|
||||
* the caller must ensure that no deadlock possible during OOM reporting.
|
||||
*/
|
||||
void updateMallocCounter(size_t nbytes);
|
||||
void updateMallocCounter(JS::Zone* zone, size_t nbytes);
|
||||
|
||||
void reportAllocationOverflow() { js::ReportAllocationOverflow(nullptr); }
|
||||
|
||||
|
@ -92,7 +92,7 @@ FinishStringFlat(JSContext* cx, StringBuffer& sb, Buffer& cb)
|
||||
* The allocation was made on a TempAllocPolicy, so account for the string
|
||||
* data on the string's zone.
|
||||
*/
|
||||
str->zone()->updateMallocCounter(sizeof(CharT) * len);
|
||||
cx->updateMallocCounter(sizeof(CharT) * len);
|
||||
|
||||
buf.forget();
|
||||
return str;
|
||||
|
Loading…
Reference in New Issue
Block a user