| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 500          memento_address + HeapObject::kHeaderSize <= top || | 500          memento_address + HeapObject::kHeaderSize <= top || | 
| 501          !NewSpacePage::OnSamePage(memento_address, top - 1)); | 501          !NewSpacePage::OnSamePage(memento_address, top - 1)); | 
| 502   if (memento_address == top) return NULL; | 502   if (memento_address == top) return NULL; | 
| 503 | 503 | 
| 504   AllocationMemento* memento = AllocationMemento::cast(candidate); | 504   AllocationMemento* memento = AllocationMemento::cast(candidate); | 
| 505   if (!memento->IsValid()) return NULL; | 505   if (!memento->IsValid()) return NULL; | 
| 506   return memento; | 506   return memento; | 
| 507 } | 507 } | 
| 508 | 508 | 
| 509 | 509 | 
| 510 void Heap::UpdateAllocationSiteFeedback(HeapObject* object, | 510 void Heap::UpdateAllocationSite(HeapObject* object, | 
| 511                                         ScratchpadSlotMode mode) { | 511                                 HashMap* pretenuring_feedback) { | 
| 512   Heap* heap = object->GetHeap(); | 512   DCHECK(InFromSpace(object)); | 
| 513   DCHECK(heap->InFromSpace(object)); |  | 
| 514 |  | 
| 515   if (!FLAG_allocation_site_pretenuring || | 513   if (!FLAG_allocation_site_pretenuring || | 
| 516       !AllocationSite::CanTrack(object->map()->instance_type())) | 514       !AllocationSite::CanTrack(object->map()->instance_type())) | 
| 517     return; | 515     return; | 
|  | 516   AllocationMemento* memento = FindAllocationMemento(object); | 
|  | 517   if (memento == nullptr) return; | 
| 518 | 518 | 
| 519   AllocationMemento* memento = heap->FindAllocationMemento(object); | 519   AllocationSite* key = memento->GetAllocationSite(); | 
| 520   if (memento == NULL) return; | 520   DCHECK(!key->IsZombie()); | 
| 521 | 521 | 
| 522   if (memento->GetAllocationSite()->IncrementMementoFoundCount()) { | 522   if (pretenuring_feedback == global_pretenuring_feedback_) { | 
| 523     heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite(), mode); | 523     // For inserting in the global pretenuring storage we need to first | 
|  | 524     // increment the memento found count on the allocation site. | 
|  | 525     if (key->IncrementMementoFoundCount()) { | 
|  | 526       global_pretenuring_feedback_->LookupOrInsert( | 
|  | 527           key, static_cast<uint32_t>(bit_cast<uintptr_t>(key))); | 
|  | 528     } | 
|  | 529   } else { | 
|  | 530     // Any other pretenuring storage than the global one is used as a cache, | 
|  | 531     // where the count is later on merge in the allocation site. | 
|  | 532     HashMap::Entry* e = pretenuring_feedback->LookupOrInsert( | 
|  | 533         key, static_cast<uint32_t>(bit_cast<uintptr_t>(key))); | 
|  | 534     DCHECK(e != nullptr); | 
|  | 535     (*bit_cast<intptr_t*>(&e->value))++; | 
| 524   } | 536   } | 
| 525 } | 537 } | 
| 526 | 538 | 
| 527 | 539 | 
|  | 540 void Heap::RemoveAllocationSitePretenuringFeedback(AllocationSite* site) { | 
|  | 541   global_pretenuring_feedback_->Remove( | 
|  | 542       site, static_cast<uint32_t>(bit_cast<uintptr_t>(site))); | 
|  | 543 } | 
|  | 544 | 
|  | 545 | 
| 528 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason, | 546 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason, | 
| 529                           const v8::GCCallbackFlags callbackFlags) { | 547                           const v8::GCCallbackFlags callbackFlags) { | 
| 530   const char* collector_reason = NULL; | 548   const char* collector_reason = NULL; | 
| 531   GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); | 549   GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); | 
| 532   return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); | 550   return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); | 
| 533 } | 551 } | 
| 534 | 552 | 
| 535 | 553 | 
| 536 Isolate* Heap::isolate() { | 554 Isolate* Heap::isolate() { | 
| 537   return reinterpret_cast<Isolate*>( | 555   return reinterpret_cast<Isolate*>( | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 701 | 719 | 
| 702 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 720 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 
| 703   for (Object** current = start; current < end; current++) { | 721   for (Object** current = start; current < end; current++) { | 
| 704     CHECK((*current)->IsSmi()); | 722     CHECK((*current)->IsSmi()); | 
| 705   } | 723   } | 
| 706 } | 724 } | 
| 707 }  // namespace internal | 725 }  // namespace internal | 
| 708 }  // namespace v8 | 726 }  // namespace v8 | 
| 709 | 727 | 
| 710 #endif  // V8_HEAP_HEAP_INL_H_ | 728 #endif  // V8_HEAP_HEAP_INL_H_ | 
| OLD | NEW | 
|---|