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

Side by Side Diff: src/heap/heap.cc

Issue 2264493002: [heap] Don't clear black areas when deserializing, they will be marked black later anyway. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/ast/context-slot-cache.h" 9 #include "src/ast/context-slot-cache.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 for (int i = 0; i < num_maps; i++) { 1139 for (int i = 0; i < num_maps; i++) {
1140 // The deserializer will update the skip list. 1140 // The deserializer will update the skip list.
1141 AllocationResult allocation = map_space()->AllocateRawUnaligned( 1141 AllocationResult allocation = map_space()->AllocateRawUnaligned(
1142 Map::kSize, PagedSpace::IGNORE_SKIP_LIST); 1142 Map::kSize, PagedSpace::IGNORE_SKIP_LIST);
1143 HeapObject* free_space = nullptr; 1143 HeapObject* free_space = nullptr;
1144 if (allocation.To(&free_space)) { 1144 if (allocation.To(&free_space)) {
1145 // Mark with a free list node, in case we have a GC before 1145 // Mark with a free list node, in case we have a GC before
1146 // deserializing. 1146 // deserializing.
1147 Address free_space_address = free_space->address(); 1147 Address free_space_address = free_space->address();
1148 CreateFillerObjectAt(free_space_address, Map::kSize, 1148 CreateFillerObjectAt(free_space_address, Map::kSize,
1149 ClearRecordedSlots::kNo); 1149 ClearRecordedSlots::kNo, ClearBlackArea::kNo);
1150 maps->Add(free_space_address); 1150 maps->Add(free_space_address);
1151 } else { 1151 } else {
1152 perform_gc = true; 1152 perform_gc = true;
1153 break; 1153 break;
1154 } 1154 }
1155 } 1155 }
1156 } else if (space == LO_SPACE) { 1156 } else if (space == LO_SPACE) {
1157 // Just check that we can allocate during deserialization. 1157 // Just check that we can allocate during deserialization.
1158 DCHECK_EQ(1, reservation->length()); 1158 DCHECK_EQ(1, reservation->length());
1159 perform_gc = !CanExpandOldGeneration(reservation->at(0).size); 1159 perform_gc = !CanExpandOldGeneration(reservation->at(0).size);
1160 } else { 1160 } else {
1161 for (auto& chunk : *reservation) { 1161 for (auto& chunk : *reservation) {
1162 AllocationResult allocation; 1162 AllocationResult allocation;
1163 int size = chunk.size; 1163 int size = chunk.size;
1164 DCHECK_LE(size, MemoryAllocator::PageAreaSize( 1164 DCHECK_LE(size, MemoryAllocator::PageAreaSize(
1165 static_cast<AllocationSpace>(space))); 1165 static_cast<AllocationSpace>(space)));
1166 if (space == NEW_SPACE) { 1166 if (space == NEW_SPACE) {
1167 allocation = new_space()->AllocateRawUnaligned(size); 1167 allocation = new_space()->AllocateRawUnaligned(size);
1168 } else { 1168 } else {
1169 // The deserializer will update the skip list. 1169 // The deserializer will update the skip list.
1170 allocation = paged_space(space)->AllocateRawUnaligned( 1170 allocation = paged_space(space)->AllocateRawUnaligned(
1171 size, PagedSpace::IGNORE_SKIP_LIST); 1171 size, PagedSpace::IGNORE_SKIP_LIST);
1172 } 1172 }
1173 HeapObject* free_space = nullptr; 1173 HeapObject* free_space = nullptr;
1174 if (allocation.To(&free_space)) { 1174 if (allocation.To(&free_space)) {
1175 // Mark with a free list node, in case we have a GC before 1175 // Mark with a free list node, in case we have a GC before
1176 // deserializing. 1176 // deserializing.
1177 Address free_space_address = free_space->address(); 1177 Address free_space_address = free_space->address();
1178 CreateFillerObjectAt(free_space_address, size, 1178 CreateFillerObjectAt(free_space_address, size,
1179 ClearRecordedSlots::kNo); 1179 ClearRecordedSlots::kNo, ClearBlackArea::kNo);
1180 DCHECK(space < SerializerDeserializer::kNumberOfPreallocatedSpaces); 1180 DCHECK(space < SerializerDeserializer::kNumberOfPreallocatedSpaces);
1181 chunk.start = free_space_address; 1181 chunk.start = free_space_address;
1182 chunk.end = free_space_address + size; 1182 chunk.end = free_space_address + size;
1183 } else { 1183 } else {
1184 perform_gc = true; 1184 perform_gc = true;
1185 break; 1185 break;
1186 } 1186 }
1187 } 1187 }
1188 } 1188 }
1189 if (perform_gc) { 1189 if (perform_gc) {
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 instance->set_interrupt_budget(interpreter::Interpreter::InterruptBudget()); 3058 instance->set_interrupt_budget(interpreter::Interpreter::InterruptBudget());
3059 instance->set_osr_loop_nesting_level(0); 3059 instance->set_osr_loop_nesting_level(0);
3060 instance->set_constant_pool(constant_pool); 3060 instance->set_constant_pool(constant_pool);
3061 instance->set_handler_table(empty_fixed_array()); 3061 instance->set_handler_table(empty_fixed_array());
3062 instance->set_source_position_table(empty_byte_array()); 3062 instance->set_source_position_table(empty_byte_array());
3063 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); 3063 CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length);
3064 3064
3065 return result; 3065 return result;
3066 } 3066 }
3067 3067
3068 void Heap::CreateFillerObjectAt(Address addr, int size, 3068 void Heap::CreateFillerObjectAt(Address addr, int size, ClearRecordedSlots mode,
3069 ClearRecordedSlots mode) { 3069 ClearBlackArea black_area_mode) {
3070 if (size == 0) return; 3070 if (size == 0) return;
3071 HeapObject* filler = HeapObject::FromAddress(addr); 3071 HeapObject* filler = HeapObject::FromAddress(addr);
3072 if (size == kPointerSize) { 3072 if (size == kPointerSize) {
3073 filler->set_map_no_write_barrier( 3073 filler->set_map_no_write_barrier(
3074 reinterpret_cast<Map*>(root(kOnePointerFillerMapRootIndex))); 3074 reinterpret_cast<Map*>(root(kOnePointerFillerMapRootIndex)));
3075 } else if (size == 2 * kPointerSize) { 3075 } else if (size == 2 * kPointerSize) {
3076 filler->set_map_no_write_barrier( 3076 filler->set_map_no_write_barrier(
3077 reinterpret_cast<Map*>(root(kTwoPointerFillerMapRootIndex))); 3077 reinterpret_cast<Map*>(root(kTwoPointerFillerMapRootIndex)));
3078 } else { 3078 } else {
3079 DCHECK_GT(size, 2 * kPointerSize); 3079 DCHECK_GT(size, 2 * kPointerSize);
3080 filler->set_map_no_write_barrier( 3080 filler->set_map_no_write_barrier(
3081 reinterpret_cast<Map*>(root(kFreeSpaceMapRootIndex))); 3081 reinterpret_cast<Map*>(root(kFreeSpaceMapRootIndex)));
3082 FreeSpace::cast(filler)->nobarrier_set_size(size); 3082 FreeSpace::cast(filler)->nobarrier_set_size(size);
3083 } 3083 }
3084 if (mode == ClearRecordedSlots::kYes) { 3084 if (mode == ClearRecordedSlots::kYes) {
3085 ClearRecordedSlotRange(addr, addr + size); 3085 ClearRecordedSlotRange(addr, addr + size);
3086 } 3086 }
3087 3087
3088 // If the location where the filler is created is within a black area we have 3088 // If the location where the filler is created is within a black area we have
3089 // to clear the mark bits of the filler space. 3089 // to clear the mark bits of the filler space.
3090 if (incremental_marking()->black_allocation() && 3090 if (black_area_mode == ClearBlackArea::kYes &&
3091 incremental_marking()->black_allocation() &&
3091 Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(addr))) { 3092 Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(addr))) {
3092 Page* page = Page::FromAddress(addr); 3093 Page* page = Page::FromAddress(addr);
3093 page->markbits()->ClearRange(page->AddressToMarkbitIndex(addr), 3094 page->markbits()->ClearRange(page->AddressToMarkbitIndex(addr),
3094 page->AddressToMarkbitIndex(addr + size)); 3095 page->AddressToMarkbitIndex(addr + size));
3095 } 3096 }
3096 3097
3097 // At this point, we may be deserializing the heap from a snapshot, and 3098 // At this point, we may be deserializing the heap from a snapshot, and
3098 // none of the maps have been created yet and are NULL. 3099 // none of the maps have been created yet and are NULL.
3099 DCHECK((filler->map() == NULL && !deserialization_complete_) || 3100 DCHECK((filler->map() == NULL && !deserialization_complete_) ||
3100 filler->map()->IsMap()); 3101 filler->map()->IsMap());
(...skipping 3393 matching lines...) Expand 10 before | Expand all | Expand 10 after
6494 } 6495 }
6495 6496
6496 6497
6497 // static 6498 // static
6498 int Heap::GetStaticVisitorIdForMap(Map* map) { 6499 int Heap::GetStaticVisitorIdForMap(Map* map) {
6499 return StaticVisitorBase::GetVisitorId(map); 6500 return StaticVisitorBase::GetVisitorId(map);
6500 } 6501 }
6501 6502
6502 } // namespace internal 6503 } // namespace internal
6503 } // namespace v8 6504 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698