| 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 512 |
| 513 bool Heap::OldGenerationAllocationLimitReached() { | 513 bool Heap::OldGenerationAllocationLimitReached() { |
| 514 if (!incremental_marking()->IsStopped() && !ShouldOptimizeForMemoryUsage()) { | 514 if (!incremental_marking()->IsStopped() && !ShouldOptimizeForMemoryUsage()) { |
| 515 return false; | 515 return false; |
| 516 } | 516 } |
| 517 return OldGenerationSpaceAvailable() < 0; | 517 return OldGenerationSpaceAvailable() < 0; |
| 518 } | 518 } |
| 519 | 519 |
| 520 template <PromotionMode promotion_mode> | 520 template <PromotionMode promotion_mode> |
| 521 bool Heap::ShouldBePromoted(Address old_address, int object_size) { | 521 bool Heap::ShouldBePromoted(Address old_address, int object_size) { |
| 522 Page* page = Page::FromAddress(old_address); | |
| 523 Address age_mark = new_space_->age_mark(); | |
| 524 | |
| 525 if (promotion_mode == PROMOTE_MARKED) { | 522 if (promotion_mode == PROMOTE_MARKED) { |
| 526 MarkBit mark_bit = ObjectMarking::MarkBitFrom(old_address); | 523 MarkBit mark_bit = ObjectMarking::MarkBitFrom(old_address); |
| 527 if (!Marking::IsWhite(mark_bit)) { | 524 if (!Marking::IsWhite(mark_bit)) { |
| 528 return true; | 525 return true; |
| 529 } | 526 } |
| 530 } | 527 } |
| 531 | 528 |
| 532 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && | 529 return Page::FromAddress(old_address)->InIntermediateGeneration(); |
| 533 (!page->ContainsLimit(age_mark) || old_address < age_mark); | |
| 534 } | 530 } |
| 535 | 531 |
| 536 PromotionMode Heap::CurrentPromotionMode() { | 532 PromotionMode Heap::CurrentPromotionMode() { |
| 537 if (incremental_marking()->IsMarking()) { | 533 if (incremental_marking()->IsMarking()) { |
| 538 return PROMOTE_MARKED; | 534 return PROMOTE_MARKED; |
| 539 } else { | 535 } else { |
| 540 return DEFAULT_PROMOTION; | 536 return DEFAULT_PROMOTION; |
| 541 } | 537 } |
| 542 } | 538 } |
| 543 | 539 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // below (memento_address == top) ensures that this is safe. Mark the word as | 620 // below (memento_address == top) ensures that this is safe. Mark the word as |
| 625 // initialized to silence MemorySanitizer warnings. | 621 // initialized to silence MemorySanitizer warnings. |
| 626 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map)); | 622 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map)); |
| 627 if (candidate_map != allocation_memento_map()) { | 623 if (candidate_map != allocation_memento_map()) { |
| 628 return nullptr; | 624 return nullptr; |
| 629 } | 625 } |
| 630 | 626 |
| 631 // Bail out if the memento is below the age mark, which can happen when | 627 // Bail out if the memento is below the age mark, which can happen when |
| 632 // mementos survived because a page got moved within new space. | 628 // mementos survived because a page got moved within new space. |
| 633 Page* object_page = Page::FromAddress(object_address); | 629 Page* object_page = Page::FromAddress(object_address); |
| 634 if (object_page->IsFlagSet(Page::NEW_SPACE_BELOW_AGE_MARK)) { | 630 if (object_page->InIntermediateGeneration()) { |
| 635 Address age_mark = | 631 return nullptr; |
| 636 reinterpret_cast<SemiSpace*>(object_page->owner())->age_mark(); | |
| 637 if (!object_page->Contains(age_mark)) { | |
| 638 return nullptr; | |
| 639 } | |
| 640 // Do an exact check in the case where the age mark is on the same page. | |
| 641 if (object_address < age_mark) { | |
| 642 return nullptr; | |
| 643 } | |
| 644 } | 632 } |
| 645 | 633 |
| 646 AllocationMemento* memento_candidate = AllocationMemento::cast(candidate); | 634 AllocationMemento* memento_candidate = AllocationMemento::cast(candidate); |
| 647 | 635 |
| 648 // Depending on what the memento is used for, we might need to perform | 636 // Depending on what the memento is used for, we might need to perform |
| 649 // additional checks. | 637 // additional checks. |
| 650 Address top; | 638 Address top; |
| 651 switch (mode) { | 639 switch (mode) { |
| 652 case Heap::kForGC: | 640 case Heap::kForGC: |
| 653 return memento_candidate; | 641 return memento_candidate; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 | 867 |
| 880 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 868 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
| 881 for (Object** current = start; current < end; current++) { | 869 for (Object** current = start; current < end; current++) { |
| 882 CHECK((*current)->IsSmi()); | 870 CHECK((*current)->IsSmi()); |
| 883 } | 871 } |
| 884 } | 872 } |
| 885 } // namespace internal | 873 } // namespace internal |
| 886 } // namespace v8 | 874 } // namespace v8 |
| 887 | 875 |
| 888 #endif // V8_HEAP_HEAP_INL_H_ | 876 #endif // V8_HEAP_HEAP_INL_H_ |
| OLD | NEW |