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

Side by Side Diff: third_party/WebKit/Source/platform/heap/GCInfo.cpp

Issue 2816033003: Replace ASSERT with DHCECK_op in platform/heap (Closed)
Patch Set: Replace ASSERT with CHECK_op in platform/heap 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/heap/GCInfo.h" 5 #include "platform/heap/GCInfo.h"
6 6
7 #include "platform/heap/Handle.h" 7 #include "platform/heap/Handle.h"
8 #include "platform/heap/Heap.h" 8 #include "platform/heap/Heap.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 // GCInfo indices start from 1 for heap objects, with 0 being treated 12 // GCInfo indices start from 1 for heap objects, with 0 being treated
13 // specially as the index for freelist entries and large heap objects. 13 // specially as the index for freelist entries and large heap objects.
14 int GCInfoTable::gc_info_index_ = 0; 14 int GCInfoTable::gc_info_index_ = 0;
15 15
16 size_t GCInfoTable::gc_info_table_size_ = 0; 16 size_t GCInfoTable::gc_info_table_size_ = 0;
17 GCInfo const** g_gc_info_table = nullptr; 17 GCInfo const** g_gc_info_table = nullptr;
18 18
19 void GCInfoTable::EnsureGCInfoIndex(const GCInfo* gc_info, 19 void GCInfoTable::EnsureGCInfoIndex(const GCInfo* gc_info,
20 size_t* gc_info_index_slot) { 20 size_t* gc_info_index_slot) {
21 ASSERT(gc_info); 21 DCHECK(gc_info);
22 ASSERT(gc_info_index_slot); 22 DCHECK(gc_info_index_slot);
23 // Keep a global GCInfoTable lock while allocating a new slot. 23 // Keep a global GCInfoTable lock while allocating a new slot.
24 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); 24 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex);
25 MutexLocker locker(mutex); 25 MutexLocker locker(mutex);
26 26
27 // If more than one thread ends up allocating a slot for 27 // If more than one thread ends up allocating a slot for
28 // the same GCInfo, have later threads reuse the slot 28 // the same GCInfo, have later threads reuse the slot
29 // allocated by the first. 29 // allocated by the first.
30 if (*gc_info_index_slot) 30 if (*gc_info_index_slot)
31 return; 31 return;
32 32
33 int index = ++gc_info_index_; 33 int index = ++gc_info_index_;
34 size_t gc_info_index = static_cast<size_t>(index); 34 size_t gc_info_index = static_cast<size_t>(index);
35 CHECK(gc_info_index < GCInfoTable::kMaxIndex); 35 CHECK(gc_info_index < GCInfoTable::kMaxIndex);
36 if (gc_info_index >= gc_info_table_size_) 36 if (gc_info_index >= gc_info_table_size_)
37 Resize(); 37 Resize();
38 38
39 g_gc_info_table[gc_info_index] = gc_info; 39 g_gc_info_table[gc_info_index] = gc_info;
40 ReleaseStore(reinterpret_cast<int*>(gc_info_index_slot), index); 40 ReleaseStore(reinterpret_cast<int*>(gc_info_index_slot), index);
41 } 41 }
42 42
43 void GCInfoTable::Resize() { 43 void GCInfoTable::Resize() {
44 static const int kGcInfoZapValue = 0x33; 44 static const int kGcInfoZapValue = 0x33;
45 // (Light) experimentation suggests that Blink doesn't need 45 // (Light) experimentation suggests that Blink doesn't need
46 // more than this while handling content on popular web properties. 46 // more than this while handling content on popular web properties.
47 const size_t kInitialSize = 512; 47 const size_t kInitialSize = 512;
48 48
49 size_t new_size = 49 size_t new_size =
50 gc_info_table_size_ ? 2 * gc_info_table_size_ : kInitialSize; 50 gc_info_table_size_ ? 2 * gc_info_table_size_ : kInitialSize;
51 ASSERT(new_size < GCInfoTable::kMaxIndex); 51 DCHECK(new_size < GCInfoTable::kMaxIndex);
Hwanseung Lee 2017/04/20 00:30:42 when replaced to DCHECK_LT, it was cause of build
52 g_gc_info_table = 52 g_gc_info_table =
53 reinterpret_cast<GCInfo const**>(WTF::Partitions::FastRealloc( 53 reinterpret_cast<GCInfo const**>(WTF::Partitions::FastRealloc(
54 g_gc_info_table, new_size * sizeof(GCInfo), "GCInfo")); 54 g_gc_info_table, new_size * sizeof(GCInfo), "GCInfo"));
55 ASSERT(g_gc_info_table); 55 DCHECK(g_gc_info_table);
56 memset(reinterpret_cast<uint8_t*>(g_gc_info_table) + 56 memset(reinterpret_cast<uint8_t*>(g_gc_info_table) +
57 gc_info_table_size_ * sizeof(GCInfo), 57 gc_info_table_size_ * sizeof(GCInfo),
58 kGcInfoZapValue, (new_size - gc_info_table_size_) * sizeof(GCInfo)); 58 kGcInfoZapValue, (new_size - gc_info_table_size_) * sizeof(GCInfo));
59 gc_info_table_size_ = new_size; 59 gc_info_table_size_ = new_size;
60 } 60 }
61 61
62 void GCInfoTable::Init() { 62 void GCInfoTable::Init() {
63 CHECK(!g_gc_info_table); 63 CHECK(!g_gc_info_table);
64 Resize(); 64 Resize();
65 } 65 }
66 66
67 #if DCHECK_IS_ON() 67 #if DCHECK_IS_ON()
68 void AssertObjectHasGCInfo(const void* payload, size_t gc_info_index) { 68 void AssertObjectHasGCInfo(const void* payload, size_t gc_info_index) {
69 HeapObjectHeader::CheckFromPayload(payload); 69 HeapObjectHeader::CheckFromPayload(payload);
70 #if !defined(COMPONENT_BUILD) 70 #if !defined(COMPONENT_BUILD)
71 // On component builds we cannot compare the gcInfos as they are statically 71 // On component builds we cannot compare the gcInfos as they are statically
72 // defined in each of the components and hence will not match. 72 // defined in each of the components and hence will not match.
73 ASSERT(HeapObjectHeader::FromPayload(payload)->GcInfoIndex() == 73 DCHECK_EQ(HeapObjectHeader::FromPayload(payload)->GcInfoIndex(),
74 gc_info_index); 74 gc_info_index);
75 #endif 75 #endif
76 } 76 }
77 #endif 77 #endif
78 78
79 } // namespace blink 79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698