| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool PagedSpace::Contains(Object* o) { | 291 bool PagedSpace::Contains(Object* o) { |
| 292 if (!o->IsHeapObject()) return false; | 292 if (!o->IsHeapObject()) return false; |
| 293 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); | 293 Page* p = Page::FromAddress(HeapObject::cast(o)->address()); |
| 294 if (!p->is_valid()) return false; | 294 if (!p->is_valid()) return false; |
| 295 return p->owner() == this; | 295 return p->owner() == this; |
| 296 } | 296 } |
| 297 | 297 |
| 298 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Heap* heap, Address addr) { | 298 MemoryChunk* MemoryChunk::FromAnyPointerAddress(Heap* heap, Address addr) { |
| 299 MemoryChunk* maybe = reinterpret_cast<MemoryChunk*>( | 299 MemoryChunk* chunk = MemoryChunk::FromAddress(addr); |
| 300 OffsetFrom(addr) & ~Page::kPageAlignmentMask); | 300 uintptr_t offset = addr - chunk->address(); |
| 301 if (maybe->owner() != NULL) return maybe; | 301 if (offset < MemoryChunk::kHeaderSize || !chunk->HasPageHeader()) { |
| 302 LargeObjectIterator iterator(heap->lo_space()); | 302 chunk = heap->lo_space()->FindPage(addr); |
| 303 for (HeapObject* o = iterator.Next(); o != NULL; o = iterator.Next()) { | |
| 304 // Fixed arrays are the only pointer-containing objects in large object | |
| 305 // space. | |
| 306 if (o->IsFixedArray()) { | |
| 307 MemoryChunk* chunk = MemoryChunk::FromAddress(o->address()); | |
| 308 if (chunk->Contains(addr)) { | |
| 309 return chunk; | |
| 310 } | |
| 311 } | |
| 312 } | 303 } |
| 313 UNREACHABLE(); | 304 return chunk; |
| 314 return NULL; | 305 } |
| 306 |
| 307 Page* Page::FromAnyPointerAddress(Heap* heap, Address addr) { |
| 308 return static_cast<Page*>(MemoryChunk::FromAnyPointerAddress(heap, addr)); |
| 315 } | 309 } |
| 316 | 310 |
| 317 | 311 |
| 318 PointerChunkIterator::PointerChunkIterator(Heap* heap) | 312 PointerChunkIterator::PointerChunkIterator(Heap* heap) |
| 319 : state_(kOldSpaceState), | 313 : state_(kOldSpaceState), |
| 320 old_iterator_(heap->old_space()), | 314 old_iterator_(heap->old_space()), |
| 321 map_iterator_(heap->map_space()), | 315 map_iterator_(heap->map_space()), |
| 322 lo_iterator_(heap->lo_space()) {} | 316 lo_iterator_(heap->lo_space()) {} |
| 323 | 317 |
| 324 | 318 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 other->allocation_info_.Reset(nullptr, nullptr); | 611 other->allocation_info_.Reset(nullptr, nullptr); |
| 618 return true; | 612 return true; |
| 619 } | 613 } |
| 620 return false; | 614 return false; |
| 621 } | 615 } |
| 622 | 616 |
| 623 } // namespace internal | 617 } // namespace internal |
| 624 } // namespace v8 | 618 } // namespace v8 |
| 625 | 619 |
| 626 #endif // V8_HEAP_SPACES_INL_H_ | 620 #endif // V8_HEAP_SPACES_INL_H_ |
| OLD | NEW |