Title: [95503] trunk/Source/_javascript_Core
Revision
95503
Author
[email protected]
Date
2011-09-19 18:21:51 -0700 (Mon, 19 Sep 2011)

Log Message

Removed lots of friend declarations from JSCell, so we can more
effectively make use of private and protected.

Reviewed by Sam Weinig.

* runtime/JSCell.h: Removed MSVCBugWorkaround because it was a lot of
confusion for not much safety.
(JSC::JSCell::operator new): Made this public because it is used by a
few clients, and not really dangerous.

* runtime/JSObject.cpp:
(JSC::JSObject::put):
(JSC::JSObject::deleteProperty):
(JSC::JSObject::defineGetter):
(JSC::JSObject::defineSetter):
(JSC::JSObject::getPropertySpecificValue):
(JSC::JSObject::getOwnPropertyNames):
(JSC::JSObject::seal):
(JSC::JSObject::freeze):
(JSC::JSObject::preventExtensions):
(JSC::JSObject::removeDirect):
(JSC::JSObject::createInheritorID):
(JSC::JSObject::allocatePropertyStorage):
(JSC::JSObject::getOwnPropertyDescriptor):
* runtime/JSObject.h:
(JSC::JSObject::getDirect):
(JSC::JSObject::getDirectLocation):
(JSC::JSObject::hasCustomProperties):
(JSC::JSObject::hasGetterSetterProperties):
(JSC::JSObject::isSealed):
(JSC::JSObject::isFrozen):
(JSC::JSObject::isExtensible):
(JSC::JSObject::flattenDictionaryObject):
(JSC::JSObject::finishCreation):
(JSC::JSObject::prototype):
(JSC::JSObject::setPrototype):
(JSC::JSObject::inlineGetOwnPropertySlot):
(JSC::JSCell::fastGetOwnProperty):
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::putDirectWithoutTransition):
(JSC::JSObject::transitionTo):
(JSC::JSObject::visitChildrenDirect): Changed all use of m_structure to
structure() / setStructure(), so we don't have to be a friend of JSCell.

* runtime/Structure.h:
(JSC::JSCell::setStructure): Added, to avoid direct access by JSObject
to JSCell::m_structure.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (95502 => 95503)


--- trunk/Source/_javascript_Core/ChangeLog	2011-09-20 01:20:12 UTC (rev 95502)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-09-20 01:21:51 UTC (rev 95503)
@@ -1,3 +1,53 @@
+2011-09-19  Geoffrey Garen  <[email protected]>
+
+        Removed lots of friend declarations from JSCell, so we can more
+        effectively make use of private and protected.
+
+        Reviewed by Sam Weinig.
+
+        * runtime/JSCell.h: Removed MSVCBugWorkaround because it was a lot of
+        confusion for not much safety.
+        (JSC::JSCell::operator new): Made this public because it is used by a
+        few clients, and not really dangerous.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::put):
+        (JSC::JSObject::deleteProperty):
+        (JSC::JSObject::defineGetter):
+        (JSC::JSObject::defineSetter):
+        (JSC::JSObject::getPropertySpecificValue):
+        (JSC::JSObject::getOwnPropertyNames):
+        (JSC::JSObject::seal):
+        (JSC::JSObject::freeze):
+        (JSC::JSObject::preventExtensions):
+        (JSC::JSObject::removeDirect):
+        (JSC::JSObject::createInheritorID):
+        (JSC::JSObject::allocatePropertyStorage):
+        (JSC::JSObject::getOwnPropertyDescriptor):
+        * runtime/JSObject.h:
+        (JSC::JSObject::getDirect):
+        (JSC::JSObject::getDirectLocation):
+        (JSC::JSObject::hasCustomProperties):
+        (JSC::JSObject::hasGetterSetterProperties):
+        (JSC::JSObject::isSealed):
+        (JSC::JSObject::isFrozen):
+        (JSC::JSObject::isExtensible):
+        (JSC::JSObject::flattenDictionaryObject):
+        (JSC::JSObject::finishCreation):
+        (JSC::JSObject::prototype):
+        (JSC::JSObject::setPrototype):
+        (JSC::JSObject::inlineGetOwnPropertySlot):
+        (JSC::JSCell::fastGetOwnProperty):
+        (JSC::JSObject::putDirectInternal):
+        (JSC::JSObject::putDirectWithoutTransition):
+        (JSC::JSObject::transitionTo):
+        (JSC::JSObject::visitChildrenDirect): Changed all use of m_structure to
+        structure() / setStructure(), so we don't have to be a friend of JSCell.
+
+        * runtime/Structure.h:
+        (JSC::JSCell::setStructure): Added, to avoid direct access by JSObject
+        to JSCell::m_structure.
+
 2011-09-19  Adam Barth  <[email protected]>
 
         Always enable ENABLE(EVENTSOURCE)

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (95502 => 95503)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-09-20 01:20:12 UTC (rev 95502)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-09-20 01:21:51 UTC (rev 95503)
@@ -38,49 +38,23 @@
     class JSGlobalObject;
     class Structure;
 
-#if COMPILER(MSVC)
-    // If WTF_MAKE_NONCOPYABLE is applied to JSCell we end up with a bunch of
-    // undefined references to the JSCell copy constructor and assignment operator
-    // when linking _javascript_Core.
-    class MSVCBugWorkaround {
-        WTF_MAKE_NONCOPYABLE(MSVCBugWorkaround);
-
-    protected:
-        MSVCBugWorkaround() { }
-        ~MSVCBugWorkaround() { }
-    };
-
-    class JSCell : MSVCBugWorkaround {
-#else
     class JSCell {
-        WTF_MAKE_NONCOPYABLE(JSCell);
-#endif
-
-        friend class ExecutableBase;
-        friend class GetterSetter;
-        friend class Heap;
-        friend class JSObject;
-        friend class JSPropertyNameIterator;
-        friend class JSString;
         friend class JSValue;
-        friend class JSAPIValueWrapper;
-        friend class JSGlobalData;
         friend class MarkedBlock;
-        friend class ScopeChainNode;
-        friend class Structure;
-        friend class StructureChain;
-        friend class RegExp;
 
+    public:
         enum CreatingEarlyCellTag { CreatingEarlyCell };
+        JSCell(CreatingEarlyCellTag);
 
-    protected:
         enum VPtrStealingHackType { VPtrStealingHack };
-
-    private:
         explicit JSCell(VPtrStealingHackType) { }
+
+    public:
+        void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; } // Used for initialization after GC allocation.
+
+    protected:
         JSCell(JSGlobalData&, Structure*);
-        JSCell(CreatingEarlyCellTag);
-        virtual ~JSCell();
+        virtual ~JSCell(); // Invoked by GC finalization.
 
     public:
         // Querying the type.
@@ -91,6 +65,7 @@
         bool isAPIValueWrapper() const;
 
         Structure* structure() const;
+        void setStructure(JSGlobalData&, Structure*);
 
         // Extracting the value.
         bool getString(ExecState* exec, UString&) const;
@@ -109,9 +84,6 @@
         virtual UString toString(ExecState*) const;
         virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
 
-        // Garbage collection.
-        void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; }
-
         virtual void visitChildren(SlotVisitor&);
 
         // Object operations, with the toObject operation included.
@@ -157,11 +129,6 @@
         virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
         virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
         
-        // Note that the first two declarations of operator new have no corresponding implementation and 
-        // will cause link errors if you use them.
-        void* operator new(size_t, ExecState*);
-        void* operator new(size_t, JSGlobalData*);
-        
         WriteBarrier<Structure> m_structure;
     };
 
@@ -372,7 +339,7 @@
 #endif
         return heap.allocate(sizeof(T));
     }
-        
+
 } // namespace JSC
 
 #endif // JSCell_h

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (95502 => 95503)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-09-20 01:20:12 UTC (rev 95502)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-09-20 01:21:51 UTC (rev 95503)
@@ -136,7 +136,7 @@
     
     unsigned attributes;
     JSCell* specificValue;
-    if ((m_structure->get(globalData, propertyName, attributes, specificValue) != WTF::notFound) && attributes & ReadOnly) {
+    if ((structure()->get(globalData, propertyName, attributes, specificValue) != WTF::notFound) && attributes & ReadOnly) {
         if (slot.isStrictMode())
             throwError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
         return;
@@ -233,7 +233,7 @@
 {
     unsigned attributes;
     JSCell* specificValue;
-    if (m_structure->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound) {
+    if (structure()->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound) {
         if ((attributes & DontDelete))
             return false;
         removeDirect(exec->globalData(), propertyName);
@@ -334,7 +334,7 @@
 
     JSValue object = getDirect(exec->globalData(), propertyName);
     if (object && object.isGetterSetter()) {
-        ASSERT(m_structure->hasGetterSetterProperties());
+        ASSERT(structure()->hasGetterSetterProperties());
         asGetterSetter(object)->setGetter(exec->globalData(), getterFunction);
         return;
     }
@@ -348,11 +348,11 @@
     // getters and setters, though, we also need to change our Structure
     // if we override an existing non-getter or non-setter.
     if (slot.type() != PutPropertySlot::NewProperty) {
-        if (!m_structure->isDictionary())
-            setStructure(exec->globalData(), Structure::getterSetterTransition(globalData, m_structure.get()));
+        if (!structure()->isDictionary())
+            setStructure(exec->globalData(), Structure::getterSetterTransition(globalData, structure()));
     }
 
-    m_structure->setHasGetterSetterProperties(true);
+    structure()->setHasGetterSetterProperties(true);
     getterSetter->setGetter(globalData, getterFunction);
 }
 
@@ -365,7 +365,7 @@
 
     JSValue object = getDirect(exec->globalData(), propertyName);
     if (object && object.isGetterSetter()) {
-        ASSERT(m_structure->hasGetterSetterProperties());
+        ASSERT(structure()->hasGetterSetterProperties());
         asGetterSetter(object)->setSetter(exec->globalData(), setterFunction);
         return;
     }
@@ -378,11 +378,11 @@
     // getters and setters, though, we also need to change our Structure
     // if we override an existing non-getter or non-setter.
     if (slot.type() != PutPropertySlot::NewProperty) {
-        if (!m_structure->isDictionary())
-            setStructure(exec->globalData(), Structure::getterSetterTransition(exec->globalData(), m_structure.get()));
+        if (!structure()->isDictionary())
+            setStructure(exec->globalData(), Structure::getterSetterTransition(exec->globalData(), structure()));
     }
 
-    m_structure->setHasGetterSetterProperties(true);
+    structure()->setHasGetterSetterProperties(true);
     getterSetter->setSetter(exec->globalData(), setterFunction);
 }
 
@@ -453,7 +453,7 @@
 bool JSObject::getPropertySpecificValue(ExecState* exec, const Identifier& propertyName, JSCell*& specificValue) const
 {
     unsigned attributes;
-    if (m_structure->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound)
+    if (structure()->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound)
         return true;
 
     // This could be a function within the static table? - should probably
@@ -486,7 +486,7 @@
 
 void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
 {
-    m_structure->getPropertyNames(exec->globalData(), propertyNames, mode);
+    structure()->getPropertyNames(exec->globalData(), propertyNames, mode);
     getClassPropertyNames(exec, classInfo(), propertyNames, mode);
 }
 
@@ -536,7 +536,7 @@
     if (isSealed(globalData))
         return;
     preventExtensions(globalData);
-    setStructure(globalData, Structure::sealTransition(globalData, m_structure.get()));
+    setStructure(globalData, Structure::sealTransition(globalData, structure()));
 }
 
 void JSObject::freeze(JSGlobalData& globalData)
@@ -544,29 +544,29 @@
     if (isFrozen(globalData))
         return;
     preventExtensions(globalData);
-    setStructure(globalData, Structure::freezeTransition(globalData, m_structure.get()));
+    setStructure(globalData, Structure::freezeTransition(globalData, structure()));
 }
 
 void JSObject::preventExtensions(JSGlobalData& globalData)
 {
     if (isExtensible())
-        setStructure(globalData, Structure::preventExtensionsTransition(globalData, m_structure.get()));
+        setStructure(globalData, Structure::preventExtensionsTransition(globalData, structure()));
 }
 
 void JSObject::removeDirect(JSGlobalData& globalData, const Identifier& propertyName)
 {
-    if (m_structure->get(globalData, propertyName) == WTF::notFound)
+    if (structure()->get(globalData, propertyName) == WTF::notFound)
         return;
 
     size_t offset;
-    if (m_structure->isUncacheableDictionary()) {
-        offset = m_structure->removePropertyWithoutTransition(globalData, propertyName);
+    if (structure()->isUncacheableDictionary()) {
+        offset = structure()->removePropertyWithoutTransition(globalData, propertyName);
         if (offset != WTF::notFound)
             putUndefinedAtDirectOffset(offset);
         return;
     }
 
-    setStructure(globalData, Structure::removePropertyTransition(globalData, m_structure.get(), propertyName, offset));
+    setStructure(globalData, Structure::removePropertyTransition(globalData, structure(), propertyName, offset));
     if (offset != WTF::notFound)
         putUndefinedAtDirectOffset(offset);
 }
@@ -584,7 +584,7 @@
 
 Structure* JSObject::createInheritorID(JSGlobalData& globalData)
 {
-    m_inheritorID.set(globalData, this, createEmptyObjectStructure(globalData, m_structure->globalObject(), this));
+    m_inheritorID.set(globalData, this, createEmptyObjectStructure(globalData, structure()->globalObject(), this));
     ASSERT(m_inheritorID->isEmpty());
     return m_inheritorID.get();
 }
@@ -593,7 +593,7 @@
 {
     ASSERT(newSize > oldSize);
 
-    // It's important that this function not rely on m_structure, since
+    // It's important that this function not rely on structure(), since
     // we might be in the middle of a transition.
     PropertyStorage newPropertyStorage = 0;
     newPropertyStorage = new WriteBarrierBase<Unknown>[newSize];
@@ -614,7 +614,7 @@
 {
     unsigned attributes = 0;
     JSCell* cell = 0;
-    size_t offset = m_structure->get(exec->globalData(), propertyName, attributes, cell);
+    size_t offset = structure()->get(exec->globalData(), propertyName, attributes, cell);
     if (offset == WTF::notFound)
         return false;
     descriptor.setDescriptor(getDirectOffset(offset), attributes);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (95502 => 95503)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2011-09-20 01:20:12 UTC (rev 95502)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2011-09-20 01:21:51 UTC (rev 95503)
@@ -90,7 +90,6 @@
         void setPrototype(JSGlobalData&, JSValue prototype);
         bool setPrototypeWithCycleCheck(JSGlobalData&, JSValue prototype);
         
-        void setStructure(JSGlobalData&, Structure*);
         Structure* inheritorID(JSGlobalData&);
 
         virtual UString className() const;
@@ -148,20 +147,20 @@
         // This get function only looks at the property map.
         JSValue getDirect(JSGlobalData& globalData, const Identifier& propertyName) const
         {
-            size_t offset = m_structure->get(globalData, propertyName);
+            size_t offset = structure()->get(globalData, propertyName);
             return offset != WTF::notFound ? getDirectOffset(offset) : JSValue();
         }
 
         WriteBarrierBase<Unknown>* getDirectLocation(JSGlobalData& globalData, const Identifier& propertyName)
         {
-            size_t offset = m_structure->get(globalData, propertyName);
+            size_t offset = structure()->get(globalData, propertyName);
             return offset != WTF::notFound ? locationForOffset(offset) : 0;
         }
 
         WriteBarrierBase<Unknown>* getDirectLocation(JSGlobalData& globalData, const Identifier& propertyName, unsigned& attributes)
         {
             JSCell* specificFunction;
-            size_t offset = m_structure->get(globalData, propertyName, attributes, specificFunction);
+            size_t offset = structure()->get(globalData, propertyName, attributes, specificFunction);
             return offset != WTF::notFound ? locationForOffset(offset) : 0;
         }
 
@@ -173,8 +172,8 @@
         void transitionTo(JSGlobalData&, Structure*);
 
         void removeDirect(JSGlobalData&, const Identifier& propertyName);
-        bool hasCustomProperties() { return m_structure->didTransition(); }
-        bool hasGetterSetterProperties() { return m_structure->hasGetterSetterProperties(); }
+        bool hasCustomProperties() { return structure()->didTransition(); }
+        bool hasGetterSetterProperties() { return structure()->hasGetterSetterProperties(); }
 
         bool putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr, bool checkReadOnly, PutPropertySlot&);
         void putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr = 0);
@@ -203,9 +202,9 @@
         void seal(JSGlobalData&);
         void freeze(JSGlobalData&);
         void preventExtensions(JSGlobalData&);
-        bool isSealed(JSGlobalData& globalData) { return m_structure->isSealed(globalData); }
-        bool isFrozen(JSGlobalData& globalData) { return m_structure->isFrozen(globalData); }
-        bool isExtensible() { return m_structure->isExtensible(); }
+        bool isSealed(JSGlobalData& globalData) { return structure()->isSealed(globalData); }
+        bool isFrozen(JSGlobalData& globalData) { return structure()->isFrozen(globalData); }
+        bool isExtensible() { return structure()->isExtensible(); }
 
         void allocatePropertyStorage(JSGlobalData&, size_t oldSize, size_t newSize);
         bool isUsingInlineStorage() const { return static_cast<const void*>(m_propertyStorage.get()) == static_cast<const void*>(this + 1); }
@@ -219,7 +218,7 @@
 
         void flattenDictionaryObject(JSGlobalData& globalData)
         {
-            m_structure->flattenDictionaryStructure(globalData, this);
+            structure()->flattenDictionaryStructure(globalData, this);
         }
 
         JSGlobalObject* globalObject() const
@@ -240,11 +239,11 @@
         {
             Base::finishCreation(globalData);
             ASSERT(inherits(&s_info));
-            ASSERT(m_structure->propertyStorageCapacity() < baseExternalStorageCapacity);
-            ASSERT(m_structure->isEmpty());
+            ASSERT(structure()->propertyStorageCapacity() < baseExternalStorageCapacity);
+            ASSERT(structure()->isEmpty());
             ASSERT(prototype().isNull() || Heap::heap(this) == Heap::heap(prototype()));
             ASSERT_UNUSED(inlineStorage, static_cast<void*>(inlineStorage) == static_cast<void*>(this + 1));
-            ASSERT(m_structure->isObject());
+            ASSERT(structure()->isObject());
         }
 
         static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
@@ -444,7 +443,7 @@
 
 inline JSValue JSObject::prototype() const
 {
-    return m_structure->storedPrototype();
+    return structure()->storedPrototype();
 }
 
 inline bool JSObject::setPrototypeWithCycleCheck(JSGlobalData& globalData, JSValue prototype)
@@ -463,15 +462,9 @@
 inline void JSObject::setPrototype(JSGlobalData& globalData, JSValue prototype)
 {
     ASSERT(prototype);
-    setStructure(globalData, Structure::changePrototypeTransition(globalData, m_structure.get(), prototype));
+    setStructure(globalData, Structure::changePrototypeTransition(globalData, structure(), prototype));
 }
 
-inline void JSObject::setStructure(JSGlobalData& globalData, Structure* structure)
-{
-    ASSERT(structure->typeInfo().overridesVisitChildren() == m_structure->typeInfo().overridesVisitChildren());
-    m_structure.set(globalData, this, structure);
-}
-
 inline Structure* JSObject::inheritorID(JSGlobalData& globalData)
 {
     if (m_inheritorID) {
@@ -500,7 +493,7 @@
 ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
     if (WriteBarrierBase<Unknown>* location = getDirectLocation(exec->globalData(), propertyName)) {
-        if (m_structure->hasGetterSetterProperties() && location->isGetterSetter())
+        if (structure()->hasGetterSetterProperties() && location->isGetterSetter())
             fillGetterPropertySlot(slot, location);
         else
             slot.setValue(this, location->get(), offsetForLocation(location));
@@ -537,10 +530,10 @@
 // case by checking whether the hash has yet been set for this string.
 ALWAYS_INLINE JSValue JSCell::fastGetOwnProperty(ExecState* exec, const UString& name)
 {
-    if (!m_structure->typeInfo().overridesGetOwnPropertySlot() && !m_structure->hasGetterSetterProperties()) {
+    if (!structure()->typeInfo().overridesGetOwnPropertySlot() && !structure()->hasGetterSetterProperties()) {
         size_t offset = name.impl()->hasHash()
-            ? m_structure->get(exec->globalData(), Identifier(exec, name))
-            : m_structure->get(exec->globalData(), name);
+            ? structure()->get(exec->globalData(), Identifier(exec, name))
+            : structure()->get(exec->globalData(), name);
         if (offset != WTF::notFound)
             return asObject(this)->locationForOffset(offset)->get();
     }
@@ -598,15 +591,15 @@
     ASSERT(value);
     ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
 
-    if (m_structure->isDictionary()) {
+    if (structure()->isDictionary()) {
         unsigned currentAttributes;
         JSCell* currentSpecificFunction;
-        size_t offset = m_structure->get(globalData, propertyName, currentAttributes, currentSpecificFunction);
+        size_t offset = structure()->get(globalData, propertyName, currentAttributes, currentSpecificFunction);
         if (offset != WTF::notFound) {
             // If there is currently a specific function, and there now either isn't,
             // or the new value is different, then despecify.
             if (currentSpecificFunction && (specificFunction != currentSpecificFunction))
-                m_structure->despecifyDictionaryFunction(globalData, propertyName);
+                structure()->despecifyDictionaryFunction(globalData, propertyName);
             if (checkReadOnly && currentAttributes & ReadOnly)
                 return false;
 
@@ -625,12 +618,12 @@
         if (checkReadOnly && !isExtensible())
             return false;
 
-        size_t currentCapacity = m_structure->propertyStorageCapacity();
-        offset = m_structure->addPropertyWithoutTransition(globalData, propertyName, attributes, specificFunction);
-        if (currentCapacity != m_structure->propertyStorageCapacity())
-            allocatePropertyStorage(globalData, currentCapacity, m_structure->propertyStorageCapacity());
+        size_t currentCapacity = structure()->propertyStorageCapacity();
+        offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, specificFunction);
+        if (currentCapacity != structure()->propertyStorageCapacity())
+            allocatePropertyStorage(globalData, currentCapacity, structure()->propertyStorageCapacity());
 
-        ASSERT(offset < m_structure->propertyStorageCapacity());
+        ASSERT(offset < structure()->propertyStorageCapacity());
         putDirectOffset(globalData, offset, value);
         // See comment on setNewProperty call below.
         if (!specificFunction)
@@ -639,8 +632,8 @@
     }
 
     size_t offset;
-    size_t currentCapacity = m_structure->propertyStorageCapacity();
-    if (Structure* structure = Structure::addPropertyTransitionToExistingStructure(m_structure.get(), propertyName, attributes, specificFunction, offset)) {    
+    size_t currentCapacity = structure()->propertyStorageCapacity();
+    if (Structure* structure = Structure::addPropertyTransitionToExistingStructure(this->structure(), propertyName, attributes, specificFunction, offset)) {    
         if (currentCapacity != structure->propertyStorageCapacity())
             allocatePropertyStorage(globalData, currentCapacity, structure->propertyStorageCapacity());
 
@@ -656,7 +649,7 @@
 
     unsigned currentAttributes;
     JSCell* currentSpecificFunction;
-    offset = m_structure->get(globalData, propertyName, currentAttributes, currentSpecificFunction);
+    offset = structure()->get(globalData, propertyName, currentAttributes, currentSpecificFunction);
     if (offset != WTF::notFound) {
         if (checkReadOnly && currentAttributes & ReadOnly)
             return false;
@@ -677,7 +670,7 @@
                 return true;
             }
             // case (2) Despecify, fall through to (3).
-            setStructure(globalData, Structure::despecifyFunctionTransition(globalData, m_structure.get(), propertyName));
+            setStructure(globalData, Structure::despecifyFunctionTransition(globalData, structure(), propertyName));
         }
 
         // case (3) set the slot, do the put, return.
@@ -689,7 +682,7 @@
     if (checkReadOnly && !isExtensible())
         return false;
 
-    Structure* structure = Structure::addPropertyTransition(globalData, m_structure.get(), propertyName, attributes, specificFunction, offset);
+    Structure* structure = Structure::addPropertyTransition(globalData, this->structure(), propertyName, attributes, specificFunction, offset);
 
     if (currentCapacity != structure->propertyStorageCapacity())
         allocatePropertyStorage(globalData, currentCapacity, structure->propertyStorageCapacity());
@@ -725,17 +718,17 @@
 
 inline void JSObject::putDirectWithoutTransition(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes)
 {
-    size_t currentCapacity = m_structure->propertyStorageCapacity();
-    size_t offset = m_structure->addPropertyWithoutTransition(globalData, propertyName, attributes, getJSFunction(globalData, value));
-    if (currentCapacity != m_structure->propertyStorageCapacity())
-        allocatePropertyStorage(globalData, currentCapacity, m_structure->propertyStorageCapacity());
+    size_t currentCapacity = structure()->propertyStorageCapacity();
+    size_t offset = structure()->addPropertyWithoutTransition(globalData, propertyName, attributes, getJSFunction(globalData, value));
+    if (currentCapacity != structure()->propertyStorageCapacity())
+        allocatePropertyStorage(globalData, currentCapacity, structure()->propertyStorageCapacity());
     putDirectOffset(globalData, offset, value);
 }
 
 inline void JSObject::transitionTo(JSGlobalData& globalData, Structure* newStructure)
 {
-    if (m_structure->propertyStorageCapacity() != newStructure->propertyStorageCapacity())
-        allocatePropertyStorage(globalData, m_structure->propertyStorageCapacity(), newStructure->propertyStorageCapacity());
+    if (structure()->propertyStorageCapacity() != newStructure->propertyStorageCapacity())
+        allocatePropertyStorage(globalData, structure()->propertyStorageCapacity(), newStructure->propertyStorageCapacity());
     setStructure(globalData, newStructure);
 }
 
@@ -826,7 +819,7 @@
     JSCell::visitChildren(visitor);
 
     PropertyStorage storage = propertyStorage();
-    size_t storageSize = m_structure->propertyStorageSize();
+    size_t storageSize = structure()->propertyStorageSize();
     visitor.appendValues(storage, storageSize);
     if (m_inheritorID)
         visitor.append(&m_inheritorID);

Modified: trunk/Source/_javascript_Core/runtime/Structure.h (95502 => 95503)


--- trunk/Source/_javascript_Core/runtime/Structure.h	2011-09-20 01:20:12 UTC (rev 95502)
+++ trunk/Source/_javascript_Core/runtime/Structure.h	2011-09-20 01:21:51 UTC (rev 95503)
@@ -326,6 +326,12 @@
         return m_structure->typeInfo().type() == APIValueWrapperType;
     }
 
+    inline void JSCell::setStructure(JSGlobalData& globalData, Structure* structure)
+    {
+        ASSERT(structure->typeInfo().overridesVisitChildren() == this->structure()->typeInfo().overridesVisitChildren());
+        m_structure.set(globalData, this, structure);
+    }
+
     inline const ClassInfo* JSCell::classInfo() const
     {
 #if ENABLE(GC_VALIDATION)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to