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 6543 matching lines...) Loading... |
6554 heap::SimulateIncrementalMarking(heap); | 6554 heap::SimulateIncrementalMarking(heap); |
6555 for (size_t j = 0; j < arrays.size(); j++) { | 6555 for (size_t j = 0; j < arrays.size(); j++) { |
6556 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); | 6556 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); |
6557 } | 6557 } |
6558 } | 6558 } |
6559 // Force allocation from the free list. | 6559 // Force allocation from the free list. |
6560 heap->set_force_oom(true); | 6560 heap->set_force_oom(true); |
6561 heap->CollectGarbage(OLD_SPACE); | 6561 heap->CollectGarbage(OLD_SPACE); |
6562 } | 6562 } |
6563 | 6563 |
6564 UNINITIALIZED_TEST(PagePromotion) { | |
6565 FLAG_page_promotion = true; | |
6566 FLAG_page_promotion_threshold = 0; // % | |
6567 i::FLAG_min_semi_space_size = 8 * (Page::kPageSize / MB); | |
6568 // We cannot optimize for size as we require a new space with more than one | |
6569 // page. | |
6570 i::FLAG_optimize_for_size = false; | |
6571 // Set max_semi_space_size because it could've been initialized by an | |
6572 // implication of optimize_for_size. | |
6573 i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; | |
6574 v8::Isolate::CreateParams create_params; | |
6575 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | |
6576 v8::Isolate* isolate = v8::Isolate::New(create_params); | |
6577 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
6578 { | |
6579 v8::Isolate::Scope isolate_scope(isolate); | |
6580 v8::HandleScope handle_scope(isolate); | |
6581 v8::Context::New(isolate)->Enter(); | |
6582 Heap* heap = i_isolate->heap(); | |
6583 | |
6584 // Clean up any left over objects from cctest initialization. | |
6585 heap->CollectAllGarbage(); | |
6586 heap->CollectAllGarbage(); | |
6587 | |
6588 std::vector<Handle<FixedArray>> handles; | |
6589 heap::SimulateFullSpace(heap->new_space(), &handles); | |
6590 heap->CollectGarbage(NEW_SPACE); | |
6591 CHECK_GT(handles.size(), 0u); | |
6592 // First object in handle should be on the first page. | |
6593 Handle<FixedArray> first_object = handles.front(); | |
6594 Page* first_page = Page::FromAddress(first_object->address()); | |
6595 // The age mark should not be on the first page. | |
6596 CHECK(!first_page->ContainsLimit(heap->new_space()->age_mark())); | |
6597 // To perform a sanity check on live bytes we need to mark the heap. | |
6598 heap::SimulateIncrementalMarking(heap, true); | |
6599 // Sanity check that the page meets the requirements for promotion. | |
6600 const int threshold_bytes = | |
6601 FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100; | |
6602 CHECK_GE(first_page->LiveBytes(), threshold_bytes); | |
6603 | |
6604 // Actual checks: The page is in new space first, but is moved to old space | |
6605 // during a full GC. | |
6606 CHECK(heap->new_space()->ContainsSlow(first_page->address())); | |
6607 CHECK(!heap->old_space()->ContainsSlow(first_page->address())); | |
6608 heap->CollectGarbage(OLD_SPACE); | |
6609 CHECK(!heap->new_space()->ContainsSlow(first_page->address())); | |
6610 CHECK(heap->old_space()->ContainsSlow(first_page->address())); | |
6611 } | |
6612 } | |
6613 | |
6614 TEST(Regress598319) { | 6564 TEST(Regress598319) { |
6615 // This test ensures that no white objects can cross the progress bar of large | 6565 // This test ensures that no white objects can cross the progress bar of large |
6616 // objects during incremental marking. It checks this by using Shift() during | 6566 // objects during incremental marking. It checks this by using Shift() during |
6617 // incremental marking. | 6567 // incremental marking. |
6618 CcTest::InitializeVM(); | 6568 CcTest::InitializeVM(); |
6619 v8::HandleScope scope(CcTest::isolate()); | 6569 v8::HandleScope scope(CcTest::isolate()); |
6620 Heap* heap = CcTest::heap(); | 6570 Heap* heap = CcTest::heap(); |
6621 Isolate* isolate = heap->isolate(); | 6571 Isolate* isolate = heap->isolate(); |
6622 | 6572 |
6623 const int kNumberOfObjects = Page::kMaxRegularHeapObjectSize / kPointerSize; | 6573 const int kNumberOfObjects = Page::kMaxRegularHeapObjectSize / kPointerSize; |
(...skipping 151 matching lines...) Loading... |
6775 int mark_sweeps_performed = mark_sweep_count_after - mark_sweep_count_before; | 6725 int mark_sweeps_performed = mark_sweep_count_after - mark_sweep_count_before; |
6776 // The memory pressuer handler either performed two GCs or performed one and | 6726 // The memory pressuer handler either performed two GCs or performed one and |
6777 // started incremental marking. | 6727 // started incremental marking. |
6778 CHECK(mark_sweeps_performed == 2 || | 6728 CHECK(mark_sweeps_performed == 2 || |
6779 (mark_sweeps_performed == 1 && | 6729 (mark_sweeps_performed == 1 && |
6780 !heap->incremental_marking()->IsStopped())); | 6730 !heap->incremental_marking()->IsStopped())); |
6781 } | 6731 } |
6782 | 6732 |
6783 } // namespace internal | 6733 } // namespace internal |
6784 } // namespace v8 | 6734 } // namespace v8 |
OLD | NEW |