OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/base/platform/semaphore.h" | 9 #include "src/base/platform/semaphore.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 497 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
498 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); | 498 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
499 chunk->mutex_ = new base::Mutex(); | 499 chunk->mutex_ = new base::Mutex(); |
500 chunk->available_in_free_list_ = 0; | 500 chunk->available_in_free_list_ = 0; |
501 chunk->wasted_memory_ = 0; | 501 chunk->wasted_memory_ = 0; |
502 chunk->ResetLiveBytes(); | 502 chunk->ResetLiveBytes(); |
503 chunk->ClearLiveness(); | 503 chunk->ClearLiveness(); |
504 chunk->set_next_chunk(nullptr); | 504 chunk->set_next_chunk(nullptr); |
505 chunk->set_prev_chunk(nullptr); | 505 chunk->set_prev_chunk(nullptr); |
506 chunk->local_tracker_ = nullptr; | 506 chunk->local_tracker_ = nullptr; |
| 507 chunk->black_area_end_marker_map_ = nullptr; |
507 | 508 |
508 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); | 509 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); |
509 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); | 510 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); |
510 | 511 |
511 if (executable == EXECUTABLE) { | 512 if (executable == EXECUTABLE) { |
512 chunk->SetFlag(IS_EXECUTABLE); | 513 chunk->SetFlag(IS_EXECUTABLE); |
513 } | 514 } |
514 | 515 |
515 if (reservation != nullptr) { | 516 if (reservation != nullptr) { |
516 chunk->reservation_.TakeControl(reservation); | 517 chunk->reservation_.TakeControl(reservation); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 // Empty space allocation info, returning unused area to free list. | 1280 // Empty space allocation info, returning unused area to free list. |
1280 void PagedSpace::EmptyAllocationInfo() { | 1281 void PagedSpace::EmptyAllocationInfo() { |
1281 // Mark the old linear allocation area with a free space map so it can be | 1282 // Mark the old linear allocation area with a free space map so it can be |
1282 // skipped when scanning the heap. | 1283 // skipped when scanning the heap. |
1283 Address current_top = top(); | 1284 Address current_top = top(); |
1284 Address current_limit = limit(); | 1285 Address current_limit = limit(); |
1285 if (current_top == nullptr) { | 1286 if (current_top == nullptr) { |
1286 DCHECK(current_limit == nullptr); | 1287 DCHECK(current_limit == nullptr); |
1287 return; | 1288 return; |
1288 } | 1289 } |
1289 int old_linear_size = static_cast<int>(current_limit - current_top); | 1290 |
| 1291 if (heap()->incremental_marking()->black_allocation()) { |
| 1292 Page* page = Page::FromAddress(current_top); |
| 1293 // We have to remember the end of the current black allocation area if |
| 1294 // something was allocated in the current bump pointer range. |
| 1295 if (allocation_info_.original_top() != current_top) { |
| 1296 Address end_black_area = current_top - kPointerSize; |
| 1297 page->AddBlackAreaEndMarker(end_black_area); |
| 1298 } |
| 1299 |
| 1300 // Clear the bits in the unused black area. |
| 1301 if (current_top != current_limit) { |
| 1302 page->markbits()->ClearRange(page->AddressToMarkbitIndex(current_top), |
| 1303 page->AddressToMarkbitIndex(current_limit)); |
| 1304 page->IncrementLiveBytes(-static_cast<int>(current_limit - current_top)); |
| 1305 } |
| 1306 } |
| 1307 |
1290 SetTopAndLimit(NULL, NULL); | 1308 SetTopAndLimit(NULL, NULL); |
1291 if (current_top != current_limit && | 1309 Free(current_top, static_cast<int>(current_limit - current_top)); |
1292 heap()->incremental_marking()->black_allocation()) { | |
1293 Page* page = Page::FromAddress(current_top); | |
1294 page->markbits()->ClearRange(page->AddressToMarkbitIndex(current_top), | |
1295 page->AddressToMarkbitIndex(current_limit)); | |
1296 page->IncrementLiveBytes(-static_cast<int>(current_limit - current_top)); | |
1297 } | |
1298 Free(current_top, old_linear_size); | |
1299 } | 1310 } |
1300 | 1311 |
1301 void PagedSpace::IncreaseCapacity(int size) { | 1312 void PagedSpace::IncreaseCapacity(int size) { |
1302 accounting_stats_.ExpandSpace(size); | 1313 accounting_stats_.ExpandSpace(size); |
1303 } | 1314 } |
1304 | 1315 |
1305 void PagedSpace::ReleasePage(Page* page) { | 1316 void PagedSpace::ReleasePage(Page* page) { |
1306 DCHECK_EQ(page->LiveBytes(), 0); | 1317 DCHECK_EQ(page->LiveBytes(), 0); |
1307 DCHECK_EQ(AreaSize(), page->area_size()); | 1318 DCHECK_EQ(AreaSize(), page->area_size()); |
1308 DCHECK_EQ(page->owner(), this); | 1319 DCHECK_EQ(page->owner(), this); |
1309 | 1320 |
1310 free_list_.EvictFreeListItems(page); | 1321 free_list_.EvictFreeListItems(page); |
1311 DCHECK(!free_list_.ContainsPageFreeListItems(page)); | 1322 DCHECK(!free_list_.ContainsPageFreeListItems(page)); |
1312 | 1323 |
| 1324 page->ReleaseBlackAreaEndMarkerMap(); |
| 1325 |
1313 if (Page::FromAllocationAreaAddress(allocation_info_.top()) == page) { | 1326 if (Page::FromAllocationAreaAddress(allocation_info_.top()) == page) { |
1314 allocation_info_.Reset(nullptr, nullptr); | 1327 allocation_info_.Reset(nullptr, nullptr); |
1315 } | 1328 } |
1316 | 1329 |
1317 // If page is still in a list, unlink it from that list. | 1330 // If page is still in a list, unlink it from that list. |
1318 if (page->next_chunk() != NULL) { | 1331 if (page->next_chunk() != NULL) { |
1319 DCHECK(page->prev_chunk() != NULL); | 1332 DCHECK(page->prev_chunk() != NULL); |
1320 page->Unlink(); | 1333 page->Unlink(); |
1321 } | 1334 } |
1322 | 1335 |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3132 object->ShortPrint(); | 3145 object->ShortPrint(); |
3133 PrintF("\n"); | 3146 PrintF("\n"); |
3134 } | 3147 } |
3135 printf(" --------------------------------------\n"); | 3148 printf(" --------------------------------------\n"); |
3136 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3149 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3137 } | 3150 } |
3138 | 3151 |
3139 #endif // DEBUG | 3152 #endif // DEBUG |
3140 } // namespace internal | 3153 } // namespace internal |
3141 } // namespace v8 | 3154 } // namespace v8 |
OLD | NEW |