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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 return old_space_->ContainsSlow(address); | 388 return old_space_->ContainsSlow(address); |
389 } | 389 } |
390 | 390 |
391 bool Heap::OldGenerationAllocationLimitReached() { | 391 bool Heap::OldGenerationAllocationLimitReached() { |
392 if (!incremental_marking()->IsStopped()) return false; | 392 if (!incremental_marking()->IsStopped()) return false; |
393 return OldGenerationSpaceAvailable() < 0; | 393 return OldGenerationSpaceAvailable() < 0; |
394 } | 394 } |
395 | 395 |
396 | 396 |
397 bool Heap::ShouldBePromoted(Address old_address, int object_size) { | 397 bool Heap::ShouldBePromoted(Address old_address, int object_size) { |
398 NewSpacePage* page = NewSpacePage::FromAddress(old_address); | 398 Page* page = Page::FromAddress(old_address); |
399 Address age_mark = new_space_.age_mark(); | 399 Address age_mark = new_space_.age_mark(); |
400 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && | 400 return page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK) && |
401 (!page->ContainsLimit(age_mark) || old_address < age_mark); | 401 (!page->ContainsLimit(age_mark) || old_address < age_mark); |
402 } | 402 } |
403 | 403 |
404 void Heap::RecordWrite(Object* object, int offset, Object* o) { | 404 void Heap::RecordWrite(Object* object, int offset, Object* o) { |
405 if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) { | 405 if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) { |
406 return; | 406 return; |
407 } | 407 } |
408 RememberedSet<OLD_TO_NEW>::Insert( | 408 RememberedSet<OLD_TO_NEW>::Insert( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 } | 469 } |
470 | 470 |
471 template <Heap::FindMementoMode mode> | 471 template <Heap::FindMementoMode mode> |
472 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { | 472 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { |
473 // Check if there is potentially a memento behind the object. If | 473 // Check if there is potentially a memento behind the object. If |
474 // the last word of the memento is on another page we return | 474 // the last word of the memento is on another page we return |
475 // immediately. | 475 // immediately. |
476 Address object_address = object->address(); | 476 Address object_address = object->address(); |
477 Address memento_address = object_address + object->Size(); | 477 Address memento_address = object_address + object->Size(); |
478 Address last_memento_word_address = memento_address + kPointerSize; | 478 Address last_memento_word_address = memento_address + kPointerSize; |
479 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) { | 479 if (!Page::OnSamePage(object_address, last_memento_word_address)) { |
480 return nullptr; | 480 return nullptr; |
481 } | 481 } |
482 HeapObject* candidate = HeapObject::FromAddress(memento_address); | 482 HeapObject* candidate = HeapObject::FromAddress(memento_address); |
483 Map* candidate_map = candidate->map(); | 483 Map* candidate_map = candidate->map(); |
484 // This fast check may peek at an uninitialized word. However, the slow check | 484 // This fast check may peek at an uninitialized word. However, the slow check |
485 // below (memento_address == top) ensures that this is safe. Mark the word as | 485 // below (memento_address == top) ensures that this is safe. Mark the word as |
486 // initialized to silence MemorySanitizer warnings. | 486 // initialized to silence MemorySanitizer warnings. |
487 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map)); | 487 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map)); |
488 if (candidate_map != allocation_memento_map()) { | 488 if (candidate_map != allocation_memento_map()) { |
489 return nullptr; | 489 return nullptr; |
490 } | 490 } |
491 AllocationMemento* memento_candidate = AllocationMemento::cast(candidate); | 491 AllocationMemento* memento_candidate = AllocationMemento::cast(candidate); |
492 | 492 |
493 // Depending on what the memento is used for, we might need to perform | 493 // Depending on what the memento is used for, we might need to perform |
494 // additional checks. | 494 // additional checks. |
495 Address top; | 495 Address top; |
496 switch (mode) { | 496 switch (mode) { |
497 case Heap::kForGC: | 497 case Heap::kForGC: |
498 return memento_candidate; | 498 return memento_candidate; |
499 case Heap::kForRuntime: | 499 case Heap::kForRuntime: |
500 if (memento_candidate == nullptr) return nullptr; | 500 if (memento_candidate == nullptr) return nullptr; |
501 // Either the object is the last object in the new space, or there is | 501 // Either the object is the last object in the new space, or there is |
502 // another object of at least word size (the header map word) following | 502 // another object of at least word size (the header map word) following |
503 // it, so suffices to compare ptr and top here. | 503 // it, so suffices to compare ptr and top here. |
504 top = NewSpaceTop(); | 504 top = NewSpaceTop(); |
505 DCHECK(memento_address == top || | 505 DCHECK(memento_address == top || |
506 memento_address + HeapObject::kHeaderSize <= top || | 506 memento_address + HeapObject::kHeaderSize <= top || |
507 !NewSpacePage::OnSamePage(memento_address, top - 1)); | 507 !Page::OnSamePage(memento_address, top - 1)); |
508 if ((memento_address != top) && memento_candidate->IsValid()) { | 508 if ((memento_address != top) && memento_candidate->IsValid()) { |
509 return memento_candidate; | 509 return memento_candidate; |
510 } | 510 } |
511 return nullptr; | 511 return nullptr; |
512 default: | 512 default: |
513 UNREACHABLE(); | 513 UNREACHABLE(); |
514 } | 514 } |
515 UNREACHABLE(); | 515 UNREACHABLE(); |
516 return nullptr; | 516 return nullptr; |
517 } | 517 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 | 742 |
743 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 743 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
744 for (Object** current = start; current < end; current++) { | 744 for (Object** current = start; current < end; current++) { |
745 CHECK((*current)->IsSmi()); | 745 CHECK((*current)->IsSmi()); |
746 } | 746 } |
747 } | 747 } |
748 } // namespace internal | 748 } // namespace internal |
749 } // namespace v8 | 749 } // namespace v8 |
750 | 750 |
751 #endif // V8_HEAP_HEAP_INL_H_ | 751 #endif // V8_HEAP_HEAP_INL_H_ |
OLD | NEW |