Bug 1549853 - Ignore associations of zero bytes of malloc memory with a GC thing r=sfink?

Differential Revision: https://phabricator.services.mozilla.com/D30355

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jon Coppeard 2019-05-08 17:46:02 +00:00
parent 94e50ef5a8
commit 75bfdb344c
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<canvas id='a' height='67108864' width='80'></canvas>
<script>
document.addEventListener("DOMContentLoaded", function() {
var c=document.getElementById('a')
var x=c.getContext('2d', {alpha: true})
c.setAttribute('width', 800)
})
</script>

View File

@ -1156,6 +1156,10 @@ JS_PUBLIC_API void JS_freeop(JSFreeOp* fop, void* p) {
JS_PUBLIC_API void JS::AddAssociatedMemory(JSObject* obj, size_t nbytes,
JS::MemoryUse use) {
MOZ_ASSERT(obj);
if (!nbytes) {
return;
}
Zone* zone = obj->zone();
zone->updateMallocCounter(nbytes);
zone->addCellMemory(obj, nbytes, use);
@ -1165,6 +1169,10 @@ JS_PUBLIC_API void JS::AddAssociatedMemory(JSObject* obj, size_t nbytes,
JS_PUBLIC_API void JS::RemoveAssociatedMemory(JSObject* obj, size_t nbytes,
JS::MemoryUse use) {
MOZ_ASSERT(obj);
if (!nbytes) {
return;
}
obj->zoneFromAnyThread()->removeCellMemory(obj, nbytes, use);
}