| OLD | NEW |
| 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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 RefillMarkingStack(); | 1210 RefillMarkingStack(); |
| 1211 EmptyMarkingStack(); | 1211 EmptyMarkingStack(); |
| 1212 } | 1212 } |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 | 1215 |
| 1216 void MarkCompactCollector::MarkObjectGroups() { | 1216 void MarkCompactCollector::MarkObjectGroups() { |
| 1217 List<ObjectGroup*>* object_groups = | 1217 List<ObjectGroup*>* object_groups = |
| 1218 heap()->isolate()->global_handles()->object_groups(); | 1218 heap()->isolate()->global_handles()->object_groups(); |
| 1219 | 1219 |
| 1220 int last = 0; |
| 1220 for (int i = 0; i < object_groups->length(); i++) { | 1221 for (int i = 0; i < object_groups->length(); i++) { |
| 1221 ObjectGroup* entry = object_groups->at(i); | 1222 ObjectGroup* entry = object_groups->at(i); |
| 1222 if (entry == NULL) continue; | 1223 ASSERT(entry != NULL); |
| 1223 | 1224 |
| 1224 List<Object**>& objects = entry->objects_; | 1225 Object*** objects = entry->objects_; |
| 1225 bool group_marked = false; | 1226 bool group_marked = false; |
| 1226 for (int j = 0; j < objects.length(); j++) { | 1227 for (size_t j = 0; j < entry->length_; j++) { |
| 1227 Object* object = *objects[j]; | 1228 Object* object = *objects[j]; |
| 1228 if (object->IsHeapObject() && HeapObject::cast(object)->IsMarked()) { | 1229 if (object->IsHeapObject() && HeapObject::cast(object)->IsMarked()) { |
| 1229 group_marked = true; | 1230 group_marked = true; |
| 1230 break; | 1231 break; |
| 1231 } | 1232 } |
| 1232 } | 1233 } |
| 1233 | 1234 |
| 1234 if (!group_marked) continue; | 1235 if (!group_marked) { |
| 1236 (*object_groups)[last++] = entry; |
| 1237 continue; |
| 1238 } |
| 1235 | 1239 |
| 1236 // An object in the group is marked, so mark as gray all white heap | 1240 // An object in the group is marked, so mark all heap objects in |
| 1237 // objects in the group. | 1241 // the group. |
| 1238 for (int j = 0; j < objects.length(); ++j) { | 1242 for (size_t j = 0; j < entry->length_; ++j) { |
| 1239 if ((*objects[j])->IsHeapObject()) { | 1243 if ((*objects[j])->IsHeapObject()) { |
| 1240 MarkObject(HeapObject::cast(*objects[j])); | 1244 MarkObject(HeapObject::cast(*objects[j])); |
| 1241 } | 1245 } |
| 1242 } | 1246 } |
| 1243 | 1247 |
| 1244 // Once the entire group has been colored gray, set the object group | 1248 // Once the entire group has been marked, dispose it because it's |
| 1245 // to NULL so it won't be processed again. | 1249 // not needed anymore. |
| 1246 delete entry; | 1250 entry->Dispose(); |
| 1247 object_groups->at(i) = NULL; | |
| 1248 } | 1251 } |
| 1252 object_groups->Rewind(last); |
| 1249 } | 1253 } |
| 1250 | 1254 |
| 1251 | 1255 |
| 1252 void MarkCompactCollector::MarkImplicitRefGroups() { | 1256 void MarkCompactCollector::MarkImplicitRefGroups() { |
| 1253 List<ImplicitRefGroup*>* ref_groups = | 1257 List<ImplicitRefGroup*>* ref_groups = |
| 1254 heap()->isolate()->global_handles()->implicit_ref_groups(); | 1258 heap()->isolate()->global_handles()->implicit_ref_groups(); |
| 1255 | 1259 |
| 1260 int last = 0; |
| 1256 for (int i = 0; i < ref_groups->length(); i++) { | 1261 for (int i = 0; i < ref_groups->length(); i++) { |
| 1257 ImplicitRefGroup* entry = ref_groups->at(i); | 1262 ImplicitRefGroup* entry = ref_groups->at(i); |
| 1258 if (entry == NULL) continue; | 1263 ASSERT(entry != NULL); |
| 1259 | 1264 |
| 1260 if (!entry->parent_->IsMarked()) continue; | 1265 if (!(*entry->parent_)->IsMarked()) { |
| 1266 (*ref_groups)[last++] = entry; |
| 1267 continue; |
| 1268 } |
| 1261 | 1269 |
| 1262 List<Object**>& children = entry->children_; | 1270 Object*** children = entry->children_; |
| 1263 // A parent object is marked, so mark as gray all child white heap | 1271 // A parent object is marked, so mark all child heap objects. |
| 1264 // objects. | 1272 for (size_t j = 0; j < entry->length_; ++j) { |
| 1265 for (int j = 0; j < children.length(); ++j) { | |
| 1266 if ((*children[j])->IsHeapObject()) { | 1273 if ((*children[j])->IsHeapObject()) { |
| 1267 MarkObject(HeapObject::cast(*children[j])); | 1274 MarkObject(HeapObject::cast(*children[j])); |
| 1268 } | 1275 } |
| 1269 } | 1276 } |
| 1270 | 1277 |
| 1271 // Once the entire group has been colored gray, set the group | 1278 // Once the entire group has been marked, dispose it because it's |
| 1272 // to NULL so it won't be processed again. | 1279 // not needed anymore. |
| 1273 delete entry; | 1280 entry->Dispose(); |
| 1274 ref_groups->at(i) = NULL; | |
| 1275 } | 1281 } |
| 1282 ref_groups->Rewind(last); |
| 1276 } | 1283 } |
| 1277 | 1284 |
| 1278 | 1285 |
| 1279 // Mark all objects reachable from the objects on the marking stack. | 1286 // Mark all objects reachable from the objects on the marking stack. |
| 1280 // Before: the marking stack contains zero or more heap object pointers. | 1287 // Before: the marking stack contains zero or more heap object pointers. |
| 1281 // After: the marking stack is empty, and all objects reachable from the | 1288 // After: the marking stack is empty, and all objects reachable from the |
| 1282 // marking stack have been marked, or are overflowed in the heap. | 1289 // marking stack have been marked, or are overflowed in the heap. |
| 1283 void MarkCompactCollector::EmptyMarkingStack() { | 1290 void MarkCompactCollector::EmptyMarkingStack() { |
| 1284 while (!marking_stack_.is_empty()) { | 1291 while (!marking_stack_.is_empty()) { |
| 1285 HeapObject* object = marking_stack_.Pop(); | 1292 HeapObject* object = marking_stack_.Pop(); |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 } | 3090 } |
| 3084 | 3091 |
| 3085 | 3092 |
| 3086 void MarkCompactCollector::Initialize() { | 3093 void MarkCompactCollector::Initialize() { |
| 3087 StaticPointersToNewGenUpdatingVisitor::Initialize(); | 3094 StaticPointersToNewGenUpdatingVisitor::Initialize(); |
| 3088 StaticMarkingVisitor::Initialize(); | 3095 StaticMarkingVisitor::Initialize(); |
| 3089 } | 3096 } |
| 3090 | 3097 |
| 3091 | 3098 |
| 3092 } } // namespace v8::internal | 3099 } } // namespace v8::internal |
| OLD | NEW |