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

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

Issue 2819123002: Replace ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/heap (Closed)
Patch Set: fix build error 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/Heap.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 // 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 {
(...skipping 14 matching lines...) Expand all
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 RELEASE_ASSERT(gc_info_index < GCInfoTable::kMaxIndex); 35 CHECK(gc_info_index < GCInfoTable::kMaxIndex);
Hwanseung Lee 2017/04/16 09:59:26 when replace to CHECK_LT, it makes build fail.
sof 2017/04/16 14:33:11 Marking GCInfoTable as |final| would have avoided
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 ASSERT(new_size < GCInfoTable::kMaxIndex);
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 ASSERT(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 RELEASE_ASSERT(!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 ASSERT(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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698