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

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

Issue 1577853007: [heap] Parallel newspace evacuation, semispace copy, and compaction \o/ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable concurrent sweeping for test expecting # of pages released Created 4 years, 11 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
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/mark-compact.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 Object** end_slot = src_slot + size_in_words; 460 Object** end_slot = src_slot + size_in_words;
461 461
462 while (src_slot != end_slot) { 462 while (src_slot != end_slot) {
463 *dst_slot++ = *src_slot++; 463 *dst_slot++ = *src_slot++;
464 } 464 }
465 } else { 465 } else {
466 MemMove(dst, src, static_cast<size_t>(byte_size)); 466 MemMove(dst, src, static_cast<size_t>(byte_size));
467 } 467 }
468 } 468 }
469 469
470 470 template <Heap::FindMementoMode mode>
471 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { 471 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
472 // Check if there is potentially a memento behind the object. If 472 // Check if there is potentially a memento behind the object. If
473 // the last word of the memento is on another page we return 473 // the last word of the memento is on another page we return
474 // immediately. 474 // immediately.
475 Address object_address = object->address(); 475 Address object_address = object->address();
476 Address memento_address = object_address + object->Size(); 476 Address memento_address = object_address + object->Size();
477 Address last_memento_word_address = memento_address + kPointerSize; 477 Address last_memento_word_address = memento_address + kPointerSize;
478 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) { 478 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) {
479 return NULL; 479 return nullptr;
480 } 480 }
481
482 HeapObject* candidate = HeapObject::FromAddress(memento_address); 481 HeapObject* candidate = HeapObject::FromAddress(memento_address);
483 Map* candidate_map = candidate->map(); 482 Map* candidate_map = candidate->map();
484 // This fast check may peek at an uninitialized word. However, the slow check 483 // 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 484 // below (memento_address == top) ensures that this is safe. Mark the word as
486 // initialized to silence MemorySanitizer warnings. 485 // initialized to silence MemorySanitizer warnings.
487 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map)); 486 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map));
488 if (candidate_map != allocation_memento_map()) return NULL; 487 if (candidate_map != allocation_memento_map()) {
488 return nullptr;
489 }
490 AllocationMemento* memento_candidate = AllocationMemento::cast(candidate);
489 491
490 // Either the object is the last object in the new space, or there is another 492 // Depending on what the memento is used for, we might need to perform
491 // object of at least word size (the header map word) following it, so 493 // additional checks.
492 // suffices to compare ptr and top here. Note that technically we do not have 494 Address top;
493 // to compare with the current top pointer of the from space page during GC, 495 switch (mode) {
494 // since we always install filler objects above the top pointer of a from 496 case Heap::kForGC:
495 // space page when performing a garbage collection. However, always performing 497 return memento_candidate;
496 // the test makes it possible to have a single, unified version of 498 case Heap::kForRuntime:
497 // FindAllocationMemento that is used both by the GC and the mutator. 499 if (memento_candidate == nullptr) return nullptr;
498 Address top = NewSpaceTop(); 500 // Either the object is the last object in the new space, or there is
499 DCHECK(memento_address == top || 501 // another object of at least word size (the header map word) following
500 memento_address + HeapObject::kHeaderSize <= top || 502 // it, so suffices to compare ptr and top here.
501 !NewSpacePage::OnSamePage(memento_address, top - 1)); 503 top = NewSpaceTop();
502 if (memento_address == top) return NULL; 504 DCHECK(memento_address == top ||
503 505 memento_address + HeapObject::kHeaderSize <= top ||
504 AllocationMemento* memento = AllocationMemento::cast(candidate); 506 !NewSpacePage::OnSamePage(memento_address, top - 1));
505 if (!memento->IsValid()) return NULL; 507 if ((memento_address != top) && memento_candidate->IsValid()) {
506 return memento; 508 return memento_candidate;
509 }
510 return nullptr;
511 default:
512 UNREACHABLE();
513 }
514 UNREACHABLE();
515 return nullptr;
507 } 516 }
508 517
509 518
510 void Heap::UpdateAllocationSite(HeapObject* object, 519 void Heap::UpdateAllocationSite(HeapObject* object,
511 HashMap* pretenuring_feedback) { 520 HashMap* pretenuring_feedback) {
512 DCHECK(InFromSpace(object)); 521 DCHECK(InFromSpace(object));
513 if (!FLAG_allocation_site_pretenuring || 522 if (!FLAG_allocation_site_pretenuring ||
514 !AllocationSite::CanTrack(object->map()->instance_type())) 523 !AllocationSite::CanTrack(object->map()->instance_type()))
515 return; 524 return;
516 AllocationMemento* memento = FindAllocationMemento(object); 525 AllocationMemento* memento_candidate = FindAllocationMemento<kForGC>(object);
517 if (memento == nullptr) return; 526 if (memento_candidate == nullptr) return;
518
519 AllocationSite* key = memento->GetAllocationSite();
520 DCHECK(!key->IsZombie());
521 527
522 if (pretenuring_feedback == global_pretenuring_feedback_) { 528 if (pretenuring_feedback == global_pretenuring_feedback_) {
529 // Entering global pretenuring feedback is only used in the scavenger, where
530 // we are allowed to actually touch the allocation site.
531 if (!memento_candidate->IsValid()) return;
532 AllocationSite* site = memento_candidate->GetAllocationSite();
533 DCHECK(!site->IsZombie());
523 // For inserting in the global pretenuring storage we need to first 534 // For inserting in the global pretenuring storage we need to first
524 // increment the memento found count on the allocation site. 535 // increment the memento found count on the allocation site.
525 if (key->IncrementMementoFoundCount()) { 536 if (site->IncrementMementoFoundCount()) {
526 global_pretenuring_feedback_->LookupOrInsert( 537 global_pretenuring_feedback_->LookupOrInsert(site,
527 key, static_cast<uint32_t>(bit_cast<uintptr_t>(key))); 538 ObjectHash(site->address()));
528 } 539 }
529 } else { 540 } else {
530 // Any other pretenuring storage than the global one is used as a cache, 541 // Entering cached feedback is used in the parallel case. We are not allowed
531 // where the count is later on merge in the allocation site. 542 // to dereference the allocation site and rather have to postpone all checks
532 HashMap::Entry* e = pretenuring_feedback->LookupOrInsert( 543 // till actually merging the data.
533 key, static_cast<uint32_t>(bit_cast<uintptr_t>(key))); 544 Address key = memento_candidate->GetAllocationSiteUnchecked();
545 HashMap::Entry* e =
546 pretenuring_feedback->LookupOrInsert(key, ObjectHash(key));
534 DCHECK(e != nullptr); 547 DCHECK(e != nullptr);
535 (*bit_cast<intptr_t*>(&e->value))++; 548 (*bit_cast<intptr_t*>(&e->value))++;
536 } 549 }
537 } 550 }
538 551
539 552
540 void Heap::RemoveAllocationSitePretenuringFeedback(AllocationSite* site) { 553 void Heap::RemoveAllocationSitePretenuringFeedback(AllocationSite* site) {
541 global_pretenuring_feedback_->Remove( 554 global_pretenuring_feedback_->Remove(
542 site, static_cast<uint32_t>(bit_cast<uintptr_t>(site))); 555 site, static_cast<uint32_t>(bit_cast<uintptr_t>(site)));
543 } 556 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 732
720 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 733 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
721 for (Object** current = start; current < end; current++) { 734 for (Object** current = start; current < end; current++) {
722 CHECK((*current)->IsSmi()); 735 CHECK((*current)->IsSmi());
723 } 736 }
724 } 737 }
725 } // namespace internal 738 } // namespace internal
726 } // namespace v8 739 } // namespace v8
727 740
728 #endif // V8_HEAP_HEAP_INL_H_ 741 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698