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

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

Issue 1323993004: [heap] Separate scavenger functionality into own file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 3 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/object-stats.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"
11 #include "src/counters.h" 11 #include "src/counters.h"
12 #include "src/heap/heap.h" 12 #include "src/heap/heap.h"
13 #include "src/heap/incremental-marking-inl.h" 13 #include "src/heap/incremental-marking-inl.h"
14 #include "src/heap/objects-visiting.h"
14 #include "src/heap/spaces-inl.h" 15 #include "src/heap/spaces-inl.h"
15 #include "src/heap/store-buffer.h" 16 #include "src/heap/store-buffer.h"
16 #include "src/heap/store-buffer-inl.h" 17 #include "src/heap/store-buffer-inl.h"
17 #include "src/heap-profiler.h" 18 #include "src/heap-profiler.h"
18 #include "src/isolate.h" 19 #include "src/isolate.h"
19 #include "src/list-inl.h" 20 #include "src/list-inl.h"
20 #include "src/log.h" 21 #include "src/log.h"
21 #include "src/msan.h" 22 #include "src/msan.h"
22 #include "src/objects-inl.h" 23 #include "src/objects-inl.h"
23 24
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 454
454 while (src_slot != end_slot) { 455 while (src_slot != end_slot) {
455 *dst_slot++ = *src_slot++; 456 *dst_slot++ = *src_slot++;
456 } 457 }
457 } else { 458 } else {
458 MemMove(dst, src, static_cast<size_t>(byte_size)); 459 MemMove(dst, src, static_cast<size_t>(byte_size));
459 } 460 }
460 } 461 }
461 462
462 463
463 void Heap::ScavengePointer(HeapObject** p) { ScavengeObject(p, *p); }
464
465
466 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { 464 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
467 // Check if there is potentially a memento behind the object. If 465 // Check if there is potentially a memento behind the object. If
468 // the last word of the memento is on another page we return 466 // the last word of the memento is on another page we return
469 // immediately. 467 // immediately.
470 Address object_address = object->address(); 468 Address object_address = object->address();
471 Address memento_address = object_address + object->Size(); 469 Address memento_address = object_address + object->Size();
472 Address last_memento_word_address = memento_address + kPointerSize; 470 Address last_memento_word_address = memento_address + kPointerSize;
473 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) { 471 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) {
474 return NULL; 472 return NULL;
475 } 473 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 511
514 AllocationMemento* memento = heap->FindAllocationMemento(object); 512 AllocationMemento* memento = heap->FindAllocationMemento(object);
515 if (memento == NULL) return; 513 if (memento == NULL) return;
516 514
517 if (memento->GetAllocationSite()->IncrementMementoFoundCount()) { 515 if (memento->GetAllocationSite()->IncrementMementoFoundCount()) {
518 heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite(), mode); 516 heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite(), mode);
519 } 517 }
520 } 518 }
521 519
522 520
523 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) {
524 DCHECK(object->GetIsolate()->heap()->InFromSpace(object));
525
526 // We use the first word (where the map pointer usually is) of a heap
527 // object to record the forwarding pointer. A forwarding pointer can
528 // point to an old space, the code space, or the to space of the new
529 // generation.
530 MapWord first_word = object->map_word();
531
532 // If the first word is a forwarding address, the object has already been
533 // copied.
534 if (first_word.IsForwardingAddress()) {
535 HeapObject* dest = first_word.ToForwardingAddress();
536 DCHECK(object->GetIsolate()->heap()->InFromSpace(*p));
537 *p = dest;
538 return;
539 }
540
541 UpdateAllocationSiteFeedback(object, IGNORE_SCRATCHPAD_SLOT);
542
543 // AllocationMementos are unrooted and shouldn't survive a scavenge
544 DCHECK(object->map() != object->GetHeap()->allocation_memento_map());
545 // Call the slow part of scavenge object.
546 return ScavengeObjectSlow(p, object);
547 }
548
549
550 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason, 521 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason,
551 const v8::GCCallbackFlags callbackFlags) { 522 const v8::GCCallbackFlags callbackFlags) {
552 const char* collector_reason = NULL; 523 const char* collector_reason = NULL;
553 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); 524 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason);
554 return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); 525 return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags);
555 } 526 }
556 527
557 528
558 Isolate* Heap::isolate() { 529 Isolate* Heap::isolate() {
559 return reinterpret_cast<Isolate*>( 530 return reinterpret_cast<Isolate*>(
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 742
772 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 743 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
773 for (Object** current = start; current < end; current++) { 744 for (Object** current = start; current < end; current++) {
774 CHECK((*current)->IsSmi()); 745 CHECK((*current)->IsSmi());
775 } 746 }
776 } 747 }
777 } 748 }
778 } // namespace v8::internal 749 } // namespace v8::internal
779 750
780 #endif // V8_HEAP_HEAP_INL_H_ 751 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/object-stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698