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

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

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/wtf/text/StringImpl.h ('k') | public/web/WebScopedMicrotaskSuppression.h » ('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 * (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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 return adoptRef(new (string) StringImpl(length, Force8BitConstructor)); 334 return adoptRef(new (string) StringImpl(length, Force8BitConstructor));
335 return adoptRef(new (string) StringImpl(length)); 335 return adoptRef(new (string) StringImpl(length));
336 } 336 }
337 337
338 static StaticStringsTable& staticStrings() 338 static StaticStringsTable& staticStrings()
339 { 339 {
340 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ()); 340 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ());
341 return staticStrings; 341 return staticStrings;
342 } 342 }
343 343
344 #ifndef NDEBUG 344 #if ENABLE(ASSERT)
345 static bool s_allowCreationOfStaticStrings = true; 345 static bool s_allowCreationOfStaticStrings = true;
346 #endif 346 #endif
347 347
348 const StaticStringsTable& StringImpl::allStaticStrings() 348 const StaticStringsTable& StringImpl::allStaticStrings()
349 { 349 {
350 return staticStrings(); 350 return staticStrings();
351 } 351 }
352 352
353 void StringImpl::freezeStaticStrings() 353 void StringImpl::freezeStaticStrings()
354 { 354 {
355 ASSERT(isMainThread()); 355 ASSERT(isMainThread());
356 356
357 #ifndef NDEBUG 357 #if ENABLE(ASSERT)
358 s_allowCreationOfStaticStrings = false; 358 s_allowCreationOfStaticStrings = false;
359 #endif 359 #endif
360 } 360 }
361 361
362 unsigned StringImpl::m_highestStaticStringLength = 0; 362 unsigned StringImpl::m_highestStaticStringLength = 0;
363 363
364 StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign ed hash) 364 StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign ed hash)
365 { 365 {
366 ASSERT(s_allowCreationOfStaticStrings); 366 ASSERT(s_allowCreationOfStaticStrings);
367 ASSERT(string); 367 ASSERT(string);
(...skipping 10 matching lines...) Expand all
378 // heap allocation from this call. 378 // heap allocation from this call.
379 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str ingImpl)) / sizeof(LChar))); 379 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str ingImpl)) / sizeof(LChar)));
380 size_t size = sizeof(StringImpl) + length * sizeof(LChar); 380 size_t size = sizeof(StringImpl) + length * sizeof(LChar);
381 381
382 WTF_ANNOTATE_SCOPED_MEMORY_LEAK; 382 WTF_ANNOTATE_SCOPED_MEMORY_LEAK;
383 StringImpl* impl = static_cast<StringImpl*>(partitionAllocGeneric(Partitions ::getBufferPartition(), size)); 383 StringImpl* impl = static_cast<StringImpl*>(partitionAllocGeneric(Partitions ::getBufferPartition(), size));
384 384
385 LChar* data = reinterpret_cast<LChar*>(impl + 1); 385 LChar* data = reinterpret_cast<LChar*>(impl + 1);
386 impl = new (impl) StringImpl(length, hash, StaticString); 386 impl = new (impl) StringImpl(length, hash, StaticString);
387 memcpy(data, string, length * sizeof(LChar)); 387 memcpy(data, string, length * sizeof(LChar));
388 #ifndef NDEBUG 388 #if ENABLE(ASSERT)
389 impl->assertHashIsCorrect(); 389 impl->assertHashIsCorrect();
390 #endif 390 #endif
391 391
392 ASSERT(isMainThread()); 392 ASSERT(isMainThread());
393 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); 393 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length);
394 staticStrings().add(hash, impl); 394 staticStrings().add(hash, impl);
395 WTF_ANNOTATE_BENIGN_RACE(impl, 395 WTF_ANNOTATE_BENIGN_RACE(impl,
396 "Benign race on the reference counter of a static string created by Stri ngImpl::createStatic"); 396 "Benign race on the reference counter of a static string created by Stri ngImpl::createStatic");
397 397
398 return impl; 398 return impl;
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 2099
2100 size_t StringImpl::sizeInBytes() const 2100 size_t StringImpl::sizeInBytes() const
2101 { 2101 {
2102 size_t size = length(); 2102 size_t size = length();
2103 if (!is8Bit()) 2103 if (!is8Bit())
2104 size *= 2; 2104 size *= 2;
2105 return size + sizeof(*this); 2105 return size + sizeof(*this);
2106 } 2106 }
2107 2107
2108 } // namespace WTF 2108 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/text/StringImpl.h ('k') | public/web/WebScopedMicrotaskSuppression.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698