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

Side by Side Diff: runtime/vm/scavenger.cc

Issue 2626343002: 1. Added new flag verify_gc_contains and moved all the asserts that do a (Closed)
Patch Set: Created 3 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 | « runtime/vm/pages.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include "vm/dart.h" 7 #include "vm/dart.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 thread_(Thread::Current()), 72 thread_(Thread::Current()),
73 scavenger_(scavenger), 73 scavenger_(scavenger),
74 from_(from), 74 from_(from),
75 heap_(scavenger->heap_), 75 heap_(scavenger->heap_),
76 vm_heap_(Dart::vm_isolate()->heap()), 76 vm_heap_(Dart::vm_isolate()->heap()),
77 page_space_(scavenger->heap_->old_space()), 77 page_space_(scavenger->heap_->old_space()),
78 bytes_promoted_(0), 78 bytes_promoted_(0),
79 visiting_old_object_(NULL) {} 79 visiting_old_object_(NULL) {}
80 80
81 void VisitPointers(RawObject** first, RawObject** last) { 81 void VisitPointers(RawObject** first, RawObject** last) {
82 ASSERT((visiting_old_object_ != NULL) || 82 if (FLAG_verify_gc_contains) {
83 scavenger_->Contains(reinterpret_cast<uword>(first)) || 83 ASSERT((visiting_old_object_ != NULL) ||
84 !heap_->Contains(reinterpret_cast<uword>(first))); 84 scavenger_->Contains(reinterpret_cast<uword>(first)) ||
85 !heap_->Contains(reinterpret_cast<uword>(first)));
86 }
85 for (RawObject** current = first; current <= last; current++) { 87 for (RawObject** current = first; current <= last; current++) {
86 ScavengePointer(current); 88 ScavengePointer(current);
87 } 89 }
88 } 90 }
89 91
90 void VisitingOldObject(RawObject* obj) { 92 void VisitingOldObject(RawObject* obj) {
91 ASSERT((obj == NULL) || obj->IsOldObject()); 93 ASSERT((obj == NULL) || obj->IsOldObject());
92 visiting_old_object_ = obj; 94 visiting_old_object_ = obj;
93 } 95 }
94 96
95 intptr_t bytes_promoted() const { return bytes_promoted_; } 97 intptr_t bytes_promoted() const { return bytes_promoted_; }
96 98
97 private: 99 private:
98 void UpdateStoreBuffer(RawObject** p, RawObject* obj) { 100 void UpdateStoreBuffer(RawObject** p, RawObject* obj) {
99 uword ptr = reinterpret_cast<uword>(p);
100 ASSERT(obj->IsHeapObject()); 101 ASSERT(obj->IsHeapObject());
101 ASSERT(!scavenger_->Contains(ptr)); 102 if (FLAG_verify_gc_contains) {
102 ASSERT(!heap_->CodeContains(ptr)); 103 uword ptr = reinterpret_cast<uword>(p);
103 ASSERT(heap_->Contains(ptr)); 104 ASSERT(!scavenger_->Contains(ptr));
105 ASSERT(heap_->DataContains(ptr));
106 }
104 // If the newly written object is not a new object, drop it immediately. 107 // If the newly written object is not a new object, drop it immediately.
105 if (!obj->IsNewObject() || visiting_old_object_->IsRemembered()) { 108 if (!obj->IsNewObject() || visiting_old_object_->IsRemembered()) {
106 return; 109 return;
107 } 110 }
108 visiting_old_object_->SetRememberedBit(); 111 visiting_old_object_->SetRememberedBit();
109 thread_->StoreBufferAddObjectGC(visiting_old_object_); 112 thread_->StoreBufferAddObjectGC(visiting_old_object_);
110 } 113 }
111 114
112 void ScavengePointer(RawObject** p) { 115 void ScavengePointer(RawObject** p) {
113 // ScavengePointer cannot be called recursively. 116 // ScavengePointer cannot be called recursively.
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 899 }
897 900
898 901
899 void Scavenger::FreeExternal(intptr_t size) { 902 void Scavenger::FreeExternal(intptr_t size) {
900 ASSERT(size >= 0); 903 ASSERT(size >= 0);
901 external_size_ -= size; 904 external_size_ -= size;
902 ASSERT(external_size_ >= 0); 905 ASSERT(external_size_ >= 0);
903 } 906 }
904 907
905 } // namespace dart 908 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698