Commit 4108deff authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

Use copying collector for out-of-line JSObject property storage

https://bugs.webkit.org/show_bug.cgi?id=76665

Reviewed by Geoffrey Garen.

* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren): Changed to use copyAndAppend whenever the property storage is out-of-line.
(JSC::JSObject::allocatePropertyStorage): Changed to use tryAllocateStorage/tryReallocateStorage as opposed to 
operator new.
* runtime/JSObject.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2f3c7a92
2012-01-23 Mark Hahnenberg <mhahnenberg@apple.com>
Use copying collector for out-of-line JSObject property storage
https://bugs.webkit.org/show_bug.cgi?id=76665
Reviewed by Geoffrey Garen.
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren): Changed to use copyAndAppend whenever the property storage is out-of-line.
(JSC::JSObject::allocatePropertyStorage): Changed to use tryAllocateStorage/tryReallocateStorage as opposed to
operator new.
* runtime/JSObject.h:
2012-01-23 Brian Weinstein <bweinstein@apple.com> 2012-01-23 Brian Weinstein <bweinstein@apple.com>
More build fixing after r105646. More build fixing after r105646.
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "config.h" #include "config.h"
#include "JSObject.h" #include "JSObject.h"
#include "BumpSpaceInlineMethods.h"
#include "DatePrototype.h" #include "DatePrototype.h"
#include "ErrorConstructor.h" #include "ErrorConstructor.h"
#include "GetterSetter.h" #include "GetterSetter.h"
...@@ -83,11 +84,6 @@ static inline void getClassPropertyNames(ExecState* exec, const ClassInfo* class ...@@ -83,11 +84,6 @@ static inline void getClassPropertyNames(ExecState* exec, const ClassInfo* class
} }
} }
void JSObject::finalize(JSCell* cell)
{
delete [] jsCast<JSObject*>(cell)->m_propertyStorage.get();
}
void JSObject::destroy(JSCell* cell) void JSObject::destroy(JSCell* cell)
{ {
jsCast<JSObject*>(cell)->JSObject::~JSObject(); jsCast<JSObject*>(cell)->JSObject::~JSObject();
...@@ -106,7 +102,13 @@ void JSObject::visitChildren(JSCell* cell, SlotVisitor& visitor) ...@@ -106,7 +102,13 @@ void JSObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
PropertyStorage storage = thisObject->propertyStorage(); PropertyStorage storage = thisObject->propertyStorage();
size_t storageSize = thisObject->structure()->propertyStorageSize(); size_t storageSize = thisObject->structure()->propertyStorageSize();
visitor.appendValues(storage, storageSize); if (thisObject->isUsingInlineStorage())
visitor.appendValues(storage, storageSize);
else {
visitor.copyAndAppend(reinterpret_cast<void**>(&storage), thisObject->structure()->propertyStorageCapacity() * sizeof(WriteBarrierBase<Unknown>), storage->slot(), storageSize);
thisObject->m_propertyStorage.set(storage, StorageBarrier::Unchecked);
}
if (thisObject->m_inheritorID) if (thisObject->m_inheritorID)
visitor.append(&thisObject->m_inheritorID); visitor.append(&thisObject->m_inheritorID);
...@@ -633,20 +635,23 @@ void JSObject::allocatePropertyStorage(JSGlobalData& globalData, size_t oldSize, ...@@ -633,20 +635,23 @@ void JSObject::allocatePropertyStorage(JSGlobalData& globalData, size_t oldSize,
// It's important that this function not rely on structure(), since // It's important that this function not rely on structure(), since
// we might be in the middle of a transition. // we might be in the middle of a transition.
PropertyStorage newPropertyStorage = 0;
newPropertyStorage = new WriteBarrierBase<Unknown>[newSize];
PropertyStorage oldPropertyStorage = m_propertyStorage.get(); PropertyStorage oldPropertyStorage = m_propertyStorage.get();
ASSERT(newPropertyStorage); PropertyStorage newPropertyStorage = 0;
for (unsigned i = 0; i < oldSize; ++i) if (isUsingInlineStorage()) {
newPropertyStorage[i] = oldPropertyStorage[i]; if (!globalData.heap.tryAllocateStorage(sizeof(WriteBarrierBase<Unknown>) * newSize, reinterpret_cast<void**>(&newPropertyStorage)))
CRASH();
if (isUsingInlineStorage()) for (unsigned i = 0; i < oldSize; ++i)
Heap::heap(this)->addFinalizer(this, &finalize); newPropertyStorage[i] = oldPropertyStorage[i];
else } else {
delete [] oldPropertyStorage; if (!globalData.heap.tryReallocateStorage(reinterpret_cast<void**>(&oldPropertyStorage), sizeof(WriteBarrierBase<Unknown>) * oldSize, sizeof(WriteBarrierBase<Unknown>) * newSize))
CRASH();
newPropertyStorage = oldPropertyStorage;
}
ASSERT(newPropertyStorage);
m_propertyStorage.set(globalData, this, newPropertyStorage); m_propertyStorage.set(globalData, this, newPropertyStorage);
} }
......
...@@ -90,8 +90,6 @@ namespace JSC { ...@@ -90,8 +90,6 @@ namespace JSC {
JS_EXPORT_PRIVATE static UString className(const JSObject*); JS_EXPORT_PRIVATE static UString className(const JSObject*);
static void finalize(JSCell*);
JSValue prototype() const; JSValue prototype() const;
void setPrototype(JSGlobalData&, JSValue prototype); void setPrototype(JSGlobalData&, JSValue prototype);
bool setPrototypeWithCycleCheck(JSGlobalData&, JSValue prototype); bool setPrototypeWithCycleCheck(JSGlobalData&, JSValue prototype);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment