Changeset 92254 in webkit
- Timestamp:
- Aug 2, 2011 7:28:33 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r92251 r92254 1 2011-08-01 David Levin <levin@chromium.org> 2 3 Add asserts to RefCounted to make sure ref/deref happens on the right thread. 4 https://bugs.webkit.org/show_bug.cgi?id=31639 5 6 Reviewed by Dmitry Titov. 7 8 * GNUmakefile.list.am: Added new files to the build. 9 * JavaScriptCore.gypi: Ditto. 10 * JavaScriptCore.vcproj/WTF/WTF.vcproj: Ditto. 11 * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. 12 * jit/ExecutableAllocator.h: 13 (JSC::ExecutablePool::ExecutablePool): Turned off checks for this 14 due to not being able to figure out what was guarding it (bug 58091). 15 * parser/SourceProvider.h: 16 (JSC::SourceProvider::SourceProvider): Ditto. 17 * wtf/CMakeLists.txt: Added new files to the build. 18 * wtf/ThreadRestrictionVerifier.h: Added. 19 Everything is done in the header to avoid the issue with exports 20 that are only useful in debug but still needing to export them. 21 * wtf/RefCounted.h: 22 (WTF::RefCountedBase::ref): Added checks using the non thread safe verifier. 23 and filed bug 58171 about making it stricter. 24 (WTF::RefCountedBase::hasOneRef): Ditto. 25 (WTF::RefCountedBase::refCount): Ditto. 26 (WTF::RefCountedBase::setMutexForVerifier): Expose a way to change the checks to be based 27 on a mutex. This is in the header to avoid adding more exports from JavaScriptCore. 28 (WTF::RefCountedBase::deprecatedTurnOffVerifier): Temporary way to turn off verification. 29 Filed bug 58174 to remove this method. 30 (WTF::RefCountedBase::derefBase): 31 * wtf/SizeLimits.cpp: Adjusted the debug size check for RefCounted. 32 * wtf/text/CString.h: 33 (WTF::CStringBuffer::CStringBuffer): Turned off checks for this while a fix is being 34 done in Chromium (bug 58093). 35 1 36 2011-08-02 Filip Pizlo <fpizlo@apple.com> 2 37 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r90953 r92254 579 579 Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp \ 580 580 Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h \ 581 Source/JavaScriptCore/wtf/ThreadRestrictionVerifier.h \ 581 582 Source/JavaScriptCore/wtf/Threading.cpp \ 582 583 Source/JavaScriptCore/wtf/Threading.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r92161 r92254 206 206 'wtf/ThreadSafeRefCounted.h', 207 207 'wtf/ThreadSpecific.h', 208 'wtf/ThreadRestrictionVerifier.h', 208 209 'wtf/Threading.h', 209 210 'wtf/ThreadingPrimitives.h', -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
r86383 r92254 1010 1010 </File> 1011 1011 <File 1012 RelativePath="..\..\wtf\ThreadRestrictionVerifier.h" 1013 > 1014 </File> 1015 <File 1012 1016 RelativePath="..\..\wtf\ThreadSafeRefCounted.h" 1013 1017 > -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r92046 r92254 45 45 0B330C270F38C62300692DE3 /* TypeTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0B330C260F38C62300692DE3 /* TypeTraits.cpp */; }; 46 46 0B4D7E630F319AC800AD7E58 /* TypeTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B4D7E620F319AC800AD7E58 /* TypeTraits.h */; settings = {ATTRIBUTES = (Private, ); }; }; 47 0BAC94A01338728400CF135B /* ThreadRestrictionVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BAC949E1338728400CF135B /* ThreadRestrictionVerifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 47 48 0BDFFAE00FC6192900D69EF4 /* CrossThreadRefCounted.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BDFFAD40FC6171000D69EF4 /* CrossThreadRefCounted.h */; settings = {ATTRIBUTES = (Private, ); }; }; 48 49 0BDFFAE10FC6193100D69EF4 /* OwnFastMallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 723 724 0B330C260F38C62300692DE3 /* TypeTraits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TypeTraits.cpp; sourceTree = "<group>"; }; 724 725 0B4D7E620F319AC800AD7E58 /* TypeTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeTraits.h; sourceTree = "<group>"; }; 726 0BAC949E1338728400CF135B /* ThreadRestrictionVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadRestrictionVerifier.h; sourceTree = "<group>"; }; 725 727 0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OwnFastMallocPtr.h; sourceTree = "<group>"; }; 726 728 0BDFFAD40FC6171000D69EF4 /* CrossThreadRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadRefCounted.h; sourceTree = "<group>"; }; … … 1651 1653 A1D764511354448B00C5C7C0 /* Alignment.h */, 1652 1654 A7C40C07130B057D00D002A1 /* BlockStack.h */, 1653 A7C40C08130B057D00D002A1 /* SentinelLinkedList.h */,1654 A7C40C09130B057D00D002A1 /* SinglyLinkedList.h */,1655 1655 5135FAD512D26856003C083B /* Decoder.h */, 1656 1656 5135FAD612D26856003C083B /* Encoder.h */, … … 1751 1751 76FB9F1012E851960051A2EB /* SHA1.cpp */, 1752 1752 76FB9F0E12E851860051A2EB /* SHA1.h */, 1753 A7C40C08130B057D00D002A1 /* SentinelLinkedList.h */, 1754 A7C40C09130B057D00D002A1 /* SinglyLinkedList.h */, 1753 1755 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */, 1754 1756 86D87DA512BC4B14008E73A1 /* StackBounds.cpp */, … … 1772 1774 BC5F7BBD11823B590052C02C /* ThreadSafeRefCounted.h */, 1773 1775 E1B7C8BD0DA3A3360074B0DC /* ThreadSpecific.h */, 1776 0BAC949E1338728400CF135B /* ThreadRestrictionVerifier.h */, 1774 1777 0B330C260F38C62300692DE3 /* TypeTraits.cpp */, 1775 1778 0B4D7E620F319AC800AD7E58 /* TypeTraits.h */, … … 2520 2523 BC18C4700E16F5CD00B34460 /* Threading.h in Headers */, 2521 2524 BC5F7BBF11823B590052C02C /* ThreadingPrimitives.h in Headers */, 2525 0BAC94A01338728400CF135B /* ThreadRestrictionVerifier.h in Headers */, 2522 2526 BC5F7BC011823B590052C02C /* ThreadSafeRefCounted.h in Headers */, 2523 2527 BC18C4710E16F5CD00B34460 /* ThreadSpecific.h in Headers */, -
trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h
r87614 r92254 353 353 CRASH(); // Failed to allocate 354 354 m_end = m_freePtr + allocSize; 355 deprecatedTurnOffVerifier(); 355 356 } 356 357 -
trunk/Source/JavaScriptCore/parser/SourceProvider.h
r85253 r92254 47 47 , m_cacheOwned(!cache) 48 48 { 49 deprecatedTurnOffVerifier(); 49 50 } 50 51 virtual ~SourceProvider() -
trunk/Source/JavaScriptCore/wtf/CMakeLists.txt
r87061 r92254 43 43 MessageQueue.h 44 44 NonCopyingSort.h 45 ThreadRestrictionVerifier.h 45 46 Noncopyable.h 46 47 NotFound.h -
trunk/Source/JavaScriptCore/wtf/RefCounted.h
r85253 r92254 24 24 #include "Assertions.h" 25 25 #include "FastAllocBase.h" 26 #include "ThreadRestrictionVerifier.h" 26 27 #include "Noncopyable.h" 28 #include "OwnPtr.h" 29 #include "UnusedParam.h" 27 30 28 31 namespace WTF { … … 35 38 void ref() 36 39 { 40 #ifndef NDEBUG 41 // Start thread verification as soon as the ref count gets to 2. This 42 // heuristic reflects the fact that items are often created on one thread 43 // and then given to another thread to be used. 44 // FIXME: Make this restriction tigher. Especially as we move to more 45 // common methods for sharing items across threads like CrossThreadCopier.h 46 // We should be able to add a "detachFromThread" method to make this explicit. 47 if (m_refCount == 1) 48 m_verifier.setShared(true); 49 #endif 50 // If this assert fires, it either indicates a thread safety issue or 51 // that the verification needs to change. See ThreadRestrictionVerifier for 52 // the different modes. 53 ASSERT(m_verifier.isSafeToUse()); 37 54 ASSERT(!m_deletionHasBegun); 38 55 ASSERT(!m_adoptionIsRequired); … … 42 59 bool hasOneRef() const 43 60 { 61 ASSERT(m_verifier.isSafeToUse()); 44 62 ASSERT(!m_deletionHasBegun); 45 63 return m_refCount == 1; … … 48 66 int refCount() const 49 67 { 68 ASSERT(m_verifier.isSafeToUse()); 50 69 return m_refCount; 70 } 71 72 void setMutexForVerifier(Mutex&); 73 74 // Turns off verification. Use of this method is discouraged (instead extend 75 // ThreadRestrictionVerifier to verify your case). 76 // FIXME: remove this method. 77 void deprecatedTurnOffVerifier() 78 { 79 #ifndef NDEBUG 80 m_verifier.turnOffVerification(); 81 #endif 51 82 } 52 83 … … 85 116 bool derefBase() 86 117 { 118 ASSERT(m_verifier.isSafeToUse()); 87 119 ASSERT(!m_deletionHasBegun); 88 120 ASSERT(!m_adoptionIsRequired); … … 97 129 98 130 --m_refCount; 131 #ifndef NDEBUG 132 // Stop thread verification when the ref goes to 1 because it 133 // is safe to be passed to another thread at this point. 134 if (m_refCount == 1) 135 m_verifier.setShared(false); 136 #endif 99 137 return false; 100 138 } … … 118 156 bool m_deletionHasBegun; 119 157 bool m_adoptionIsRequired; 158 ThreadRestrictionVerifier m_verifier; 120 159 #endif 121 160 }; … … 165 204 }; 166 205 206 #ifdef NDEBUG 207 inline void RefCountedBase::setMutexForVerifier(Mutex&) { } 208 #else 209 inline void RefCountedBase::setMutexForVerifier(Mutex& mutex) 210 { 211 m_verifier.setMutexMode(mutex); 212 } 213 #endif 214 167 215 } // namespace WTF 168 216 -
trunk/Source/JavaScriptCore/wtf/SizeLimits.cpp
r85253 r92254 37 37 #include <wtf/RefCounted.h> 38 38 #include <wtf/RefPtr.h> 39 #include <wtf/ThreadRestrictionVerifier.h> 39 40 #include <wtf/Vector.h> 40 41 … … 42 43 43 44 #ifndef NDEBUG 44 struct StructWithIntAndTwoBools { int a; bool b; bool c; }; 45 static const size_t refCountedExtraDebugSize = sizeof(StructWithIntAndTwoBools) - sizeof(int); 45 struct SameSizeAsRefCounted { 46 int a; 47 bool b; 48 bool c; 49 ThreadRestrictionVerifier d; 50 // The debug version may get bigger. 51 }; 46 52 #else 47 static const size_t refCountedExtraDebugSize = 0; 53 struct SameSizeAsRefCounted { 54 int a; 55 // Don't add anything here because this should stay small. 56 }; 48 57 #endif 49 58 50 59 COMPILE_ASSERT(sizeof(OwnPtr<int>) == sizeof(int*), OwnPtr_should_stay_small); 51 60 COMPILE_ASSERT(sizeof(PassRefPtr<RefCounted<int> >) == sizeof(int*), PassRefPtr_should_stay_small); 52 COMPILE_ASSERT(sizeof(RefCounted<int>) == sizeof( int) + refCountedExtraDebugSize, RefCounted_should_stay_small);53 COMPILE_ASSERT(sizeof(RefCountedCustomAllocated<int>) == sizeof( int) + refCountedExtraDebugSize, RefCountedCustomAllocated_should_stay_small);61 COMPILE_ASSERT(sizeof(RefCounted<int>) == sizeof(SameSizeAsRefCounted), RefCounted_should_stay_small); 62 COMPILE_ASSERT(sizeof(RefCountedCustomAllocated<int>) == sizeof(SameSizeAsRefCounted), RefCountedCustomAllocated_should_stay_small); 54 63 COMPILE_ASSERT(sizeof(RefPtr<RefCounted<int> >) == sizeof(int*), RefPtr_should_stay_small); 55 64 COMPILE_ASSERT(sizeof(Vector<int>) == 3 * sizeof(int*), Vector_should_stay_small); -
trunk/Source/JavaScriptCore/wtf/text/CString.h
r85253 r92254 42 42 43 43 static PassRefPtr<CStringBuffer> create(size_t length) { return adoptRef(new CStringBuffer(length)); } 44 CStringBuffer(size_t length) : m_vector(length) { } 44 CStringBuffer(size_t length) : m_vector(length) 45 { 46 #if PLATFORM(CHROMIUM) 47 // FIXME: Need to fix some start-up code in Chromium Linux and some test code for 48 // Chromium OS X in order to remove this. 49 deprecatedTurnOffVerifier(); 50 #endif 51 } 45 52 char* mutableData() { return m_vector.data(); } 46 53 -
trunk/Source/JavaScriptGlue/ChangeLog
r91903 r92254 1 2011-08-01 David Levin <levin@chromium.org> 2 3 Add asserts to RefCounted to make sure ref/deref happens on the right thread. 4 https://bugs.webkit.org/show_bug.cgi?id=31639 5 6 Reviewed by Dmitry Titov. 7 8 * ForwardingHeaders/wtf/ThreadRestrictionVerifier.h: Added. 9 1 10 2011-07-27 Mark Hahnenberg <mhahnenberg@apple.com> 2 11 -
trunk/Source/WebCore/ChangeLog
r92253 r92254 1 2011-08-01 David Levin <levin@chromium.org> 2 3 Add asserts to RefCounted to make sure ref/deref happens on the right thread. 4 https://bugs.webkit.org/show_bug.cgi?id=31639 5 6 Reviewed by Dmitry Titov. 7 8 No new functionality exposed so no new tests. (The change is basically adding 9 more testing.) 10 11 * ForwardingHeaders/wtf/ThreadRestrictionVerifier.h: Added. 12 * loader/icon/IconDatabase.cpp: 13 (WebCore::IconDatabase::defaultIcon): Set the mutex which does the guarding of the variable. 14 (WebCore::IconDatabase::setIconDataForIconURL): Ditto. 15 (WebCore::IconDatabase::getOrCreateIconRecord): Ditto. 16 (WebCore::IconDatabase::readFromDatabase): Ditto. 17 1 18 2011-08-02 Luke Macpherson <macpherson@chromium.org> 2 19 -
trunk/Source/WebCore/loader/icon/IconDatabase.cpp
r91540 r92254 388 388 if (!m_defaultIconRecord) { 389 389 m_defaultIconRecord = IconRecord::create("urlIcon"); 390 m_defaultIconRecord->setMutexForVerifier(m_urlAndIconLock); 390 391 loadDefaultIconRecord(m_defaultIconRecord.get()); 391 392 } … … 518 519 519 520 RefPtr<SharedBuffer> data = dataOriginal ? dataOriginal->copy() : PassRefPtr<SharedBuffer>(0); 521 if (data) 522 data->setMutexForVerifier(m_urlAndIconLock); 520 523 String iconURL = iconURLOriginal.crossThreadString(); 521 524 … … 879 882 880 883 RefPtr<IconRecord> newIcon = IconRecord::create(iconURL); 884 newIcon->setMutexForVerifier(m_urlAndIconLock); 881 885 m_iconURLToRecordMap.set(iconURL, newIcon.get()); 882 886 … … 1480 1484 didAnyWork = true; 1481 1485 RefPtr<SharedBuffer> imageData = getImageDataForIconURLFromSQLDatabase(icons[i]->iconURL()); 1486 imageData->setMutexForVerifier(m_urlAndIconLock); 1482 1487 1483 1488 // Verify this icon still wants to be read from disk
Note: See TracChangeset
for help on using the changeset viewer.