OLD | NEW |
---|---|
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 VerifyEvacuation(heap->old_pointer_space()); | 216 VerifyEvacuation(heap->old_pointer_space()); |
217 VerifyEvacuation(heap->old_data_space()); | 217 VerifyEvacuation(heap->old_data_space()); |
218 VerifyEvacuation(heap->code_space()); | 218 VerifyEvacuation(heap->code_space()); |
219 VerifyEvacuation(heap->cell_space()); | 219 VerifyEvacuation(heap->cell_space()); |
220 VerifyEvacuation(heap->map_space()); | 220 VerifyEvacuation(heap->map_space()); |
221 VerifyEvacuation(heap->new_space()); | 221 VerifyEvacuation(heap->new_space()); |
222 | 222 |
223 VerifyEvacuationVisitor visitor; | 223 VerifyEvacuationVisitor visitor; |
224 heap->IterateStrongRoots(&visitor, VISIT_ALL); | 224 heap->IterateStrongRoots(&visitor, VISIT_ALL); |
225 } | 225 } |
226 | |
227 | |
228 class VerifyGlobalContextSeparationVisitor: public ObjectVisitor { | |
229 public: | |
230 VerifyGlobalContextSeparationVisitor() : current_global_context_(NULL) {} | |
231 | |
232 void VisitPointers(Object** start, Object** end) { | |
233 for (Object** current = start; current < end; current++) { | |
234 if ((*current)->IsHeapObject()) { | |
235 HeapObject* object = HeapObject::cast(*current); | |
236 if (object->IsString()) continue; | |
237 switch (object->map()->instance_type()) { | |
238 case JS_FUNCTION_TYPE: | |
239 CheckContext(JSFunction::cast(object)->context()); | |
240 break; | |
241 case JS_GLOBAL_PROXY_TYPE: | |
242 CheckContext(JSGlobalProxy::cast(object)->context()); | |
243 break; | |
244 case JS_GLOBAL_OBJECT_TYPE: | |
245 case JS_BUILTINS_OBJECT_TYPE: | |
246 CheckContext(GlobalObject::cast(object)->global_context()); | |
247 break; | |
248 case JS_ARRAY_TYPE: | |
249 case JS_DATE_TYPE: | |
250 case JS_OBJECT_TYPE: | |
251 case JS_REGEXP_TYPE: | |
252 VisitPointer(HeapObject::RawField(object, JSObject::kMapOffset)); | |
253 break; | |
254 case MAP_TYPE: | |
255 VisitPointer(HeapObject::RawField(object, Map::kPrototypeOffset)); | |
256 VisitPointer(HeapObject::RawField(object, Map::kConstructorOffset)); | |
257 break; | |
258 case FIXED_ARRAY_TYPE: | |
259 if (object->IsContext()) { | |
260 CheckContext(object); | |
261 } else { | |
262 FixedArray* array = FixedArray::cast(object); | |
263 int length = array->length(); | |
264 array->set_length(0); | |
Toon Verwaest
2012/07/30 10:09:38
Adding a comment here is probably useful. Why do w
Michael Starzinger
2012/07/30 10:44:32
Done. For JSObjects we don't have the problem, bec
| |
265 array->IterateBody( | |
266 FIXED_ARRAY_TYPE, FixedArray::SizeFor(length), this); | |
267 array->set_length(length); | |
268 } | |
269 break; | |
270 case JS_GLOBAL_PROPERTY_CELL_TYPE: | |
271 case JS_PROXY_TYPE: | |
272 case JS_VALUE_TYPE: | |
273 case TYPE_FEEDBACK_INFO_TYPE: | |
274 object->Iterate(this); | |
275 break; | |
276 case ACCESSOR_INFO_TYPE: | |
277 case BYTE_ARRAY_TYPE: | |
278 case CALL_HANDLER_INFO_TYPE: | |
279 case CODE_TYPE: | |
280 case FIXED_DOUBLE_ARRAY_TYPE: | |
281 case HEAP_NUMBER_TYPE: | |
282 case INTERCEPTOR_INFO_TYPE: | |
283 case ODDBALL_TYPE: | |
284 case SCRIPT_TYPE: | |
285 case SHARED_FUNCTION_INFO_TYPE: | |
286 break; | |
287 default: | |
288 UNREACHABLE(); | |
289 } | |
290 } | |
291 } | |
292 } | |
293 | |
294 private: | |
295 void CheckContext(Object* context) { | |
296 if (!context->IsContext()) return; | |
297 Context* global_context = Context::cast(context)->global_context(); | |
298 if (current_global_context_ == NULL) { | |
299 current_global_context_ = global_context; | |
300 } else { | |
301 CHECK_EQ(current_global_context_, global_context); | |
302 } | |
303 } | |
304 | |
305 Context* current_global_context_; | |
306 }; | |
307 | |
308 | |
309 static void VerifyGlobalContextSeparation(Heap* heap) { | |
310 HeapObjectIterator it(heap->code_space()); | |
311 | |
312 for (Object* object = it.Next(); object != NULL; object = it.Next()) { | |
313 VerifyGlobalContextSeparationVisitor visitor; | |
314 Code::cast(object)->CodeIterateBody(&visitor); | |
315 } | |
316 } | |
226 #endif | 317 #endif |
227 | 318 |
228 | 319 |
229 void MarkCompactCollector::AddEvacuationCandidate(Page* p) { | 320 void MarkCompactCollector::AddEvacuationCandidate(Page* p) { |
230 p->MarkEvacuationCandidate(); | 321 p->MarkEvacuationCandidate(); |
231 evacuation_candidates_.Add(p); | 322 evacuation_candidates_.Add(p); |
232 } | 323 } |
233 | 324 |
234 | 325 |
235 static void TraceFragmentation(PagedSpace* space) { | 326 static void TraceFragmentation(PagedSpace* space) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 #ifdef DEBUG | 380 #ifdef DEBUG |
290 if (FLAG_verify_heap) { | 381 if (FLAG_verify_heap) { |
291 VerifyMarking(heap_); | 382 VerifyMarking(heap_); |
292 } | 383 } |
293 #endif | 384 #endif |
294 | 385 |
295 SweepSpaces(); | 386 SweepSpaces(); |
296 | 387 |
297 if (!FLAG_collect_maps) ReattachInitialMaps(); | 388 if (!FLAG_collect_maps) ReattachInitialMaps(); |
298 | 389 |
390 #ifdef DEBUG | |
391 if (FLAG_verify_global_context_separation) { | |
392 VerifyGlobalContextSeparation(heap_); | |
393 } | |
394 #endif | |
395 | |
299 Finish(); | 396 Finish(); |
300 | 397 |
301 tracer_ = NULL; | 398 tracer_ = NULL; |
302 } | 399 } |
303 | 400 |
304 | 401 |
305 #ifdef DEBUG | 402 #ifdef DEBUG |
306 void MarkCompactCollector::VerifyMarkbitsAreClean(PagedSpace* space) { | 403 void MarkCompactCollector::VerifyMarkbitsAreClean(PagedSpace* space) { |
307 PageIterator it(space); | 404 PageIterator it(space); |
308 | 405 |
(...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4149 while (buffer != NULL) { | 4246 while (buffer != NULL) { |
4150 SlotsBuffer* next_buffer = buffer->next(); | 4247 SlotsBuffer* next_buffer = buffer->next(); |
4151 DeallocateBuffer(buffer); | 4248 DeallocateBuffer(buffer); |
4152 buffer = next_buffer; | 4249 buffer = next_buffer; |
4153 } | 4250 } |
4154 *buffer_address = NULL; | 4251 *buffer_address = NULL; |
4155 } | 4252 } |
4156 | 4253 |
4157 | 4254 |
4158 } } // namespace v8::internal | 4255 } } // namespace v8::internal |
OLD | NEW |