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 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 | 1924 |
1925 // There may be overflowed objects in the heap. Visit them now. | 1925 // There may be overflowed objects in the heap. Visit them now. |
1926 while (marking_deque_.overflowed()) { | 1926 while (marking_deque_.overflowed()) { |
1927 RefillMarkingDeque(); | 1927 RefillMarkingDeque(); |
1928 EmptyMarkingDeque(); | 1928 EmptyMarkingDeque(); |
1929 } | 1929 } |
1930 } | 1930 } |
1931 | 1931 |
1932 | 1932 |
1933 void MarkCompactCollector::MarkImplicitRefGroups() { | 1933 void MarkCompactCollector::MarkImplicitRefGroups() { |
1934 Isolate* isolate = Isolate::Current(); | 1934 List<ImplicitRefGroup*>* ref_groups = |
1935 List<ObjectGroupConnection>* ref_groups = | 1935 isolate()->global_handles()->implicit_ref_groups(); |
1936 isolate->global_handles()->implicit_ref_groups(); | |
1937 List<ObjectGroupRepresentative>* representative_objects = | |
1938 isolate->global_handles()->representative_objects(); | |
1939 | 1936 |
1940 if (ref_groups->length() == 0) | 1937 int last = 0; |
1941 return; | 1938 for (int i = 0; i < ref_groups->length(); i++) { |
| 1939 ImplicitRefGroup* entry = ref_groups->at(i); |
| 1940 ASSERT(entry != NULL); |
1942 | 1941 |
1943 ref_groups->Sort(); | 1942 if (!IsMarked(*entry->parent_)) { |
1944 representative_objects->Sort(); | 1943 (*ref_groups)[last++] = entry; |
| 1944 continue; |
| 1945 } |
1945 | 1946 |
1946 int surviving_ref_group_index = 0; | 1947 Object*** children = entry->children_; |
1947 int surviving_representative_object_index = 0; | 1948 // A parent object is marked, so mark all child heap objects. |
1948 | 1949 for (size_t j = 0; j < entry->length_; ++j) { |
1949 int representative_objects_index = 0; | 1950 if ((*children[j])->IsHeapObject()) { |
1950 UniqueId current_group_id(0); | 1951 HeapObject* child = HeapObject::cast(*children[j]); |
1951 int current_group_start = 0; | 1952 MarkBit mark = Marking::MarkBitFrom(child); |
1952 for (int i = 0; i <= ref_groups->length(); ++i) { | 1953 MarkObject(child, mark); |
1953 if (i == 0) | |
1954 current_group_id = ref_groups->at(i).id; | |
1955 if (i == ref_groups->length() || current_group_id != ref_groups->at(i).id) { | |
1956 // Group detected: objects in indices [current_group_start, i[. | |
1957 | |
1958 // Find the representative object for this group. | |
1959 while (representative_objects_index < representative_objects->length() && | |
1960 representative_objects->at(representative_objects_index).id < | |
1961 current_group_id) | |
1962 ++representative_objects_index; | |
1963 | |
1964 if (representative_objects_index < representative_objects->length() && | |
1965 representative_objects->at(representative_objects_index).id == | |
1966 current_group_id) { | |
1967 HeapObject* parent = | |
1968 *(representative_objects->at(representative_objects_index).object); | |
1969 | |
1970 if (!IsMarked(parent)) { | |
1971 // Nothing tbd, copy the reference group so that it can be iterated | |
1972 // during the next call. | |
1973 for (int j = current_group_start; j < i; ++j) | |
1974 ref_groups->at(surviving_ref_group_index++) = ref_groups->at(j); | |
1975 representative_objects->at(surviving_representative_object_index++) = | |
1976 representative_objects->at(representative_objects_index); | |
1977 } else { | |
1978 // A parent object is marked, so mark all child heap objects. | |
1979 for (int j = current_group_start; j < i; ++j) { | |
1980 if ((*ref_groups->at(j).object)->IsHeapObject()) { | |
1981 HeapObject* child = HeapObject::cast(*ref_groups->at(j).object); | |
1982 MarkBit mark = Marking::MarkBitFrom(child); | |
1983 MarkObject(child, mark); | |
1984 } | |
1985 } | |
1986 } | |
1987 } else { | |
1988 // This should not happen: representative object for a group was not | |
1989 // set! | |
1990 UNREACHABLE(); | |
1991 } | |
1992 if (i < ref_groups->length()) { | |
1993 current_group_id = ref_groups->at(i).id; | |
1994 current_group_start = i; | |
1995 } | 1954 } |
1996 } | 1955 } |
| 1956 |
| 1957 // Once the entire group has been marked, dispose it because it's |
| 1958 // not needed anymore. |
| 1959 entry->Dispose(); |
1997 } | 1960 } |
1998 ref_groups->Rewind(surviving_ref_group_index); | 1961 ref_groups->Rewind(last); |
1999 representative_objects->Rewind(surviving_representative_object_index); | |
2000 } | 1962 } |
2001 | 1963 |
2002 | 1964 |
2003 // Mark all objects reachable from the objects on the marking stack. | 1965 // Mark all objects reachable from the objects on the marking stack. |
2004 // Before: the marking stack contains zero or more heap object pointers. | 1966 // Before: the marking stack contains zero or more heap object pointers. |
2005 // After: the marking stack is empty, and all objects reachable from the | 1967 // After: the marking stack is empty, and all objects reachable from the |
2006 // marking stack have been marked, or are overflowed in the heap. | 1968 // marking stack have been marked, or are overflowed in the heap. |
2007 void MarkCompactCollector::EmptyMarkingDeque() { | 1969 void MarkCompactCollector::EmptyMarkingDeque() { |
2008 while (!marking_deque_.IsEmpty()) { | 1970 while (!marking_deque_.IsEmpty()) { |
2009 while (!marking_deque_.IsEmpty()) { | 1971 while (!marking_deque_.IsEmpty()) { |
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4169 while (buffer != NULL) { | 4131 while (buffer != NULL) { |
4170 SlotsBuffer* next_buffer = buffer->next(); | 4132 SlotsBuffer* next_buffer = buffer->next(); |
4171 DeallocateBuffer(buffer); | 4133 DeallocateBuffer(buffer); |
4172 buffer = next_buffer; | 4134 buffer = next_buffer; |
4173 } | 4135 } |
4174 *buffer_address = NULL; | 4136 *buffer_address = NULL; |
4175 } | 4137 } |
4176 | 4138 |
4177 | 4139 |
4178 } } // namespace v8::internal | 4140 } } // namespace v8::internal |
OLD | NEW |