Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: test/cctest/test-heap.cc

Issue 1314863003: [heap] More flag cleanup. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation and add const to parameters Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 2772
2773 HEAP_TEST(GCFlags) { 2773 HEAP_TEST(GCFlags) {
2774 CcTest::InitializeVM(); 2774 CcTest::InitializeVM();
2775 Heap* heap = CcTest::heap(); 2775 Heap* heap = CcTest::heap();
2776 2776
2777 heap->set_current_gc_flags(Heap::kNoGCFlags); 2777 heap->set_current_gc_flags(Heap::kNoGCFlags);
2778 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); 2778 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_);
2779 2779
2780 // Set the flags to check whether we appropriately resets them after the GC. 2780 // Set the flags to check whether we appropriately resets them after the GC.
2781 heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask); 2781 heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask);
2782 heap->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); 2782 heap->CollectAllGarbage("GCFlags", Heap::kReduceMemoryFootprintMask);
2783 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); 2783 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_);
2784 2784
2785 MarkCompactCollector* collector = heap->mark_compact_collector(); 2785 MarkCompactCollector* collector = heap->mark_compact_collector();
2786 if (collector->sweeping_in_progress()) { 2786 if (collector->sweeping_in_progress()) {
2787 collector->EnsureSweepingCompleted(); 2787 collector->EnsureSweepingCompleted();
2788 } 2788 }
2789 2789
2790 IncrementalMarking* marking = heap->incremental_marking(); 2790 IncrementalMarking* marking = heap->incremental_marking();
2791 marking->Stop(); 2791 marking->Stop();
2792 heap->StartIncrementalMarking(Heap::kReduceMemoryFootprintMask); 2792 heap->StartIncrementalMarking(Heap::kReduceMemoryFootprintMask);
2793 CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask); 2793 CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask);
2794 2794
2795 heap->CollectGarbage(NEW_SPACE); 2795 heap->CollectGarbage(NEW_SPACE);
2796 // NewSpace scavenges should not overwrite the flags. 2796 // NewSpace scavenges should not overwrite the flags.
2797 CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask); 2797 CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask);
2798 2798
2799 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 2799 heap->CollectAllGarbage("GCFlags", Heap::kAbortIncrementalMarkingMask);
2800 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); 2800 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_);
2801 } 2801 }
2802 2802
2803 2803
2804 TEST(IdleNotificationFinishMarking) { 2804 TEST(IdleNotificationFinishMarking) {
2805 i::FLAG_allow_natives_syntax = true; 2805 i::FLAG_allow_natives_syntax = true;
2806 CcTest::InitializeVM(); 2806 CcTest::InitializeVM();
2807 SimulateFullSpace(CcTest::heap()->old_space()); 2807 SimulateFullSpace(CcTest::heap()->old_space());
2808 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2808 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2809 marking->Stop(); 2809 marking->Stop();
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
3675 CHECK_EQ(1, old_space->CountTotalPages()); 3675 CHECK_EQ(1, old_space->CountTotalPages());
3676 for (int i = 0; i < number_of_test_pages; i++) { 3676 for (int i = 0; i < number_of_test_pages; i++) {
3677 AlwaysAllocateScope always_allocate(isolate); 3677 AlwaysAllocateScope always_allocate(isolate);
3678 SimulateFullSpace(old_space); 3678 SimulateFullSpace(old_space);
3679 factory->NewFixedArray(1, TENURED); 3679 factory->NewFixedArray(1, TENURED);
3680 } 3680 }
3681 CHECK_EQ(number_of_test_pages + 1, old_space->CountTotalPages()); 3681 CHECK_EQ(number_of_test_pages + 1, old_space->CountTotalPages());
3682 3682
3683 // Triggering one GC will cause a lot of garbage to be discovered but 3683 // Triggering one GC will cause a lot of garbage to be discovered but
3684 // even spread across all allocated pages. 3684 // even spread across all allocated pages.
3685 heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, 3685 heap->CollectAllGarbage("triggered for preparation",
3686 "triggered for preparation"); 3686 Heap::kFinalizeIncrementalMarkingMask);
3687 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages()); 3687 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages());
3688 3688
3689 // Triggering subsequent GCs should cause at least half of the pages 3689 // Triggering subsequent GCs should cause at least half of the pages
3690 // to be released to the OS after at most two cycles. 3690 // to be released to the OS after at most two cycles.
3691 heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, 3691 heap->CollectAllGarbage("triggered by test 1",
3692 "triggered by test 1"); 3692 Heap::kFinalizeIncrementalMarkingMask);
3693 ;
3693 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages()); 3694 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages());
3694 heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, 3695 heap->CollectAllGarbage("triggered by test 2",
3695 "triggered by test 2"); 3696 Heap::kFinalizeIncrementalMarkingMask);
3696 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages() * 2); 3697 CHECK_GE(number_of_test_pages + 1, old_space->CountTotalPages() * 2);
3697 3698
3698 // Triggering a last-resort GC should cause all pages to be released to the 3699 // Triggering a last-resort GC should cause all pages to be released to the
3699 // OS so that other processes can seize the memory. If we get a failure here 3700 // OS so that other processes can seize the memory. If we get a failure here
3700 // where there are 2 pages left instead of 1, then we should increase the 3701 // where there are 2 pages left instead of 1, then we should increase the
3701 // size of the first page a little in SizeOfFirstPage in spaces.cc. The 3702 // size of the first page a little in SizeOfFirstPage in spaces.cc. The
3702 // first page should be small in order to reduce memory used when the VM 3703 // first page should be small in order to reduce memory used when the VM
3703 // boots, but if the 20 small arrays don't fit on the first page then that's 3704 // boots, but if the 20 small arrays don't fit on the first page then that's
3704 // an indication that it is too small. 3705 // an indication that it is too small.
3705 heap->CollectAllAvailableGarbage("triggered really hard"); 3706 heap->CollectAllAvailableGarbage("triggered really hard");
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after
6525 { 6526 {
6526 SharedFunctionInfo::Iterator iterator(isolate); 6527 SharedFunctionInfo::Iterator iterator(isolate);
6527 while (iterator.Next()) sfi_count--; 6528 while (iterator.Next()) sfi_count--;
6528 } 6529 }
6529 6530
6530 CHECK_EQ(0, sfi_count); 6531 CHECK_EQ(0, sfi_count);
6531 } 6532 }
6532 6533
6533 } // namespace internal 6534 } // namespace internal
6534 } // namespace v8 6535 } // namespace v8
OLDNEW
« src/heap/heap.cc ('K') | « test/cctest/test-debug.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698