Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: src/mark-compact.cc

Issue 10996017: Revert 12609 (Allow partial scanning of large arrays) (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.h ('k') | src/spaces.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 if (end - start >= kMinRangeForMarkingRecursion) { 1059 if (end - start >= kMinRangeForMarkingRecursion) {
1060 if (VisitUnmarkedObjects(heap, start, end)) return; 1060 if (VisitUnmarkedObjects(heap, start, end)) return;
1061 // We are close to a stack overflow, so just mark the objects. 1061 // We are close to a stack overflow, so just mark the objects.
1062 } 1062 }
1063 MarkCompactCollector* collector = heap->mark_compact_collector(); 1063 MarkCompactCollector* collector = heap->mark_compact_collector();
1064 for (Object** p = start; p < end; p++) { 1064 for (Object** p = start; p < end; p++) {
1065 MarkObjectByPointer(collector, start, p); 1065 MarkObjectByPointer(collector, start, p);
1066 } 1066 }
1067 } 1067 }
1068 1068
1069 static void VisitHugeFixedArray(Heap* heap, FixedArray* array, int length);
1070
1071 // The deque is contiguous and we use new space, it is therefore contained in
1072 // one page minus the header. It also has a size that is a power of two so
1073 // it is half the size of a page. We want to scan a number of array entries
1074 // that is less than the number of entries in the deque, so we divide by 2
1075 // once more.
1076 static const int kScanningChunk = Page::kPageSize / 4 / kPointerSize;
1077
1078 INLINE(static void VisitFixedArray(Map* map, HeapObject* object)) {
1079 FixedArray* array = FixedArray::cast(object);
1080 int length = array->length();
1081 Heap* heap = map->GetHeap();
1082
1083 if (length < kScanningChunk ||
1084 MemoryChunk::FromAddress(array->address())->owner()->identity() !=
1085 LO_SPACE) {
1086 Object** start = array->data_start();
1087 VisitPointers(heap, start, start + length);
1088 } else {
1089 VisitHugeFixedArray(heap, array, length);
1090 }
1091 }
1092
1093 // Marks the object black and pushes it on the marking stack. 1069 // Marks the object black and pushes it on the marking stack.
1094 INLINE(static void MarkObject(Heap* heap, HeapObject* object)) { 1070 INLINE(static void MarkObject(Heap* heap, HeapObject* object)) {
1095 MarkBit mark = Marking::MarkBitFrom(object); 1071 MarkBit mark = Marking::MarkBitFrom(object);
1096 heap->mark_compact_collector()->MarkObject(object, mark); 1072 heap->mark_compact_collector()->MarkObject(object, mark);
1097 } 1073 }
1098 1074
1099 // Marks the object black without pushing it on the marking stack. 1075 // Marks the object black without pushing it on the marking stack.
1100 // Returns true if object needed marking and false otherwise. 1076 // Returns true if object needed marking and false otherwise.
1101 INLINE(static bool MarkObjectWithoutPush(Heap* heap, HeapObject* object)) { 1077 INLINE(static bool MarkObjectWithoutPush(Heap* heap, HeapObject* object)) {
1102 MarkBit mark_bit = Marking::MarkBitFrom(object); 1078 MarkBit mark_bit = Marking::MarkBitFrom(object);
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 heap, 1497 heap,
1522 HeapObject::RawField(object, 1498 HeapObject::RawField(object,
1523 SharedFunctionInfo::kOptimizedCodeMapOffset), 1499 SharedFunctionInfo::kOptimizedCodeMapOffset),
1524 HeapObject::RawField(object, SharedFunctionInfo::kSize)); 1500 HeapObject::RawField(object, SharedFunctionInfo::kSize));
1525 } 1501 }
1526 1502
1527 static VisitorDispatchTable<Callback> non_count_table_; 1503 static VisitorDispatchTable<Callback> non_count_table_;
1528 }; 1504 };
1529 1505
1530 1506
1531 void MarkCompactMarkingVisitor::VisitHugeFixedArray(Heap* heap,
1532 FixedArray* array,
1533 int length) {
1534 MemoryChunk* chunk = MemoryChunk::FromAddress(array->address());
1535
1536 ASSERT(chunk->owner()->identity() == LO_SPACE);
1537
1538 Object** start = array->data_start();
1539 int from =
1540 chunk->IsPartiallyScanned() ? chunk->PartiallyScannedProgress() : 0;
1541 int to = Min(from + kScanningChunk, length);
1542 VisitPointers(heap, start + from, start + to);
1543
1544 if (to == length) {
1545 chunk->SetCompletelyScanned();
1546 } else {
1547 chunk->SetPartiallyScannedProgress(to);
1548 }
1549 }
1550
1551
1552 void MarkCompactMarkingVisitor::ObjectStatsCountFixedArray( 1507 void MarkCompactMarkingVisitor::ObjectStatsCountFixedArray(
1553 FixedArrayBase* fixed_array, 1508 FixedArrayBase* fixed_array,
1554 FixedArraySubInstanceType fast_type, 1509 FixedArraySubInstanceType fast_type,
1555 FixedArraySubInstanceType dictionary_type) { 1510 FixedArraySubInstanceType dictionary_type) {
1556 Heap* heap = fixed_array->map()->GetHeap(); 1511 Heap* heap = fixed_array->map()->GetHeap();
1557 if (fixed_array->map() != heap->fixed_cow_array_map() && 1512 if (fixed_array->map() != heap->fixed_cow_array_map() &&
1558 fixed_array->map() != heap->fixed_double_array_map() && 1513 fixed_array->map() != heap->fixed_double_array_map() &&
1559 fixed_array != heap->empty_fixed_array()) { 1514 fixed_array != heap->empty_fixed_array()) {
1560 if (fixed_array->IsDictionary()) { 1515 if (fixed_array->IsDictionary()) {
1561 heap->RecordObjectStats(FIXED_ARRAY_TYPE, 1516 heap->RecordObjectStats(FIXED_ARRAY_TYPE,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 1638
1684 table_.Register(kVisitSharedFunctionInfo, 1639 table_.Register(kVisitSharedFunctionInfo,
1685 &VisitSharedFunctionInfoAndFlushCode); 1640 &VisitSharedFunctionInfoAndFlushCode);
1686 1641
1687 table_.Register(kVisitJSFunction, 1642 table_.Register(kVisitJSFunction,
1688 &VisitJSFunctionAndFlushCode); 1643 &VisitJSFunctionAndFlushCode);
1689 1644
1690 table_.Register(kVisitJSRegExp, 1645 table_.Register(kVisitJSRegExp,
1691 &VisitRegExpAndFlushCode); 1646 &VisitRegExpAndFlushCode);
1692 1647
1693 table_.Register(kVisitFixedArray,
1694 &VisitFixedArray);
1695
1696 if (FLAG_track_gc_object_stats) { 1648 if (FLAG_track_gc_object_stats) {
1697 // Copy the visitor table to make call-through possible. 1649 // Copy the visitor table to make call-through possible.
1698 non_count_table_.CopyFrom(&table_); 1650 non_count_table_.CopyFrom(&table_);
1699 #define VISITOR_ID_COUNT_FUNCTION(id) \ 1651 #define VISITOR_ID_COUNT_FUNCTION(id) \
1700 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit); 1652 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit);
1701 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION) 1653 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION)
1702 #undef VISITOR_ID_COUNT_FUNCTION 1654 #undef VISITOR_ID_COUNT_FUNCTION
1703 } 1655 }
1704 } 1656 }
1705 1657
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 ASSERT(object->IsHeapObject()); 2121 ASSERT(object->IsHeapObject());
2170 ASSERT(heap()->Contains(object)); 2122 ASSERT(heap()->Contains(object));
2171 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object))); 2123 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object)));
2172 2124
2173 Map* map = object->map(); 2125 Map* map = object->map();
2174 MarkBit map_mark = Marking::MarkBitFrom(map); 2126 MarkBit map_mark = Marking::MarkBitFrom(map);
2175 MarkObject(map, map_mark); 2127 MarkObject(map, map_mark);
2176 2128
2177 MarkCompactMarkingVisitor::IterateBody(map, object); 2129 MarkCompactMarkingVisitor::IterateBody(map, object);
2178 } 2130 }
2179 ProcessLargePostponedArrays(heap(), &marking_deque_);
2180 2131
2181 // Process encountered weak maps, mark objects only reachable by those 2132 // Process encountered weak maps, mark objects only reachable by those
2182 // weak maps and repeat until fix-point is reached. 2133 // weak maps and repeat until fix-point is reached.
2183 ProcessWeakMaps(); 2134 ProcessWeakMaps();
2184 } 2135 }
2185 } 2136 }
2186 2137
2187 2138
2188 void MarkCompactCollector::ProcessLargePostponedArrays(Heap* heap,
2189 MarkingDeque* deque) {
2190 ASSERT(deque->IsEmpty());
2191 LargeObjectIterator it(heap->lo_space());
2192 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
2193 if (!obj->IsFixedArray()) continue;
2194 MemoryChunk* p = MemoryChunk::FromAddress(obj->address());
2195 if (p->IsPartiallyScanned()) {
2196 deque->PushBlack(obj);
2197 }
2198 }
2199 }
2200
2201
2202 // Sweep the heap for overflowed objects, clear their overflow bits, and 2139 // Sweep the heap for overflowed objects, clear their overflow bits, and
2203 // push them on the marking stack. Stop early if the marking stack fills 2140 // push them on the marking stack. Stop early if the marking stack fills
2204 // before sweeping completes. If sweeping completes, there are no remaining 2141 // before sweeping completes. If sweeping completes, there are no remaining
2205 // overflowed objects in the heap so the overflow flag on the markings stack 2142 // overflowed objects in the heap so the overflow flag on the markings stack
2206 // is cleared. 2143 // is cleared.
2207 void MarkCompactCollector::RefillMarkingDeque() { 2144 void MarkCompactCollector::RefillMarkingDeque() {
2208 if (FLAG_trace_gc) {
2209 PrintPID("Marking queue overflowed\n");
2210 }
2211 ASSERT(marking_deque_.overflowed()); 2145 ASSERT(marking_deque_.overflowed());
2212 2146
2213 SemiSpaceIterator new_it(heap()->new_space()); 2147 SemiSpaceIterator new_it(heap()->new_space());
2214 DiscoverGreyObjectsWithIterator(heap(), &marking_deque_, &new_it); 2148 DiscoverGreyObjectsWithIterator(heap(), &marking_deque_, &new_it);
2215 if (marking_deque_.IsFull()) return; 2149 if (marking_deque_.IsFull()) return;
2216 2150
2217 DiscoverGreyObjectsInSpace(heap(), 2151 DiscoverGreyObjectsInSpace(heap(),
2218 &marking_deque_, 2152 &marking_deque_,
2219 heap()->old_pointer_space()); 2153 heap()->old_pointer_space());
2220 if (marking_deque_.IsFull()) return; 2154 if (marking_deque_.IsFull()) return;
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
4131 while (buffer != NULL) { 4065 while (buffer != NULL) {
4132 SlotsBuffer* next_buffer = buffer->next(); 4066 SlotsBuffer* next_buffer = buffer->next();
4133 DeallocateBuffer(buffer); 4067 DeallocateBuffer(buffer);
4134 buffer = next_buffer; 4068 buffer = next_buffer;
4135 } 4069 }
4136 *buffer_address = NULL; 4070 *buffer_address = NULL;
4137 } 4071 }
4138 4072
4139 4073
4140 } } // namespace v8::internal 4074 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698