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

Side by Side Diff: src/mark-compact.cc

Issue 23468021: move HEAP to /test (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/isolate.h ('k') | src/mksnapshot.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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 tracer_(NULL), 72 tracer_(NULL),
73 migration_slots_buffer_(NULL), 73 migration_slots_buffer_(NULL),
74 heap_(NULL), 74 heap_(NULL),
75 code_flusher_(NULL), 75 code_flusher_(NULL),
76 encountered_weak_collections_(NULL), 76 encountered_weak_collections_(NULL),
77 have_code_to_deoptimize_(false) { } 77 have_code_to_deoptimize_(false) { }
78 78
79 #ifdef VERIFY_HEAP 79 #ifdef VERIFY_HEAP
80 class VerifyMarkingVisitor: public ObjectVisitor { 80 class VerifyMarkingVisitor: public ObjectVisitor {
81 public: 81 public:
82 explicit VerifyMarkingVisitor(Heap* heap) : heap_(heap) {}
83
82 void VisitPointers(Object** start, Object** end) { 84 void VisitPointers(Object** start, Object** end) {
83 for (Object** current = start; current < end; current++) { 85 for (Object** current = start; current < end; current++) {
84 if ((*current)->IsHeapObject()) { 86 if ((*current)->IsHeapObject()) {
85 HeapObject* object = HeapObject::cast(*current); 87 HeapObject* object = HeapObject::cast(*current);
86 CHECK(HEAP->mark_compact_collector()->IsMarked(object)); 88 CHECK(heap_->mark_compact_collector()->IsMarked(object));
87 } 89 }
88 } 90 }
89 } 91 }
90 92
91 void VisitEmbeddedPointer(RelocInfo* rinfo) { 93 void VisitEmbeddedPointer(RelocInfo* rinfo) {
92 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); 94 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
93 if (!FLAG_weak_embedded_maps_in_optimized_code || !FLAG_collect_maps || 95 if (!FLAG_weak_embedded_maps_in_optimized_code || !FLAG_collect_maps ||
94 rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || 96 rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION ||
95 !rinfo->target_object()->IsMap() || 97 !rinfo->target_object()->IsMap() ||
96 !Map::cast(rinfo->target_object())->CanTransition()) { 98 !Map::cast(rinfo->target_object())->CanTransition()) {
97 VisitPointer(rinfo->target_object_address()); 99 VisitPointer(rinfo->target_object_address());
98 } 100 }
99 } 101 }
102
103 private:
104 Heap* heap_;
100 }; 105 };
101 106
102 107
103 static void VerifyMarking(Address bottom, Address top) { 108 static void VerifyMarking(Heap* heap, Address bottom, Address top) {
104 VerifyMarkingVisitor visitor; 109 VerifyMarkingVisitor visitor(heap);
105 HeapObject* object; 110 HeapObject* object;
106 Address next_object_must_be_here_or_later = bottom; 111 Address next_object_must_be_here_or_later = bottom;
107 112
108 for (Address current = bottom; 113 for (Address current = bottom;
109 current < top; 114 current < top;
110 current += kPointerSize) { 115 current += kPointerSize) {
111 object = HeapObject::FromAddress(current); 116 object = HeapObject::FromAddress(current);
112 if (MarkCompactCollector::IsMarked(object)) { 117 if (MarkCompactCollector::IsMarked(object)) {
113 CHECK(current >= next_object_must_be_here_or_later); 118 CHECK(current >= next_object_must_be_here_or_later);
114 object->Iterate(&visitor); 119 object->Iterate(&visitor);
115 next_object_must_be_here_or_later = current + object->Size(); 120 next_object_must_be_here_or_later = current + object->Size();
116 } 121 }
117 } 122 }
118 } 123 }
119 124
120 125
121 static void VerifyMarking(NewSpace* space) { 126 static void VerifyMarking(NewSpace* space) {
122 Address end = space->top(); 127 Address end = space->top();
123 NewSpacePageIterator it(space->bottom(), end); 128 NewSpacePageIterator it(space->bottom(), end);
124 // The bottom position is at the start of its page. Allows us to use 129 // The bottom position is at the start of its page. Allows us to use
125 // page->area_start() as start of range on all pages. 130 // page->area_start() as start of range on all pages.
126 CHECK_EQ(space->bottom(), 131 CHECK_EQ(space->bottom(),
127 NewSpacePage::FromAddress(space->bottom())->area_start()); 132 NewSpacePage::FromAddress(space->bottom())->area_start());
128 while (it.has_next()) { 133 while (it.has_next()) {
129 NewSpacePage* page = it.next(); 134 NewSpacePage* page = it.next();
130 Address limit = it.has_next() ? page->area_end() : end; 135 Address limit = it.has_next() ? page->area_end() : end;
131 CHECK(limit == end || !page->Contains(end)); 136 CHECK(limit == end || !page->Contains(end));
132 VerifyMarking(page->area_start(), limit); 137 VerifyMarking(space->heap(), page->area_start(), limit);
133 } 138 }
134 } 139 }
135 140
136 141
137 static void VerifyMarking(PagedSpace* space) { 142 static void VerifyMarking(PagedSpace* space) {
138 PageIterator it(space); 143 PageIterator it(space);
139 144
140 while (it.has_next()) { 145 while (it.has_next()) {
141 Page* p = it.next(); 146 Page* p = it.next();
142 VerifyMarking(p->area_start(), p->area_end()); 147 VerifyMarking(space->heap(), p->area_start(), p->area_end());
143 } 148 }
144 } 149 }
145 150
146 151
147 static void VerifyMarking(Heap* heap) { 152 static void VerifyMarking(Heap* heap) {
148 VerifyMarking(heap->old_pointer_space()); 153 VerifyMarking(heap->old_pointer_space());
149 VerifyMarking(heap->old_data_space()); 154 VerifyMarking(heap->old_data_space());
150 VerifyMarking(heap->code_space()); 155 VerifyMarking(heap->code_space());
151 VerifyMarking(heap->cell_space()); 156 VerifyMarking(heap->cell_space());
152 VerifyMarking(heap->property_cell_space()); 157 VerifyMarking(heap->property_cell_space());
153 VerifyMarking(heap->map_space()); 158 VerifyMarking(heap->map_space());
154 VerifyMarking(heap->new_space()); 159 VerifyMarking(heap->new_space());
155 160
156 VerifyMarkingVisitor visitor; 161 VerifyMarkingVisitor visitor(heap);
157 162
158 LargeObjectIterator it(heap->lo_space()); 163 LargeObjectIterator it(heap->lo_space());
159 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 164 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
160 if (MarkCompactCollector::IsMarked(obj)) { 165 if (MarkCompactCollector::IsMarked(obj)) {
161 obj->Iterate(&visitor); 166 obj->Iterate(&visitor);
162 } 167 }
163 } 168 }
164 169
165 heap->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); 170 heap->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG);
166 } 171 }
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 MarkBit mark = Marking::MarkBitFrom(object); 1407 MarkBit mark = Marking::MarkBitFrom(object);
1403 collector->MarkObject(object, mark); 1408 collector->MarkObject(object, mark);
1404 } 1409 }
1405 1410
1406 1411
1407 // Visit an unmarked object. 1412 // Visit an unmarked object.
1408 INLINE(static void VisitUnmarkedObject(MarkCompactCollector* collector, 1413 INLINE(static void VisitUnmarkedObject(MarkCompactCollector* collector,
1409 HeapObject* obj)) { 1414 HeapObject* obj)) {
1410 #ifdef DEBUG 1415 #ifdef DEBUG
1411 ASSERT(collector->heap()->Contains(obj)); 1416 ASSERT(collector->heap()->Contains(obj));
1412 ASSERT(!HEAP->mark_compact_collector()->IsMarked(obj)); 1417 ASSERT(!collector->heap()->mark_compact_collector()->IsMarked(obj));
1413 #endif 1418 #endif
1414 Map* map = obj->map(); 1419 Map* map = obj->map();
1415 Heap* heap = obj->GetHeap(); 1420 Heap* heap = obj->GetHeap();
1416 MarkBit mark = Marking::MarkBitFrom(obj); 1421 MarkBit mark = Marking::MarkBitFrom(obj);
1417 heap->mark_compact_collector()->SetMark(obj, mark); 1422 heap->mark_compact_collector()->SetMark(obj, mark);
1418 // Mark the map pointer and the body. 1423 // Mark the map pointer and the body.
1419 MarkBit map_mark = Marking::MarkBitFrom(map); 1424 MarkBit map_mark = Marking::MarkBitFrom(map);
1420 heap->mark_compact_collector()->MarkObject(map, map_mark); 1425 heap->mark_compact_collector()->MarkObject(map, map_mark);
1421 IterateBody(map, obj); 1426 IterateBody(map, obj);
1422 } 1427 }
(...skipping 2886 matching lines...) Expand 10 before | Expand all | Expand 10 after
4309 while (buffer != NULL) { 4314 while (buffer != NULL) {
4310 SlotsBuffer* next_buffer = buffer->next(); 4315 SlotsBuffer* next_buffer = buffer->next();
4311 DeallocateBuffer(buffer); 4316 DeallocateBuffer(buffer);
4312 buffer = next_buffer; 4317 buffer = next_buffer;
4313 } 4318 }
4314 *buffer_address = NULL; 4319 *buffer_address = NULL;
4315 } 4320 }
4316 4321
4317 4322
4318 } } // namespace v8::internal 4323 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/mksnapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698