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

Side by Side Diff: src/heap/spaces-inl.h

Issue 437993003: Move a bunch of GC related files to heap/ subdirectory (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: make presubmit happy Created 6 years, 4 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 | « src/heap/spaces.cc ('k') | src/heap/sweeper-thread.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project 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 #ifndef V8_SPACES_INL_H_ 5 #ifndef V8_HEAP_SPACES_INL_H_
6 #define V8_SPACES_INL_H_ 6 #define V8_HEAP_SPACES_INL_H_
7 7
8 #include "src/heap/spaces.h"
8 #include "src/heap-profiler.h" 9 #include "src/heap-profiler.h"
9 #include "src/isolate.h" 10 #include "src/isolate.h"
10 #include "src/spaces.h"
11 #include "src/v8memory.h" 11 #include "src/v8memory.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 16
17 // ----------------------------------------------------------------------------- 17 // -----------------------------------------------------------------------------
18 // Bitmap 18 // Bitmap
19 19
20 void Bitmap::Clear(MemoryChunk* chunk) { 20 void Bitmap::Clear(MemoryChunk* chunk) {
21 Bitmap* bitmap = chunk->markbits(); 21 Bitmap* bitmap = chunk->markbits();
22 for (int i = 0; i < bitmap->CellsCount(); i++) bitmap->cells()[i] = 0; 22 for (int i = 0; i < bitmap->CellsCount(); i++) bitmap->cells()[i] = 0;
23 chunk->ResetLiveBytes(); 23 chunk->ResetLiveBytes();
24 } 24 }
25 25
26 26
27 // ----------------------------------------------------------------------------- 27 // -----------------------------------------------------------------------------
28 // PageIterator 28 // PageIterator
29 29
30 30
31 PageIterator::PageIterator(PagedSpace* space) 31 PageIterator::PageIterator(PagedSpace* space)
32 : space_(space), 32 : space_(space),
33 prev_page_(&space->anchor_), 33 prev_page_(&space->anchor_),
34 next_page_(prev_page_->next_page()) { } 34 next_page_(prev_page_->next_page()) {}
35 35
36 36
37 bool PageIterator::has_next() { 37 bool PageIterator::has_next() { return next_page_ != &space_->anchor_; }
38 return next_page_ != &space_->anchor_;
39 }
40 38
41 39
42 Page* PageIterator::next() { 40 Page* PageIterator::next() {
43 DCHECK(has_next()); 41 DCHECK(has_next());
44 prev_page_ = next_page_; 42 prev_page_ = next_page_;
45 next_page_ = next_page_->next_page(); 43 next_page_ = next_page_->next_page();
46 return prev_page_; 44 return prev_page_;
47 } 45 }
48 46
49 47
50 // ----------------------------------------------------------------------------- 48 // -----------------------------------------------------------------------------
51 // NewSpacePageIterator 49 // NewSpacePageIterator
52 50
53 51
54 NewSpacePageIterator::NewSpacePageIterator(NewSpace* space) 52 NewSpacePageIterator::NewSpacePageIterator(NewSpace* space)
55 : prev_page_(NewSpacePage::FromAddress(space->ToSpaceStart())->prev_page()), 53 : prev_page_(NewSpacePage::FromAddress(space->ToSpaceStart())->prev_page()),
56 next_page_(NewSpacePage::FromAddress(space->ToSpaceStart())), 54 next_page_(NewSpacePage::FromAddress(space->ToSpaceStart())),
57 last_page_(NewSpacePage::FromLimit(space->ToSpaceEnd())) { } 55 last_page_(NewSpacePage::FromLimit(space->ToSpaceEnd())) {}
58 56
59 NewSpacePageIterator::NewSpacePageIterator(SemiSpace* space) 57 NewSpacePageIterator::NewSpacePageIterator(SemiSpace* space)
60 : prev_page_(space->anchor()), 58 : prev_page_(space->anchor()),
61 next_page_(prev_page_->next_page()), 59 next_page_(prev_page_->next_page()),
62 last_page_(prev_page_->prev_page()) { } 60 last_page_(prev_page_->prev_page()) {}
63 61
64 NewSpacePageIterator::NewSpacePageIterator(Address start, Address limit) 62 NewSpacePageIterator::NewSpacePageIterator(Address start, Address limit)
65 : prev_page_(NewSpacePage::FromAddress(start)->prev_page()), 63 : prev_page_(NewSpacePage::FromAddress(start)->prev_page()),
66 next_page_(NewSpacePage::FromAddress(start)), 64 next_page_(NewSpacePage::FromAddress(start)),
67 last_page_(NewSpacePage::FromLimit(limit)) { 65 last_page_(NewSpacePage::FromLimit(limit)) {
68 SemiSpace::AssertValidRange(start, limit); 66 SemiSpace::AssertValidRange(start, limit);
69 } 67 }
70 68
71 69
72 bool NewSpacePageIterator::has_next() { 70 bool NewSpacePageIterator::has_next() { return prev_page_ != last_page_; }
73 return prev_page_ != last_page_;
74 }
75 71
76 72
77 NewSpacePage* NewSpacePageIterator::next() { 73 NewSpacePage* NewSpacePageIterator::next() {
78 DCHECK(has_next()); 74 DCHECK(has_next());
79 prev_page_ = next_page_; 75 prev_page_ = next_page_;
80 next_page_ = next_page_->next_page(); 76 next_page_ = next_page_->next_page();
81 return prev_page_; 77 return prev_page_;
82 } 78 }
83 79
84 80
(...skipping 21 matching lines...) Expand all
106 // ----------------------------------------------------------------------------- 102 // -----------------------------------------------------------------------------
107 // MemoryAllocator 103 // MemoryAllocator
108 104
109 #ifdef ENABLE_HEAP_PROTECTION 105 #ifdef ENABLE_HEAP_PROTECTION
110 106
111 void MemoryAllocator::Protect(Address start, size_t size) { 107 void MemoryAllocator::Protect(Address start, size_t size) {
112 base::OS::Protect(start, size); 108 base::OS::Protect(start, size);
113 } 109 }
114 110
115 111
116 void MemoryAllocator::Unprotect(Address start, 112 void MemoryAllocator::Unprotect(Address start, size_t size,
117 size_t size,
118 Executability executable) { 113 Executability executable) {
119 base::OS::Unprotect(start, size, executable); 114 base::OS::Unprotect(start, size, executable);
120 } 115 }
121 116
122 117
123 void MemoryAllocator::ProtectChunkFromPage(Page* page) { 118 void MemoryAllocator::ProtectChunkFromPage(Page* page) {
124 int id = GetChunkId(page); 119 int id = GetChunkId(page);
125 base::OS::Protect(chunks_[id].address(), chunks_[id].size()); 120 base::OS::Protect(chunks_[id].address(), chunks_[id].size());
126 } 121 }
127 122
128 123
129 void MemoryAllocator::UnprotectChunkFromPage(Page* page) { 124 void MemoryAllocator::UnprotectChunkFromPage(Page* page) {
130 int id = GetChunkId(page); 125 int id = GetChunkId(page);
131 base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(), 126 base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(),
132 chunks_[id].owner()->executable() == EXECUTABLE); 127 chunks_[id].owner()->executable() == EXECUTABLE);
133 } 128 }
134 129
135 #endif 130 #endif
136 131
137 132
138 // -------------------------------------------------------------------------- 133 // --------------------------------------------------------------------------
139 // PagedSpace 134 // PagedSpace
140 Page* Page::Initialize(Heap* heap, 135 Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable,
141 MemoryChunk* chunk,
142 Executability executable,
143 PagedSpace* owner) { 136 PagedSpace* owner) {
144 Page* page = reinterpret_cast<Page*>(chunk); 137 Page* page = reinterpret_cast<Page*>(chunk);
145 DCHECK(page->area_size() <= kMaxRegularHeapObjectSize); 138 DCHECK(page->area_size() <= kMaxRegularHeapObjectSize);
146 DCHECK(chunk->owner() == owner); 139 DCHECK(chunk->owner() == owner);
147 owner->IncreaseCapacity(page->area_size()); 140 owner->IncreaseCapacity(page->area_size());
148 owner->Free(page->area_start(), page->area_size()); 141 owner->Free(page->area_start(), page->area_size());
149 142
150 heap->incremental_marking()->SetOldSpacePageFlags(chunk); 143 heap->incremental_marking()->SetOldSpacePageFlags(chunk);
151 144
152 return page; 145 return page;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (new_mark > chunk->high_water_mark_) { 195 if (new_mark > chunk->high_water_mark_) {
203 chunk->high_water_mark_ = new_mark; 196 chunk->high_water_mark_ = new_mark;
204 } 197 }
205 } 198 }
206 199
207 200
208 PointerChunkIterator::PointerChunkIterator(Heap* heap) 201 PointerChunkIterator::PointerChunkIterator(Heap* heap)
209 : state_(kOldPointerState), 202 : state_(kOldPointerState),
210 old_pointer_iterator_(heap->old_pointer_space()), 203 old_pointer_iterator_(heap->old_pointer_space()),
211 map_iterator_(heap->map_space()), 204 map_iterator_(heap->map_space()),
212 lo_iterator_(heap->lo_space()) { } 205 lo_iterator_(heap->lo_space()) {}
213 206
214 207
215 Page* Page::next_page() { 208 Page* Page::next_page() {
216 DCHECK(next_chunk()->owner() == owner()); 209 DCHECK(next_chunk()->owner() == owner());
217 return static_cast<Page*>(next_chunk()); 210 return static_cast<Page*>(next_chunk());
218 } 211 }
219 212
220 213
221 Page* Page::prev_page() { 214 Page* Page::prev_page() {
222 DCHECK(prev_chunk()->owner() == owner()); 215 DCHECK(prev_chunk()->owner() == owner());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 291
299 292
300 intptr_t LargeObjectSpace::Available() { 293 intptr_t LargeObjectSpace::Available() {
301 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available()); 294 return ObjectSizeFor(heap()->isolate()->memory_allocator()->Available());
302 } 295 }
303 296
304 297
305 bool FreeListNode::IsFreeListNode(HeapObject* object) { 298 bool FreeListNode::IsFreeListNode(HeapObject* object) {
306 Map* map = object->map(); 299 Map* map = object->map();
307 Heap* heap = object->GetHeap(); 300 Heap* heap = object->GetHeap();
308 return map == heap->raw_unchecked_free_space_map() 301 return map == heap->raw_unchecked_free_space_map() ||
309 || map == heap->raw_unchecked_one_pointer_filler_map() 302 map == heap->raw_unchecked_one_pointer_filler_map() ||
310 || map == heap->raw_unchecked_two_pointer_filler_map(); 303 map == heap->raw_unchecked_two_pointer_filler_map();
311 } 304 }
305 }
306 } // namespace v8::internal
312 307
313 } } // namespace v8::internal 308 #endif // V8_HEAP_SPACES_INL_H_
314
315 #endif // V8_SPACES_INL_H_
OLDNEW
« no previous file with comments | « src/heap/spaces.cc ('k') | src/heap/sweeper-thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698