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

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

Issue 2753953002: Revert of Un-DCHECK-guard ThreadRestrictionVerifier for strings. (Closed)
Patch Set: 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 // TODO(meade): Revert this by 17 Mar 17. 38 #if DCHECK_IS_ON()
39 // This is for investigating crbug.com/694520
40 // #if DCHECK_IS_ON()
41 #include "wtf/ThreadRestrictionVerifier.h" 39 #include "wtf/ThreadRestrictionVerifier.h"
42 // #endif 40 #endif
43 41
44 #if OS(MACOSX) 42 #if OS(MACOSX)
45 typedef const struct __CFString* CFStringRef; 43 typedef const struct __CFString* CFStringRef;
46 #endif 44 #endif
47 45
48 #ifdef __OBJC__ 46 #ifdef __OBJC__
49 @class NSString; 47 @class NSString;
50 #endif 48 #endif
51 49
52 namespace WTF { 50 namespace WTF {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return m_hash; 300 return m_hash;
303 } 301 }
304 302
305 unsigned hash() const { 303 unsigned hash() const {
306 if (hasHash()) 304 if (hasHash())
307 return existingHash(); 305 return existingHash();
308 return hashSlowCase(); 306 return hashSlowCase();
309 } 307 }
310 308
311 ALWAYS_INLINE bool hasOneRef() const { 309 ALWAYS_INLINE bool hasOneRef() const {
312 // TODO(meade): Revert this by 17 Mar 17. 310 #if DCHECK_IS_ON()
313 // This is for investigating crbug.com/694520 311 DCHECK(isStatic() || m_verifier.isSafeToUse()) << asciiForDebugging();
314 // #if DCHECK_IS_ON() 312 #endif
315 CHECK(isStatic() || m_verifier.isSafeToUse()) << asciiForDebugging();
316 // #endif
317 return m_refCount == 1; 313 return m_refCount == 1;
318 } 314 }
319 315
320 ALWAYS_INLINE void ref() const { 316 ALWAYS_INLINE void ref() const {
321 // TODO(meade): Revert this by 17 Mar 17. 317 #if DCHECK_IS_ON()
322 // This is for investigating crbug.com/694520 318 DCHECK(isStatic() || m_verifier.onRef(m_refCount)) << asciiForDebugging();
323 // #if DCHECK_IS_ON() 319 #endif
324 CHECK(isStatic() || m_verifier.onRef(m_refCount)) << asciiForDebugging();
325 // #endif
326 ++m_refCount; 320 ++m_refCount;
327 } 321 }
328 322
329 ALWAYS_INLINE void deref() const { 323 ALWAYS_INLINE void deref() const {
330 // TODO(meade): Revert this by 17 Mar 17. 324 #if DCHECK_IS_ON()
331 // This is for investigating crbug.com/694520 325 DCHECK(isStatic() || m_verifier.onDeref(m_refCount))
332 // #if DCHECK_IS_ON()
333 CHECK(isStatic() || m_verifier.onDeref(m_refCount))
334 << asciiForDebugging() << " " << currentThread(); 326 << asciiForDebugging() << " " << currentThread();
335 // #endif 327 #endif
336 if (!--m_refCount) 328 if (!--m_refCount)
337 destroyIfNotStatic(); 329 destroyIfNotStatic();
338 } 330 }
339 331
340 // FIXME: Does this really belong in StringImpl? 332 // FIXME: Does this really belong in StringImpl?
341 template <typename T> 333 template <typename T>
342 static void copyChars(T* destination, 334 static void copyChars(T* destination,
343 const T* source, 335 const T* source,
344 unsigned numCharacters) { 336 unsigned numCharacters) {
345 memcpy(destination, source, numCharacters * sizeof(T)); 337 memcpy(destination, source, numCharacters * sizeof(T));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 template <class UCharPredicate> 504 template <class UCharPredicate>
513 PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate); 505 PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate);
514 template <typename CharType, class UCharPredicate> 506 template <typename CharType, class UCharPredicate>
515 PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate, 507 PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate,
516 StripBehavior); 508 StripBehavior);
517 NEVER_INLINE unsigned hashSlowCase() const; 509 NEVER_INLINE unsigned hashSlowCase() const;
518 510
519 void destroyIfNotStatic() const; 511 void destroyIfNotStatic() const;
520 void updateContainsOnlyASCII() const; 512 void updateContainsOnlyASCII() const;
521 513
522 // TODO(meade): Revert this by 17 Mar 17. 514 #if DCHECK_IS_ON()
523 // This is for investigating crbug.com/694520
524 // #if DCHECK_IS_ON()
525 std::string asciiForDebugging() const; 515 std::string asciiForDebugging() const;
526 // #endif 516 #endif
527 517
528 #ifdef STRING_STATS 518 #ifdef STRING_STATS
529 static StringStats m_stringStats; 519 static StringStats m_stringStats;
530 #endif 520 #endif
531 521
532 static unsigned m_highestStaticStringLength; 522 static unsigned m_highestStaticStringLength;
533 523
534 #if DCHECK_IS_ON() 524 #if DCHECK_IS_ON()
535 void assertHashIsCorrect() { 525 void assertHashIsCorrect() {
536 DCHECK(hasHash()); 526 DCHECK(hasHash());
537 DCHECK_EQ(existingHash(), StringHasher::computeHashAndMaskTop8Bits( 527 DCHECK_EQ(existingHash(), StringHasher::computeHashAndMaskTop8Bits(
538 characters8(), length())); 528 characters8(), length()));
539 } 529 }
540 #endif 530 #endif
541 531
542 private: 532 private:
543 // TODO(meade): Revert this by 17 Mar 17. 533 #if DCHECK_IS_ON()
544 // This is for investigating crbug.com/694520
545 // #if DCHECK_IS_ON()
546 mutable ThreadRestrictionVerifier m_verifier; 534 mutable ThreadRestrictionVerifier m_verifier;
547 // #endif 535 #endif
548 mutable unsigned m_refCount; 536 mutable unsigned m_refCount;
549 const unsigned m_length; 537 const unsigned m_length;
550 mutable unsigned m_hash : 24; 538 mutable unsigned m_hash : 24;
551 mutable unsigned m_containsOnlyASCII : 1; 539 mutable unsigned m_containsOnlyASCII : 1;
552 mutable unsigned m_needsASCIICheck : 1; 540 mutable unsigned m_needsASCIICheck : 1;
553 unsigned m_isAtomic : 1; 541 unsigned m_isAtomic : 1;
554 const unsigned m_is8Bit : 1; 542 const unsigned m_is8Bit : 1;
555 const unsigned m_isStatic : 1; 543 const unsigned m_isStatic : 1;
556 }; 544 };
557 545
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 using WTF::TextCaseASCIIInsensitive; 888 using WTF::TextCaseASCIIInsensitive;
901 using WTF::TextCaseUnicodeInsensitive; 889 using WTF::TextCaseUnicodeInsensitive;
902 using WTF::TextCaseSensitive; 890 using WTF::TextCaseSensitive;
903 using WTF::TextCaseSensitivity; 891 using WTF::TextCaseSensitivity;
904 using WTF::equal; 892 using WTF::equal;
905 using WTF::equalNonNull; 893 using WTF::equalNonNull;
906 using WTF::lengthOfNullTerminatedString; 894 using WTF::lengthOfNullTerminatedString;
907 using WTF::reverseFind; 895 using WTF::reverseFind;
908 896
909 #endif 897 #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