| 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 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 | 495 |
| 496 void Heap::RepairFreeListsAfterDeserialization() { | 496 void Heap::RepairFreeListsAfterDeserialization() { |
| 497 PagedSpaces spaces(this); | 497 PagedSpaces spaces(this); |
| 498 for (PagedSpace* space = spaces.next(); space != NULL; | 498 for (PagedSpace* space = spaces.next(); space != NULL; |
| 499 space = spaces.next()) { | 499 space = spaces.next()) { |
| 500 space->RepairFreeListsAfterDeserialization(); | 500 space->RepairFreeListsAfterDeserialization(); |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 | 503 |
| 504 | |
| 505 void Heap::MergeAllocationSitePretenuringFeedback( | 504 void Heap::MergeAllocationSitePretenuringFeedback( |
| 506 const HashMap& local_pretenuring_feedback) { | 505 const base::HashMap& local_pretenuring_feedback) { |
| 507 AllocationSite* site = nullptr; | 506 AllocationSite* site = nullptr; |
| 508 for (HashMap::Entry* local_entry = local_pretenuring_feedback.Start(); | 507 for (base::HashMap::Entry* local_entry = local_pretenuring_feedback.Start(); |
| 509 local_entry != nullptr; | 508 local_entry != nullptr; |
| 510 local_entry = local_pretenuring_feedback.Next(local_entry)) { | 509 local_entry = local_pretenuring_feedback.Next(local_entry)) { |
| 511 site = reinterpret_cast<AllocationSite*>(local_entry->key); | 510 site = reinterpret_cast<AllocationSite*>(local_entry->key); |
| 512 MapWord map_word = site->map_word(); | 511 MapWord map_word = site->map_word(); |
| 513 if (map_word.IsForwardingAddress()) { | 512 if (map_word.IsForwardingAddress()) { |
| 514 site = AllocationSite::cast(map_word.ToForwardingAddress()); | 513 site = AllocationSite::cast(map_word.ToForwardingAddress()); |
| 515 } | 514 } |
| 516 | 515 |
| 517 // We have not validated the allocation site yet, since we have not | 516 // We have not validated the allocation site yet, since we have not |
| 518 // dereferenced the site during collecting information. | 517 // dereferenced the site during collecting information. |
| 519 // This is an inlined check of AllocationMemento::IsValid. | 518 // This is an inlined check of AllocationMemento::IsValid. |
| 520 if (!site->IsAllocationSite() || site->IsZombie()) continue; | 519 if (!site->IsAllocationSite() || site->IsZombie()) continue; |
| 521 | 520 |
| 522 int value = | 521 int value = |
| 523 static_cast<int>(reinterpret_cast<intptr_t>(local_entry->value)); | 522 static_cast<int>(reinterpret_cast<intptr_t>(local_entry->value)); |
| 524 DCHECK_GT(value, 0); | 523 DCHECK_GT(value, 0); |
| 525 | 524 |
| 526 if (site->IncrementMementoFoundCount(value)) { | 525 if (site->IncrementMementoFoundCount(value)) { |
| 527 global_pretenuring_feedback_->LookupOrInsert(site, | 526 global_pretenuring_feedback_->LookupOrInsert(site, |
| 528 ObjectHash(site->address())); | 527 ObjectHash(site->address())); |
| 529 } | 528 } |
| 530 } | 529 } |
| 531 } | 530 } |
| 532 | 531 |
| 533 | 532 |
| 534 class Heap::PretenuringScope { | 533 class Heap::PretenuringScope { |
| 535 public: | 534 public: |
| 536 explicit PretenuringScope(Heap* heap) : heap_(heap) { | 535 explicit PretenuringScope(Heap* heap) : heap_(heap) { |
| 537 heap_->global_pretenuring_feedback_ = | 536 heap_->global_pretenuring_feedback_ = new base::HashMap( |
| 538 new HashMap(HashMap::PointersMatch, kInitialFeedbackCapacity); | 537 base::HashMap::PointersMatch, kInitialFeedbackCapacity); |
| 539 } | 538 } |
| 540 | 539 |
| 541 ~PretenuringScope() { | 540 ~PretenuringScope() { |
| 542 delete heap_->global_pretenuring_feedback_; | 541 delete heap_->global_pretenuring_feedback_; |
| 543 heap_->global_pretenuring_feedback_ = nullptr; | 542 heap_->global_pretenuring_feedback_ = nullptr; |
| 544 } | 543 } |
| 545 | 544 |
| 546 private: | 545 private: |
| 547 Heap* heap_; | 546 Heap* heap_; |
| 548 }; | 547 }; |
| 549 | 548 |
| 550 | 549 |
| 551 void Heap::ProcessPretenuringFeedback() { | 550 void Heap::ProcessPretenuringFeedback() { |
| 552 bool trigger_deoptimization = false; | 551 bool trigger_deoptimization = false; |
| 553 if (FLAG_allocation_site_pretenuring) { | 552 if (FLAG_allocation_site_pretenuring) { |
| 554 int tenure_decisions = 0; | 553 int tenure_decisions = 0; |
| 555 int dont_tenure_decisions = 0; | 554 int dont_tenure_decisions = 0; |
| 556 int allocation_mementos_found = 0; | 555 int allocation_mementos_found = 0; |
| 557 int allocation_sites = 0; | 556 int allocation_sites = 0; |
| 558 int active_allocation_sites = 0; | 557 int active_allocation_sites = 0; |
| 559 | 558 |
| 560 AllocationSite* site = nullptr; | 559 AllocationSite* site = nullptr; |
| 561 | 560 |
| 562 // Step 1: Digest feedback for recorded allocation sites. | 561 // Step 1: Digest feedback for recorded allocation sites. |
| 563 bool maximum_size_scavenge = MaximumSizeScavenge(); | 562 bool maximum_size_scavenge = MaximumSizeScavenge(); |
| 564 for (HashMap::Entry* e = global_pretenuring_feedback_->Start(); | 563 for (base::HashMap::Entry* e = global_pretenuring_feedback_->Start(); |
| 565 e != nullptr; e = global_pretenuring_feedback_->Next(e)) { | 564 e != nullptr; e = global_pretenuring_feedback_->Next(e)) { |
| 566 allocation_sites++; | 565 allocation_sites++; |
| 567 site = reinterpret_cast<AllocationSite*>(e->key); | 566 site = reinterpret_cast<AllocationSite*>(e->key); |
| 568 int found_count = site->memento_found_count(); | 567 int found_count = site->memento_found_count(); |
| 569 // An entry in the storage does not imply that the count is > 0 because | 568 // An entry in the storage does not imply that the count is > 0 because |
| 570 // allocation sites might have been reset due to too many objects dying | 569 // allocation sites might have been reset due to too many objects dying |
| 571 // in old space. | 570 // in old space. |
| 572 if (found_count > 0) { | 571 if (found_count > 0) { |
| 573 DCHECK(site->IsAllocationSite()); | 572 DCHECK(site->IsAllocationSite()); |
| 574 active_allocation_sites++; | 573 active_allocation_sites++; |
| (...skipping 5832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6407 } | 6406 } |
| 6408 | 6407 |
| 6409 | 6408 |
| 6410 // static | 6409 // static |
| 6411 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6410 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6412 return StaticVisitorBase::GetVisitorId(map); | 6411 return StaticVisitorBase::GetVisitorId(map); |
| 6413 } | 6412 } |
| 6414 | 6413 |
| 6415 } // namespace internal | 6414 } // namespace internal |
| 6416 } // namespace v8 | 6415 } // namespace v8 |
| OLD | NEW |