OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 void GCInfoTable::resize() | 43 void GCInfoTable::resize() |
44 { | 44 { |
45 static const int gcInfoZapValue = 0x33; | 45 static const int gcInfoZapValue = 0x33; |
46 // (Light) experimentation suggests that Blink doesn't need | 46 // (Light) experimentation suggests that Blink doesn't need |
47 // more than this while handling content on popular web properties. | 47 // more than this while handling content on popular web properties. |
48 const size_t initialSize = 512; | 48 const size_t initialSize = 512; |
49 | 49 |
50 size_t newSize = s_gcInfoTableSize ? 2 * s_gcInfoTableSize : initialSize; | 50 size_t newSize = s_gcInfoTableSize ? 2 * s_gcInfoTableSize : initialSize; |
51 ASSERT(newSize < GCInfoTable::maxIndex); | 51 ASSERT(newSize < GCInfoTable::maxIndex); |
52 s_gcInfoTable = reinterpret_cast<GCInfo const**>(realloc(s_gcInfoTable, newS
ize * sizeof(GCInfo))); | 52 s_gcInfoTable = reinterpret_cast<GCInfo const**>(WTF::Partitions::fastReallo
c(s_gcInfoTable, newSize * sizeof(GCInfo), "GCInfo")); |
53 ASSERT(s_gcInfoTable); | 53 ASSERT(s_gcInfoTable); |
54 memset(reinterpret_cast<uint8_t*>(s_gcInfoTable) + s_gcInfoTableSize * sizeo
f(GCInfo), gcInfoZapValue, (newSize - s_gcInfoTableSize) * sizeof(GCInfo)); | 54 memset(reinterpret_cast<uint8_t*>(s_gcInfoTable) + s_gcInfoTableSize * sizeo
f(GCInfo), gcInfoZapValue, (newSize - s_gcInfoTableSize) * sizeof(GCInfo)); |
55 s_gcInfoTableSize = newSize; | 55 s_gcInfoTableSize = newSize; |
56 } | 56 } |
57 | 57 |
58 void GCInfoTable::init() | 58 void GCInfoTable::init() |
59 { | 59 { |
60 RELEASE_ASSERT(!s_gcInfoTable); | 60 RELEASE_ASSERT(!s_gcInfoTable); |
61 resize(); | 61 resize(); |
62 } | 62 } |
63 | 63 |
64 void GCInfoTable::shutdown() | 64 void GCInfoTable::shutdown() |
65 { | 65 { |
66 free(s_gcInfoTable); | 66 WTF::Partitions::fastFree(s_gcInfoTable); |
67 s_gcInfoTable = nullptr; | 67 s_gcInfoTable = nullptr; |
68 } | 68 } |
69 | 69 |
70 #if ENABLE(ASSERT) | 70 #if ENABLE(ASSERT) |
71 void assertObjectHasGCInfo(const void* payload, size_t gcInfoIndex) | 71 void assertObjectHasGCInfo(const void* payload, size_t gcInfoIndex) |
72 { | 72 { |
73 ASSERT(HeapObjectHeader::fromPayload(payload)->checkHeader()); | 73 ASSERT(HeapObjectHeader::fromPayload(payload)->checkHeader()); |
74 #if !defined(COMPONENT_BUILD) | 74 #if !defined(COMPONENT_BUILD) |
75 // On component builds we cannot compare the gcInfos as they are statically | 75 // On component builds we cannot compare the gcInfos as they are statically |
76 // defined in each of the components and hence will not match. | 76 // defined in each of the components and hence will not match. |
77 BasePage* page = pageFromObject(payload); | 77 BasePage* page = pageFromObject(payload); |
78 ASSERT(!page->orphaned()); | 78 ASSERT(!page->orphaned()); |
79 ASSERT(HeapObjectHeader::fromPayload(payload)->gcInfoIndex() == gcInfoIndex)
; | 79 ASSERT(HeapObjectHeader::fromPayload(payload)->gcInfoIndex() == gcInfoIndex)
; |
80 #endif | 80 #endif |
81 } | 81 } |
82 #endif | 82 #endif |
83 | 83 |
84 } // namespace blink | 84 } // namespace blink |
OLD | NEW |