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

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

Issue 751553004: CL for perf tryjob ThreadSafeRefCountedStringImpl Linux blink_perf.dom Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | Tools/run-perf-test.cfg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 reserved. 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * Copyright (C) 2009 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef StringImpl_h 23 #ifndef StringImpl_h
24 #define StringImpl_h 24 #define StringImpl_h
25 25
26 #include <limits.h> 26 #include <limits.h>
27 #include "wtf/ASCIICType.h" 27 #include "wtf/ASCIICType.h"
28 #include "wtf/DynamicAnnotations.h"
28 #include "wtf/Forward.h" 29 #include "wtf/Forward.h"
29 #include "wtf/HashMap.h" 30 #include "wtf/HashMap.h"
30 #include "wtf/StringHasher.h" 31 #include "wtf/StringHasher.h"
31 #include "wtf/Vector.h" 32 #include "wtf/Vector.h"
32 #include "wtf/WTFExport.h" 33 #include "wtf/WTFExport.h"
33 #include "wtf/unicode/Unicode.h" 34 #include "wtf/unicode/Unicode.h"
34 35
35 #if USE(CF) 36 #if USE(CF)
36 typedef const struct __CFString * CFStringRef; 37 typedef const struct __CFString * CFStringRef;
37 #endif 38 #endif
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return rawHash(); 277 return rawHash();
277 } 278 }
278 279
279 unsigned hash() const 280 unsigned hash() const
280 { 281 {
281 if (hasHash()) 282 if (hasHash())
282 return existingHash(); 283 return existingHash();
283 return hashSlowCase(); 284 return hashSlowCase();
284 } 285 }
285 286
287 ALWAYS_INLINE unsigned refCount() const
288 {
289 return static_cast<int const volatile &>(m_refCount);
290 }
291
286 ALWAYS_INLINE bool hasOneRef() const 292 ALWAYS_INLINE bool hasOneRef() const
287 { 293 {
288 return m_refCount == 1; 294 return refCount() == 1;
289 } 295 }
290 296
291 ALWAYS_INLINE void ref() 297 ALWAYS_INLINE void ref()
292 { 298 {
293 ++m_refCount; 299 atomicIncrement(&m_refCount);
294 } 300 }
295 301
296 ALWAYS_INLINE void deref() 302 ALWAYS_INLINE void deref()
297 { 303 {
298 if (hasOneRef()) { 304 WTF_ANNOTATE_HAPPENS_BEFORE(&m_refCount);
305 if (atomicDecrement(&m_refCount) <= 0) {
306 WTF_ANNOTATE_HAPPENS_AFTER(&m_refCount);
Alexander Potapenko 2014/12/08 11:46:57 Please do not use WTF_ANNOTATE_HAPPENS_AFTER. They
299 destroyIfNotStatic(); 307 destroyIfNotStatic();
300 return;
301 } 308 }
302
303 --m_refCount;
304 } 309 }
305 310
306 static StringImpl* empty(); 311 static StringImpl* empty();
307 static StringImpl* empty16Bit(); 312 static StringImpl* empty16Bit();
308 313
309 // FIXME: Does this really belong in StringImpl? 314 // FIXME: Does this really belong in StringImpl?
310 template <typename T> static void copyChars(T* destination, const T* source, unsigned numCharacters) 315 template <typename T> static void copyChars(T* destination, const T* source, unsigned numCharacters)
311 { 316 {
312 memcpy(destination, source, numCharacters * sizeof(T)); 317 memcpy(destination, source, numCharacters * sizeof(T));
313 } 318 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 446
442 #if ENABLE(ASSERT) 447 #if ENABLE(ASSERT)
443 void assertHashIsCorrect() 448 void assertHashIsCorrect()
444 { 449 {
445 ASSERT(hasHash()); 450 ASSERT(hasHash());
446 ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(charac ters8(), length())); 451 ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(charac ters8(), length()));
447 } 452 }
448 #endif 453 #endif
449 454
450 private: 455 private:
451 unsigned m_refCount; 456 int m_refCount;
452 unsigned m_length; 457 unsigned m_length;
453 mutable unsigned m_hash : 24; 458 mutable unsigned m_hash : 24;
454 unsigned m_isAtomic : 1; 459 unsigned m_isAtomic : 1;
455 unsigned m_is8Bit : 1; 460 unsigned m_is8Bit : 1;
456 unsigned m_isStatic : 1; 461 unsigned m_isStatic : 1;
457 }; 462 };
458 463
459 template <> 464 template <>
460 ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return cha racters8(); } 465 ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return cha racters8(); }
461 466
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 } 748 }
744 749
745 using WTF::StringImpl; 750 using WTF::StringImpl;
746 using WTF::equal; 751 using WTF::equal;
747 using WTF::equalNonNull; 752 using WTF::equalNonNull;
748 using WTF::TextCaseSensitivity; 753 using WTF::TextCaseSensitivity;
749 using WTF::TextCaseSensitive; 754 using WTF::TextCaseSensitive;
750 using WTF::TextCaseInsensitive; 755 using WTF::TextCaseInsensitive;
751 756
752 #endif 757 #endif
OLDNEW
« no previous file with comments | « no previous file | Tools/run-perf-test.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698