 Chromium Code Reviews
 Chromium Code Reviews Issue 14175005:
  New GC related APIs: Implicit references.  (Closed) 
  Base URL: git://github.com/v8/v8.git@master
    
  
    Issue 14175005:
  New GC related APIs: Implicit references.  (Closed) 
  Base URL: git://github.com/v8/v8.git@master| 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 List<ImplicitRefGroup*>* ref_groups = | 1934 Isolate* isolate = Isolate::Current(); | 
| 1935 isolate()->global_handles()->implicit_ref_groups(); | 1935 List<ObjectGroupConnection>* ref_groups = | 
| 1936 isolate->global_handles()->implicit_ref_groups(); | |
| 1937 List<ObjectGroupRepresentativeObject>* representative_objects = | |
| 1938 isolate->global_handles()->representative_objects(); | |
| 1936 | 1939 | 
| 1937 int last = 0; | 1940 if (ref_groups->length() == 0) | 
| 1938 for (int i = 0; i < ref_groups->length(); i++) { | 1941 return; | 
| 1939 ImplicitRefGroup* entry = ref_groups->at(i); | |
| 1940 ASSERT(entry != NULL); | |
| 1941 | 1942 | 
| 1942 if (!IsMarked(*entry->parent_)) { | 1943 ref_groups->Sort(); | 
| 1943 (*ref_groups)[last++] = entry; | 1944 representative_objects->Sort(); | 
| 1944 continue; | |
| 1945 } | |
| 1946 | 1945 | 
| 1947 Object*** children = entry->children_; | 1946 int surviving_ref_group_index = 0; | 
| 1948 // A parent object is marked, so mark all child heap objects. | 1947 int surviving_representative_object_index = 0; | 
| 1949 for (size_t j = 0; j < entry->length_; ++j) { | 1948 | 
| 1950 if ((*children[j])->IsHeapObject()) { | 1949 int representative_objects_index = 0; | 
| 1951 HeapObject* child = HeapObject::cast(*children[j]); | 1950 UniqueId current_group_id(0); | 
| 1952 MarkBit mark = Marking::MarkBitFrom(child); | 1951 size_t current_group_start = 0; | 
| 1953 MarkObject(child, mark); | 1952 for (int i = 0; i <= ref_groups->length(); ++i) { | 
| 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 | |
| 
Michael Starzinger
2013/04/16 10:42:16
Add an "UNREACHABLE();" here.
 
marja
2013/04/16 12:28:37
Done.
 | |
| 1989 // set! | |
| 1990 } | |
| 1991 if (i < ref_groups->length()) { | |
| 1992 current_group_id = ref_groups->at(i).id; | |
| 1993 current_group_start = i; | |
| 1954 } | 1994 } | 
| 1955 } | 1995 } | 
| 1956 | |
| 1957 // Once the entire group has been marked, dispose it because it's | |
| 1958 // not needed anymore. | |
| 1959 entry->Dispose(); | |
| 1960 } | 1996 } | 
| 1961 ref_groups->Rewind(last); | 1997 ref_groups->Rewind(surviving_ref_group_index); | 
| 1998 representative_objects->Rewind(surviving_representative_object_index); | |
| 1962 } | 1999 } | 
| 1963 | 2000 | 
| 1964 | 2001 | 
| 1965 // Mark all objects reachable from the objects on the marking stack. | 2002 // Mark all objects reachable from the objects on the marking stack. | 
| 1966 // Before: the marking stack contains zero or more heap object pointers. | 2003 // Before: the marking stack contains zero or more heap object pointers. | 
| 1967 // After: the marking stack is empty, and all objects reachable from the | 2004 // After: the marking stack is empty, and all objects reachable from the | 
| 1968 // marking stack have been marked, or are overflowed in the heap. | 2005 // marking stack have been marked, or are overflowed in the heap. | 
| 1969 void MarkCompactCollector::EmptyMarkingDeque() { | 2006 void MarkCompactCollector::EmptyMarkingDeque() { | 
| 1970 while (!marking_deque_.IsEmpty()) { | 2007 while (!marking_deque_.IsEmpty()) { | 
| 1971 while (!marking_deque_.IsEmpty()) { | 2008 while (!marking_deque_.IsEmpty()) { | 
| (...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4133 while (buffer != NULL) { | 4170 while (buffer != NULL) { | 
| 4134 SlotsBuffer* next_buffer = buffer->next(); | 4171 SlotsBuffer* next_buffer = buffer->next(); | 
| 4135 DeallocateBuffer(buffer); | 4172 DeallocateBuffer(buffer); | 
| 4136 buffer = next_buffer; | 4173 buffer = next_buffer; | 
| 4137 } | 4174 } | 
| 4138 *buffer_address = NULL; | 4175 *buffer_address = NULL; | 
| 4139 } | 4176 } | 
| 4140 | 4177 | 
| 4141 | 4178 | 
| 4142 } } // namespace v8::internal | 4179 } } // namespace v8::internal | 
| OLD | NEW |