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

Side by Side Diff: third_party/WebKit/Source/platform/wtf/Vector.h

Issue 2778993002: HashTable check
Patch Set: fix Created 3 years, 8 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) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // 353 //
354 // Not meant for general consumption. 354 // Not meant for general consumption.
355 355
356 template <typename T, bool hasInlineCapacity, typename Allocator> 356 template <typename T, bool hasInlineCapacity, typename Allocator>
357 class VectorBufferBase { 357 class VectorBufferBase {
358 WTF_MAKE_NONCOPYABLE(VectorBufferBase); 358 WTF_MAKE_NONCOPYABLE(VectorBufferBase);
359 DISALLOW_NEW(); 359 DISALLOW_NEW();
360 360
361 public: 361 public:
362 void allocateBuffer(size_t newCapacity) { 362 void allocateBuffer(size_t newCapacity) {
363 checkCreationThread();
363 DCHECK(newCapacity); 364 DCHECK(newCapacity);
364 DCHECK_LE(newCapacity, 365 DCHECK_LE(newCapacity,
365 Allocator::template maxElementCountInBackingStore<T>()); 366 Allocator::template maxElementCountInBackingStore<T>());
366 size_t sizeToAllocate = allocationSize(newCapacity); 367 size_t sizeToAllocate = allocationSize(newCapacity);
367 if (hasInlineCapacity) 368 if (hasInlineCapacity)
368 m_buffer = 369 m_buffer =
369 Allocator::template allocateInlineVectorBacking<T>(sizeToAllocate); 370 Allocator::template allocateInlineVectorBacking<T>(sizeToAllocate);
370 else 371 else
371 m_buffer = Allocator::template allocateVectorBacking<T>(sizeToAllocate); 372 m_buffer = Allocator::template allocateVectorBacking<T>(sizeToAllocate);
372 m_capacity = sizeToAllocate / sizeof(T); 373 m_capacity = sizeToAllocate / sizeof(T);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 OffsetRange() : begin(0), end(0) {} 419 OffsetRange() : begin(0), end(0) {}
419 explicit OffsetRange(size_t begin, size_t end) : begin(begin), end(end) { 420 explicit OffsetRange(size_t begin, size_t end) : begin(begin), end(end) {
420 DCHECK_LE(begin, end); 421 DCHECK_LE(begin, end);
421 } 422 }
422 bool empty() const { return begin == end; } 423 bool empty() const { return begin == end; }
423 size_t begin; 424 size_t begin;
424 size_t end; 425 size_t end;
425 }; 426 };
426 427
427 protected: 428 protected:
428 VectorBufferBase() : m_buffer(nullptr), m_capacity(0) {} 429 VectorBufferBase() : m_buffer(nullptr), m_capacity(0) {
430 if (Allocator::isGarbageCollected)
431 m_creationThread = currentThread();
432 }
429 433
430 VectorBufferBase(T* buffer, size_t capacity) 434 VectorBufferBase(T* buffer, size_t capacity)
431 : m_buffer(buffer), m_capacity(capacity) {} 435 : m_buffer(buffer), m_capacity(capacity) {
436 if (Allocator::isGarbageCollected)
437 m_creationThread = currentThread();
438 }
439
440 #if DCHECK_IS_ON()
441 void checkCreationThread() const {
442 DCHECK(!Allocator::isGarbageCollected ||
443 m_creationThread == currentThread());
444 }
445 #endif
432 446
433 T* m_buffer; 447 T* m_buffer;
434 unsigned m_capacity; 448 unsigned m_capacity;
435 unsigned m_size; 449 unsigned m_size;
450 #if DCHECK_IS_ON()
451 ThreadIdentifier m_creationThread;
452 #endif
436 }; 453 };
437 454
438 template <typename T, 455 template <typename T,
439 size_t inlineCapacity, 456 size_t inlineCapacity,
440 typename Allocator = PartitionAllocator> 457 typename Allocator = PartitionAllocator>
441 class VectorBuffer; 458 class VectorBuffer;
442 459
443 template <typename T, typename Allocator> 460 template <typename T, typename Allocator>
444 class VectorBuffer<T, 0, Allocator> 461 class VectorBuffer<T, 0, Allocator>
445 : protected VectorBufferBase<T, false, Allocator> { 462 : protected VectorBufferBase<T, false, Allocator> {
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 visitor, *const_cast<T*>(bufferEntry)); 1918 visitor, *const_cast<T*>(bufferEntry));
1902 checkUnusedSlots(buffer() + size(), buffer() + capacity()); 1919 checkUnusedSlots(buffer() + size(), buffer() + capacity());
1903 } 1920 }
1904 } 1921 }
1905 1922
1906 } // namespace WTF 1923 } // namespace WTF
1907 1924
1908 using WTF::Vector; 1925 using WTF::Vector;
1909 1926
1910 #endif // WTF_Vector_h 1927 #endif // WTF_Vector_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/HashTable.h ('k') | third_party/WebKit/Source/wtf/SizeLimits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698