JSString::resolveRope() should report extra memory cost to the heap.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Feb 2012 16:02:02 +0000 (16:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Feb 2012 16:02:02 +0000 (16:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79555

Patch by Yong Li <yoli@rim.com> on 2012-02-28
Reviewed by Michael Saboff.

At the time a JSString is constructed with fibers, it doesn't report
extra memory cost, which is reasonable because it hasn't allocate
new memory. However when the rope is resolved, it should report meory
cost for the new buffer.

* runtime/JSString.cpp:
(JSC::JSString::resolveRope):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSString.cpp

index 62e4c28..c4d17bb 100644 (file)
@@ -1,3 +1,18 @@
+2012-02-28  Yong Li  <yoli@rim.com>
+
+        JSString::resolveRope() should report extra memory cost to the heap.
+        https://bugs.webkit.org/show_bug.cgi?id=79555
+
+        Reviewed by Michael Saboff.
+
+        At the time a JSString is constructed with fibers, it doesn't report
+        extra memory cost, which is reasonable because it hasn't allocate
+        new memory. However when the rope is resolved, it should report meory
+        cost for the new buffer.
+
+        * runtime/JSString.cpp:
+        (JSC::JSString::resolveRope):
+
 2012-02-27  Oliver Hunt  <oliver@apple.com>
 
         sputnik/Unicode/Unicode_500/S7.2_A1.6_T1.html crashes in the interpreter
index cfa7d03..e84ce36 100644 (file)
@@ -65,9 +65,10 @@ void JSString::resolveRope(ExecState* exec) const
 
     if (is8Bit()) {
         LChar* buffer;
-        if (RefPtr<StringImpl> newImpl = StringImpl::tryCreateUninitialized(m_length, buffer))
+        if (RefPtr<StringImpl> newImpl = StringImpl::tryCreateUninitialized(m_length, buffer)) {
+            Heap::heap(this)->reportExtraMemoryCost(newImpl->cost());
             m_value = newImpl.release();
-        else {
+        else {
             outOfMemory(exec);
             return;
         }
@@ -92,9 +93,10 @@ void JSString::resolveRope(ExecState* exec) const
     }
 
     UChar* buffer;
-    if (RefPtr<StringImpl> newImpl = StringImpl::tryCreateUninitialized(m_length, buffer))
+    if (RefPtr<StringImpl> newImpl = StringImpl::tryCreateUninitialized(m_length, buffer)) {
+        Heap::heap(this)->reportExtraMemoryCost(newImpl->cost());
         m_value = newImpl.release();
-    else {
+    else {
         outOfMemory(exec);
         return;
     }