Bug 903519 - Register more nursery string buffers to be freed, r=leak
☠☠ backed out by b580ce0f1d06 ☠ ☠
authorSteve Fink <sfink@mozilla.com>
Thu, 11 Jan 2018 11:27:56 -0800
changeset 450697 2dab1647f93321a1bb6f418495f55260f2eacc28
parent 450665 6e926521ce37cadc4fcbd3451542a7975446311e
child 450698 16740cf93a77c1f8ba6d39cf5748e0180e7e95dc
push id8531
push userryanvm@gmail.com
push dateFri, 12 Jan 2018 16:47:01 +0000
treeherdermozilla-beta@0bc627ade5a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersleak
bugs903519
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 903519 - Register more nursery string buffers to be freed, r=leak
js/src/vm/String.cpp
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -698,16 +698,24 @@ template <typename CharT>
 JSFlatString*
 JSDependentString::undependInternal(JSContext* cx)
 {
     size_t n = length();
     CharT* s = cx->pod_malloc<CharT>(n + 1);
     if (!s)
         return nullptr;
 
+    if (!isTenured()) {
+        if (!cx->runtime()->gc.nursery().registerMallocedBuffer(s)) {
+            js_free(s);
+            ReportOutOfMemory(cx);
+            return nullptr;
+        }
+    }
+
     AutoCheckCannotGC nogc;
     PodCopy(s, nonInlineChars<CharT>(nogc), n);
     s[n] = '\0';
     setNonInlineChars<CharT>(s);
 
     /*
      * Transform *this into an undepended string so 'base' will remain rooted
      * for the benefit of any other dependent string that depends on *this.
@@ -1100,16 +1108,24 @@ JSExternalString::ensureFlat(JSContext* 
 {
     MOZ_ASSERT(hasTwoByteChars());
 
     size_t n = length();
     char16_t* s = cx->pod_malloc<char16_t>(n + 1);
     if (!s)
         return nullptr;
 
+    if (!isTenured()) {
+        if (!cx->runtime()->gc.nursery().registerMallocedBuffer(s)) {
+            js_free(s);
+            ReportOutOfMemory(cx);
+            return nullptr;
+        }
+    }
+
     // Copy the chars before finalizing the string.
     {
         AutoCheckCannotGC nogc;
         PodCopy(s, nonInlineChars<char16_t>(nogc), n);
         s[n] = '\0';
     }
 
     // Release the external chars.