[bmalloc] IsoTLS is not deallocated in TLS destructor
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2019 00:09:36 +0000 (00:09 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jul 2019 00:09:36 +0000 (00:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200019

Reviewed by Mark Lam.

TLS destructor for IsoTLS needs to deallocate memory used for IsoTLS itself.
While we are correctly deallocating old IsoTLS when extending it to the new one,
we lack deallocation when the thread is destroyed. IsoTLS is per-thread, so we
should destroy IsoTLS when a thread finishes.

* bmalloc/IsoTLS.cpp:
(bmalloc::IsoTLS::ensureEntries):
(bmalloc::IsoTLS::destructor):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/IsoTLS.cpp

index 541539f..d85d748 100644 (file)
@@ -1,3 +1,19 @@
+2019-07-22  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [bmalloc] IsoTLS is not deallocated in TLS destructor
+        https://bugs.webkit.org/show_bug.cgi?id=200019
+
+        Reviewed by Mark Lam.
+
+        TLS destructor for IsoTLS needs to deallocate memory used for IsoTLS itself.
+        While we are correctly deallocating old IsoTLS when extending it to the new one,
+        we lack deallocation when the thread is destroyed. IsoTLS is per-thread, so we
+        should destroy IsoTLS when a thread finishes.
+
+        * bmalloc/IsoTLS.cpp:
+        (bmalloc::IsoTLS::ensureEntries):
+        (bmalloc::IsoTLS::destructor):
+
 2019-07-12  Keith Miller  <keith_miller@apple.com>
 
         Increase JSValue cage size on iOS and reduce the max slide
index b5d3221..5f4306d 100644 (file)
@@ -114,6 +114,7 @@ IsoTLS* IsoTLS::ensureEntries(unsigned offset)
                     entry->move(src, dst);
                     entry->destruct(src);
                 });
+            tls->~IsoTLS();
             vmDeallocate(tls, tls->size());
         }
         tls = newTLS;
@@ -141,6 +142,8 @@ void IsoTLS::destructor(void* arg)
             entry->scavenge(data);
             entry->destruct(data);
         });
+    tls->~IsoTLS();
+    vmDeallocate(tls, tls->size());
 }
 
 size_t IsoTLS::sizeForCapacity(unsigned capacity)