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

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

Issue 10830049: Implement verification of context separation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 8 years, 4 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/flag-definitions.h ('k') | src/objects-printer.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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Set array length to zero to prevent cycles while iterating
265 // over array bodies, this is easier than intrusive marking.
266 array->set_length(0);
267 array->IterateBody(
268 FIXED_ARRAY_TYPE, FixedArray::SizeFor(length), this);
269 array->set_length(length);
270 }
271 break;
272 case JS_GLOBAL_PROPERTY_CELL_TYPE:
273 case JS_PROXY_TYPE:
274 case JS_VALUE_TYPE:
275 case TYPE_FEEDBACK_INFO_TYPE:
276 object->Iterate(this);
277 break;
278 case ACCESSOR_INFO_TYPE:
279 case BYTE_ARRAY_TYPE:
280 case CALL_HANDLER_INFO_TYPE:
281 case CODE_TYPE:
282 case FIXED_DOUBLE_ARRAY_TYPE:
283 case HEAP_NUMBER_TYPE:
284 case INTERCEPTOR_INFO_TYPE:
285 case ODDBALL_TYPE:
286 case SCRIPT_TYPE:
287 case SHARED_FUNCTION_INFO_TYPE:
288 break;
289 default:
290 UNREACHABLE();
291 }
292 }
293 }
294 }
295
296 private:
297 void CheckContext(Object* context) {
298 if (!context->IsContext()) return;
299 Context* global_context = Context::cast(context)->global_context();
300 if (current_global_context_ == NULL) {
301 current_global_context_ = global_context;
302 } else {
303 CHECK_EQ(current_global_context_, global_context);
304 }
305 }
306
307 Context* current_global_context_;
308 };
309
310
311 static void VerifyGlobalContextSeparation(Heap* heap) {
312 HeapObjectIterator it(heap->code_space());
313
314 for (Object* object = it.Next(); object != NULL; object = it.Next()) {
315 VerifyGlobalContextSeparationVisitor visitor;
316 Code::cast(object)->CodeIterateBody(&visitor);
317 }
318 }
226 #endif 319 #endif
227 320
228 321
229 void MarkCompactCollector::AddEvacuationCandidate(Page* p) { 322 void MarkCompactCollector::AddEvacuationCandidate(Page* p) {
230 p->MarkEvacuationCandidate(); 323 p->MarkEvacuationCandidate();
231 evacuation_candidates_.Add(p); 324 evacuation_candidates_.Add(p);
232 } 325 }
233 326
234 327
235 static void TraceFragmentation(PagedSpace* space) { 328 static void TraceFragmentation(PagedSpace* space) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 #ifdef DEBUG 382 #ifdef DEBUG
290 if (FLAG_verify_heap) { 383 if (FLAG_verify_heap) {
291 VerifyMarking(heap_); 384 VerifyMarking(heap_);
292 } 385 }
293 #endif 386 #endif
294 387
295 SweepSpaces(); 388 SweepSpaces();
296 389
297 if (!FLAG_collect_maps) ReattachInitialMaps(); 390 if (!FLAG_collect_maps) ReattachInitialMaps();
298 391
392 #ifdef DEBUG
393 if (FLAG_verify_global_context_separation) {
394 VerifyGlobalContextSeparation(heap_);
395 }
396 #endif
397
299 Finish(); 398 Finish();
300 399
301 tracer_ = NULL; 400 tracer_ = NULL;
302 } 401 }
303 402
304 403
305 #ifdef DEBUG 404 #ifdef DEBUG
306 void MarkCompactCollector::VerifyMarkbitsAreClean(PagedSpace* space) { 405 void MarkCompactCollector::VerifyMarkbitsAreClean(PagedSpace* space) {
307 PageIterator it(space); 406 PageIterator it(space);
308 407
(...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 while (buffer != NULL) { 4248 while (buffer != NULL) {
4150 SlotsBuffer* next_buffer = buffer->next(); 4249 SlotsBuffer* next_buffer = buffer->next();
4151 DeallocateBuffer(buffer); 4250 DeallocateBuffer(buffer);
4152 buffer = next_buffer; 4251 buffer = next_buffer;
4153 } 4252 }
4154 *buffer_address = NULL; 4253 *buffer_address = NULL;
4155 } 4254 }
4156 4255
4157 4256
4158 } } // namespace v8::internal 4257 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698