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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 return nullptr; | 519 return nullptr; |
520 default: | 520 default: |
521 UNREACHABLE(); | 521 UNREACHABLE(); |
522 } | 522 } |
523 UNREACHABLE(); | 523 UNREACHABLE(); |
524 return nullptr; | 524 return nullptr; |
525 } | 525 } |
526 | 526 |
527 template <Heap::UpdateAllocationSiteMode mode> | 527 template <Heap::UpdateAllocationSiteMode mode> |
528 void Heap::UpdateAllocationSite(HeapObject* object, | 528 void Heap::UpdateAllocationSite(HeapObject* object, |
529 HashMap* pretenuring_feedback) { | 529 base::HashMap* pretenuring_feedback) { |
530 DCHECK(InFromSpace(object)); | 530 DCHECK(InFromSpace(object)); |
531 if (!FLAG_allocation_site_pretenuring || | 531 if (!FLAG_allocation_site_pretenuring || |
532 !AllocationSite::CanTrack(object->map()->instance_type())) | 532 !AllocationSite::CanTrack(object->map()->instance_type())) |
533 return; | 533 return; |
534 AllocationMemento* memento_candidate = FindAllocationMemento<kForGC>(object); | 534 AllocationMemento* memento_candidate = FindAllocationMemento<kForGC>(object); |
535 if (memento_candidate == nullptr) return; | 535 if (memento_candidate == nullptr) return; |
536 | 536 |
537 if (mode == kGlobal) { | 537 if (mode == kGlobal) { |
538 DCHECK_EQ(pretenuring_feedback, global_pretenuring_feedback_); | 538 DCHECK_EQ(pretenuring_feedback, global_pretenuring_feedback_); |
539 // Entering global pretenuring feedback is only used in the scavenger, where | 539 // Entering global pretenuring feedback is only used in the scavenger, where |
540 // we are allowed to actually touch the allocation site. | 540 // we are allowed to actually touch the allocation site. |
541 if (!memento_candidate->IsValid()) return; | 541 if (!memento_candidate->IsValid()) return; |
542 AllocationSite* site = memento_candidate->GetAllocationSite(); | 542 AllocationSite* site = memento_candidate->GetAllocationSite(); |
543 DCHECK(!site->IsZombie()); | 543 DCHECK(!site->IsZombie()); |
544 // For inserting in the global pretenuring storage we need to first | 544 // For inserting in the global pretenuring storage we need to first |
545 // increment the memento found count on the allocation site. | 545 // increment the memento found count on the allocation site. |
546 if (site->IncrementMementoFoundCount()) { | 546 if (site->IncrementMementoFoundCount()) { |
547 global_pretenuring_feedback_->LookupOrInsert(site, | 547 global_pretenuring_feedback_->LookupOrInsert(site, |
548 ObjectHash(site->address())); | 548 ObjectHash(site->address())); |
549 } | 549 } |
550 } else { | 550 } else { |
551 DCHECK_EQ(mode, kCached); | 551 DCHECK_EQ(mode, kCached); |
552 DCHECK_NE(pretenuring_feedback, global_pretenuring_feedback_); | 552 DCHECK_NE(pretenuring_feedback, global_pretenuring_feedback_); |
553 // Entering cached feedback is used in the parallel case. We are not allowed | 553 // Entering cached feedback is used in the parallel case. We are not allowed |
554 // to dereference the allocation site and rather have to postpone all checks | 554 // to dereference the allocation site and rather have to postpone all checks |
555 // till actually merging the data. | 555 // till actually merging the data. |
556 Address key = memento_candidate->GetAllocationSiteUnchecked(); | 556 Address key = memento_candidate->GetAllocationSiteUnchecked(); |
557 HashMap::Entry* e = | 557 base::HashMap::Entry* e = |
558 pretenuring_feedback->LookupOrInsert(key, ObjectHash(key)); | 558 pretenuring_feedback->LookupOrInsert(key, ObjectHash(key)); |
559 DCHECK(e != nullptr); | 559 DCHECK(e != nullptr); |
560 (*bit_cast<intptr_t*>(&e->value))++; | 560 (*bit_cast<intptr_t*>(&e->value))++; |
561 } | 561 } |
562 } | 562 } |
563 | 563 |
564 | 564 |
565 void Heap::RemoveAllocationSitePretenuringFeedback(AllocationSite* site) { | 565 void Heap::RemoveAllocationSitePretenuringFeedback(AllocationSite* site) { |
566 global_pretenuring_feedback_->Remove( | 566 global_pretenuring_feedback_->Remove( |
567 site, static_cast<uint32_t>(bit_cast<uintptr_t>(site))); | 567 site, static_cast<uint32_t>(bit_cast<uintptr_t>(site))); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 750 |
751 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 751 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
752 for (Object** current = start; current < end; current++) { | 752 for (Object** current = start; current < end; current++) { |
753 CHECK((*current)->IsSmi()); | 753 CHECK((*current)->IsSmi()); |
754 } | 754 } |
755 } | 755 } |
756 } // namespace internal | 756 } // namespace internal |
757 } // namespace v8 | 757 } // namespace v8 |
758 | 758 |
759 #endif // V8_HEAP_HEAP_INL_H_ | 759 #endif // V8_HEAP_HEAP_INL_H_ |
OLD | NEW |