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

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

Issue 3764011: Link all global contexts into a weak list. (Closed)
Patch Set: Created 10 years, 2 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
« src/contexts.h ('K') | « src/heap.cc ('k') | src/objects.h » ('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 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 &FixedBodyVisitor<StaticMarkingVisitor, 275 &FixedBodyVisitor<StaticMarkingVisitor,
276 ConsString::BodyDescriptor, 276 ConsString::BodyDescriptor,
277 void>::Visit); 277 void>::Visit);
278 278
279 279
280 table_.Register(kVisitFixedArray, 280 table_.Register(kVisitFixedArray,
281 &FlexibleBodyVisitor<StaticMarkingVisitor, 281 &FlexibleBodyVisitor<StaticMarkingVisitor,
282 FixedArray::BodyDescriptor, 282 FixedArray::BodyDescriptor,
283 void>::Visit); 283 void>::Visit);
284 284
285 table_.Register(kVisitGlobalContext,
286 &FixedBodyVisitor<StaticMarkingVisitor,
287 Context::MarkCompactBodyDescriptor,
288 void>::Visit);
289
285 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); 290 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo);
286 291
287 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); 292 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
288 table_.Register(kVisitSeqAsciiString, &DataObjectVisitor::Visit); 293 table_.Register(kVisitSeqAsciiString, &DataObjectVisitor::Visit);
289 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); 294 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
290 295
291 table_.Register(kVisitOddball, 296 table_.Register(kVisitOddball,
292 &FixedBodyVisitor<StaticMarkingVisitor, 297 &FixedBodyVisitor<StaticMarkingVisitor,
293 Oddball::BodyDescriptor, 298 Oddball::BodyDescriptor,
294 void>::Visit); 299 void>::Visit);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 reinterpret_cast<Object**>((obj)->address() + offset) 576 reinterpret_cast<Object**>((obj)->address() + offset)
572 577
573 VisitPointers(SLOT_ADDR(object, JSFunction::kPropertiesOffset), 578 VisitPointers(SLOT_ADDR(object, JSFunction::kPropertiesOffset),
574 SLOT_ADDR(object, JSFunction::kCodeEntryOffset)); 579 SLOT_ADDR(object, JSFunction::kCodeEntryOffset));
575 580
576 VisitCodeEntry(object->address() + JSFunction::kCodeEntryOffset); 581 VisitCodeEntry(object->address() + JSFunction::kCodeEntryOffset);
577 582
578 VisitPointers(SLOT_ADDR(object, 583 VisitPointers(SLOT_ADDR(object,
579 JSFunction::kCodeEntryOffset + kPointerSize), 584 JSFunction::kCodeEntryOffset + kPointerSize),
580 SLOT_ADDR(object, JSFunction::kSize)); 585 SLOT_ADDR(object, JSFunction::kSize));
586
581 #undef SLOT_ADDR 587 #undef SLOT_ADDR
582 } 588 }
583 589
584 590
585 typedef void (*Callback)(Map* map, HeapObject* object); 591 typedef void (*Callback)(Map* map, HeapObject* object);
586 592
587 static VisitorDispatchTable<Callback> table_; 593 static VisitorDispatchTable<Callback> table_;
588 }; 594 };
589 595
590 596
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 737 }
732 738
733 int PointersRemoved() { 739 int PointersRemoved() {
734 return pointers_removed_; 740 return pointers_removed_;
735 } 741 }
736 private: 742 private:
737 int pointers_removed_; 743 int pointers_removed_;
738 }; 744 };
739 745
740 746
747 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects
748 // are retained.
749 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer {
750 public:
751 virtual Object* RetainAs(Object* object) {
752 MapWord first_word = HeapObject::cast(object)->map_word();
753 if (first_word.IsMarked()) {
754 return object;
755 } else {
756 return NULL;
757 }
758 }
759 };
760
761
741 void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) { 762 void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) {
742 ASSERT(!object->IsMarked()); 763 ASSERT(!object->IsMarked());
743 ASSERT(Heap::Contains(object)); 764 ASSERT(Heap::Contains(object));
744 if (object->IsMap()) { 765 if (object->IsMap()) {
745 Map* map = Map::cast(object); 766 Map* map = Map::cast(object);
746 if (FLAG_cleanup_caches_in_maps_at_gc) { 767 if (FLAG_cleanup_caches_in_maps_at_gc) {
747 map->ClearCodeCache(); 768 map->ClearCodeCache();
748 } 769 }
749 SetMark(map); 770 SetMark(map);
750 if (FLAG_collect_maps && 771 if (FLAG_collect_maps &&
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // Prune the symbol table removing all symbols only pointed to by the 1083 // Prune the symbol table removing all symbols only pointed to by the
1063 // symbol table. Cannot use symbol_table() here because the symbol 1084 // symbol table. Cannot use symbol_table() here because the symbol
1064 // table is marked. 1085 // table is marked.
1065 SymbolTable* symbol_table = Heap::raw_unchecked_symbol_table(); 1086 SymbolTable* symbol_table = Heap::raw_unchecked_symbol_table();
1066 SymbolTableCleaner v; 1087 SymbolTableCleaner v;
1067 symbol_table->IterateElements(&v); 1088 symbol_table->IterateElements(&v);
1068 symbol_table->ElementsRemoved(v.PointersRemoved()); 1089 symbol_table->ElementsRemoved(v.PointersRemoved());
1069 ExternalStringTable::Iterate(&v); 1090 ExternalStringTable::Iterate(&v);
1070 ExternalStringTable::CleanUp(); 1091 ExternalStringTable::CleanUp();
1071 1092
1093 // Process the weak references.
1094 MarkCompactWeakObjectRetainer mark_compact_object_retainer;
1095 Heap::ProcessWeakReferences(&mark_compact_object_retainer);
1096
1072 // Remove object groups after marking phase. 1097 // Remove object groups after marking phase.
1073 GlobalHandles::RemoveObjectGroups(); 1098 GlobalHandles::RemoveObjectGroups();
1074 } 1099 }
1075 1100
1076 1101
1077 static int CountMarkedCallback(HeapObject* obj) { 1102 static int CountMarkedCallback(HeapObject* obj) {
1078 MapWord map_word = obj->map_word(); 1103 MapWord map_word = obj->map_word();
1079 map_word.ClearMark(); 1104 map_word.ClearMark();
1080 return obj->SizeFromMap(map_word.ToMap()); 1105 return obj->SizeFromMap(map_word.ToMap());
1081 } 1106 }
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 cell != NULL; 1657 cell != NULL;
1633 cell = cell_iterator.next()) { 1658 cell = cell_iterator.next()) {
1634 if (cell->IsJSGlobalPropertyCell()) { 1659 if (cell->IsJSGlobalPropertyCell()) {
1635 Address value_address = 1660 Address value_address =
1636 reinterpret_cast<Address>(cell) + 1661 reinterpret_cast<Address>(cell) +
1637 (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag); 1662 (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag);
1638 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); 1663 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
1639 } 1664 }
1640 } 1665 }
1641 1666
1667 // Update pointer from the global contexts list.
1668 updating_visitor.VisitPointer(Heap::global_contexts_list_address());
1669
1642 // Update pointers from external string table. 1670 // Update pointers from external string table.
1643 Heap::UpdateNewSpaceReferencesInExternalStringTable( 1671 Heap::UpdateNewSpaceReferencesInExternalStringTable(
1644 &UpdateNewSpaceReferenceInExternalStringTableEntry); 1672 &UpdateNewSpaceReferenceInExternalStringTableEntry);
1645 1673
1646 // All pointers were updated. Update auxiliary allocation info. 1674 // All pointers were updated. Update auxiliary allocation info.
1647 Heap::IncrementYoungSurvivorsCounter(survivors_size); 1675 Heap::IncrementYoungSurvivorsCounter(survivors_size);
1648 space->set_age_mark(space->top()); 1676 space->set_age_mark(space->top());
1649 } 1677 }
1650 1678
1651 1679
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 2266
2239 void MarkCompactCollector::UpdatePointers() { 2267 void MarkCompactCollector::UpdatePointers() {
2240 #ifdef DEBUG 2268 #ifdef DEBUG
2241 ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES); 2269 ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES);
2242 state_ = UPDATE_POINTERS; 2270 state_ = UPDATE_POINTERS;
2243 #endif 2271 #endif
2244 UpdatingVisitor updating_visitor; 2272 UpdatingVisitor updating_visitor;
2245 Heap::IterateRoots(&updating_visitor, VISIT_ONLY_STRONG); 2273 Heap::IterateRoots(&updating_visitor, VISIT_ONLY_STRONG);
2246 GlobalHandles::IterateWeakRoots(&updating_visitor); 2274 GlobalHandles::IterateWeakRoots(&updating_visitor);
2247 2275
2276 // Update the pointer to the head of the weak list of global contexts.
2277 updating_visitor.VisitPointer(&Heap::global_contexts_list_);
marklam 2010/10/19 00:57:19 For consistency, shouldn't this be made to call He
2278
2248 int live_maps_size = IterateLiveObjects(Heap::map_space(), 2279 int live_maps_size = IterateLiveObjects(Heap::map_space(),
2249 &UpdatePointersInOldObject); 2280 &UpdatePointersInOldObject);
2250 int live_pointer_olds_size = IterateLiveObjects(Heap::old_pointer_space(), 2281 int live_pointer_olds_size = IterateLiveObjects(Heap::old_pointer_space(),
2251 &UpdatePointersInOldObject); 2282 &UpdatePointersInOldObject);
2252 int live_data_olds_size = IterateLiveObjects(Heap::old_data_space(), 2283 int live_data_olds_size = IterateLiveObjects(Heap::old_data_space(),
2253 &UpdatePointersInOldObject); 2284 &UpdatePointersInOldObject);
2254 int live_codes_size = IterateLiveObjects(Heap::code_space(), 2285 int live_codes_size = IterateLiveObjects(Heap::code_space(),
2255 &UpdatePointersInOldObject); 2286 &UpdatePointersInOldObject);
2256 int live_cells_size = IterateLiveObjects(Heap::cell_space(), 2287 int live_cells_size = IterateLiveObjects(Heap::cell_space(),
2257 &UpdatePointersInOldObject); 2288 &UpdatePointersInOldObject);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 } 2665 }
2635 2666
2636 2667
2637 void MarkCompactCollector::Initialize() { 2668 void MarkCompactCollector::Initialize() {
2638 StaticPointersToNewGenUpdatingVisitor::Initialize(); 2669 StaticPointersToNewGenUpdatingVisitor::Initialize();
2639 StaticMarkingVisitor::Initialize(); 2670 StaticMarkingVisitor::Initialize();
2640 } 2671 }
2641 2672
2642 2673
2643 } } // namespace v8::internal 2674 } } // namespace v8::internal
OLDNEW
« src/contexts.h ('K') | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698