OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_HEAP_INL_H_ | 5 #ifndef V8_HEAP_HEAP_INL_H_ |
6 #define V8_HEAP_HEAP_INL_H_ | 6 #define V8_HEAP_HEAP_INL_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 NewSpacePage* page = NewSpacePage::FromAddress(old_address); | 392 NewSpacePage* page = NewSpacePage::FromAddress(old_address); |
393 Address age_mark = new_space_.age_mark(); | 393 Address age_mark = new_space_.age_mark(); |
394 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && | 394 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && |
395 (!page->ContainsLimit(age_mark) || old_address < age_mark); | 395 (!page->ContainsLimit(age_mark) || old_address < age_mark); |
396 } | 396 } |
397 | 397 |
398 void Heap::RecordWrite(Object* object, int offset, Object* o) { | 398 void Heap::RecordWrite(Object* object, int offset, Object* o) { |
399 if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) { | 399 if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) { |
400 return; | 400 return; |
401 } | 401 } |
402 RememberedSet<OLD_TO_NEW>::Insert( | 402 Page* page = Page::FromAddress(reinterpret_cast<Address>(object)); |
403 Page::FromAddress(reinterpret_cast<Address>(object)), | 403 Address slot = HeapObject::cast(object)->address() + offset; |
404 HeapObject::cast(object)->address() + offset); | 404 RememberedSet<OLD_TO_NEW>::Insert(page, slot); |
405 } | |
406 | |
407 void Heap::RecordFixedArrayElements(FixedArray* array, int offset, int length) { | |
408 if (InNewSpace(array)) return; | |
409 Page* page = Page::FromAddress(reinterpret_cast<Address>(array)); | |
410 for (int i = 0; i < length; i++) { | |
411 if (!InNewSpace(array->get(i))) continue; | |
412 RememberedSet<OLD_TO_NEW>::Insert( | |
413 page, | |
414 reinterpret_cast<Address>(array->RawFieldOfElementAt(offset + i))); | |
415 } | |
416 } | 405 } |
417 | 406 |
418 | 407 |
419 bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) { | 408 bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) { |
420 // Object migration is governed by the following rules: | 409 // Object migration is governed by the following rules: |
421 // | 410 // |
422 // 1) Objects in new-space can be migrated to the old space | 411 // 1) Objects in new-space can be migrated to the old space |
423 // that matches their target space or they stay in new-space. | 412 // that matches their target space or they stay in new-space. |
424 // 2) Objects in old-space stay in the same space when migrating. | 413 // 2) Objects in old-space stay in the same space when migrating. |
425 // 3) Fillers (two or more words) can migrate due to left-trimming of | 414 // 3) Fillers (two or more words) can migrate due to left-trimming of |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 717 |
729 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 718 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
730 for (Object** current = start; current < end; current++) { | 719 for (Object** current = start; current < end; current++) { |
731 CHECK((*current)->IsSmi()); | 720 CHECK((*current)->IsSmi()); |
732 } | 721 } |
733 } | 722 } |
734 } // namespace internal | 723 } // namespace internal |
735 } // namespace v8 | 724 } // namespace v8 |
736 | 725 |
737 #endif // V8_HEAP_HEAP_INL_H_ | 726 #endif // V8_HEAP_HEAP_INL_H_ |
OLD | NEW |