OLD | NEW |
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_HEAP_SPACES_INL_H_ | 5 #ifndef V8_HEAP_SPACES_INL_H_ |
6 #define V8_HEAP_SPACES_INL_H_ | 6 #define V8_HEAP_SPACES_INL_H_ |
7 | 7 |
8 #include "src/heap/incremental-marking.h" | 8 #include "src/heap/incremental-marking.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 | 172 |
173 void MemoryAllocator::UnprotectChunkFromPage(Page* page) { | 173 void MemoryAllocator::UnprotectChunkFromPage(Page* page) { |
174 int id = GetChunkId(page); | 174 int id = GetChunkId(page); |
175 base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(), | 175 base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(), |
176 chunks_[id].owner()->executable() == EXECUTABLE); | 176 chunks_[id].owner()->executable() == EXECUTABLE); |
177 } | 177 } |
178 | 178 |
179 #endif | 179 #endif |
180 | 180 |
| 181 // ----------------------------------------------------------------------------- |
| 182 // SemiSpace |
| 183 |
| 184 bool SemiSpace::Contains(HeapObject* o) { |
| 185 return id_ == kToSpace |
| 186 ? MemoryChunk::FromAddress(o->address())->InToSpace() |
| 187 : MemoryChunk::FromAddress(o->address())->InFromSpace(); |
| 188 } |
| 189 |
| 190 bool SemiSpace::Contains(Object* o) { |
| 191 return o->IsHeapObject() && Contains(HeapObject::cast(o)); |
| 192 } |
| 193 |
| 194 bool SemiSpace::ContainsSlow(Address a) { |
| 195 NewSpacePageIterator it(this); |
| 196 while (it.has_next()) { |
| 197 if (it.next() == MemoryChunk::FromAddress(a)) return true; |
| 198 } |
| 199 return false; |
| 200 } |
| 201 |
| 202 // -------------------------------------------------------------------------- |
| 203 // NewSpace |
| 204 |
| 205 bool NewSpace::Contains(HeapObject* o) { |
| 206 return MemoryChunk::FromAddress(o->address())->InNewSpace(); |
| 207 } |
| 208 |
| 209 bool NewSpace::Contains(Object* o) { |
| 210 return o->IsHeapObject() && Contains(HeapObject::cast(o)); |
| 211 } |
| 212 |
| 213 bool NewSpace::ContainsSlow(Address a) { |
| 214 return from_space_.ContainsSlow(a) || to_space_.ContainsSlow(a); |
| 215 } |
| 216 |
| 217 bool NewSpace::ToSpaceContainsSlow(Address a) { |
| 218 return to_space_.ContainsSlow(a); |
| 219 } |
| 220 |
| 221 bool NewSpace::FromSpaceContainsSlow(Address a) { |
| 222 return from_space_.ContainsSlow(a); |
| 223 } |
| 224 |
| 225 bool NewSpace::ToSpaceContains(Object* o) { return to_space_.Contains(o); } |
| 226 bool NewSpace::FromSpaceContains(Object* o) { return from_space_.Contains(o); } |
181 | 227 |
182 // -------------------------------------------------------------------------- | 228 // -------------------------------------------------------------------------- |
183 // AllocationResult | 229 // AllocationResult |
184 | 230 |
185 AllocationSpace AllocationResult::RetrySpace() { | 231 AllocationSpace AllocationResult::RetrySpace() { |
186 DCHECK(IsRetry()); | 232 DCHECK(IsRetry()); |
187 return static_cast<AllocationSpace>(Smi::cast(object_)->value()); | 233 return static_cast<AllocationSpace>(Smi::cast(object_)->value()); |
188 } | 234 } |
189 | 235 |
190 | 236 |
(...skipping 14 matching lines...) Expand all Loading... |
205 return page; | 251 return page; |
206 } | 252 } |
207 | 253 |
208 | 254 |
209 bool PagedSpace::Contains(Address addr) { | 255 bool PagedSpace::Contains(Address addr) { |
210 Page* p = Page::FromAddress(addr); | 256 Page* p = Page::FromAddress(addr); |
211 if (!p->is_valid()) return false; | 257 if (!p->is_valid()) return false; |
212 return p->owner() == this; | 258 return p->owner() == this; |
213 } | 259 } |
214 | 260 |
215 | 261 bool PagedSpace::Contains(Object* o) { |
216 bool PagedSpace::Contains(HeapObject* o) { return Contains(o->address()); } | 262 if (!o->IsHeapObject()) return false; |
217 | 263 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); |
| 264 if (!p->is_valid()) return false; |
| 265 return p->owner() == this; |
| 266 } |
218 | 267 |
219 void MemoryChunk::set_scan_on_scavenge(bool scan) { | 268 void MemoryChunk::set_scan_on_scavenge(bool scan) { |
220 if (scan) { | 269 if (scan) { |
221 if (!scan_on_scavenge()) heap_->increment_scan_on_scavenge_pages(); | 270 if (!scan_on_scavenge()) heap_->increment_scan_on_scavenge_pages(); |
222 SetFlag(SCAN_ON_SCAVENGE); | 271 SetFlag(SCAN_ON_SCAVENGE); |
223 } else { | 272 } else { |
224 if (scan_on_scavenge()) heap_->decrement_scan_on_scavenge_pages(); | 273 if (scan_on_scavenge()) heap_->decrement_scan_on_scavenge_pages(); |
225 ClearFlag(SCAN_ON_SCAVENGE); | 274 ClearFlag(SCAN_ON_SCAVENGE); |
226 } | 275 } |
227 heap_->incremental_marking()->SetOldSpacePageFlags(this); | 276 heap_->incremental_marking()->SetOldSpacePageFlags(this); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 other->allocation_info_.Reset(nullptr, nullptr); | 593 other->allocation_info_.Reset(nullptr, nullptr); |
545 return true; | 594 return true; |
546 } | 595 } |
547 return false; | 596 return false; |
548 } | 597 } |
549 | 598 |
550 } // namespace internal | 599 } // namespace internal |
551 } // namespace v8 | 600 } // namespace v8 |
552 | 601 |
553 #endif // V8_HEAP_SPACES_INL_H_ | 602 #endif // V8_HEAP_SPACES_INL_H_ |
OLD | NEW |