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 3506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 // The optimizer can allocate stuff, messing up the test. | 3517 // The optimizer can allocate stuff, messing up the test. |
3518 i::FLAG_crankshaft = false; | 3518 i::FLAG_crankshaft = false; |
3519 i::FLAG_always_opt = false; | 3519 i::FLAG_always_opt = false; |
3520 // Parallel compaction increases fragmentation, depending on how existing | 3520 // Parallel compaction increases fragmentation, depending on how existing |
3521 // memory is distributed. Since this is non-deterministic because of | 3521 // memory is distributed. Since this is non-deterministic because of |
3522 // concurrent sweeping, we disable it for this test. | 3522 // concurrent sweeping, we disable it for this test. |
3523 i::FLAG_parallel_compaction = false; | 3523 i::FLAG_parallel_compaction = false; |
3524 // Concurrent sweeping adds non determinism, depending on when memory is | 3524 // Concurrent sweeping adds non determinism, depending on when memory is |
3525 // available for further reuse. | 3525 // available for further reuse. |
3526 i::FLAG_concurrent_sweeping = false; | 3526 i::FLAG_concurrent_sweeping = false; |
| 3527 // Fast evacuation of pages may result in a different page count in old space. |
| 3528 i::FLAG_page_promotion = false; |
3527 CcTest::InitializeVM(); | 3529 CcTest::InitializeVM(); |
3528 Isolate* isolate = CcTest::i_isolate(); | 3530 Isolate* isolate = CcTest::i_isolate(); |
3529 Factory* factory = isolate->factory(); | 3531 Factory* factory = isolate->factory(); |
3530 Heap* heap = isolate->heap(); | 3532 Heap* heap = isolate->heap(); |
3531 v8::HandleScope scope(CcTest::isolate()); | 3533 v8::HandleScope scope(CcTest::isolate()); |
3532 static const int number_of_test_pages = 20; | 3534 static const int number_of_test_pages = 20; |
3533 | 3535 |
3534 // Prepare many pages with low live-bytes count. | 3536 // Prepare many pages with low live-bytes count. |
3535 PagedSpace* old_space = heap->old_space(); | 3537 PagedSpace* old_space = heap->old_space(); |
3536 CHECK_EQ(1, old_space->CountTotalPages()); | 3538 CHECK_EQ(1, old_space->CountTotalPages()); |
(...skipping 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6566 SimulateIncrementalMarking(heap); | 6568 SimulateIncrementalMarking(heap); |
6567 for (size_t j = 0; j < arrays.size(); j++) { | 6569 for (size_t j = 0; j < arrays.size(); j++) { |
6568 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); | 6570 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); |
6569 } | 6571 } |
6570 } | 6572 } |
6571 // Force allocation from the free list. | 6573 // Force allocation from the free list. |
6572 heap->set_force_oom(true); | 6574 heap->set_force_oom(true); |
6573 heap->CollectGarbage(OLD_SPACE); | 6575 heap->CollectGarbage(OLD_SPACE); |
6574 } | 6576 } |
6575 | 6577 |
| 6578 UNINITIALIZED_TEST(PagePromotion) { |
| 6579 FLAG_page_promotion = true; |
| 6580 FLAG_page_promotion_threshold = 0; // % |
| 6581 i::FLAG_min_semi_space_size = 8 * (Page::kPageSize / MB); |
| 6582 // We cannot optimize for size as we require a new space with more than one |
| 6583 // page. |
| 6584 i::FLAG_optimize_for_size = false; |
| 6585 // Set max_semi_space_size because it could've been initialized by an |
| 6586 // implication of optimize_for_size. |
| 6587 i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; |
| 6588 v8::Isolate::CreateParams create_params; |
| 6589 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 6590 v8::Isolate* isolate = v8::Isolate::New(create_params); |
| 6591 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6592 { |
| 6593 v8::Isolate::Scope isolate_scope(isolate); |
| 6594 v8::HandleScope handle_scope(isolate); |
| 6595 v8::Context::New(isolate)->Enter(); |
| 6596 Heap* heap = i_isolate->heap(); |
| 6597 std::vector<Handle<FixedArray>> handles; |
| 6598 SimulateFullSpace(heap->new_space(), &handles); |
| 6599 heap->CollectGarbage(NEW_SPACE); |
| 6600 CHECK_GT(handles.size(), 0u); |
| 6601 // First object in handle should be on the first page. |
| 6602 Handle<FixedArray> first_object = handles.front(); |
| 6603 NewSpacePage* first_page = |
| 6604 NewSpacePage::FromAddress(first_object->address()); |
| 6605 // The age mark should not be on the first page. |
| 6606 CHECK(!first_page->ContainsLimit(heap->new_space()->age_mark())); |
| 6607 // To perform a sanity check on live bytes we need to mark the heap. |
| 6608 SimulateIncrementalMarking(heap, true); |
| 6609 // Sanity check that the page meets the requirements for promotion. |
| 6610 const int threshold_bytes = |
| 6611 FLAG_page_promotion_threshold * NewSpacePage::kAllocatableMemory / 100; |
| 6612 CHECK_GE(first_page->LiveBytes(), threshold_bytes); |
| 6613 |
| 6614 // Actual checks: The page is in new space first, but is moved to old space |
| 6615 // during a full GC. |
| 6616 CHECK(heap->new_space()->ContainsSlow(first_page->address())); |
| 6617 CHECK(!heap->old_space()->ContainsSlow(first_page->address())); |
| 6618 heap->CollectGarbage(OLD_SPACE); |
| 6619 CHECK(!heap->new_space()->ContainsSlow(first_page->address())); |
| 6620 CHECK(heap->old_space()->ContainsSlow(first_page->address())); |
| 6621 } |
| 6622 } |
| 6623 |
6576 } // namespace internal | 6624 } // namespace internal |
6577 } // namespace v8 | 6625 } // namespace v8 |
OLD | NEW |