Changeset 86383 in webkit


Ignore:
Timestamp:
May 12, 2011 2:56:45 PM (13 years ago)
Author:
Patrick Gansterer
Message:

2011-05-12 Maciej Stachowiak <mjs@apple.com>

Reviewed by Darin Adler.

XMLDocumentParserLibxml2 should play nice with strict OwnPtrs
https://bugs.webkit.org/show_bug.cgi?id=59394

This portion of the change introduces a PassTraits template, which
is used to enable takeFirst() to work for a Deque holding OwnPtrs,
and optimize it for a Deque holding RefPtrs. In the future it can
be deployed elsewhere to make our data structures work better with
our smart pointers.

  • GNUmakefile.list.am:
  • JavaScriptCore.gypi:
  • JavaScriptCore.vcproj/WTF/WTF.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/Deque.h: (WTF::::takeFirst):
  • wtf/PassTraits.h: Added. (WTF::PassTraits::transfer):

2011-05-12 Maciej Stachowiak <mjs@apple.com>

Reviewed by Darin Adler.

XMLDocumentParserLibxml2 should play nice with strict OwnPtrs
https://bugs.webkit.org/show_bug.cgi?id=59394

Properly fix this (formerly rolled out for breaking the build). I think the original
failure had nothing to do with Deque<OwnPtr>, which in fact appears to work fine.

  • dom/XMLDocumentParserLibxml2.cpp: (WebCore::PendingCallbacks::~PendingCallbacks): (WebCore::PendingCallbacks::create): (WebCore::PendingCallbacks::appendStartElementNSCallback): (WebCore::PendingCallbacks::appendEndElementNSCallback): (WebCore::PendingCallbacks::appendCharactersCallback): (WebCore::PendingCallbacks::appendProcessingInstructionCallback): (WebCore::PendingCallbacks::appendCDATABlockCallback): (WebCore::PendingCallbacks::appendCommentCallback): (WebCore::PendingCallbacks::appendInternalSubsetCallback): (WebCore::PendingCallbacks::appendErrorCallback): (WebCore::PendingCallbacks::PendingCallbacks): (WebCore::XMLDocumentParser::XMLDocumentParser):
Location:
trunk/Source
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r86335 r86383  
     12011-05-12  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        XMLDocumentParserLibxml2 should play nice with strict OwnPtrs
     6        https://bugs.webkit.org/show_bug.cgi?id=59394
     7
     8        This portion of the change introduces a PassTraits template, which
     9        is used to enable takeFirst() to work for a Deque holding OwnPtrs,
     10        and optimize it for a Deque holding RefPtrs. In the future it can
     11        be deployed elsewhere to make our data structures work better with
     12        our smart pointers.
     13
     14        * GNUmakefile.list.am:
     15        * JavaScriptCore.gypi:
     16        * JavaScriptCore.vcproj/WTF/WTF.vcproj:
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * wtf/CMakeLists.txt:
     19        * wtf/Deque.h:
     20        (WTF::::takeFirst):
     21        * wtf/PassTraits.h: Added.
     22        (WTF::PassTraits::transfer):
     23
    1242011-05-12  Nikolas Zimmermann  <nzimmermann@rim.com>
    225
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r86330 r86383  
    480480        Source/JavaScriptCore/wtf/PassOwnPtr.h \
    481481        Source/JavaScriptCore/wtf/PassRefPtr.h \
     482        Source/JavaScriptCore/wtf/PassTraits.h \
    482483        Source/JavaScriptCore/wtf/ParallelJobs.h \
    483484        Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp \
  • trunk/Source/JavaScriptCore/JavaScriptCore.gypi

    r86330 r86383  
    188188            'wtf/PassOwnPtr.h',
    189189            'wtf/PassRefPtr.h',
     190            'wtf/PassTraits.h',
    190191            'wtf/Platform.h',
    191192            'wtf/PossiblyNull.h',
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj

    r86330 r86383  
    850850                </File>
    851851                <File
     852                        RelativePath="..\..\wtf\PassTraits.h"
     853                        >
     854                </File>
     855                <File
    852856                        RelativePath="..\..\wtf\ParallelJobs.h"
    853857                        >
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r86330 r86383  
    219219                5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */ = {isa = PBXBuildFile; fileRef = F692A8540255597D01FF60F7 /* create_hash_table */; settings = {ATTRIBUTES = (); }; };
    220220                6507D29E0E871E5E00D7D896 /* JSTypeInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6507D2970E871E4A00D7D896 /* JSTypeInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
     221                651DCA04136A6FEF00F74194 /* PassTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 651DCA02136A6FAB00F74194 /* PassTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
    221222                655EB29B10CE2581001A990E /* NodesCodegen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 655EB29A10CE2581001A990E /* NodesCodegen.cpp */; };
    222223                65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65DFC92D08EA173A00F7300B /* HashTable.cpp */; };
     
    869870                5DE3D0F40DD8DDFB00468714 /* WebKitAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAvailability.h; sourceTree = "<group>"; };
    870871                6507D2970E871E4A00D7D896 /* JSTypeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypeInfo.h; sourceTree = "<group>"; };
     872                651DCA02136A6FAB00F74194 /* PassTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassTraits.h; sourceTree = "<group>"; };
    871873                651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; tabWidth = 8; };
    872874                651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; tabWidth = 8; };
     
    17251727                                44DD48520FAEA85000D6B4EB /* PassOwnPtr.h */,
    17261728                                6580F795094070560082C219 /* PassRefPtr.h */,
     1729                                651DCA02136A6FAB00F74194 /* PassTraits.h */,
    17271730                                7934BB761361979300CB99A1 /* ParallelJobs.h */,
    17281731                                7934BB771361979300CB99A1 /* ParallelJobsGeneric.cpp */,
     
    26042607                                7934BB7E1361979400CB99A1 /* ParallelJobsLibdispatch.h in Headers */,
    26052608                                7934BB7F1361979400CB99A1 /* ParallelJobsOpenMP.h in Headers */,
     2609                                651DCA04136A6FEF00F74194 /* PassTraits.h in Headers */,
    26062610                        );
    26072611                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/wtf/CMakeLists.txt

    r85253 r86383  
    5959    PassOwnPtr.h
    6060    PassRefPtr.h
     61    PassTraits.h
    6162    ParallelJobs.h
    6263    ParallelJobsGeneric.h
  • trunk/Source/JavaScriptCore/wtf/Deque.h

    r79538 r86383  
    3434// Deque doesn't actually use Vector.
    3535
     36#include "PassTraits.h"
    3637#include "Vector.h"
    3738
     
    5253        typedef DequeReverseIterator<T, inlineCapacity> reverse_iterator;
    5354        typedef DequeConstReverseIterator<T, inlineCapacity> const_reverse_iterator;
     55        typedef PassTraits<T> Pass;
     56        typedef typename PassTraits<T>::PassType PassType;
    5457
    5558        Deque();
     
    7477        T& first() { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; }
    7578        const T& first() const { ASSERT(m_start != m_end); return m_buffer.buffer()[m_start]; }
    76         T takeFirst();
     79        PassType takeFirst();
    7780
    7881        template<typename U> void append(const U&);
     
    437440
    438441    template<typename T, size_t inlineCapacity>
    439     inline T Deque<T, inlineCapacity>::takeFirst()
    440     {
    441         T oldFirst = first();
     442    inline typename Deque<T, inlineCapacity>::PassType Deque<T, inlineCapacity>::takeFirst()
     443    {
     444        T oldFirst = Pass::transfer(first());
    442445        removeFirst();
    443         return oldFirst;
     446        return Pass::transfer(oldFirst);
    444447    }
    445448
  • trunk/Source/WebCore/ChangeLog

    r86381 r86383  
     12011-05-12  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        XMLDocumentParserLibxml2 should play nice with strict OwnPtrs
     6        https://bugs.webkit.org/show_bug.cgi?id=59394
     7
     8        Properly fix this (formerly rolled out for breaking the build). I think the original
     9        failure had nothing to do with Deque<OwnPtr>, which in fact appears to work fine.
     10
     11        * dom/XMLDocumentParserLibxml2.cpp:
     12        (WebCore::PendingCallbacks::~PendingCallbacks):
     13        (WebCore::PendingCallbacks::create):
     14        (WebCore::PendingCallbacks::appendStartElementNSCallback):
     15        (WebCore::PendingCallbacks::appendEndElementNSCallback):
     16        (WebCore::PendingCallbacks::appendCharactersCallback):
     17        (WebCore::PendingCallbacks::appendProcessingInstructionCallback):
     18        (WebCore::PendingCallbacks::appendCDATABlockCallback):
     19        (WebCore::PendingCallbacks::appendCommentCallback):
     20        (WebCore::PendingCallbacks::appendInternalSubsetCallback):
     21        (WebCore::PendingCallbacks::appendErrorCallback):
     22        (WebCore::PendingCallbacks::PendingCallbacks):
     23        (WebCore::XMLDocumentParser::XMLDocumentParser):
     24
    1252011-05-12  Daniel Bates  <dbates@rim.com>
    226
  • trunk/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp

    r86330 r86383  
    2626
    2727#include "config.h"
    28 
    29 // FIXME: Remove this define!
    30 #define LOOSE_OWN_PTR
    31 
    3228#include "XMLDocumentParser.h"
    3329
     
    8581    WTF_MAKE_NONCOPYABLE(PendingCallbacks);
    8682public:
    87     PendingCallbacks() { }
    88     ~PendingCallbacks()
     83    ~PendingCallbacks() { }
     84    static PassOwnPtr<PendingCallbacks> create()
    8985    {
    90         deleteAllValues(m_callbacks);
    91     }
    92 
     86        return adoptPtr(new PendingCallbacks);
     87    }
     88   
    9389    void appendStartElementNSCallback(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
    9490                                      const xmlChar** namespaces, int nb_attributes, int nb_defaulted, const xmlChar** attributes)
    9591    {
    96         PendingStartElementNSCallback* callback = new PendingStartElementNSCallback;
     92        OwnPtr<PendingStartElementNSCallback> callback = adoptPtr(new PendingStartElementNSCallback);
    9793
    9894        callback->xmlLocalName = xmlStrdup(xmlLocalName);
     
    119115        }
    120116
    121         m_callbacks.append(callback);
     117        m_callbacks.append(callback.release());
    122118    }
    123119
    124120    void appendEndElementNSCallback()
    125121    {
    126         PendingEndElementNSCallback* callback = new PendingEndElementNSCallback;
    127 
    128         m_callbacks.append(callback);
     122        m_callbacks.append(adoptPtr(new PendingEndElementNSCallback));
    129123    }
    130124
    131125    void appendCharactersCallback(const xmlChar* s, int len)
    132126    {
    133         PendingCharactersCallback* callback = new PendingCharactersCallback;
     127        OwnPtr<PendingCharactersCallback> callback = adoptPtr(new PendingCharactersCallback);
    134128
    135129        callback->s = xmlStrndup(s, len);
    136130        callback->len = len;
    137131
    138         m_callbacks.append(callback);
     132        m_callbacks.append(callback.release());
    139133    }
    140134
    141135    void appendProcessingInstructionCallback(const xmlChar* target, const xmlChar* data)
    142136    {
    143         PendingProcessingInstructionCallback* callback = new PendingProcessingInstructionCallback;
     137        OwnPtr<PendingProcessingInstructionCallback> callback = adoptPtr(new PendingProcessingInstructionCallback);
    144138
    145139        callback->target = xmlStrdup(target);
    146140        callback->data = xmlStrdup(data);
    147141
    148         m_callbacks.append(callback);
     142        m_callbacks.append(callback.release());
    149143    }
    150144
    151145    void appendCDATABlockCallback(const xmlChar* s, int len)
    152146    {
    153         PendingCDATABlockCallback* callback = new PendingCDATABlockCallback;
     147        OwnPtr<PendingCDATABlockCallback> callback = adoptPtr(new PendingCDATABlockCallback);
    154148
    155149        callback->s = xmlStrndup(s, len);
    156150        callback->len = len;
    157151
    158         m_callbacks.append(callback);
     152        m_callbacks.append(callback.release());
    159153    }
    160154
    161155    void appendCommentCallback(const xmlChar* s)
    162156    {
    163         PendingCommentCallback* callback = new PendingCommentCallback;
     157        OwnPtr<PendingCommentCallback> callback = adoptPtr(new PendingCommentCallback);
    164158
    165159        callback->s = xmlStrdup(s);
    166160
    167         m_callbacks.append(callback);
     161        m_callbacks.append(callback.release());
    168162    }
    169163
    170164    void appendInternalSubsetCallback(const xmlChar* name, const xmlChar* externalID, const xmlChar* systemID)
    171165    {
    172         PendingInternalSubsetCallback* callback = new PendingInternalSubsetCallback;
     166        OwnPtr<PendingInternalSubsetCallback> callback = adoptPtr(new PendingInternalSubsetCallback);
    173167
    174168        callback->name = xmlStrdup(name);
     
    176170        callback->systemID = xmlStrdup(systemID);
    177171
    178         m_callbacks.append(callback);
     172        m_callbacks.append(callback.release());
    179173    }
    180174
    181175    void appendErrorCallback(XMLDocumentParser::ErrorType type, const xmlChar* message, int lineNumber, int columnNumber)
    182176    {
    183         PendingErrorCallback* callback = new PendingErrorCallback;
     177        OwnPtr<PendingErrorCallback> callback = adoptPtr(new PendingErrorCallback);
    184178
    185179        callback->message = xmlStrdup(message);
     
    188182        callback->columnNumber = columnNumber;
    189183
    190         m_callbacks.append(callback);
     184        m_callbacks.append(callback.release());
    191185    }
    192186
    193187    void callAndRemoveFirstCallback(XMLDocumentParser* parser)
    194188    {
    195         OwnPtr<PendingCallback> callback(m_callbacks.takeFirst());
     189        OwnPtr<PendingCallback> callback = m_callbacks.takeFirst();
    196190        callback->call(parser);
    197191    }
     
    200194
    201195private:
     196    PendingCallbacks() { }
     197
    202198    struct PendingCallback {
    203199        virtual ~PendingCallback() { }
     
    339335    };
    340336
    341     Deque<PendingCallback*> m_callbacks;
     337    Deque<OwnPtr<PendingCallback> > m_callbacks;
    342338};
    343339// --------------------------------
     
    552548    , m_view(frameView)
    553549    , m_context(0)
    554     , m_pendingCallbacks(new PendingCallbacks)
     550    , m_pendingCallbacks(PendingCallbacks::create())
    555551    , m_currentNode(document)
    556552    , m_sawError(false)
     
    579575    , m_view(0)
    580576    , m_context(0)
    581     , m_pendingCallbacks(new PendingCallbacks)
     577    , m_pendingCallbacks(PendingCallbacks::create())
    582578    , m_currentNode(fragment)
    583579    , m_sawError(false)
Note: See TracChangeset for help on using the changeset viewer.