Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/heap/heap-inl.h

Issue 1659823002: [heap] Slightly optimize Heap::UpdateAllocationSite() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return memento_candidate; 508 return memento_candidate;
509 } 509 }
510 return nullptr; 510 return nullptr;
511 default: 511 default:
512 UNREACHABLE(); 512 UNREACHABLE();
513 } 513 }
514 UNREACHABLE(); 514 UNREACHABLE();
515 return nullptr; 515 return nullptr;
516 } 516 }
517 517
518 518 template <Heap::UpdateAllocationSiteMode mode>
519 void Heap::UpdateAllocationSite(HeapObject* object, 519 void Heap::UpdateAllocationSite(HeapObject* object,
520 HashMap* pretenuring_feedback) { 520 HashMap* pretenuring_feedback) {
521 DCHECK(InFromSpace(object)); 521 DCHECK(InFromSpace(object));
522 if (!FLAG_allocation_site_pretenuring || 522 if (!FLAG_allocation_site_pretenuring ||
523 !AllocationSite::CanTrack(object->map()->instance_type())) 523 !AllocationSite::CanTrack(object->map()->instance_type()))
524 return; 524 return;
525 AllocationMemento* memento_candidate = FindAllocationMemento<kForGC>(object); 525 AllocationMemento* memento_candidate = FindAllocationMemento<kForGC>(object);
526 if (memento_candidate == nullptr) return; 526 if (memento_candidate == nullptr) return;
527 527
528 if (pretenuring_feedback == global_pretenuring_feedback_) { 528 if (mode == kGlobal) {
529 DCHECK_EQ(pretenuring_feedback, global_pretenuring_feedback_);
529 // Entering global pretenuring feedback is only used in the scavenger, where 530 // Entering global pretenuring feedback is only used in the scavenger, where
530 // we are allowed to actually touch the allocation site. 531 // we are allowed to actually touch the allocation site.
531 if (!memento_candidate->IsValid()) return; 532 if (!memento_candidate->IsValid()) return;
532 AllocationSite* site = memento_candidate->GetAllocationSite(); 533 AllocationSite* site = memento_candidate->GetAllocationSite();
533 DCHECK(!site->IsZombie()); 534 DCHECK(!site->IsZombie());
534 // For inserting in the global pretenuring storage we need to first 535 // For inserting in the global pretenuring storage we need to first
535 // increment the memento found count on the allocation site. 536 // increment the memento found count on the allocation site.
536 if (site->IncrementMementoFoundCount()) { 537 if (site->IncrementMementoFoundCount()) {
537 global_pretenuring_feedback_->LookupOrInsert(site, 538 global_pretenuring_feedback_->LookupOrInsert(site,
538 ObjectHash(site->address())); 539 ObjectHash(site->address()));
539 } 540 }
540 } else { 541 } else {
542 DCHECK_EQ(mode, kCached);
543 DCHECK_NE(pretenuring_feedback, global_pretenuring_feedback_);
541 // Entering cached feedback is used in the parallel case. We are not allowed 544 // Entering cached feedback is used in the parallel case. We are not allowed
542 // to dereference the allocation site and rather have to postpone all checks 545 // to dereference the allocation site and rather have to postpone all checks
543 // till actually merging the data. 546 // till actually merging the data.
544 Address key = memento_candidate->GetAllocationSiteUnchecked(); 547 Address key = memento_candidate->GetAllocationSiteUnchecked();
545 HashMap::Entry* e = 548 HashMap::Entry* e =
546 pretenuring_feedback->LookupOrInsert(key, ObjectHash(key)); 549 pretenuring_feedback->LookupOrInsert(key, ObjectHash(key));
547 DCHECK(e != nullptr); 550 DCHECK(e != nullptr);
548 (*bit_cast<intptr_t*>(&e->value))++; 551 (*bit_cast<intptr_t*>(&e->value))++;
549 } 552 }
550 } 553 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 735
733 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 736 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
734 for (Object** current = start; current < end; current++) { 737 for (Object** current = start; current < end; current++) {
735 CHECK((*current)->IsSmi()); 738 CHECK((*current)->IsSmi());
736 } 739 }
737 } 740 }
738 } // namespace internal 741 } // namespace internal
739 } // namespace v8 742 } // namespace v8
740 743
741 #endif // V8_HEAP_HEAP_INL_H_ 744 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« src/heap/heap.h ('K') | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698