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 6541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6552 heap::SimulateIncrementalMarking(heap); | 6552 heap::SimulateIncrementalMarking(heap); |
6553 for (size_t j = 0; j < arrays.size(); j++) { | 6553 for (size_t j = 0; j < arrays.size(); j++) { |
6554 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); | 6554 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); |
6555 } | 6555 } |
6556 } | 6556 } |
6557 // Force allocation from the free list. | 6557 // Force allocation from the free list. |
6558 heap->set_force_oom(true); | 6558 heap->set_force_oom(true); |
6559 heap->CollectGarbage(OLD_SPACE); | 6559 heap->CollectGarbage(OLD_SPACE); |
6560 } | 6560 } |
6561 | 6561 |
6562 UNINITIALIZED_TEST(PagePromotion) { | |
6563 FLAG_page_promotion = true; | |
6564 FLAG_page_promotion_threshold = 0; // % | |
6565 i::FLAG_min_semi_space_size = 8 * (Page::kPageSize / MB); | |
6566 // We cannot optimize for size as we require a new space with more than one | |
6567 // page. | |
6568 i::FLAG_optimize_for_size = false; | |
6569 // Set max_semi_space_size because it could've been initialized by an | |
6570 // implication of optimize_for_size. | |
6571 i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; | |
6572 v8::Isolate::CreateParams create_params; | |
6573 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | |
6574 v8::Isolate* isolate = v8::Isolate::New(create_params); | |
6575 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
6576 { | |
6577 v8::Isolate::Scope isolate_scope(isolate); | |
6578 v8::HandleScope handle_scope(isolate); | |
6579 v8::Context::New(isolate)->Enter(); | |
6580 Heap* heap = i_isolate->heap(); | |
6581 | |
6582 // Clean up any left over objects from cctest initialization. | |
6583 heap->CollectAllGarbage(); | |
6584 heap->CollectAllGarbage(); | |
6585 | |
6586 std::vector<Handle<FixedArray>> handles; | |
6587 heap::SimulateFullSpace(heap->new_space(), &handles); | |
6588 heap->CollectGarbage(NEW_SPACE); | |
6589 CHECK_GT(handles.size(), 0u); | |
6590 // First object in handle should be on the first page. | |
6591 Handle<FixedArray> first_object = handles.front(); | |
6592 Page* first_page = Page::FromAddress(first_object->address()); | |
6593 // The age mark should not be on the first page. | |
6594 CHECK(!first_page->ContainsLimit(heap->new_space()->age_mark())); | |
6595 // To perform a sanity check on live bytes we need to mark the heap. | |
6596 heap::SimulateIncrementalMarking(heap, true); | |
6597 // Sanity check that the page meets the requirements for promotion. | |
6598 const int threshold_bytes = | |
6599 FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100; | |
6600 CHECK_GE(first_page->LiveBytes(), threshold_bytes); | |
6601 | |
6602 // Actual checks: The page is in new space first, but is moved to old space | |
6603 // during a full GC. | |
6604 CHECK(heap->new_space()->ContainsSlow(first_page->address())); | |
6605 CHECK(!heap->old_space()->ContainsSlow(first_page->address())); | |
6606 heap->CollectGarbage(OLD_SPACE); | |
6607 CHECK(!heap->new_space()->ContainsSlow(first_page->address())); | |
6608 CHECK(heap->old_space()->ContainsSlow(first_page->address())); | |
6609 } | |
6610 } | |
6611 | |
6612 TEST(Regress598319) { | 6562 TEST(Regress598319) { |
6613 // This test ensures that no white objects can cross the progress bar of large | 6563 // This test ensures that no white objects can cross the progress bar of large |
6614 // objects during incremental marking. It checks this by using Shift() during | 6564 // objects during incremental marking. It checks this by using Shift() during |
6615 // incremental marking. | 6565 // incremental marking. |
6616 CcTest::InitializeVM(); | 6566 CcTest::InitializeVM(); |
6617 v8::HandleScope scope(CcTest::isolate()); | 6567 v8::HandleScope scope(CcTest::isolate()); |
6618 Heap* heap = CcTest::heap(); | 6568 Heap* heap = CcTest::heap(); |
6619 Isolate* isolate = heap->isolate(); | 6569 Isolate* isolate = heap->isolate(); |
6620 | 6570 |
6621 const int kNumberOfObjects = Page::kMaxRegularHeapObjectSize / kPointerSize; | 6571 const int kNumberOfObjects = Page::kMaxRegularHeapObjectSize / kPointerSize; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6755 CHECK(marking->IsComplete()); | 6705 CHECK(marking->IsComplete()); |
6756 intptr_t size_before = heap->SizeOfObjects(); | 6706 intptr_t size_before = heap->SizeOfObjects(); |
6757 CcTest::heap()->CollectAllGarbage(); | 6707 CcTest::heap()->CollectAllGarbage(); |
6758 intptr_t size_after = heap->SizeOfObjects(); | 6708 intptr_t size_after = heap->SizeOfObjects(); |
6759 // Live size does not increase after garbage collection. | 6709 // Live size does not increase after garbage collection. |
6760 CHECK_LE(size_after, size_before); | 6710 CHECK_LE(size_after, size_before); |
6761 } | 6711 } |
6762 | 6712 |
6763 } // namespace internal | 6713 } // namespace internal |
6764 } // namespace v8 | 6714 } // namespace v8 |
OLD | NEW |