| OLD | NEW |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 using namespace std; | 53 using namespace std; |
| 54 | 54 |
| 55 namespace WTF { | 55 namespace WTF { |
| 56 | 56 |
| 57 using namespace Unicode; | 57 using namespace Unicode; |
| 58 | 58 |
| 59 // As of Jan 2017, StringImpl needs 2 * sizeof(int) + 29 bits of data, and | 59 // As of Jan 2017, StringImpl needs 2 * sizeof(int) + 29 bits of data, and |
| 60 // sizeof(ThreadRestrictionVerifier) is 16 bytes. Thus, in DCHECK mode the | 60 // sizeof(ThreadRestrictionVerifier) is 16 bytes. Thus, in DCHECK mode the |
| 61 // class may be padded to 32 bytes. | 61 // class may be padded to 32 bytes. |
| 62 #if DCHECK_IS_ON() | 62 // TODO(meade): Revert this by 17 Mar 17. |
| 63 // This is for investigating crbug.com/694520 |
| 64 // #if DCHECK_IS_ON() |
| 63 static_assert(sizeof(StringImpl) <= 8 * sizeof(int), | 65 static_assert(sizeof(StringImpl) <= 8 * sizeof(int), |
| 64 "StringImpl should stay small"); | 66 "StringImpl should stay small"); |
| 65 #else | 67 // #else |
| 66 static_assert(sizeof(StringImpl) <= 3 * sizeof(int), | 68 // static_assert(sizeof(StringImpl) <= 3 * sizeof(int), |
| 67 "StringImpl should stay small"); | 69 // "StringImpl should stay small"); |
| 68 #endif | 70 // #endif |
| 69 | 71 |
| 70 #ifdef STRING_STATS | 72 #ifdef STRING_STATS |
| 71 | 73 |
| 72 static Mutex& statsMutex() { | 74 static Mutex& statsMutex() { |
| 73 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); | 75 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); |
| 74 return mutex; | 76 return mutex; |
| 75 } | 77 } |
| 76 | 78 |
| 77 static HashSet<void*>& liveStrings() { | 79 static HashSet<void*>& liveStrings() { |
| 78 // Notice that we can't use HashSet<StringImpl*> because then HashSet would | 80 // Notice that we can't use HashSet<StringImpl*> because then HashSet would |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return true; | 329 return true; |
| 328 // AtomicStrings are not safe to send between threads as ~StringImpl() | 330 // AtomicStrings are not safe to send between threads as ~StringImpl() |
| 329 // will try to remove them from the wrong AtomicStringTable. | 331 // will try to remove them from the wrong AtomicStringTable. |
| 330 if (isAtomic()) | 332 if (isAtomic()) |
| 331 return false; | 333 return false; |
| 332 if (hasOneRef()) | 334 if (hasOneRef()) |
| 333 return true; | 335 return true; |
| 334 return false; | 336 return false; |
| 335 } | 337 } |
| 336 | 338 |
| 337 #if DCHECK_IS_ON() | 339 // TODO(meade): Revert this by 17 Mar 17. |
| 340 // This is for investigating crbug.com/694520 |
| 341 // #if DCHECK_IS_ON() |
| 338 std::string StringImpl::asciiForDebugging() const { | 342 std::string StringImpl::asciiForDebugging() const { |
| 339 CString ascii = String(isolatedCopy()->substring(0, 128)).ascii(); | 343 CString ascii = String(isolatedCopy()->substring(0, 128)).ascii(); |
| 340 return std::string(ascii.data(), ascii.length()); | 344 return std::string(ascii.data(), ascii.length()); |
| 341 } | 345 } |
| 342 #endif | 346 // #endif |
| 343 | 347 |
| 344 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, | 348 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, |
| 345 LChar*& data) { | 349 LChar*& data) { |
| 346 if (!length) { | 350 if (!length) { |
| 347 data = 0; | 351 data = 0; |
| 348 return empty; | 352 return empty; |
| 349 } | 353 } |
| 350 | 354 |
| 351 // Allocate a single buffer large enough to contain the StringImpl | 355 // Allocate a single buffer large enough to contain the StringImpl |
| 352 // struct as well as the data which it contains. This removes one | 356 // struct as well as the data which it contains. This removes one |
| (...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2239 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
| 2236 // TODO(rob.buis) implement upper-casing rules for lt | 2240 // TODO(rob.buis) implement upper-casing rules for lt |
| 2237 // like in StringImpl::upper(locale). | 2241 // like in StringImpl::upper(locale). |
| 2238 } | 2242 } |
| 2239 } | 2243 } |
| 2240 | 2244 |
| 2241 return toUpper(c); | 2245 return toUpper(c); |
| 2242 } | 2246 } |
| 2243 | 2247 |
| 2244 } // namespace WTF | 2248 } // namespace WTF |
| OLD | NEW |