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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1846 template void Marker<MarkCompactCollector>::MarkMapContents(Map* map); | 1846 template void Marker<MarkCompactCollector>::MarkMapContents(Map* map); |
1847 | 1847 |
1848 | 1848 |
1849 template <class T> | 1849 template <class T> |
1850 void Marker<T>::MarkMapContents(Map* map) { | 1850 void Marker<T>::MarkMapContents(Map* map) { |
1851 // Make sure that the back pointer stored either in the map itself or inside | 1851 // Make sure that the back pointer stored either in the map itself or inside |
1852 // its prototype transitions array is marked. Treat pointers in the descriptor | 1852 // its prototype transitions array is marked. Treat pointers in the descriptor |
1853 // array as weak and also mark that array to prevent visiting it later. | 1853 // array as weak and also mark that array to prevent visiting it later. |
1854 base_marker()->MarkObjectAndPush(HeapObject::cast(map->GetBackPointer())); | 1854 base_marker()->MarkObjectAndPush(HeapObject::cast(map->GetBackPointer())); |
1855 | 1855 |
1856 Object** descriptor_array_slot = | 1856 Object** start_slot = |
1857 HeapObject::RawField(map, Map::kInstanceDescriptorsOrBackPointerOffset); | 1857 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset); |
1858 Object* descriptor_array = *descriptor_array_slot; | 1858 |
1859 if (descriptor_array->IsDescriptorArray()) { | 1859 Object** transitions_slot = |
1860 MarkDescriptorArray(reinterpret_cast<DescriptorArray*>(descriptor_array)); | 1860 HeapObject::RawField(map, Map::kTransitionsOrBackPointerOffset); |
1861 Object* transitions = *transitions_slot; | |
1862 if (transitions->IsTransitionArray()) { | |
1863 mark_compact_collector()->RecordSlot( | |
1864 start_slot, transitions_slot, transitions); | |
1865 MarkTransitionArray(reinterpret_cast<TransitionArray*>(transitions)); | |
1861 } else { | 1866 } else { |
1862 // Already marked by marking map->GetBackPointer(). | 1867 // Already marked by marking map->GetBackPointer(). |
1863 ASSERT(descriptor_array->IsMap() || descriptor_array->IsUndefined()); | 1868 ASSERT(transitions->IsMap() || transitions->IsUndefined()); |
1864 } | 1869 } |
1865 | 1870 |
1866 // Mark the Object* fields of the Map. Since the descriptor array has been | 1871 // Mark the Object* fields of the Map. Since the descriptor array has been |
1867 // marked already, it is fine that one of these fields contains a pointer | 1872 // marked already, it is fine that one of these fields contains a pointer |
1868 // to it. But make sure to skip back pointer. | 1873 // to it. But make sure to skip back pointer. |
1869 STATIC_ASSERT(Map::kPointerFieldsEndOffset == | 1874 STATIC_ASSERT(Map::kPointerFieldsEndOffset == |
1870 Map::kBitField3Offset + kPointerSize); | 1875 Map::kBitField3Offset + kPointerSize); |
1871 Object** start_slot = | |
1872 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset); | |
1873 Object** end_slot = HeapObject::RawField(map, Map::kBitField3Offset); | 1876 Object** end_slot = HeapObject::RawField(map, Map::kBitField3Offset); |
1874 for (Object** slot = start_slot; slot < end_slot; slot++) { | 1877 for (Object** slot = start_slot; slot < end_slot; slot++) { |
1875 Object* obj = *slot; | 1878 Object* obj = *slot; |
1876 if (!obj->NonFailureIsHeapObject()) continue; | 1879 if (!obj->NonFailureIsHeapObject()) continue; |
1877 mark_compact_collector()->RecordSlot(start_slot, slot, obj); | 1880 mark_compact_collector()->RecordSlot(start_slot, slot, obj); |
1878 base_marker()->MarkObjectAndPush(reinterpret_cast<HeapObject*>(obj)); | 1881 base_marker()->MarkObjectAndPush(reinterpret_cast<HeapObject*>(obj)); |
1879 } | 1882 } |
1880 } | 1883 } |
1881 | 1884 |
1882 | 1885 |
1883 template <class T> | 1886 template <class T> |
1884 void Marker<T>::MarkDescriptorArray(DescriptorArray* descriptors) { | |
Michael Starzinger
2012/08/06 14:15:52
Oh yeah! I like that!
| |
1885 // Empty descriptor array is marked as a root before any maps are marked. | |
1886 ASSERT(descriptors != descriptors->GetHeap()->empty_descriptor_array()); | |
1887 | |
1888 if (!base_marker()->MarkObjectWithoutPush(descriptors)) return; | |
1889 Object** descriptor_start = descriptors->data_start(); | |
1890 | |
1891 // Since the descriptor array itself is not pushed for scanning, all fields | |
1892 // that point to objects manually have to be pushed, marked, and their slots | |
1893 // recorded. | |
1894 if (descriptors->HasEnumCache()) { | |
1895 Object** enum_cache_slot = descriptors->GetEnumCacheSlot(); | |
1896 Object* enum_cache = *enum_cache_slot; | |
1897 base_marker()->MarkObjectAndPush( | |
1898 reinterpret_cast<HeapObject*>(enum_cache)); | |
1899 mark_compact_collector()->RecordSlot(descriptor_start, | |
1900 enum_cache_slot, | |
1901 enum_cache); | |
1902 } | |
1903 | |
1904 if (descriptors->HasTransitionArray()) { | |
1905 Object** transitions_slot = descriptors->GetTransitionsSlot(); | |
1906 Object* transitions = *transitions_slot; | |
1907 mark_compact_collector()->RecordSlot(descriptor_start, | |
1908 transitions_slot, | |
1909 transitions); | |
1910 MarkTransitionArray(reinterpret_cast<TransitionArray*>(transitions)); | |
1911 } | |
1912 | |
1913 // If the descriptor contains a transition (value is a Map), we don't mark the | |
1914 // value as live. It might be removed by ClearNonLiveTransitions later. | |
1915 for (int i = 0; i < descriptors->number_of_descriptors(); ++i) { | |
1916 Object** key_slot = descriptors->GetKeySlot(i); | |
1917 Object* key = *key_slot; | |
1918 if (key->IsHeapObject()) { | |
1919 base_marker()->MarkObjectAndPush(HeapObject::cast(key)); | |
1920 mark_compact_collector()->RecordSlot(descriptor_start, key_slot, key); | |
1921 } | |
1922 | |
1923 Object** value_slot = descriptors->GetValueSlot(i); | |
1924 if (!(*value_slot)->IsHeapObject()) continue; | |
1925 HeapObject* value = HeapObject::cast(*value_slot); | |
1926 | |
1927 mark_compact_collector()->RecordSlot(descriptor_start, | |
1928 value_slot, | |
1929 value); | |
1930 | |
1931 PropertyDetails details(descriptors->GetDetails(i)); | |
1932 | |
1933 switch (details.type()) { | |
1934 case NORMAL: | |
1935 case FIELD: | |
1936 case CONSTANT_FUNCTION: | |
1937 case HANDLER: | |
1938 case INTERCEPTOR: | |
1939 case CALLBACKS: | |
1940 base_marker()->MarkObjectAndPush(value); | |
1941 break; | |
1942 case TRANSITION: | |
1943 case NONEXISTENT: | |
1944 UNREACHABLE(); | |
1945 break; | |
1946 } | |
1947 } | |
1948 } | |
1949 | |
1950 template <class T> | |
1951 void Marker<T>::MarkTransitionArray(TransitionArray* transitions) { | 1887 void Marker<T>::MarkTransitionArray(TransitionArray* transitions) { |
1952 if (!base_marker()->MarkObjectWithoutPush(transitions)) return; | 1888 if (!base_marker()->MarkObjectWithoutPush(transitions)) return; |
1953 Object** transitions_start = transitions->data_start(); | 1889 Object** transitions_start = transitions->data_start(); |
1954 | 1890 |
1891 DescriptorArray* descriptors = transitions->descriptors(); | |
1892 base_marker()->MarkObjectAndPush(descriptors); | |
1893 mark_compact_collector()->RecordSlot( | |
1894 transitions_start, transitions->GetDescriptorsSlot(), descriptors); | |
1895 | |
1955 if (transitions->HasPrototypeTransitions()) { | 1896 if (transitions->HasPrototypeTransitions()) { |
1956 // Mark prototype transitions array but don't push it into marking stack. | 1897 // Mark prototype transitions array but don't push it into marking stack. |
1957 // This will make references from it weak. We will clean dead prototype | 1898 // This will make references from it weak. We will clean dead prototype |
1958 // transitions in ClearNonLiveTransitions. | 1899 // transitions in ClearNonLiveTransitions. |
1959 Object** proto_trans_slot = transitions->GetPrototypeTransitionsSlot(); | 1900 Object** proto_trans_slot = transitions->GetPrototypeTransitionsSlot(); |
1960 HeapObject* prototype_transitions = HeapObject::cast(*proto_trans_slot); | 1901 HeapObject* prototype_transitions = HeapObject::cast(*proto_trans_slot); |
1961 base_marker()->MarkObjectWithoutPush(prototype_transitions); | 1902 base_marker()->MarkObjectWithoutPush(prototype_transitions); |
1962 mark_compact_collector()->RecordSlot( | 1903 mark_compact_collector()->RecordSlot( |
1963 transitions_start, proto_trans_slot, prototype_transitions); | 1904 transitions_start, proto_trans_slot, prototype_transitions); |
1964 } | 1905 } |
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4149 while (buffer != NULL) { | 4090 while (buffer != NULL) { |
4150 SlotsBuffer* next_buffer = buffer->next(); | 4091 SlotsBuffer* next_buffer = buffer->next(); |
4151 DeallocateBuffer(buffer); | 4092 DeallocateBuffer(buffer); |
4152 buffer = next_buffer; | 4093 buffer = next_buffer; |
4153 } | 4094 } |
4154 *buffer_address = NULL; | 4095 *buffer_address = NULL; |
4155 } | 4096 } |
4156 | 4097 |
4157 | 4098 |
4158 } } // namespace v8::internal | 4099 } } // namespace v8::internal |
OLD | NEW |