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

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

Issue 234703003: Unify mechanism to find trailing AllocationMementos (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/objects.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 OS::MemMove(dst, src, static_cast<size_t>(byte_size)); 483 OS::MemMove(dst, src, static_cast<size_t>(byte_size));
484 } 484 }
485 } 485 }
486 486
487 487
488 void Heap::ScavengePointer(HeapObject** p) { 488 void Heap::ScavengePointer(HeapObject** p) {
489 ScavengeObject(p, *p); 489 ScavengeObject(p, *p);
490 } 490 }
491 491
492 492
493 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
494 // Check if there is potentially a memento behind the object. If
495 // the last word of the momento is on another page we return
496 // immediately.
497 Address object_address = object->address();
498 Address memento_address = object_address + object->Size();
499 Address last_memento_word_address = memento_address + kPointerSize;
500 if (!NewSpacePage::OnSamePage(object_address,
501 last_memento_word_address)) {
502 return NULL;
503 }
504
505 HeapObject* candidate = HeapObject::FromAddress(memento_address);
506 if (candidate->map() != allocation_memento_map()) return NULL;
507
508 // Either the object is the last object in the new space, or there is another
509 // object of at least word size (the header map word) following it, so
510 // suffices to compare ptr and top here. Note that technically we do not have
511 // to compare with the current top pointer of the from space page during GC,
512 // since we always install filler objects above the top pointer of a from
513 // space page when performing a garbage collection. However, always performing
514 // the test makes it possible to have a single, unified version of
515 // FindAllocationMemento that is used both by the GC and the mutator.
516 Address top = NewSpaceTop();
517 ASSERT(memento_address == top ||
518 memento_address + HeapObject::kHeaderSize <= top ||
519 !NewSpacePage::OnSamePage(memento_address, top));
520 if (memento_address == top) return NULL;
521
522 AllocationMemento* memento = AllocationMemento::cast(candidate);
523 if (!memento->IsValid()) return NULL;
524 return memento;
525 }
526
527
493 void Heap::UpdateAllocationSiteFeedback(HeapObject* object, 528 void Heap::UpdateAllocationSiteFeedback(HeapObject* object,
494 ScratchpadSlotMode mode) { 529 ScratchpadSlotMode mode) {
495 Heap* heap = object->GetHeap(); 530 Heap* heap = object->GetHeap();
496 ASSERT(heap->InFromSpace(object)); 531 ASSERT(heap->InFromSpace(object));
497 532
498 if (!FLAG_allocation_site_pretenuring || 533 if (!FLAG_allocation_site_pretenuring ||
499 !AllocationSite::CanTrack(object->map()->instance_type())) return; 534 !AllocationSite::CanTrack(object->map()->instance_type())) return;
500 535
501 // Check if there is potentially a memento behind the object. If 536 AllocationMemento* memento = heap->FindAllocationMemento(object);
502 // the last word of the momento is on another page we return 537 if (memento == NULL) return;
503 // immediatelly. Note that we do not have to compare with the current
504 // top pointer of the from space page, since we always install filler
505 // objects above the top pointer of a from space page when performing
506 // a garbage collection.
507 Address object_address = object->address();
508 Address memento_address = object_address + object->Size();
509 Address last_memento_word_address = memento_address + kPointerSize;
510 if (!NewSpacePage::OnSamePage(object_address,
511 last_memento_word_address)) {
512 return;
513 }
514
515 HeapObject* candidate = HeapObject::FromAddress(memento_address);
516 if (candidate->map() != heap->allocation_memento_map()) return;
517
518 AllocationMemento* memento = AllocationMemento::cast(candidate);
519 if (!memento->IsValid()) return;
520 538
521 if (memento->GetAllocationSite()->IncrementMementoFoundCount()) { 539 if (memento->GetAllocationSite()->IncrementMementoFoundCount()) {
522 heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite(), mode); 540 heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite(), mode);
523 } 541 }
524 } 542 }
525 543
526 544
527 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { 545 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) {
528 ASSERT(object->GetIsolate()->heap()->InFromSpace(object)); 546 ASSERT(object->GetIsolate()->heap()->InFromSpace(object));
529 547
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 835
818 836
819 double GCTracer::SizeOfHeapObjects() { 837 double GCTracer::SizeOfHeapObjects() {
820 return (static_cast<double>(heap_->SizeOfObjects())) / MB; 838 return (static_cast<double>(heap_->SizeOfObjects())) / MB;
821 } 839 }
822 840
823 841
824 } } // namespace v8::internal 842 } } // namespace v8::internal
825 843
826 #endif // V8_HEAP_INL_H_ 844 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698