Ignore:
Timestamp:
Sep 19, 2011, 6:21:51 PM (14 years ago)
Author:
[email protected]
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r95439 r95503  
    137137    unsigned attributes;
    138138    JSCell* specificValue;
    139     if ((m_structure->get(globalData, propertyName, attributes, specificValue) != WTF::notFound) && attributes & ReadOnly) {
     139    if ((structure()->get(globalData, propertyName, attributes, specificValue) != WTF::notFound) && attributes & ReadOnly) {
    140140        if (slot.isStrictMode())
    141141            throwError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
     
    234234    unsigned attributes;
    235235    JSCell* specificValue;
    236     if (m_structure->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound) {
     236    if (structure()->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound) {
    237237        if ((attributes & DontDelete))
    238238            return false;
     
    335335    JSValue object = getDirect(exec->globalData(), propertyName);
    336336    if (object && object.isGetterSetter()) {
    337         ASSERT(m_structure->hasGetterSetterProperties());
     337        ASSERT(structure()->hasGetterSetterProperties());
    338338        asGetterSetter(object)->setGetter(exec->globalData(), getterFunction);
    339339        return;
     
    349349    // if we override an existing non-getter or non-setter.
    350350    if (slot.type() != PutPropertySlot::NewProperty) {
    351         if (!m_structure->isDictionary())
    352             setStructure(exec->globalData(), Structure::getterSetterTransition(globalData, m_structure.get()));
    353     }
    354 
    355     m_structure->setHasGetterSetterProperties(true);
     351        if (!structure()->isDictionary())
     352            setStructure(exec->globalData(), Structure::getterSetterTransition(globalData, structure()));
     353    }
     354
     355    structure()->setHasGetterSetterProperties(true);
    356356    getterSetter->setGetter(globalData, getterFunction);
    357357}
     
    366366    JSValue object = getDirect(exec->globalData(), propertyName);
    367367    if (object && object.isGetterSetter()) {
    368         ASSERT(m_structure->hasGetterSetterProperties());
     368        ASSERT(structure()->hasGetterSetterProperties());
    369369        asGetterSetter(object)->setSetter(exec->globalData(), setterFunction);
    370370        return;
     
    379379    // if we override an existing non-getter or non-setter.
    380380    if (slot.type() != PutPropertySlot::NewProperty) {
    381         if (!m_structure->isDictionary())
    382             setStructure(exec->globalData(), Structure::getterSetterTransition(exec->globalData(), m_structure.get()));
    383     }
    384 
    385     m_structure->setHasGetterSetterProperties(true);
     381        if (!structure()->isDictionary())
     382            setStructure(exec->globalData(), Structure::getterSetterTransition(exec->globalData(), structure()));
     383    }
     384
     385    structure()->setHasGetterSetterProperties(true);
    386386    getterSetter->setSetter(exec->globalData(), setterFunction);
    387387}
     
    454454{
    455455    unsigned attributes;
    456     if (m_structure->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound)
     456    if (structure()->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound)
    457457        return true;
    458458
     
    487487void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    488488{
    489     m_structure->getPropertyNames(exec->globalData(), propertyNames, mode);
     489    structure()->getPropertyNames(exec->globalData(), propertyNames, mode);
    490490    getClassPropertyNames(exec, classInfo(), propertyNames, mode);
    491491}
     
    537537        return;
    538538    preventExtensions(globalData);
    539     setStructure(globalData, Structure::sealTransition(globalData, m_structure.get()));
     539    setStructure(globalData, Structure::sealTransition(globalData, structure()));
    540540}
    541541
     
    545545        return;
    546546    preventExtensions(globalData);
    547     setStructure(globalData, Structure::freezeTransition(globalData, m_structure.get()));
     547    setStructure(globalData, Structure::freezeTransition(globalData, structure()));
    548548}
    549549
     
    551551{
    552552    if (isExtensible())
    553         setStructure(globalData, Structure::preventExtensionsTransition(globalData, m_structure.get()));
     553        setStructure(globalData, Structure::preventExtensionsTransition(globalData, structure()));
    554554}
    555555
    556556void JSObject::removeDirect(JSGlobalData& globalData, const Identifier& propertyName)
    557557{
    558     if (m_structure->get(globalData, propertyName) == WTF::notFound)
     558    if (structure()->get(globalData, propertyName) == WTF::notFound)
    559559        return;
    560560
    561561    size_t offset;
    562     if (m_structure->isUncacheableDictionary()) {
    563         offset = m_structure->removePropertyWithoutTransition(globalData, propertyName);
     562    if (structure()->isUncacheableDictionary()) {
     563        offset = structure()->removePropertyWithoutTransition(globalData, propertyName);
    564564        if (offset != WTF::notFound)
    565565            putUndefinedAtDirectOffset(offset);
     
    567567    }
    568568
    569     setStructure(globalData, Structure::removePropertyTransition(globalData, m_structure.get(), propertyName, offset));
     569    setStructure(globalData, Structure::removePropertyTransition(globalData, structure(), propertyName, offset));
    570570    if (offset != WTF::notFound)
    571571        putUndefinedAtDirectOffset(offset);
     
    585585Structure* JSObject::createInheritorID(JSGlobalData& globalData)
    586586{
    587     m_inheritorID.set(globalData, this, createEmptyObjectStructure(globalData, m_structure->globalObject(), this));
     587    m_inheritorID.set(globalData, this, createEmptyObjectStructure(globalData, structure()->globalObject(), this));
    588588    ASSERT(m_inheritorID->isEmpty());
    589589    return m_inheritorID.get();
     
    594594    ASSERT(newSize > oldSize);
    595595
    596     // It's important that this function not rely on m_structure, since
     596    // It's important that this function not rely on structure(), since
    597597    // we might be in the middle of a transition.
    598598    PropertyStorage newPropertyStorage = 0;
     
    615615    unsigned attributes = 0;
    616616    JSCell* cell = 0;
    617     size_t offset = m_structure->get(exec->globalData(), propertyName, attributes, cell);
     617    size_t offset = structure()->get(exec->globalData(), propertyName, attributes, cell);
    618618    if (offset == WTF::notFound)
    619619        return false;
Note: See TracChangeset for help on using the changeset viewer.