| OLD | NEW |
| 1 // Copyright 2011 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 |
| (...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 ObjectIterator* CreateIterator(); | 1922 ObjectIterator* CreateIterator(); |
| 1923 | 1923 |
| 1924 int current_space_; // from enum AllocationSpace. | 1924 int current_space_; // from enum AllocationSpace. |
| 1925 ObjectIterator* iterator_; // object iterator for the current space. | 1925 ObjectIterator* iterator_; // object iterator for the current space. |
| 1926 HeapObjectCallback size_func_; | 1926 HeapObjectCallback size_func_; |
| 1927 }; | 1927 }; |
| 1928 | 1928 |
| 1929 | 1929 |
| 1930 // A HeapIterator provides iteration over the whole heap. It | 1930 // A HeapIterator provides iteration over the whole heap. It |
| 1931 // aggregates the specific iterators for the different spaces as | 1931 // aggregates the specific iterators for the different spaces as |
| 1932 // these can only iterate over one space only. It can only be guaranteed | 1932 // these can only iterate over one space only. |
| 1933 // to iterate over live objects. | |
| 1934 // | 1933 // |
| 1935 // HeapIterator can skip free list nodes (that is, de-allocated heap | 1934 // HeapIterator can skip free list nodes (that is, de-allocated heap |
| 1936 // objects that still remain in the heap). As implementation of free | 1935 // objects that still remain in the heap). As implementation of free |
| 1937 // nodes filtering uses GC marks, it can't be used during MS/MC GC | 1936 // nodes filtering uses GC marks, it can't be used during MS/MC GC |
| 1938 // phases. Also, it is forbidden to interrupt iteration in this mode, | 1937 // phases. Also, it is forbidden to interrupt iteration in this mode, |
| 1939 // as this will leave heap objects marked (and thus, unusable). | 1938 // as this will leave heap objects marked (and thus, unusable). |
| 1940 class HeapObjectsFilter; | 1939 class HeapObjectsFilter; |
| 1941 | 1940 |
| 1942 class HeapIterator BASE_EMBEDDED { | 1941 class HeapIterator BASE_EMBEDDED { |
| 1943 public: | 1942 public: |
| 1943 enum HeapObjectsFiltering { |
| 1944 kNoFiltering, |
| 1945 kFilterFreeListNodes, |
| 1946 kFilterUnreachable |
| 1947 }; |
| 1948 |
| 1944 HeapIterator(); | 1949 HeapIterator(); |
| 1950 explicit HeapIterator(HeapObjectsFiltering filtering); |
| 1945 ~HeapIterator(); | 1951 ~HeapIterator(); |
| 1946 | 1952 |
| 1947 HeapObject* Next(); | 1953 HeapObject* next(); |
| 1948 void Reset(); | 1954 void reset(); |
| 1949 | 1955 |
| 1950 private: | 1956 private: |
| 1951 // Perform the initialization. | 1957 // Perform the initialization. |
| 1952 void Init(); | 1958 void Init(); |
| 1953 // Perform all necessary shutdown (destruction) work. | 1959 // Perform all necessary shutdown (destruction) work. |
| 1954 void Shutdown(); | 1960 void Shutdown(); |
| 1961 HeapObject* NextObject(); |
| 1955 | 1962 |
| 1963 HeapObjectsFiltering filtering_; |
| 1964 HeapObjectsFilter* filter_; |
| 1956 // Space iterator for iterating all the spaces. | 1965 // Space iterator for iterating all the spaces. |
| 1957 SpaceIterator* space_iterator_; | 1966 SpaceIterator* space_iterator_; |
| 1958 // Object iterator for the space currently being iterated. | 1967 // Object iterator for the space currently being iterated. |
| 1959 ObjectIterator* object_iterator_; | 1968 ObjectIterator* object_iterator_; |
| 1960 }; | 1969 }; |
| 1961 | 1970 |
| 1962 | 1971 |
| 1963 // Cache for mapping (map, property name) into field offset. | 1972 // Cache for mapping (map, property name) into field offset. |
| 1964 // Cleared at startup and prior to mark sweep collection. | 1973 // Cleared at startup and prior to mark sweep collection. |
| 1965 class KeyedLookupCache { | 1974 class KeyedLookupCache { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 object->set_map_word(MapWord::FromRawValue(map_word | kNotMarkedBit)); | 2357 object->set_map_word(MapWord::FromRawValue(map_word | kNotMarkedBit)); |
| 2349 ASSERT(!IsMarked(object)); | 2358 ASSERT(!IsMarked(object)); |
| 2350 } | 2359 } |
| 2351 | 2360 |
| 2352 static void SetMark(HeapObject* object) { | 2361 static void SetMark(HeapObject* object) { |
| 2353 uintptr_t map_word = object->map_word().ToRawValue(); | 2362 uintptr_t map_word = object->map_word().ToRawValue(); |
| 2354 object->set_map_word(MapWord::FromRawValue(map_word & ~kNotMarkedBit)); | 2363 object->set_map_word(MapWord::FromRawValue(map_word & ~kNotMarkedBit)); |
| 2355 ASSERT(IsMarked(object)); | 2364 ASSERT(IsMarked(object)); |
| 2356 } | 2365 } |
| 2357 | 2366 |
| 2367 static Map* MapOfMarkedObject(HeapObject* object) { |
| 2368 uintptr_t map_word = object->map_word().ToRawValue(); |
| 2369 return MapWord::FromRawValue(map_word | kNotMarkedBit).ToMap(); |
| 2370 } |
| 2371 |
| 2358 static int SizeOfMarkedObject(HeapObject* object) { | 2372 static int SizeOfMarkedObject(HeapObject* object) { |
| 2359 uintptr_t map_word = object->map_word().ToRawValue(); | 2373 return object->SizeFromMap(MapOfMarkedObject(object)); |
| 2360 Map* map = MapWord::FromRawValue(map_word | kNotMarkedBit).ToMap(); | |
| 2361 return object->SizeFromMap(map); | |
| 2362 } | 2374 } |
| 2363 | 2375 |
| 2364 private: | 2376 private: |
| 2365 static const uintptr_t kNotMarkedBit = 0x1; | 2377 static const uintptr_t kNotMarkedBit = 0x1; |
| 2366 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); | 2378 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); |
| 2367 }; | 2379 }; |
| 2368 | 2380 |
| 2369 | 2381 |
| 2370 #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) | 2382 #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) |
| 2371 // Helper class for tracing paths to a search target Object from all roots. | 2383 // Helper class for tracing paths to a search target Object from all roots. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2423 | 2435 |
| 2424 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2436 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2425 }; | 2437 }; |
| 2426 #endif // DEBUG || LIVE_OBJECT_LIST | 2438 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2427 | 2439 |
| 2428 } } // namespace v8::internal | 2440 } } // namespace v8::internal |
| 2429 | 2441 |
| 2430 #undef HEAP | 2442 #undef HEAP |
| 2431 | 2443 |
| 2432 #endif // V8_HEAP_H_ | 2444 #endif // V8_HEAP_H_ |
| OLD | NEW |