| 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 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 | 1578 |
| 1579 // A HeapIterator provides iteration over the whole heap. It | 1579 // A HeapIterator provides iteration over the whole heap. It |
| 1580 // aggregates the specific iterators for the different spaces as | 1580 // aggregates the specific iterators for the different spaces as |
| 1581 // these can only iterate over one space only. | 1581 // these can only iterate over one space only. |
| 1582 // | 1582 // |
| 1583 // HeapIterator can skip free list nodes (that is, de-allocated heap | 1583 // HeapIterator can skip free list nodes (that is, de-allocated heap |
| 1584 // objects that still remain in the heap). As implementation of free | 1584 // objects that still remain in the heap). As implementation of free |
| 1585 // nodes filtering uses GC marks, it can't be used during MS/MC GC | 1585 // nodes filtering uses GC marks, it can't be used during MS/MC GC |
| 1586 // phases. Also, it is forbidden to interrupt iteration in this mode, | 1586 // phases. Also, it is forbidden to interrupt iteration in this mode, |
| 1587 // as this will leave heap objects marked (and thus, unusable). | 1587 // as this will leave heap objects marked (and thus, unusable). |
| 1588 class FreeListNodesFilter; | 1588 class HeapObjectsFilter; |
| 1589 | 1589 |
| 1590 class HeapIterator BASE_EMBEDDED { | 1590 class HeapIterator BASE_EMBEDDED { |
| 1591 public: | 1591 public: |
| 1592 enum FreeListNodesFiltering { | 1592 enum HeapObjectsFiltering { |
| 1593 kNoFiltering, | 1593 kNoFiltering, |
| 1594 kPreciseFiltering | 1594 kFilterFreeListNodes, |
| 1595 kFilterUnreachable |
| 1595 }; | 1596 }; |
| 1596 | 1597 |
| 1597 HeapIterator(); | 1598 HeapIterator(); |
| 1598 explicit HeapIterator(FreeListNodesFiltering filtering); | 1599 explicit HeapIterator(HeapObjectsFiltering filtering); |
| 1599 ~HeapIterator(); | 1600 ~HeapIterator(); |
| 1600 | 1601 |
| 1601 HeapObject* next(); | 1602 HeapObject* next(); |
| 1602 void reset(); | 1603 void reset(); |
| 1603 | 1604 |
| 1604 private: | 1605 private: |
| 1605 // Perform the initialization. | 1606 // Perform the initialization. |
| 1606 void Init(); | 1607 void Init(); |
| 1607 // Perform all necessary shutdown (destruction) work. | 1608 // Perform all necessary shutdown (destruction) work. |
| 1608 void Shutdown(); | 1609 void Shutdown(); |
| 1609 HeapObject* NextObject(); | 1610 HeapObject* NextObject(); |
| 1610 | 1611 |
| 1611 FreeListNodesFiltering filtering_; | 1612 HeapObjectsFiltering filtering_; |
| 1612 FreeListNodesFilter* filter_; | 1613 HeapObjectsFilter* filter_; |
| 1613 // Space iterator for iterating all the spaces. | 1614 // Space iterator for iterating all the spaces. |
| 1614 SpaceIterator* space_iterator_; | 1615 SpaceIterator* space_iterator_; |
| 1615 // Object iterator for the space currently being iterated. | 1616 // Object iterator for the space currently being iterated. |
| 1616 ObjectIterator* object_iterator_; | 1617 ObjectIterator* object_iterator_; |
| 1617 }; | 1618 }; |
| 1618 | 1619 |
| 1619 | 1620 |
| 1620 // Cache for mapping (map, property name) into field offset. | 1621 // Cache for mapping (map, property name) into field offset. |
| 1621 // Cleared at startup and prior to mark sweep collection. | 1622 // Cleared at startup and prior to mark sweep collection. |
| 1622 class KeyedLookupCache { | 1623 class KeyedLookupCache { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 // Size of objects alive after last GC. | 1962 // Size of objects alive after last GC. |
| 1962 static intptr_t alive_after_last_gc_; | 1963 static intptr_t alive_after_last_gc_; |
| 1963 | 1964 |
| 1964 static double last_gc_end_timestamp_; | 1965 static double last_gc_end_timestamp_; |
| 1965 }; | 1966 }; |
| 1966 | 1967 |
| 1967 | 1968 |
| 1968 class TranscendentalCache { | 1969 class TranscendentalCache { |
| 1969 public: | 1970 public: |
| 1970 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; | 1971 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; |
| 1972 static const int kTranscendentalTypeBits = 3; |
| 1973 STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches); |
| 1971 | 1974 |
| 1972 explicit TranscendentalCache(Type t); | 1975 explicit TranscendentalCache(Type t); |
| 1973 | 1976 |
| 1974 // Returns a heap number with f(input), where f is a math function specified | 1977 // Returns a heap number with f(input), where f is a math function specified |
| 1975 // by the 'type' argument. | 1978 // by the 'type' argument. |
| 1976 MUST_USE_RESULT static inline MaybeObject* Get(Type type, double input) { | 1979 MUST_USE_RESULT static inline MaybeObject* Get(Type type, double input) { |
| 1977 TranscendentalCache* cache = caches_[type]; | 1980 TranscendentalCache* cache = caches_[type]; |
| 1978 if (cache == NULL) { | 1981 if (cache == NULL) { |
| 1979 caches_[type] = cache = new TranscendentalCache(type); | 1982 caches_[type] = cache = new TranscendentalCache(type); |
| 1980 } | 1983 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 return (hash & (kCacheSize - 1)); | 2050 return (hash & (kCacheSize - 1)); |
| 2048 } | 2051 } |
| 2049 | 2052 |
| 2050 static Address cache_array_address() { | 2053 static Address cache_array_address() { |
| 2051 // Used to create an external reference. | 2054 // Used to create an external reference. |
| 2052 return reinterpret_cast<Address>(caches_); | 2055 return reinterpret_cast<Address>(caches_); |
| 2053 } | 2056 } |
| 2054 | 2057 |
| 2055 // Allow access to the caches_ array as an ExternalReference. | 2058 // Allow access to the caches_ array as an ExternalReference. |
| 2056 friend class ExternalReference; | 2059 friend class ExternalReference; |
| 2057 // Inline implementation of the caching. | 2060 // Inline implementation of the cache. |
| 2058 friend class TranscendentalCacheStub; | 2061 friend class TranscendentalCacheStub; |
| 2062 friend class TranscendentalCacheSSE2Stub; |
| 2059 | 2063 |
| 2060 static TranscendentalCache* caches_[kNumberOfCaches]; | 2064 static TranscendentalCache* caches_[kNumberOfCaches]; |
| 2061 Element elements_[kCacheSize]; | 2065 Element elements_[kCacheSize]; |
| 2062 Type type_; | 2066 Type type_; |
| 2063 }; | 2067 }; |
| 2064 | 2068 |
| 2065 | 2069 |
| 2066 // External strings table is a place where all external strings are | 2070 // External strings table is a place where all external strings are |
| 2067 // registered. We need to keep track of such strings to properly | 2071 // registered. We need to keep track of such strings to properly |
| 2068 // finalize them. | 2072 // finalize them. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 // Return whether this object should be retained. If NULL is returned the | 2109 // Return whether this object should be retained. If NULL is returned the |
| 2106 // object has no references. Otherwise the address of the retained object | 2110 // object has no references. Otherwise the address of the retained object |
| 2107 // should be returned as in some GC situations the object has been moved. | 2111 // should be returned as in some GC situations the object has been moved. |
| 2108 virtual Object* RetainAs(Object* object) = 0; | 2112 virtual Object* RetainAs(Object* object) = 0; |
| 2109 }; | 2113 }; |
| 2110 | 2114 |
| 2111 | 2115 |
| 2112 } } // namespace v8::internal | 2116 } } // namespace v8::internal |
| 2113 | 2117 |
| 2114 #endif // V8_HEAP_H_ | 2118 #endif // V8_HEAP_H_ |
| OLD | NEW |