Follow-up for 32-bit test failures after...
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Nov 2015 22:16:47 +0000 (22:16 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Nov 2015 22:16:47 +0000 (22:16 +0000)
[JSC] JSPropertyNameEnumerator could be destructorless.
<https://webkit.org/b/151242>

Reviewed by Mark Lam

Apparently copied space allocations need to be in multiples of 8 bytes.
Have JSPropertyNameEnumerator do what other copied space clients already do
and round the allocation size up to a multiple of 8.

Added a little helper function to compute the allocation size so this doesn't
have to be repeated everywhere.

* runtime/JSPropertyNameEnumerator.cpp:
(JSC::JSPropertyNameEnumerator::finishCreation):
(JSC::JSPropertyNameEnumerator::visitChildren):
(JSC::JSPropertyNameEnumerator::copyBackingStore):
* runtime/JSPropertyNameEnumerator.h:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.cpp
Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h

index 3da2331..66bb789 100644 (file)
@@ -1,3 +1,24 @@
+2015-11-13  Andreas Kling  <akling@apple.com>
+
+        Follow-up for 32-bit test failures after...
+        [JSC] JSPropertyNameEnumerator could be destructorless.
+        <https://webkit.org/b/151242>
+
+        Reviewed by Mark Lam
+
+        Apparently copied space allocations need to be in multiples of 8 bytes.
+        Have JSPropertyNameEnumerator do what other copied space clients already do
+        and round the allocation size up to a multiple of 8.
+
+        Added a little helper function to compute the allocation size so this doesn't
+        have to be repeated everywhere.
+
+        * runtime/JSPropertyNameEnumerator.cpp:
+        (JSC::JSPropertyNameEnumerator::finishCreation):
+        (JSC::JSPropertyNameEnumerator::visitChildren):
+        (JSC::JSPropertyNameEnumerator::copyBackingStore):
+        * runtime/JSPropertyNameEnumerator.h:
+
 2015-11-13  Saam barati  <sbarati@apple.com>
 
         sub IC does not properly handle exception handling now that try/catch is compiled in the FTL
index a0d6c62..2415517 100644 (file)
@@ -74,7 +74,7 @@ void JSPropertyNameEnumerator::finishCreation(VM& vm, uint32_t indexedLength, ui
 
     if (!vector.isEmpty()) {
         void* backingStore;
-        RELEASE_ASSERT(vm.heap.tryAllocateStorage(this, vector.size() * sizeof(WriteBarrier<JSString>), &backingStore));
+        RELEASE_ASSERT(vm.heap.tryAllocateStorage(this, propertyNameCacheSize(), &backingStore));
         WriteBarrier<JSString>* propertyNames = reinterpret_cast<WriteBarrier<JSString>*>(backingStore);
         m_propertyNames.set(vm, this, propertyNames);
 
@@ -93,7 +93,7 @@ void JSPropertyNameEnumerator::visitChildren(JSCell* cell, SlotVisitor& visitor)
         visitor.appendValues(reinterpret_cast<WriteBarrier<Unknown>*>(thisObject->m_propertyNames.getWithoutBarrier()), thisObject->cachedPropertyNameCount());
         visitor.copyLater(
             thisObject, JSPropertyNameEnumeratorCopyToken,
-            thisObject->m_propertyNames.getWithoutBarrier(), thisObject->cachedPropertyNameCount() * sizeof(JSString*));
+            thisObject->m_propertyNames.getWithoutBarrier(), thisObject->propertyNameCacheSize());
     }
 }
 
@@ -106,10 +106,10 @@ void JSPropertyNameEnumerator::copyBackingStore(JSCell* cell, CopyVisitor& visit
 
     void* oldPropertyNames = thisObject->m_propertyNames.getWithoutBarrier();
     if (visitor.checkIfShouldCopy(oldPropertyNames)) {
-        WriteBarrier<JSString>* newPropertyNames = static_cast<WriteBarrier<JSString>*>(visitor.allocateNewSpace(thisObject->cachedPropertyNameCount() * sizeof(WriteBarrier<JSString>)));
-        memcpy(newPropertyNames, oldPropertyNames, thisObject->cachedPropertyNameCount() * sizeof(JSString*));
+        WriteBarrier<JSString>* newPropertyNames = static_cast<WriteBarrier<JSString>*>(visitor.allocateNewSpace(thisObject->propertyNameCacheSize()));
+        memcpy(newPropertyNames, oldPropertyNames, thisObject->propertyNameCacheSize());
         thisObject->m_propertyNames.setWithoutBarrier(newPropertyNames);
-        visitor.didCopy(oldPropertyNames, thisObject->cachedPropertyNameCount() * sizeof(JSString*));
+        visitor.didCopy(oldPropertyNames, thisObject->propertyNameCacheSize());
     }
 }
 
index 7f48655..2e2b194 100644 (file)
@@ -90,6 +90,11 @@ public:
         return m_endGenericPropertyIndex;
     }
 
+    size_t propertyNameCacheSize() const
+    {
+        return WTF::roundUpToMultipleOf<8>(cachedPropertyNameCount() * sizeof(WriteBarrier<JSString>));
+    }
+
 private:
     JSPropertyNameEnumerator(VM&, StructureID, uint32_t);
     void finishCreation(VM&, uint32_t, uint32_t, PassRefPtr<PropertyNameArrayData>);