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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 }; | 1882 }; |
1883 | 1883 |
1884 | 1884 |
1885 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects | 1885 // Implementation of WeakObjectRetainer for mark compact GCs. All marked objects |
1886 // are retained. | 1886 // are retained. |
1887 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { | 1887 class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { |
1888 public: | 1888 public: |
1889 virtual Object* RetainAs(Object* object) { | 1889 virtual Object* RetainAs(Object* object) { |
1890 if (Marking::MarkBitFrom(HeapObject::cast(object)).Get()) { | 1890 if (Marking::MarkBitFrom(HeapObject::cast(object)).Get()) { |
1891 return object; | 1891 return object; |
| 1892 } else if (object->IsAllocationSite() && |
| 1893 !(AllocationSite::cast(object)->IsZombie())) { |
| 1894 // "dead" AllocationSites need to live long enough for a traversal of new |
| 1895 // space. These sites get a one-time reprieve. |
| 1896 AllocationSite* site = AllocationSite::cast(object); |
| 1897 site->MarkZombie(); |
| 1898 site->GetHeap()->mark_compact_collector()->MarkAllocationSite(site); |
| 1899 return object; |
1892 } else { | 1900 } else { |
1893 return NULL; | 1901 return NULL; |
1894 } | 1902 } |
1895 } | 1903 } |
1896 }; | 1904 }; |
1897 | 1905 |
1898 | 1906 |
1899 // Fill the marking stack with overflowed objects returned by the given | 1907 // Fill the marking stack with overflowed objects returned by the given |
1900 // iterator. Stop when the marking stack is filled or the end of the space | 1908 // iterator. Stop when the marking stack is filled or the end of the space |
1901 // is reached, whichever comes first. | 1909 // is reached, whichever comes first. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 while (current_cell != 0) { | 2001 while (current_cell != 0) { |
1994 int trailing_zeros = CompilerIntrinsics::CountTrailingZeros(current_cell); | 2002 int trailing_zeros = CompilerIntrinsics::CountTrailingZeros(current_cell); |
1995 current_cell >>= trailing_zeros; | 2003 current_cell >>= trailing_zeros; |
1996 offset += trailing_zeros; | 2004 offset += trailing_zeros; |
1997 Address address = cell_base + offset * kPointerSize; | 2005 Address address = cell_base + offset * kPointerSize; |
1998 HeapObject* object = HeapObject::FromAddress(address); | 2006 HeapObject* object = HeapObject::FromAddress(address); |
1999 | 2007 |
2000 int size = object->Size(); | 2008 int size = object->Size(); |
2001 survivors_size += size; | 2009 survivors_size += size; |
2002 | 2010 |
2003 if (FLAG_trace_track_allocation_sites && object->IsJSObject()) { | 2011 Heap::AddressMemento(object); |
2004 if (AllocationMemento::FindForJSObject(JSObject::cast(object), true) | |
2005 != NULL) { | |
2006 heap()->allocation_mementos_found_++; | |
2007 } | |
2008 } | |
2009 | 2012 |
2010 offset++; | 2013 offset++; |
2011 current_cell >>= 1; | 2014 current_cell >>= 1; |
2012 // Aggressively promote young survivors to the old space. | 2015 // Aggressively promote young survivors to the old space. |
2013 if (TryPromoteObject(object, size)) { | 2016 if (TryPromoteObject(object, size)) { |
2014 continue; | 2017 continue; |
2015 } | 2018 } |
2016 | 2019 |
2017 // Promotion failed. Just migrate object to another semispace. | 2020 // Promotion failed. Just migrate object to another semispace. |
2018 MaybeObject* allocation = new_space->AllocateRaw(size); | 2021 MaybeObject* allocation = new_space->AllocateRaw(size); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 StringTable* string_table = heap()->string_table(); | 2094 StringTable* string_table = heap()->string_table(); |
2092 // Mark the string table itself. | 2095 // Mark the string table itself. |
2093 MarkBit string_table_mark = Marking::MarkBitFrom(string_table); | 2096 MarkBit string_table_mark = Marking::MarkBitFrom(string_table); |
2094 SetMark(string_table, string_table_mark); | 2097 SetMark(string_table, string_table_mark); |
2095 // Explicitly mark the prefix. | 2098 // Explicitly mark the prefix. |
2096 string_table->IteratePrefix(visitor); | 2099 string_table->IteratePrefix(visitor); |
2097 ProcessMarkingDeque(); | 2100 ProcessMarkingDeque(); |
2098 } | 2101 } |
2099 | 2102 |
2100 | 2103 |
| 2104 void MarkCompactCollector::MarkAllocationSite(AllocationSite* site) { |
| 2105 MarkBit mark_bit = Marking::MarkBitFrom(site); |
| 2106 SetMark(site, mark_bit); |
| 2107 } |
| 2108 |
| 2109 |
2101 void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { | 2110 void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { |
2102 // Mark the heap roots including global variables, stack variables, | 2111 // Mark the heap roots including global variables, stack variables, |
2103 // etc., and all objects reachable from them. | 2112 // etc., and all objects reachable from them. |
2104 heap()->IterateStrongRoots(visitor, VISIT_ONLY_STRONG); | 2113 heap()->IterateStrongRoots(visitor, VISIT_ONLY_STRONG); |
2105 | 2114 |
2106 // Handle the string table specially. | 2115 // Handle the string table specially. |
2107 MarkStringTable(visitor); | 2116 MarkStringTable(visitor); |
2108 | 2117 |
2109 MarkWeakObjectToCodeTable(); | 2118 MarkWeakObjectToCodeTable(); |
2110 | 2119 |
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4364 while (buffer != NULL) { | 4373 while (buffer != NULL) { |
4365 SlotsBuffer* next_buffer = buffer->next(); | 4374 SlotsBuffer* next_buffer = buffer->next(); |
4366 DeallocateBuffer(buffer); | 4375 DeallocateBuffer(buffer); |
4367 buffer = next_buffer; | 4376 buffer = next_buffer; |
4368 } | 4377 } |
4369 *buffer_address = NULL; | 4378 *buffer_address = NULL; |
4370 } | 4379 } |
4371 | 4380 |
4372 | 4381 |
4373 } } // namespace v8::internal | 4382 } } // namespace v8::internal |
OLD | NEW |