Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringImpl.h

Issue 2743663003: Un-DCHECK-guard ThreadRestrictionVerifier for strings. (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2009 Google Inc. All rights reserved. 5 * Copyright (C) 2009 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 17 matching lines...) Expand all
28 #include "wtf/Forward.h" 28 #include "wtf/Forward.h"
29 #include "wtf/HashMap.h" 29 #include "wtf/HashMap.h"
30 #include "wtf/StringHasher.h" 30 #include "wtf/StringHasher.h"
31 #include "wtf/Vector.h" 31 #include "wtf/Vector.h"
32 #include "wtf/WTFExport.h" 32 #include "wtf/WTFExport.h"
33 #include "wtf/text/ASCIIFastPath.h" 33 #include "wtf/text/ASCIIFastPath.h"
34 #include "wtf/text/Unicode.h" 34 #include "wtf/text/Unicode.h"
35 #include <limits.h> 35 #include <limits.h>
36 #include <string.h> 36 #include <string.h>
37 37
38 #if DCHECK_IS_ON() 38 // TODO(meade): Revert this by 17 Mar 17.
39 // This is for investigating crbug.com/694520
40 // #if DCHECK_IS_ON()
39 #include "wtf/ThreadRestrictionVerifier.h" 41 #include "wtf/ThreadRestrictionVerifier.h"
40 #endif 42 // #endif
41 43
42 #if OS(MACOSX) 44 #if OS(MACOSX)
43 typedef const struct __CFString* CFStringRef; 45 typedef const struct __CFString* CFStringRef;
44 #endif 46 #endif
45 47
46 #ifdef __OBJC__ 48 #ifdef __OBJC__
47 @class NSString; 49 @class NSString;
48 #endif 50 #endif
49 51
50 namespace WTF { 52 namespace WTF {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return m_hash; 302 return m_hash;
301 } 303 }
302 304
303 unsigned hash() const { 305 unsigned hash() const {
304 if (hasHash()) 306 if (hasHash())
305 return existingHash(); 307 return existingHash();
306 return hashSlowCase(); 308 return hashSlowCase();
307 } 309 }
308 310
309 ALWAYS_INLINE bool hasOneRef() const { 311 ALWAYS_INLINE bool hasOneRef() const {
310 #if DCHECK_IS_ON() 312 // TODO(meade): Revert this by 17 Mar 17.
311 DCHECK(isStatic() || m_verifier.isSafeToUse()) << asciiForDebugging(); 313 // This is for investigating crbug.com/694520
312 #endif 314 // #if DCHECK_IS_ON()
315 CHECK(isStatic() || m_verifier.isSafeToUse()) << asciiForDebugging();
316 // #endif
313 return m_refCount == 1; 317 return m_refCount == 1;
314 } 318 }
315 319
316 ALWAYS_INLINE void ref() const { 320 ALWAYS_INLINE void ref() const {
317 #if DCHECK_IS_ON() 321 // TODO(meade): Revert this by 17 Mar 17.
318 DCHECK(isStatic() || m_verifier.onRef(m_refCount)) << asciiForDebugging(); 322 // This is for investigating crbug.com/694520
319 #endif 323 // #if DCHECK_IS_ON()
324 CHECK(isStatic() || m_verifier.onRef(m_refCount)) << asciiForDebugging();
325 // #endif
320 ++m_refCount; 326 ++m_refCount;
321 } 327 }
322 328
323 ALWAYS_INLINE void deref() const { 329 ALWAYS_INLINE void deref() const {
324 #if DCHECK_IS_ON() 330 // TODO(meade): Revert this by 17 Mar 17.
325 DCHECK(isStatic() || m_verifier.onDeref(m_refCount)) 331 // This is for investigating crbug.com/694520
332 // #if DCHECK_IS_ON()
333 CHECK(isStatic() || m_verifier.onDeref(m_refCount))
326 << asciiForDebugging() << " " << currentThread(); 334 << asciiForDebugging() << " " << currentThread();
327 #endif 335 // #endif
328 if (!--m_refCount) 336 if (!--m_refCount)
329 destroyIfNotStatic(); 337 destroyIfNotStatic();
330 } 338 }
331 339
332 // FIXME: Does this really belong in StringImpl? 340 // FIXME: Does this really belong in StringImpl?
333 template <typename T> 341 template <typename T>
334 static void copyChars(T* destination, 342 static void copyChars(T* destination,
335 const T* source, 343 const T* source,
336 unsigned numCharacters) { 344 unsigned numCharacters) {
337 memcpy(destination, source, numCharacters * sizeof(T)); 345 memcpy(destination, source, numCharacters * sizeof(T));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 template <class UCharPredicate> 512 template <class UCharPredicate>
505 PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate); 513 PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate);
506 template <typename CharType, class UCharPredicate> 514 template <typename CharType, class UCharPredicate>
507 PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate, 515 PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate,
508 StripBehavior); 516 StripBehavior);
509 NEVER_INLINE unsigned hashSlowCase() const; 517 NEVER_INLINE unsigned hashSlowCase() const;
510 518
511 void destroyIfNotStatic() const; 519 void destroyIfNotStatic() const;
512 void updateContainsOnlyASCII() const; 520 void updateContainsOnlyASCII() const;
513 521
514 #if DCHECK_IS_ON() 522 // TODO(meade): Revert this by 17 Mar 17.
523 // This is for investigating crbug.com/694520
524 // #if DCHECK_IS_ON()
515 std::string asciiForDebugging() const; 525 std::string asciiForDebugging() const;
516 #endif 526 // #endif
517 527
518 #ifdef STRING_STATS 528 #ifdef STRING_STATS
519 static StringStats m_stringStats; 529 static StringStats m_stringStats;
520 #endif 530 #endif
521 531
522 static unsigned m_highestStaticStringLength; 532 static unsigned m_highestStaticStringLength;
523 533
524 #if DCHECK_IS_ON() 534 #if DCHECK_IS_ON()
525 void assertHashIsCorrect() { 535 void assertHashIsCorrect() {
526 DCHECK(hasHash()); 536 DCHECK(hasHash());
527 DCHECK_EQ(existingHash(), StringHasher::computeHashAndMaskTop8Bits( 537 DCHECK_EQ(existingHash(), StringHasher::computeHashAndMaskTop8Bits(
528 characters8(), length())); 538 characters8(), length()));
529 } 539 }
530 #endif 540 #endif
531 541
532 private: 542 private:
533 #if DCHECK_IS_ON() 543 // TODO(meade): Revert this by 17 Mar 17.
544 // This is for investigating crbug.com/694520
545 // #if DCHECK_IS_ON()
534 mutable ThreadRestrictionVerifier m_verifier; 546 mutable ThreadRestrictionVerifier m_verifier;
535 #endif 547 // #endif
536 mutable unsigned m_refCount; 548 mutable unsigned m_refCount;
537 const unsigned m_length; 549 const unsigned m_length;
538 mutable unsigned m_hash : 24; 550 mutable unsigned m_hash : 24;
539 mutable unsigned m_containsOnlyASCII : 1; 551 mutable unsigned m_containsOnlyASCII : 1;
540 mutable unsigned m_needsASCIICheck : 1; 552 mutable unsigned m_needsASCIICheck : 1;
541 unsigned m_isAtomic : 1; 553 unsigned m_isAtomic : 1;
542 const unsigned m_is8Bit : 1; 554 const unsigned m_is8Bit : 1;
543 const unsigned m_isStatic : 1; 555 const unsigned m_isStatic : 1;
544 }; 556 };
545 557
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 using WTF::TextCaseASCIIInsensitive; 900 using WTF::TextCaseASCIIInsensitive;
889 using WTF::TextCaseUnicodeInsensitive; 901 using WTF::TextCaseUnicodeInsensitive;
890 using WTF::TextCaseSensitive; 902 using WTF::TextCaseSensitive;
891 using WTF::TextCaseSensitivity; 903 using WTF::TextCaseSensitivity;
892 using WTF::equal; 904 using WTF::equal;
893 using WTF::equalNonNull; 905 using WTF::equalNonNull;
894 using WTF::lengthOfNullTerminatedString; 906 using WTF::lengthOfNullTerminatedString;
895 using WTF::reverseFind; 907 using WTF::reverseFind;
896 908
897 #endif 909 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ThreadRestrictionVerifier.h ('k') | third_party/WebKit/Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698