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

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

Issue 585643002: Annotate Heap::FindAllocationMemento for MemorySanitizer. (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: Created 6 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 | « no previous file | src/msan.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/cpu-profiler.h" 11 #include "src/cpu-profiler.h"
12 #include "src/heap/heap.h" 12 #include "src/heap/heap.h"
13 #include "src/heap/store-buffer.h" 13 #include "src/heap/store-buffer.h"
14 #include "src/heap/store-buffer-inl.h" 14 #include "src/heap/store-buffer-inl.h"
15 #include "src/heap-profiler.h" 15 #include "src/heap-profiler.h"
16 #include "src/isolate.h" 16 #include "src/isolate.h"
17 #include "src/list-inl.h" 17 #include "src/list-inl.h"
18 #include "src/msan.h"
18 #include "src/objects.h" 19 #include "src/objects.h"
19 20
20 namespace v8 { 21 namespace v8 {
21 namespace internal { 22 namespace internal {
22 23
23 void PromotionQueue::insert(HeapObject* target, int size) { 24 void PromotionQueue::insert(HeapObject* target, int size) {
24 if (emergency_stack_ != NULL) { 25 if (emergency_stack_ != NULL) {
25 emergency_stack_->Add(Entry(target, size)); 26 emergency_stack_->Add(Entry(target, size));
26 return; 27 return;
27 } 28 }
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 MemMove(dst, src, static_cast<size_t>(byte_size)); 489 MemMove(dst, src, static_cast<size_t>(byte_size));
489 } 490 }
490 } 491 }
491 492
492 493
493 void Heap::ScavengePointer(HeapObject** p) { ScavengeObject(p, *p); } 494 void Heap::ScavengePointer(HeapObject** p) { ScavengeObject(p, *p); }
494 495
495 496
496 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { 497 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
497 // Check if there is potentially a memento behind the object. If 498 // Check if there is potentially a memento behind the object. If
498 // the last word of the momento is on another page we return 499 // the last word of the memento is on another page we return
499 // immediately. 500 // immediately.
500 Address object_address = object->address(); 501 Address object_address = object->address();
501 Address memento_address = object_address + object->Size(); 502 Address memento_address = object_address + object->Size();
502 Address last_memento_word_address = memento_address + kPointerSize; 503 Address last_memento_word_address = memento_address + kPointerSize;
503 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) { 504 if (!NewSpacePage::OnSamePage(object_address, last_memento_word_address)) {
504 return NULL; 505 return NULL;
505 } 506 }
506 507
507 HeapObject* candidate = HeapObject::FromAddress(memento_address); 508 HeapObject* candidate = HeapObject::FromAddress(memento_address);
508 if (candidate->map() != allocation_memento_map()) return NULL; 509 Map* candidate_map = candidate->map();
510 // This fast check may peek at an uninitialized word. However, the slow check
511 // below (memento_address == top) ensures that this is safe. Mark the word as
512 // initialized to silence MemorySanitizer warnings.
513 MSAN_MEMORY_IS_INITIALIZED(&candidate_map, sizeof(candidate_map));
514 if (candidate_map != allocation_memento_map()) return NULL;
509 515
510 // Either the object is the last object in the new space, or there is another 516 // Either the object is the last object in the new space, or there is another
511 // object of at least word size (the header map word) following it, so 517 // object of at least word size (the header map word) following it, so
512 // suffices to compare ptr and top here. Note that technically we do not have 518 // suffices to compare ptr and top here. Note that technically we do not have
513 // to compare with the current top pointer of the from space page during GC, 519 // to compare with the current top pointer of the from space page during GC,
514 // since we always install filler objects above the top pointer of a from 520 // since we always install filler objects above the top pointer of a from
515 // space page when performing a garbage collection. However, always performing 521 // space page when performing a garbage collection. However, always performing
516 // the test makes it possible to have a single, unified version of 522 // the test makes it possible to have a single, unified version of
517 // FindAllocationMemento that is used both by the GC and the mutator. 523 // FindAllocationMemento that is used both by the GC and the mutator.
518 Address top = NewSpaceTop(); 524 Address top = NewSpaceTop();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 771
766 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 772 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
767 for (Object** current = start; current < end; current++) { 773 for (Object** current = start; current < end; current++) {
768 CHECK((*current)->IsSmi()); 774 CHECK((*current)->IsSmi());
769 } 775 }
770 } 776 }
771 } 777 }
772 } // namespace v8::internal 778 } // namespace v8::internal
773 779
774 #endif // V8_HEAP_HEAP_INL_H_ 780 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« no previous file with comments | « no previous file | src/msan.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698