Changeset 128115 in webkit


Ignore:
Timestamp:
Sep 10, 2012 3:18:40 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r128109.
http://trac.webkit.org/changeset/128109
https://bugs.webkit.org/show_bug.cgi?id=96326

broke win and lion builds (Requested by kling on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-09-10

  • WebCore.exp.in:
  • dom/Element.cpp:

(WebCore::Element::createMutableAttributeData):

  • dom/ElementAttributeData.cpp:

(WebCore::immutableElementAttributeDataSize):
(WebCore::ElementAttributeData::createImmutable):
(WebCore::ElementAttributeData::ElementAttributeData):
(WebCore::ElementAttributeData::~ElementAttributeData):
(WebCore::ElementAttributeData::addAttribute):
(WebCore::ElementAttributeData::removeAttribute):
(WebCore::ElementAttributeData::reportMemoryUsage):
(WebCore::ElementAttributeData::cloneDataFrom):
(WebCore::ElementAttributeData::clearAttributes):

  • dom/ElementAttributeData.h:

(WebCore):
(WebCore::ElementAttributeData::create):
(ElementAttributeData):
(WebCore::ElementAttributeData::isMutable):
(WebCore::ElementAttributeData::makeMutable):
(WebCore::ElementAttributeData::length):
(WebCore::ElementAttributeData::attributeItem):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128114 r128115  
     12012-09-10  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r128109.
     4        http://trac.webkit.org/changeset/128109
     5        https://bugs.webkit.org/show_bug.cgi?id=96326
     6
     7        broke win and lion builds (Requested by kling on #webkit).
     8
     9        * WebCore.exp.in:
     10        * dom/Element.cpp:
     11        (WebCore::Element::createMutableAttributeData):
     12        * dom/ElementAttributeData.cpp:
     13        (WebCore::immutableElementAttributeDataSize):
     14        (WebCore::ElementAttributeData::createImmutable):
     15        (WebCore::ElementAttributeData::ElementAttributeData):
     16        (WebCore::ElementAttributeData::~ElementAttributeData):
     17        (WebCore::ElementAttributeData::addAttribute):
     18        (WebCore::ElementAttributeData::removeAttribute):
     19        (WebCore::ElementAttributeData::reportMemoryUsage):
     20        (WebCore::ElementAttributeData::cloneDataFrom):
     21        (WebCore::ElementAttributeData::clearAttributes):
     22        * dom/ElementAttributeData.h:
     23        (WebCore):
     24        (WebCore::ElementAttributeData::create):
     25        (ElementAttributeData):
     26        (WebCore::ElementAttributeData::isMutable):
     27        (WebCore::ElementAttributeData::makeMutable):
     28        (WebCore::ElementAttributeData::length):
     29        (WebCore::ElementAttributeData::attributeItem):
     30
    1312012-09-10  Chris Fleizach  <cfleizach@apple.com>
    232
  • trunk/Source/WebCore/WebCore.exp.in

    r128109 r128115  
    231231__ZN7WebCore13toHTMLElementEPNS_21FormAssociatedElementE
    232232__ZN7WebCore13toJSDOMWindowEN3JSC7JSValueE
    233 __ZN7WebCore13QualifiedNameD1Ev
    234233__ZN7WebCore14CachedResource12removeClientEPNS_20CachedResourceClientE
    235234__ZN7WebCore14CachedResource16unregisterHandleEPNS_24CachedResourceHandleBaseE
     
    540539__ZN7WebCore20makeRGBA32FromFloatsEffff
    541540__ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
    542 __ZN7WebCore20SpaceSplitStringDataD1Ev
    543541__ZN7WebCore21BackForwardController11itemAtIndexEi
    544542__ZN7WebCore21MemoryPressureHandler7installEv
  • trunk/Source/WebCore/dom/Element.cpp

    r128109 r128115  
    22472247        m_attributeData = ElementAttributeData::create();
    22482248    else
    2249         m_attributeData = m_attributeData->makeMutableCopy();
     2249        m_attributeData = m_attributeData->makeMutable();
    22502250}
    22512251
  • trunk/Source/WebCore/dom/ElementAttributeData.cpp

    r128109 r128115  
    3737static size_t immutableElementAttributeDataSize(unsigned count)
    3838{
    39     return sizeof(ImmutableElementAttributeData) + sizeof(Attribute) * count;
     39    return sizeof(ElementAttributeData) - sizeof(void*) + sizeof(Attribute) * count;
    4040}
    4141
     
    4343{
    4444    void* slot = WTF::fastMalloc(immutableElementAttributeDataSize(attributes.size()));
    45     return adoptRef(new (slot) ImmutableElementAttributeData(attributes));
    46 }
    47 
    48 PassRefPtr<ElementAttributeData> ElementAttributeData::create()
    49 {
    50     return adoptRef(new MutableElementAttributeData);
    51 }
    52 
    53 ImmutableElementAttributeData::ImmutableElementAttributeData(const Vector<Attribute>& attributes)
    54     : ElementAttributeData(attributes.size())
    55 {
    56     for (unsigned i = 0; i < m_arraySize; ++i)
    57         new (&m_attributeArray[i]) Attribute(attributes[i]);
    58 }
    59 
    60 MutableElementAttributeData::MutableElementAttributeData(const ImmutableElementAttributeData& other)
    61 {
    62     const ElementAttributeData& baseOther = static_cast<const ElementAttributeData&>(other);
    63 
    64     m_inlineStyleDecl = baseOther.m_inlineStyleDecl;
    65     m_attributeStyle = baseOther.m_attributeStyle;
    66     m_classNames = baseOther.m_classNames;
    67     m_idForStyleResolution = baseOther.m_idForStyleResolution;
    68 
    69     // An ImmutableElementAttributeData should never have a mutable inline StylePropertySet attached.
    70     ASSERT(!baseOther.m_inlineStyleDecl || !baseOther.m_inlineStyleDecl->isMutable());
    71 
    72     m_attributeVector.reserveCapacity(baseOther.m_arraySize);
    73     for (unsigned i = 0; i < baseOther.m_arraySize; ++i)
    74         m_attributeVector.uncheckedAppend(other.m_attributeArray[i]);
    75 }
    76 
    77 ImmutableElementAttributeData::~ImmutableElementAttributeData()
    78 {
    79     for (unsigned i = 0; i < m_arraySize; ++i)
    80         m_attributeArray[i].~Attribute();
    81 }
    82 
    83 PassRefPtr<ElementAttributeData> ElementAttributeData::makeMutableCopy() const
    84 {
    85     ASSERT(!isMutable());
    86     return adoptRef(new MutableElementAttributeData(static_cast<const ImmutableElementAttributeData&>(*this)));
     45    return adoptRef(new (slot) ElementAttributeData(attributes));
     46}
     47
     48ElementAttributeData::ElementAttributeData()
     49    : m_isMutable(true)
     50    , m_arraySize(0)
     51    , m_mutableAttributeVector(new Vector<Attribute, 4>)
     52{
     53}
     54
     55ElementAttributeData::ElementAttributeData(const Vector<Attribute>& attributes)
     56    : m_isMutable(false)
     57    , m_arraySize(attributes.size())
     58{
     59    Attribute* buffer = reinterpret_cast<Attribute*>(&m_attributes);
     60    for (unsigned i = 0; i < attributes.size(); ++i)
     61        new (&buffer[i]) Attribute(attributes[i]);
     62}
     63
     64ElementAttributeData::ElementAttributeData(const ElementAttributeData& other)
     65    : RefCounted<ElementAttributeData>()
     66    , m_isMutable(true)
     67    , m_arraySize(0)
     68    , m_inlineStyleDecl(other.m_inlineStyleDecl)
     69    , m_attributeStyle(other.m_attributeStyle)
     70    , m_classNames(other.m_classNames)
     71    , m_idForStyleResolution(other.m_idForStyleResolution)
     72    , m_mutableAttributeVector(new Vector<Attribute, 4>)
     73{
     74    // This copy constructor should only be used by makeMutable() to go from immutable to mutable.
     75    ASSERT(!other.m_isMutable);
     76
     77    // An immutable ElementAttributeData should never have a mutable inline StylePropertySet attached.
     78    ASSERT(!other.m_inlineStyleDecl || !other.m_inlineStyleDecl->isMutable());
     79
     80    const Attribute* otherBuffer = reinterpret_cast<const Attribute*>(&other.m_attributes);
     81    for (unsigned i = 0; i < other.m_arraySize; ++i)
     82        m_mutableAttributeVector->append(otherBuffer[i]);
     83}
     84
     85ElementAttributeData::~ElementAttributeData()
     86{
     87    if (isMutable()) {
     88        ASSERT(!m_arraySize);
     89        delete m_mutableAttributeVector;
     90    } else {
     91        Attribute* buffer = reinterpret_cast<Attribute*>(&m_attributes);
     92        for (unsigned i = 0; i < m_arraySize; ++i)
     93            buffer[i].~Attribute();
     94    }
    8795}
    8896
     
    229237        element->willModifyAttribute(attribute.name(), nullAtom, attribute.value());
    230238
    231     mutableAttributeVector().append(attribute);
     239    m_mutableAttributeVector->append(attribute);
    232240
    233241    if (element && inSynchronizationOfLazyAttribute == NotInSynchronizationOfLazyAttribute)
     
    240248    ASSERT(index < length());
    241249
    242     Attribute& attribute = mutableAttributeVector().at(index);
     250    Attribute& attribute = m_mutableAttributeVector->at(index);
    243251    QualifiedName name = attribute.name();
    244252
     
    249257        attr->detachFromElementWithValue(attribute.value());
    250258
    251     mutableAttributeVector().remove(index);
     259    m_mutableAttributeVector->remove(index);
    252260
    253261    if (element && inSynchronizationOfLazyAttribute == NotInSynchronizationOfLazyAttribute)
     
    297305    info.addInstrumentedMember(m_idForStyleResolution);
    298306    if (m_isMutable)
    299         info.addVector(mutableAttributeVector());
     307        info.addVectorPtr(m_mutableAttributeVector);
    300308    for (unsigned i = 0, len = length(); i < len; i++)
    301309        info.addInstrumentedMember(*attributeItem(i));
     
    341349
    342350    if (sourceData.isMutable())
    343         mutableAttributeVector() = sourceData.mutableAttributeVector();
     351        *m_mutableAttributeVector = *sourceData.m_mutableAttributeVector;
    344352    else {
    345         mutableAttributeVector().reserveInitialCapacity(sourceData.m_arraySize);
     353        ASSERT(m_mutableAttributeVector->isEmpty());
     354        m_mutableAttributeVector->reserveInitialCapacity(sourceData.m_arraySize);
     355        const Attribute* sourceBuffer = reinterpret_cast<const Attribute*>(&sourceData.m_attributes);
    346356        for (unsigned i = 0; i < sourceData.m_arraySize; ++i)
    347             mutableAttributeVector().uncheckedAppend(sourceData.immutableAttributeArray()[i]);
     357            m_mutableAttributeVector->uncheckedAppend(sourceBuffer[i]);
    348358    }
    349359
    350360    for (unsigned i = 0; i < length(); ++i) {
    351         const Attribute& attribute = mutableAttributeVector().at(i);
     361        const Attribute& attribute = m_mutableAttributeVector->at(i);
    352362        if (targetElement.isStyledElement() && attribute.name() == HTMLNames::styleAttr) {
    353363            static_cast<StyledElement&>(targetElement).styleAttributeChanged(attribute.value(), StyledElement::DoNotReparseStyleAttribute);
     
    371381
    372382    clearClass();
    373     mutableAttributeVector().clear();
     383    m_mutableAttributeVector->clear();
    374384}
    375385
  • trunk/Source/WebCore/dom/ElementAttributeData.h

    r128109 r128115  
    3636class Attr;
    3737class Element;
    38 class ImmutableElementAttributeData;
    3938class MemoryObjectInfo;
    40 class MutableElementAttributeData;
    4139
    4240enum SynchronizationOfLazyAttribute { NotInSynchronizationOfLazyAttribute, InSynchronizationOfLazyAttribute };
     
    4543    WTF_MAKE_FAST_ALLOCATED;
    4644public:
    47     static PassRefPtr<ElementAttributeData> create();
     45    static PassRefPtr<ElementAttributeData> create() { return adoptRef(new ElementAttributeData); }
    4846    static PassRefPtr<ElementAttributeData> createImmutable(const Vector<Attribute>&);
     47    ~ElementAttributeData();
    4948
    5049    void clearClass() { m_classNames.clear(); }
     
    9796    void reportMemoryUsage(MemoryObjectInfo*) const;
    9897
    99     bool isMutable() const { return m_isMutable; }
    100 
    101 protected:
    102     ElementAttributeData()
    103         : m_isMutable(true)
    104         , m_arraySize(0)
    105     { }
    106 
    107     ElementAttributeData(unsigned arraySize)
    108         : m_isMutable(false)
    109         , m_arraySize(arraySize)
    110     { }
    111 
    112     mutable RefPtr<StylePropertySet> m_inlineStyleDecl;
    113     mutable RefPtr<StylePropertySet> m_attributeStyle;
    114     mutable SpaceSplitString m_classNames;
    115     mutable AtomicString m_idForStyleResolution;
    116 
    117     unsigned m_isMutable : 1;
    118     unsigned m_arraySize : 31;
    119 
    12098private:
    12199    friend class Element;
    122100    friend class HTMLConstructionSite;
    123     friend class ImmutableElementAttributeData;
    124     friend class MutableElementAttributeData;
     101
     102    ElementAttributeData();
     103    ElementAttributeData(const ElementAttributeData&);
     104    ElementAttributeData(const Vector<Attribute>&);
    125105
    126106    Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase);
     
    130110    void clearAttributes(Element*);
    131111
    132     PassRefPtr<ElementAttributeData> makeMutableCopy() const;
    133 
    134     Vector<Attribute, 4>& mutableAttributeVector();
    135     const Vector<Attribute, 4>& mutableAttributeVector() const;
    136     const Attribute* immutableAttributeArray() const;
     112    bool isMutable() const { return m_isMutable; }
     113    PassRefPtr<ElementAttributeData> makeMutable() const { return adoptRef(new ElementAttributeData(*this)); }
     114
     115    unsigned m_isMutable : 1;
     116    unsigned m_arraySize : 31;
     117
     118    mutable RefPtr<StylePropertySet> m_inlineStyleDecl;
     119    mutable RefPtr<StylePropertySet> m_attributeStyle;
     120    mutable SpaceSplitString m_classNames;
     121    mutable AtomicString m_idForStyleResolution;
     122
     123    union {
     124        Vector<Attribute, 4>* m_mutableAttributeVector;
     125        void* m_attributes;
     126    };
    137127};
    138128
    139 class ImmutableElementAttributeData : public ElementAttributeData {
    140 public:
    141     ImmutableElementAttributeData(const Vector<Attribute>&);
    142     ~ImmutableElementAttributeData();
    143 
    144     Attribute m_attributeArray[0];
    145 };
    146 
    147 class MutableElementAttributeData : public ElementAttributeData {
    148 public:
    149     MutableElementAttributeData() { }
    150     MutableElementAttributeData(const ImmutableElementAttributeData&);
    151 
    152     Vector<Attribute, 4> m_attributeVector;
    153 };
    154 
    155 inline Vector<Attribute, 4>& ElementAttributeData::mutableAttributeVector()
    156 {
    157     ASSERT(m_isMutable);
    158     return static_cast<MutableElementAttributeData*>(this)->m_attributeVector;
    159 }
    160 
    161 inline const Vector<Attribute, 4>& ElementAttributeData::mutableAttributeVector() const
    162 {
    163     ASSERT(m_isMutable);
    164     return static_cast<const MutableElementAttributeData*>(this)->m_attributeVector;
    165 }
    166 
    167 inline const Attribute* ElementAttributeData::immutableAttributeArray() const
    168 {
    169     ASSERT(!m_isMutable);
    170     return static_cast<const ImmutableElementAttributeData*>(this)->m_attributeArray;
    171 }
    172 
    173129inline size_t ElementAttributeData::length() const
    174130{
    175131    if (isMutable())
    176         return mutableAttributeVector().size();
     132        return m_mutableAttributeVector->size();
    177133    return m_arraySize;
    178134}
     
    246202{
    247203    ASSERT(index < length());
    248     if (m_isMutable)
    249         return &mutableAttributeVector().at(index);
    250     return &immutableAttributeArray()[index];
     204    if (isMutable())
     205        return &m_mutableAttributeVector->at(index);
     206    const Attribute* buffer = reinterpret_cast<const Attribute*>(&m_attributes);
     207    return &buffer[index];
    251208}
    252209
    253210inline Attribute* ElementAttributeData::attributeItem(unsigned index)
    254211{
     212    ASSERT(isMutable());
    255213    ASSERT(index < length());
    256     return &mutableAttributeVector().at(index);
    257 }
    258 
    259 }
    260 
    261 namespace WTF {
    262 
    263 template <> inline void deleteOwnedPtr<WebCore::ElementAttributeData>(WebCore::ElementAttributeData* ptr)
    264 {
    265     if (!ptr)
    266         return;
    267     if (ptr->isMutable())
    268         delete static_cast<WebCore::MutableElementAttributeData*>(ptr);
    269     else
    270         delete static_cast<WebCore::ImmutableElementAttributeData*>(ptr);
     214    return &m_mutableAttributeVector->at(index);
    271215}
    272216
Note: See TracChangeset for help on using the changeset viewer.