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

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

Issue 6711027: [Isolates] Merge 7201:7258 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 1227
1228 if (!group_marked) continue; 1228 if (!group_marked) continue;
1229 1229
1230 // An object in the group is marked, so mark as gray all white heap 1230 // An object in the group is marked, so mark as gray all white heap
1231 // objects in the group. 1231 // objects in the group.
1232 for (int j = 0; j < objects.length(); ++j) { 1232 for (int j = 0; j < objects.length(); ++j) {
1233 if ((*objects[j])->IsHeapObject()) { 1233 if ((*objects[j])->IsHeapObject()) {
1234 MarkObject(HeapObject::cast(*objects[j])); 1234 MarkObject(HeapObject::cast(*objects[j]));
1235 } 1235 }
1236 } 1236 }
1237
1237 // Once the entire group has been colored gray, set the object group 1238 // Once the entire group has been colored gray, set the object group
1238 // to NULL so it won't be processed again. 1239 // to NULL so it won't be processed again.
1239 delete object_groups->at(i); 1240 delete entry;
1240 object_groups->at(i) = NULL; 1241 object_groups->at(i) = NULL;
1241 } 1242 }
1242 } 1243 }
1243 1244
1244 1245
1246 void MarkCompactCollector::MarkImplicitRefGroups() {
1247 List<ImplicitRefGroup*>* ref_groups = GlobalHandles::ImplicitRefGroups();
1248
1249 for (int i = 0; i < ref_groups->length(); i++) {
1250 ImplicitRefGroup* entry = ref_groups->at(i);
1251 if (entry == NULL) continue;
1252
1253 if (!entry->parent_->IsMarked()) continue;
1254
1255 List<Object**>& children = entry->children_;
1256 // A parent object is marked, so mark as gray all child white heap
1257 // objects.
1258 for (int j = 0; j < children.length(); ++j) {
1259 if ((*children[j])->IsHeapObject()) {
1260 MarkObject(HeapObject::cast(*children[j]));
1261 }
1262 }
1263
1264 // Once the entire group has been colored gray, set the group
1265 // to NULL so it won't be processed again.
1266 delete entry;
1267 ref_groups->at(i) = NULL;
1268 }
1269 }
1270
1271
1245 // Mark all objects reachable from the objects on the marking stack. 1272 // Mark all objects reachable from the objects on the marking stack.
1246 // Before: the marking stack contains zero or more heap object pointers. 1273 // Before: the marking stack contains zero or more heap object pointers.
1247 // After: the marking stack is empty, and all objects reachable from the 1274 // After: the marking stack is empty, and all objects reachable from the
1248 // marking stack have been marked, or are overflowed in the heap. 1275 // marking stack have been marked, or are overflowed in the heap.
1249 void MarkCompactCollector::EmptyMarkingStack() { 1276 void MarkCompactCollector::EmptyMarkingStack() {
1250 while (!marking_stack_.is_empty()) { 1277 while (!marking_stack_.is_empty()) {
1251 HeapObject* object = marking_stack_.Pop(); 1278 HeapObject* object = marking_stack_.Pop();
1252 ASSERT(object->IsHeapObject()); 1279 ASSERT(object->IsHeapObject());
1253 ASSERT(heap_->Contains(object)); 1280 ASSERT(heap_->Contains(object));
1254 ASSERT(object->IsMarked()); 1281 ASSERT(object->IsMarked());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 // objects in the heap. 1340 // objects in the heap.
1314 void MarkCompactCollector::ProcessMarkingStack() { 1341 void MarkCompactCollector::ProcessMarkingStack() {
1315 EmptyMarkingStack(); 1342 EmptyMarkingStack();
1316 while (marking_stack_.overflowed()) { 1343 while (marking_stack_.overflowed()) {
1317 RefillMarkingStack(); 1344 RefillMarkingStack();
1318 EmptyMarkingStack(); 1345 EmptyMarkingStack();
1319 } 1346 }
1320 } 1347 }
1321 1348
1322 1349
1323 void MarkCompactCollector::ProcessObjectGroups() { 1350 void MarkCompactCollector::ProcessExternalMarking() {
1324 bool work_to_do = true; 1351 bool work_to_do = true;
1325 ASSERT(marking_stack_.is_empty()); 1352 ASSERT(marking_stack_.is_empty());
1326 while (work_to_do) { 1353 while (work_to_do) {
1327 MarkObjectGroups(); 1354 MarkObjectGroups();
1355 MarkImplicitRefGroups();
1328 work_to_do = !marking_stack_.is_empty(); 1356 work_to_do = !marking_stack_.is_empty();
1329 ProcessMarkingStack(); 1357 ProcessMarkingStack();
1330 } 1358 }
1331 } 1359 }
1332 1360
1333 1361
1334 void MarkCompactCollector::MarkLiveObjects() { 1362 void MarkCompactCollector::MarkLiveObjects() {
1335 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_MARK); 1363 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_MARK);
1336 // The recursive GC marker detects when it is nearing stack overflow, 1364 // The recursive GC marker detects when it is nearing stack overflow,
1337 // and switches to a different marking system. JS interrupts interfere 1365 // and switches to a different marking system. JS interrupts interfere
(...skipping 10 matching lines...) Expand all
1348 heap_->new_space()->FromSpaceHigh()); 1376 heap_->new_space()->FromSpaceHigh());
1349 1377
1350 ASSERT(!marking_stack_.overflowed()); 1378 ASSERT(!marking_stack_.overflowed());
1351 1379
1352 PrepareForCodeFlushing(); 1380 PrepareForCodeFlushing();
1353 1381
1354 RootMarkingVisitor root_visitor(heap_); 1382 RootMarkingVisitor root_visitor(heap_);
1355 MarkRoots(&root_visitor); 1383 MarkRoots(&root_visitor);
1356 1384
1357 // The objects reachable from the roots are marked, yet unreachable 1385 // The objects reachable from the roots are marked, yet unreachable
1358 // objects are unmarked. Mark objects reachable from object groups 1386 // objects are unmarked. Mark objects reachable due to host
1359 // containing at least one marked object, and continue until no new 1387 // application specific logic.
1360 // objects are reachable from the object groups. 1388 ProcessExternalMarking();
1361 ProcessObjectGroups();
1362 1389
1363 // The objects reachable from the roots or object groups are marked, 1390 // The objects reachable from the roots or object groups are marked,
1364 // yet unreachable objects are unmarked. Mark objects reachable 1391 // yet unreachable objects are unmarked. Mark objects reachable
1365 // only from weak global handles. 1392 // only from weak global handles.
1366 // 1393 //
1367 // First we identify nonlive weak handles and mark them as pending 1394 // First we identify nonlive weak handles and mark them as pending
1368 // destruction. 1395 // destruction.
1369 heap_->isolate()->global_handles()->IdentifyWeakHandles( 1396 heap_->isolate()->global_handles()->IdentifyWeakHandles(
1370 &IsUnmarkedHeapObject); 1397 &IsUnmarkedHeapObject);
1371 // Then we mark the objects and process the transitive closure. 1398 // Then we mark the objects and process the transitive closure.
1372 heap_->isolate()->global_handles()->IterateWeakRoots(&root_visitor); 1399 heap_->isolate()->global_handles()->IterateWeakRoots(&root_visitor);
1373 while (marking_stack_.overflowed()) { 1400 while (marking_stack_.overflowed()) {
1374 RefillMarkingStack(); 1401 RefillMarkingStack();
1375 EmptyMarkingStack(); 1402 EmptyMarkingStack();
1376 } 1403 }
1377 1404
1378 // Repeat the object groups to mark unmarked groups reachable from the 1405 // Repeat host application specific marking to mark unmarked objects
1379 // weak roots. 1406 // reachable from the weak roots.
1380 ProcessObjectGroups(); 1407 ProcessExternalMarking();
1381 1408
1382 // Prune the symbol table removing all symbols only pointed to by the 1409 // Prune the symbol table removing all symbols only pointed to by the
1383 // symbol table. Cannot use symbol_table() here because the symbol 1410 // symbol table. Cannot use symbol_table() here because the symbol
1384 // table is marked. 1411 // table is marked.
1385 SymbolTable* symbol_table = heap_->raw_unchecked_symbol_table(); 1412 SymbolTable* symbol_table = heap_->raw_unchecked_symbol_table();
1386 SymbolTableCleaner v; 1413 SymbolTableCleaner v;
1387 symbol_table->IterateElements(&v); 1414 symbol_table->IterateElements(&v);
1388 symbol_table->ElementsRemoved(v.PointersRemoved()); 1415 symbol_table->ElementsRemoved(v.PointersRemoved());
1389 heap_->external_string_table_.Iterate(&v); 1416 heap_->external_string_table_.Iterate(&v);
1390 heap_->external_string_table_.CleanUp(); 1417 heap_->external_string_table_.CleanUp();
1391 1418
1392 // Process the weak references. 1419 // Process the weak references.
1393 MarkCompactWeakObjectRetainer mark_compact_object_retainer; 1420 MarkCompactWeakObjectRetainer mark_compact_object_retainer;
1394 heap_->ProcessWeakReferences(&mark_compact_object_retainer); 1421 heap_->ProcessWeakReferences(&mark_compact_object_retainer);
1395 1422
1396 // Remove object groups after marking phase. 1423 // Remove object groups after marking phase.
1397 heap_->isolate()->global_handles()->RemoveObjectGroups(); 1424 heap_->isolate()->global_handles()->RemoveObjectGroups();
1425 GlobalHandles::RemoveImplicitRefGroups();
1398 1426
1399 // Flush code from collected candidates. 1427 // Flush code from collected candidates.
1400 if (is_code_flushing_enabled()) { 1428 if (is_code_flushing_enabled()) {
1401 code_flusher_->ProcessCandidates(); 1429 code_flusher_->ProcessCandidates();
1402 } 1430 }
1403 1431
1404 // Clean up dead objects from the runtime profiler. 1432 // Clean up dead objects from the runtime profiler.
1405 heap_->isolate()->runtime_profiler()->RemoveDeadSamples(); 1433 heap_->isolate()->runtime_profiler()->RemoveDeadSamples();
1406 } 1434 }
1407 1435
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 } 3065 }
3038 3066
3039 3067
3040 void MarkCompactCollector::Initialize() { 3068 void MarkCompactCollector::Initialize() {
3041 StaticPointersToNewGenUpdatingVisitor::Initialize(); 3069 StaticPointersToNewGenUpdatingVisitor::Initialize();
3042 StaticMarkingVisitor::Initialize(); 3070 StaticMarkingVisitor::Initialize();
3043 } 3071 }
3044 3072
3045 3073
3046 } } // namespace v8::internal 3074 } } // namespace v8::internal
OLDNEW
« src/global-handles.cc ('K') | « src/mark-compact.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698