| 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 r
ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 double overheadPercent = (double)totalOverhead / (double)totalDataBytes * 10
0; | 254 double overheadPercent = (double)totalOverhead / (double)totalDataBytes * 10
0; |
| 255 dataLogF(" StringImpl overheader: %8u (%5.2f%%)\n", totalOverhead, o
verheadPercent); | 255 dataLogF(" StringImpl overheader: %8u (%5.2f%%)\n", totalOverhead, o
verheadPercent); |
| 256 | 256 |
| 257 internal::callOnMainThread(&printLiveStringStats, nullptr); | 257 internal::callOnMainThread(&printLiveStringStats, nullptr); |
| 258 } | 258 } |
| 259 #endif | 259 #endif |
| 260 | 260 |
| 261 void* StringImpl::operator new(size_t size) | 261 void* StringImpl::operator new(size_t size) |
| 262 { | 262 { |
| 263 ASSERT(size == sizeof(StringImpl)); | 263 ASSERT(size == sizeof(StringImpl)); |
| 264 return Partitions::bufferMalloc(size, WTF_HEAP_PROFILER_TYPE_NAME(StringImpl
)); | 264 return Partitions::bufferMalloc(size, "WTF::StringImpl"); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void StringImpl::operator delete(void* ptr) | 267 void StringImpl::operator delete(void* ptr) |
| 268 { | 268 { |
| 269 Partitions::bufferFree(ptr); | 269 Partitions::bufferFree(ptr); |
| 270 } | 270 } |
| 271 | 271 |
| 272 inline StringImpl::~StringImpl() | 272 inline StringImpl::~StringImpl() |
| 273 { | 273 { |
| 274 ASSERT(!isStatic()); | 274 ASSERT(!isStatic()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 288 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*&
data) | 288 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*&
data) |
| 289 { | 289 { |
| 290 if (!length) { | 290 if (!length) { |
| 291 data = 0; | 291 data = 0; |
| 292 return empty(); | 292 return empty(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Allocate a single buffer large enough to contain the StringImpl | 295 // Allocate a single buffer large enough to contain the StringImpl |
| 296 // struct as well as the data which it contains. This removes one | 296 // struct as well as the data which it contains. This removes one |
| 297 // heap allocation from this call. | 297 // heap allocation from this call. |
| 298 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferMalloc(alloc
ationSize<LChar>(length), WTF_HEAP_PROFILER_TYPE_NAME(StringImpl))); | 298 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferMalloc(alloc
ationSize<LChar>(length), "WTF::StringImpl")); |
| 299 | 299 |
| 300 data = reinterpret_cast<LChar*>(string + 1); | 300 data = reinterpret_cast<LChar*>(string + 1); |
| 301 return adoptRef(new (string) StringImpl(length, Force8BitConstructor)); | 301 return adoptRef(new (string) StringImpl(length, Force8BitConstructor)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, UChar*&
data) | 304 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, UChar*&
data) |
| 305 { | 305 { |
| 306 if (!length) { | 306 if (!length) { |
| 307 data = 0; | 307 data = 0; |
| 308 return empty(); | 308 return empty(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 // Allocate a single buffer large enough to contain the StringImpl | 311 // Allocate a single buffer large enough to contain the StringImpl |
| 312 // struct as well as the data which it contains. This removes one | 312 // struct as well as the data which it contains. This removes one |
| 313 // heap allocation from this call. | 313 // heap allocation from this call. |
| 314 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferMalloc(alloc
ationSize<UChar>(length), WTF_HEAP_PROFILER_TYPE_NAME(StringImpl))); | 314 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferMalloc(alloc
ationSize<UChar>(length), "WTF::StringImpl")); |
| 315 | 315 |
| 316 data = reinterpret_cast<UChar*>(string + 1); | 316 data = reinterpret_cast<UChar*>(string + 1); |
| 317 return adoptRef(new (string) StringImpl(length)); | 317 return adoptRef(new (string) StringImpl(length)); |
| 318 } | 318 } |
| 319 | 319 |
| 320 static StaticStringsTable& staticStrings() | 320 static StaticStringsTable& staticStrings() |
| 321 { | 321 { |
| 322 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ()); | 322 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ()); |
| 323 return staticStrings; | 323 return staticStrings; |
| 324 } | 324 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 355 return it->value; | 355 return it->value; |
| 356 } | 356 } |
| 357 | 357 |
| 358 // Allocate a single buffer large enough to contain the StringImpl | 358 // Allocate a single buffer large enough to contain the StringImpl |
| 359 // struct as well as the data which it contains. This removes one | 359 // struct as well as the data which it contains. This removes one |
| 360 // heap allocation from this call. | 360 // heap allocation from this call. |
| 361 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str
ingImpl)) / sizeof(LChar))); | 361 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str
ingImpl)) / sizeof(LChar))); |
| 362 size_t size = sizeof(StringImpl) + length * sizeof(LChar); | 362 size_t size = sizeof(StringImpl) + length * sizeof(LChar); |
| 363 | 363 |
| 364 WTF_ANNOTATE_SCOPED_MEMORY_LEAK; | 364 WTF_ANNOTATE_SCOPED_MEMORY_LEAK; |
| 365 StringImpl* impl = static_cast<StringImpl*>(Partitions::bufferMalloc(size, W
TF_HEAP_PROFILER_TYPE_NAME(StringImpl))); | 365 StringImpl* impl = static_cast<StringImpl*>(Partitions::bufferMalloc(size, "
WTF::StringImpl")); |
| 366 | 366 |
| 367 LChar* data = reinterpret_cast<LChar*>(impl + 1); | 367 LChar* data = reinterpret_cast<LChar*>(impl + 1); |
| 368 impl = new (impl) StringImpl(length, hash, StaticString); | 368 impl = new (impl) StringImpl(length, hash, StaticString); |
| 369 memcpy(data, string, length * sizeof(LChar)); | 369 memcpy(data, string, length * sizeof(LChar)); |
| 370 #if ENABLE(ASSERT) | 370 #if ENABLE(ASSERT) |
| 371 impl->assertHashIsCorrect(); | 371 impl->assertHashIsCorrect(); |
| 372 #endif | 372 #endif |
| 373 | 373 |
| 374 ASSERT(isMainThread()); | 374 ASSERT(isMainThread()); |
| 375 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); | 375 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); |
| (...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2109 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
| 2110 // TODO(rob.buis) implement upper-casing rules for lt | 2110 // TODO(rob.buis) implement upper-casing rules for lt |
| 2111 // like in StringImpl::upper(locale). | 2111 // like in StringImpl::upper(locale). |
| 2112 } | 2112 } |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 return toUpper(c); | 2115 return toUpper(c); |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 } // namespace WTF | 2118 } // namespace WTF |
| OLD | NEW |