OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1551 int counter_; | 1551 int counter_; |
1552 }; | 1552 }; |
1553 | 1553 |
1554 | 1554 |
1555 // Space iterator for iterating over all spaces of the heap. | 1555 // Space iterator for iterating over all spaces of the heap. |
1556 // For each space an object iterator is provided. The deallocation of the | 1556 // For each space an object iterator is provided. The deallocation of the |
1557 // returned object iterators is handled by the space iterator. | 1557 // returned object iterators is handled by the space iterator. |
1558 class SpaceIterator : public Malloced { | 1558 class SpaceIterator : public Malloced { |
1559 public: | 1559 public: |
1560 SpaceIterator(); | 1560 SpaceIterator(); |
1561 explicit SpaceIterator(HeapObjectCallback size_func); | |
1561 virtual ~SpaceIterator(); | 1562 virtual ~SpaceIterator(); |
1562 | 1563 |
1563 bool has_next(); | 1564 bool has_next(); |
1564 ObjectIterator* next(); | 1565 ObjectIterator* next(); |
1565 | 1566 |
1566 private: | 1567 private: |
1567 ObjectIterator* CreateIterator(); | 1568 ObjectIterator* CreateIterator(); |
1568 | 1569 |
1569 int current_space_; // from enum AllocationSpace. | 1570 int current_space_; // from enum AllocationSpace. |
1570 ObjectIterator* iterator_; // object iterator for the current space. | 1571 ObjectIterator* iterator_; // object iterator for the current space. |
1572 HeapObjectCallback size_func_; | |
1571 }; | 1573 }; |
1572 | 1574 |
1573 | 1575 |
1574 // A HeapIterator provides iteration over the whole heap It aggregates a the | 1576 // A HeapIterator provides iteration over the whole heap It aggregates |
antonm
2010/11/13 17:37:51
nit: a dot after 'heap'.
mnaganov (inactive)
2010/11/13 19:05:30
Done.
| |
1575 // specific iterators for the different spaces as these can only iterate over | 1577 // a the specific iterators for the different spaces as these can only |
antonm
2010/11/13 17:37:51
nit: 'a' and 'the' at the beginning of the line
mnaganov (inactive)
2010/11/13 19:05:30
Done.
| |
1576 // one space only. | 1578 // iterate over one space only. |
1579 // | |
1580 // HeapIterator can skip free list nodes (that is, de-allocated heap | |
1581 // objects that still remain in the heap). As implementation of free | |
1582 // nodes filtering uses GC marks, it can't be used during MS/MC GC | |
1583 // phases. Also, it is forbidden to interrupt iteration in this mode, | |
1584 // as this will leave heap objects marked (and thus, unusable). | |
1585 class FreeListNodesFilter; | |
1577 | 1586 |
1578 class HeapIterator BASE_EMBEDDED { | 1587 class HeapIterator BASE_EMBEDDED { |
1579 public: | 1588 public: |
1580 explicit HeapIterator(); | 1589 enum FreeListNodesFiltering { |
1581 virtual ~HeapIterator(); | 1590 kNoFiltering, |
1591 kPreciseFiltering | |
1592 }; | |
1593 | |
1594 HeapIterator(); | |
1595 explicit HeapIterator(FreeListNodesFiltering filtering); | |
antonm
2010/11/13 17:37:51
maybe turn filtering it a param with default value
mnaganov (inactive)
2010/11/13 19:05:30
The style guide is against it:
http://google-style
| |
1596 ~HeapIterator(); | |
1582 | 1597 |
1583 HeapObject* next(); | 1598 HeapObject* next(); |
1584 void reset(); | 1599 void reset(); |
1585 | 1600 |
1586 private: | 1601 private: |
1587 // Perform the initialization. | 1602 // Perform the initialization. |
1588 void Init(); | 1603 void Init(); |
1589 | |
1590 // Perform all necessary shutdown (destruction) work. | 1604 // Perform all necessary shutdown (destruction) work. |
1591 void Shutdown(); | 1605 void Shutdown(); |
1606 HeapObject* NextObject(); | |
1592 | 1607 |
1608 FreeListNodesFiltering filtering_; | |
1609 FreeListNodesFilter* filter_; | |
1593 // Space iterator for iterating all the spaces. | 1610 // Space iterator for iterating all the spaces. |
1594 SpaceIterator* space_iterator_; | 1611 SpaceIterator* space_iterator_; |
1595 // Object iterator for the space currently being iterated. | 1612 // Object iterator for the space currently being iterated. |
1596 ObjectIterator* object_iterator_; | 1613 ObjectIterator* object_iterator_; |
1597 }; | 1614 }; |
1598 | 1615 |
1599 | 1616 |
1600 // Cache for mapping (map, property name) into field offset. | 1617 // Cache for mapping (map, property name) into field offset. |
1601 // Cleared at startup and prior to mark sweep collection. | 1618 // Cleared at startup and prior to mark sweep collection. |
1602 class KeyedLookupCache { | 1619 class KeyedLookupCache { |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2085 // Return whether this object should be retained. If NULL is returned the | 2102 // Return whether this object should be retained. If NULL is returned the |
2086 // object has no references. Otherwise the address of the retained object | 2103 // object has no references. Otherwise the address of the retained object |
2087 // should be returned as in some GC situations the object has been moved. | 2104 // should be returned as in some GC situations the object has been moved. |
2088 virtual Object* RetainAs(Object* object) = 0; | 2105 virtual Object* RetainAs(Object* object) = 0; |
2089 }; | 2106 }; |
2090 | 2107 |
2091 | 2108 |
2092 } } // namespace v8::internal | 2109 } } // namespace v8::internal |
2093 | 2110 |
2094 #endif // V8_HEAP_H_ | 2111 #endif // V8_HEAP_H_ |
OLD | NEW |