| 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 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 // Mark all the objects reachable from the map and body. May leave | 1832 // Mark all the objects reachable from the map and body. May leave |
| 1833 // overflowed objects in the heap. | 1833 // overflowed objects in the heap. |
| 1834 collector_->EmptyMarkingDeque(); | 1834 collector_->EmptyMarkingDeque(); |
| 1835 } | 1835 } |
| 1836 | 1836 |
| 1837 MarkCompactCollector* collector_; | 1837 MarkCompactCollector* collector_; |
| 1838 }; | 1838 }; |
| 1839 | 1839 |
| 1840 | 1840 |
| 1841 // Helper class for pruning the string table. | 1841 // Helper class for pruning the string table. |
| 1842 template<bool finalize_external_strings> |
| 1842 class StringTableCleaner : public ObjectVisitor { | 1843 class StringTableCleaner : public ObjectVisitor { |
| 1843 public: | 1844 public: |
| 1844 explicit StringTableCleaner(Heap* heap) | 1845 explicit StringTableCleaner(Heap* heap) |
| 1845 : heap_(heap), pointers_removed_(0) { } | 1846 : heap_(heap), pointers_removed_(0) { } |
| 1846 | 1847 |
| 1847 virtual void VisitPointers(Object** start, Object** end) { | 1848 virtual void VisitPointers(Object** start, Object** end) { |
| 1848 // Visit all HeapObject pointers in [start, end). | 1849 // Visit all HeapObject pointers in [start, end). |
| 1849 for (Object** p = start; p < end; p++) { | 1850 for (Object** p = start; p < end; p++) { |
| 1850 Object* o = *p; | 1851 Object* o = *p; |
| 1851 if (o->IsHeapObject() && | 1852 if (o->IsHeapObject() && |
| 1852 !Marking::MarkBitFrom(HeapObject::cast(o)).Get()) { | 1853 !Marking::MarkBitFrom(HeapObject::cast(o)).Get()) { |
| 1853 // Check if the internalized string being pruned is external. We need to | 1854 if (finalize_external_strings) { |
| 1854 // delete the associated external data as this string is going away. | 1855 if (o->IsExternalString()) { |
| 1855 | 1856 heap_->FinalizeExternalString(String::cast(*p)); |
| 1856 // Since no objects have yet been moved we can safely access the map of | 1857 } |
| 1857 // the object. | 1858 } else { |
| 1858 if (o->IsExternalString()) { | 1859 pointers_removed_++; |
| 1859 heap_->FinalizeExternalString(String::cast(*p)); | |
| 1860 } | 1860 } |
| 1861 // Set the entry to the_hole_value (as deleted). | 1861 // Set the entry to the_hole_value (as deleted). |
| 1862 *p = heap_->the_hole_value(); | 1862 *p = heap_->the_hole_value(); |
| 1863 pointers_removed_++; | |
| 1864 } | 1863 } |
| 1865 } | 1864 } |
| 1866 } | 1865 } |
| 1867 | 1866 |
| 1868 int PointersRemoved() { | 1867 int PointersRemoved() { |
| 1868 ASSERT(!finalize_external_strings); |
| 1869 return pointers_removed_; | 1869 return pointers_removed_; |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 private: | 1872 private: |
| 1873 Heap* heap_; | 1873 Heap* heap_; |
| 1874 int pointers_removed_; | 1874 int pointers_removed_; |
| 1875 }; | 1875 }; |
| 1876 | 1876 |
| 1877 | 1877 |
| 1878 typedef StringTableCleaner<false> InternalizedStringTableCleaner; |
| 1879 typedef StringTableCleaner<true> ExternalStringTableCleaner; |
| 1880 |
| 1881 |
| 1878 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects | 1882 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects |
| 1879 // are retained. | 1883 // are retained. |
| 1880 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { | 1884 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { |
| 1881 public: | 1885 public: |
| 1882 virtual Object* RetainAs(Object* object) { | 1886 virtual Object* RetainAs(Object* object) { |
| 1883 if (Marking::MarkBitFrom(HeapObject::cast(object)).Get()) { | 1887 if (Marking::MarkBitFrom(HeapObject::cast(object)).Get()) { |
| 1884 return object; | 1888 return object; |
| 1885 } else if (object->IsAllocationSite() && | 1889 } else if (object->IsAllocationSite() && |
| 1886 !(AllocationSite::cast(object)->IsZombie())) { | 1890 !(AllocationSite::cast(object)->IsZombie())) { |
| 1887 // "dead" AllocationSites need to live long enough for a traversal of new | 1891 // "dead" AllocationSites need to live long enough for a traversal of new |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 // Object literal map caches reference strings (cache keys) and maps | 2395 // Object literal map caches reference strings (cache keys) and maps |
| 2392 // (cache values). At this point still useful maps have already been | 2396 // (cache values). At this point still useful maps have already been |
| 2393 // marked. Mark the keys for the alive values before we process the | 2397 // marked. Mark the keys for the alive values before we process the |
| 2394 // string table. | 2398 // string table. |
| 2395 ProcessMapCaches(); | 2399 ProcessMapCaches(); |
| 2396 | 2400 |
| 2397 // Prune the string table removing all strings only pointed to by the | 2401 // Prune the string table removing all strings only pointed to by the |
| 2398 // string table. Cannot use string_table() here because the string | 2402 // string table. Cannot use string_table() here because the string |
| 2399 // table is marked. | 2403 // table is marked. |
| 2400 StringTable* string_table = heap()->string_table(); | 2404 StringTable* string_table = heap()->string_table(); |
| 2401 StringTableCleaner v(heap()); | 2405 InternalizedStringTableCleaner internalized_visitor(heap()); |
| 2402 string_table->IterateElements(&v); | 2406 string_table->IterateElements(&internalized_visitor); |
| 2403 string_table->ElementsRemoved(v.PointersRemoved()); | 2407 string_table->ElementsRemoved(internalized_visitor.PointersRemoved()); |
| 2404 heap()->external_string_table_.Iterate(&v); | 2408 |
| 2409 ExternalStringTableCleaner external_visitor(heap()); |
| 2410 heap()->external_string_table_.Iterate(&external_visitor); |
| 2405 heap()->external_string_table_.CleanUp(); | 2411 heap()->external_string_table_.CleanUp(); |
| 2406 | 2412 |
| 2407 // Process the weak references. | 2413 // Process the weak references. |
| 2408 MarkCompactWeakObjectRetainer mark_compact_object_retainer; | 2414 MarkCompactWeakObjectRetainer mark_compact_object_retainer; |
| 2409 heap()->ProcessWeakReferences(&mark_compact_object_retainer); | 2415 heap()->ProcessWeakReferences(&mark_compact_object_retainer); |
| 2410 | 2416 |
| 2411 // Remove object groups after marking phase. | 2417 // Remove object groups after marking phase. |
| 2412 heap()->isolate()->global_handles()->RemoveObjectGroups(); | 2418 heap()->isolate()->global_handles()->RemoveObjectGroups(); |
| 2413 heap()->isolate()->global_handles()->RemoveImplicitRefGroups(); | 2419 heap()->isolate()->global_handles()->RemoveImplicitRefGroups(); |
| 2414 | 2420 |
| (...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4356 while (buffer != NULL) { | 4362 while (buffer != NULL) { |
| 4357 SlotsBuffer* next_buffer = buffer->next(); | 4363 SlotsBuffer* next_buffer = buffer->next(); |
| 4358 DeallocateBuffer(buffer); | 4364 DeallocateBuffer(buffer); |
| 4359 buffer = next_buffer; | 4365 buffer = next_buffer; |
| 4360 } | 4366 } |
| 4361 *buffer_address = NULL; | 4367 *buffer_address = NULL; |
| 4362 } | 4368 } |
| 4363 | 4369 |
| 4364 | 4370 |
| 4365 } } // namespace v8::internal | 4371 } } // namespace v8::internal |
| OLD | NEW |