OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 // Performs garbage collection operation. | 756 // Performs garbage collection operation. |
757 // Returns whether there is a chance that another major GC could | 757 // Returns whether there is a chance that another major GC could |
758 // collect more garbage. | 758 // collect more garbage. |
759 static bool CollectGarbage(AllocationSpace space, GarbageCollector collector); | 759 static bool CollectGarbage(AllocationSpace space, GarbageCollector collector); |
760 | 760 |
761 // Performs garbage collection operation. | 761 // Performs garbage collection operation. |
762 // Returns whether there is a chance that another major GC could | 762 // Returns whether there is a chance that another major GC could |
763 // collect more garbage. | 763 // collect more garbage. |
764 inline static bool CollectGarbage(AllocationSpace space); | 764 inline static bool CollectGarbage(AllocationSpace space); |
765 | 765 |
766 static const int kNoGCFlags = 0; | |
767 static const int kForceCompactionMask = 1; | |
768 static const int kSweepPreciselyMask = 2; | |
Vyacheslav Egorov (Chromium)
2011/03/15 09:20:09
maybe better hide the concept of conservative and
Erik Corry
2011/03/17 13:39:17
Done.
| |
769 | |
766 // Performs a full garbage collection. Force compaction if the | 770 // Performs a full garbage collection. Force compaction if the |
767 // parameter is true. | 771 // parameter is true. |
768 static void CollectAllGarbage(bool force_compaction); | 772 static void CollectAllGarbage(int flags); |
773 | |
774 | |
775 // Ensure that we have swept all spaces in such a way that we can iterate | |
776 // over live objects. May cause a GC. | |
777 static void EnsureHeapIsIterable(); | |
769 | 778 |
770 // Last hope GC, should try to squeeze as much as possible. | 779 // Last hope GC, should try to squeeze as much as possible. |
771 static void CollectAllAvailableGarbage(); | 780 static void CollectAllAvailableGarbage(); |
772 | 781 |
773 // Notify the heap that a context has been disposed. | 782 // Notify the heap that a context has been disposed. |
774 static int NotifyContextDisposed() { return ++contexts_disposed_; } | 783 static int NotifyContextDisposed() { return ++contexts_disposed_; } |
775 | 784 |
776 // Utility to invoke the scavenger. This is needed in test code to | 785 // Utility to invoke the scavenger. This is needed in test code to |
777 // ensure correct callback for weak global handles. | 786 // ensure correct callback for weak global handles. |
778 static void PerformScavenge(); | 787 static void PerformScavenge(); |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1603 ObjectIterator* CreateIterator(); | 1612 ObjectIterator* CreateIterator(); |
1604 | 1613 |
1605 int current_space_; // from enum AllocationSpace. | 1614 int current_space_; // from enum AllocationSpace. |
1606 ObjectIterator* iterator_; // object iterator for the current space. | 1615 ObjectIterator* iterator_; // object iterator for the current space. |
1607 HeapObjectCallback size_func_; | 1616 HeapObjectCallback size_func_; |
1608 }; | 1617 }; |
1609 | 1618 |
1610 | 1619 |
1611 // A HeapIterator provides iteration over the whole heap. It | 1620 // A HeapIterator provides iteration over the whole heap. It |
1612 // aggregates the specific iterators for the different spaces as | 1621 // aggregates the specific iterators for the different spaces as |
1613 // these can only iterate over one space only. | 1622 // these can only iterate over one space only. It can only be guaranteed |
1623 // to iterate over live objects. | |
1614 // | 1624 // |
1615 // HeapIterator can skip free list nodes (that is, de-allocated heap | 1625 // HeapIterator can skip free list nodes (that is, de-allocated heap |
1616 // objects that still remain in the heap). As implementation of free | 1626 // objects that still remain in the heap). As implementation of free |
1617 // nodes filtering uses GC marks, it can't be used during MS/MC GC | 1627 // nodes filtering uses GC marks, it can't be used during MS/MC GC |
1618 // phases. Also, it is forbidden to interrupt iteration in this mode, | 1628 // phases. Also, it is forbidden to interrupt iteration in this mode, |
1619 // as this will leave heap objects marked (and thus, unusable). | 1629 // as this will leave heap objects marked (and thus, unusable). |
1620 class HeapObjectsFilter; | 1630 class HeapObjectsFilter; |
1621 | 1631 |
1622 class HeapIterator BASE_EMBEDDED { | 1632 class HeapIterator BASE_EMBEDDED { |
1623 public: | 1633 public: |
1624 enum HeapObjectsFiltering { | |
1625 kNoFiltering, | |
1626 kFilterFreeListNodes, | |
1627 kFilterUnreachable | |
1628 }; | |
1629 | |
1630 HeapIterator(); | 1634 HeapIterator(); |
1631 explicit HeapIterator(HeapObjectsFiltering filtering); | |
1632 ~HeapIterator(); | 1635 ~HeapIterator(); |
1633 | 1636 |
1634 HeapObject* next(); | 1637 HeapObject* Next(); |
1635 void reset(); | 1638 void Reset(); |
1636 | 1639 |
1637 private: | 1640 private: |
1638 // Perform the initialization. | 1641 // Perform the initialization. |
1639 void Init(); | 1642 void Init(); |
1640 // Perform all necessary shutdown (destruction) work. | 1643 // Perform all necessary shutdown (destruction) work. |
1641 void Shutdown(); | 1644 void Shutdown(); |
1642 HeapObject* NextObject(); | |
1643 | 1645 |
1644 HeapObjectsFiltering filtering_; | |
1645 HeapObjectsFilter* filter_; | |
1646 // Space iterator for iterating all the spaces. | 1646 // Space iterator for iterating all the spaces. |
1647 SpaceIterator* space_iterator_; | 1647 SpaceIterator* space_iterator_; |
1648 // Object iterator for the space currently being iterated. | 1648 // Object iterator for the space currently being iterated. |
1649 ObjectIterator* object_iterator_; | 1649 ObjectIterator* object_iterator_; |
1650 }; | 1650 }; |
1651 | 1651 |
1652 | 1652 |
1653 // Cache for mapping (map, property name) into field offset. | 1653 // Cache for mapping (map, property name) into field offset. |
1654 // Cleared at startup and prior to mark sweep collection. | 1654 // Cleared at startup and prior to mark sweep collection. |
1655 class KeyedLookupCache { | 1655 class KeyedLookupCache { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2173 | 2173 |
2174 private: | 2174 private: |
2175 static const uintptr_t kNotMarkedBit = 0x1; | 2175 static const uintptr_t kNotMarkedBit = 0x1; |
2176 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); | 2176 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); |
2177 }; | 2177 }; |
2178 | 2178 |
2179 | 2179 |
2180 } } // namespace v8::internal | 2180 } } // namespace v8::internal |
2181 | 2181 |
2182 #endif // V8_HEAP_H_ | 2182 #endif // V8_HEAP_H_ |
OLD | NEW |