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 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 DeleteArray(promoted_histogram_); | 1379 DeleteArray(promoted_histogram_); |
1380 promoted_histogram_ = NULL; | 1380 promoted_histogram_ = NULL; |
1381 } | 1381 } |
1382 | 1382 |
1383 allocation_info_.Reset(nullptr, nullptr); | 1383 allocation_info_.Reset(nullptr, nullptr); |
1384 | 1384 |
1385 to_space_.TearDown(); | 1385 to_space_.TearDown(); |
1386 from_space_.TearDown(); | 1386 from_space_.TearDown(); |
1387 } | 1387 } |
1388 | 1388 |
| 1389 void NewSpace::SwapFromSpacePageWithToSpacePage(Page* from_space_page) { |
| 1390 // The method is called when replacing a *to* space page with a *from* space |
| 1391 // page when moving a page within new space. Since there's still a full page |
| 1392 // to move (which would've been copied otherwise) *to* space cannot be |
| 1393 // on the last page. |
| 1394 DCHECK(!to_space_.OnLastPage()); |
| 1395 |
| 1396 Page* to_space_page = to_space_.anchor()->prev_page(); |
| 1397 Page* from_space_page_prev_page = from_space_page->prev_page(); |
| 1398 SwapPages(from_space_page, to_space_page, to_space_.anchor(), |
| 1399 from_space_page_prev_page); |
| 1400 // Since we removed an unused to space page but added a used one we need |
| 1401 // to increment the page counter. |
| 1402 pages_used_++; |
| 1403 } |
| 1404 |
| 1405 void NewSpace::SwapPages(Page* from_space_page, Page* to_space_page, |
| 1406 Page* from_target, Page* to_target) { |
| 1407 DCHECK(from_space_page->InFromSpace()); |
| 1408 DCHECK(to_space_page->InToSpace()); |
| 1409 to_space_page->Unlink(); |
| 1410 from_space_page->Unlink(); |
| 1411 // Swap owner. |
| 1412 to_space_page->set_owner(&from_space_); |
| 1413 from_space_page->set_owner(&to_space_); |
| 1414 // Swap flags. |
| 1415 intptr_t tmp_flags = to_space_page->GetFlags(); |
| 1416 to_space_page->SetFlags(from_space_page->GetFlags(), Page::kCopyAllFlags); |
| 1417 from_space_page->SetFlags(tmp_flags, Page::kCopyAllFlags); |
| 1418 // Insert again. |
| 1419 to_space_page->InsertAfter(to_target); |
| 1420 from_space_page->InsertAfter(from_target); |
| 1421 DCHECK(to_space_page->InFromSpace()); |
| 1422 DCHECK(from_space_page->InToSpace()); |
| 1423 // Update current page of space. |
| 1424 if (from_space_.current_page() == from_space_page) |
| 1425 from_space_.current_page_ = to_space_page; |
| 1426 if (to_space_.current_page() == to_space_page) |
| 1427 to_space_.current_page_ = from_space_page; |
| 1428 } |
1389 | 1429 |
1390 void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); } | 1430 void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); } |
1391 | 1431 |
1392 | 1432 |
1393 void NewSpace::Grow() { | 1433 void NewSpace::Grow() { |
1394 // Double the semispace size but only up to maximum capacity. | 1434 // Double the semispace size but only up to maximum capacity. |
1395 DCHECK(TotalCapacity() < MaximumCapacity()); | 1435 DCHECK(TotalCapacity() < MaximumCapacity()); |
1396 int new_capacity = | 1436 int new_capacity = |
1397 Min(MaximumCapacity(), | 1437 Min(MaximumCapacity(), |
1398 FLAG_semi_space_growth_factor * static_cast<int>(TotalCapacity())); | 1438 FLAG_semi_space_growth_factor * static_cast<int>(TotalCapacity())); |
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3220 object->ShortPrint(); | 3260 object->ShortPrint(); |
3221 PrintF("\n"); | 3261 PrintF("\n"); |
3222 } | 3262 } |
3223 printf(" --------------------------------------\n"); | 3263 printf(" --------------------------------------\n"); |
3224 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3264 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3225 } | 3265 } |
3226 | 3266 |
3227 #endif // DEBUG | 3267 #endif // DEBUG |
3228 } // namespace internal | 3268 } // namespace internal |
3229 } // namespace v8 | 3269 } // namespace v8 |
OLD | NEW |