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

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

Issue 2624443003: Enable ThreadRestrictionVerifier for StringImpl (Closed)
Patch Set: rebase on TLS CL (inc. asan errors) Created 3 years, 11 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 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) 4 * (C) 2001 Dirk Mueller ( mueller@kde.org )
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 7 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 14 matching lines...) Expand all
25 25
26 #include "wtf/text/StringImpl.h" 26 #include "wtf/text/StringImpl.h"
27 27
28 #include "wtf/DynamicAnnotations.h" 28 #include "wtf/DynamicAnnotations.h"
29 #include "wtf/LeakAnnotations.h" 29 #include "wtf/LeakAnnotations.h"
30 #include "wtf/PtrUtil.h" 30 #include "wtf/PtrUtil.h"
31 #include "wtf/StdLibExtras.h" 31 #include "wtf/StdLibExtras.h"
32 #include "wtf/allocator/Partitions.h" 32 #include "wtf/allocator/Partitions.h"
33 #include "wtf/text/AtomicString.h" 33 #include "wtf/text/AtomicString.h"
34 #include "wtf/text/AtomicStringTable.h" 34 #include "wtf/text/AtomicStringTable.h"
35 #include "wtf/text/CString.h"
35 #include "wtf/text/CharacterNames.h" 36 #include "wtf/text/CharacterNames.h"
36 #include "wtf/text/StringBuffer.h" 37 #include "wtf/text/StringBuffer.h"
37 #include "wtf/text/StringHash.h" 38 #include "wtf/text/StringHash.h"
38 #include "wtf/text/StringToNumber.h" 39 #include "wtf/text/StringToNumber.h"
39 #include <algorithm> 40 #include <algorithm>
40 #include <memory> 41 #include <memory>
41 42
42 #ifdef STRING_STATS 43 #ifdef STRING_STATS
43 #include "wtf/DataLog.h" 44 #include "wtf/DataLog.h"
44 #include "wtf/HashMap.h" 45 #include "wtf/HashMap.h"
45 #include "wtf/HashSet.h" 46 #include "wtf/HashSet.h"
46 #include "wtf/RefCounted.h" 47 #include "wtf/RefCounted.h"
47 #include "wtf/ThreadingPrimitives.h" 48 #include "wtf/ThreadingPrimitives.h"
48 #include <unistd.h> 49 #include <unistd.h>
49 #endif 50 #endif
50 51
51 using namespace std; 52 using namespace std;
52 53
53 namespace WTF { 54 namespace WTF {
54 55
55 using namespace Unicode; 56 using namespace Unicode;
56 57
58 #if !DCHECK_IS_ON()
57 static_assert(sizeof(StringImpl) == 3 * sizeof(int), 59 static_assert(sizeof(StringImpl) == 3 * sizeof(int),
58 "StringImpl should stay small"); 60 "StringImpl should stay small");
61 #endif
59 62
60 #ifdef STRING_STATS 63 #ifdef STRING_STATS
61 64
62 static Mutex& statsMutex() { 65 static Mutex& statsMutex() {
63 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); 66 DEFINE_STATIC_LOCAL(Mutex, mutex, ());
64 return mutex; 67 return mutex;
65 } 68 }
66 69
67 static HashSet<void*>& liveStrings() { 70 static HashSet<void*>& liveStrings() {
68 // Notice that we can't use HashSet<StringImpl*> because then HashSet would 71 // Notice that we can't use HashSet<StringImpl*> because then HashSet would
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return true; 320 return true;
318 // AtomicStrings are not safe to send between threads as ~StringImpl() 321 // AtomicStrings are not safe to send between threads as ~StringImpl()
319 // will try to remove them from the wrong AtomicStringTable. 322 // will try to remove them from the wrong AtomicStringTable.
320 if (isAtomic()) 323 if (isAtomic())
321 return false; 324 return false;
322 if (hasOneRef()) 325 if (hasOneRef())
323 return true; 326 return true;
324 return false; 327 return false;
325 } 328 }
326 329
330 #if DCHECK_IS_ON()
331 std::string StringImpl::asciiForDebugging() const {
332 CString ascii = String(this->isolatedCopy()).left(128).ascii();
esprehn 2017/01/12 23:00:00 just use substring, that's all left() does anyway:
Charlie Harrison 2017/01/13 17:42:25 substring is not const because it can ref |this| (
333 return std::string(ascii.data(), ascii.length());
334 }
335 #endif
336
327 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, 337 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length,
328 LChar*& data) { 338 LChar*& data) {
329 if (!length) { 339 if (!length) {
330 data = 0; 340 data = 0;
331 return empty(); 341 return empty();
332 } 342 }
333 343
334 // Allocate a single buffer large enough to contain the StringImpl 344 // Allocate a single buffer large enough to contain the StringImpl
335 // struct as well as the data which it contains. This removes one 345 // struct as well as the data which it contains. This removes one
336 // heap allocation from this call. 346 // heap allocation from this call.
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2187 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2178 // TODO(rob.buis) implement upper-casing rules for lt 2188 // TODO(rob.buis) implement upper-casing rules for lt
2179 // like in StringImpl::upper(locale). 2189 // like in StringImpl::upper(locale).
2180 } 2190 }
2181 } 2191 }
2182 2192
2183 return toUpper(c); 2193 return toUpper(c);
2184 } 2194 }
2185 2195
2186 } // namespace WTF 2196 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698