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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 2688083002: Move VisitorMarkingMode into Visitor. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 3767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 // This is a low-level test where we call checkAndMarkPointer. This method 3778 // This is a low-level test where we call checkAndMarkPointer. This method
3779 // causes the object start bitmap to be computed which requires the heap 3779 // causes the object start bitmap to be computed which requires the heap
3780 // to be in a consistent state (e.g. the free allocation area must be put 3780 // to be in a consistent state (e.g. the free allocation area must be put
3781 // into a free list header). However when we call makeConsistentForGC it 3781 // into a free list header). However when we call makeConsistentForGC it
3782 // also clears out the freelists so we have to rebuild those before trying 3782 // also clears out the freelists so we have to rebuild those before trying
3783 // to allocate anything again. We do this by forcing a GC after doing the 3783 // to allocate anything again. We do this by forcing a GC after doing the
3784 // checkAndMarkPointer tests. 3784 // checkAndMarkPointer tests.
3785 { 3785 {
3786 TestGCScope scope(BlinkGC::HeapPointersOnStack); 3786 TestGCScope scope(BlinkGC::HeapPointersOnStack);
3787 ThreadState::GCForbiddenScope gcScope(ThreadState::current()); 3787 ThreadState::GCForbiddenScope gcScope(ThreadState::current());
3788 Visitor visitor(ThreadState::current(), VisitorMarkingMode::GlobalMarking); 3788 Visitor visitor(ThreadState::current(), Visitor::GlobalMarking);
3789 EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not 3789 EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not
3790 // park all threads. 3790 // park all threads.
3791 heap.flushHeapDoesNotContainCache(); 3791 heap.flushHeapDoesNotContainCache();
3792 for (size_t i = 0; i < objectAddresses.size(); i++) { 3792 for (size_t i = 0; i < objectAddresses.size(); i++) {
3793 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, objectAddresses[i], 3793 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, objectAddresses[i],
3794 reportMarkedPointer)); 3794 reportMarkedPointer));
3795 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, endAddresses[i], 3795 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, endAddresses[i],
3796 reportMarkedPointer)); 3796 reportMarkedPointer));
3797 } 3797 }
3798 EXPECT_EQ(objectAddresses.size() * 2, s_checkMarkCount); 3798 EXPECT_EQ(objectAddresses.size() * 2, s_checkMarkCount);
3799 s_checkMarkCount = 0; 3799 s_checkMarkCount = 0;
3800 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, largeObjectAddress, 3800 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, largeObjectAddress,
3801 reportMarkedPointer)); 3801 reportMarkedPointer));
3802 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, largeObjectEndAddress, 3802 EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, largeObjectEndAddress,
3803 reportMarkedPointer)); 3803 reportMarkedPointer));
3804 EXPECT_EQ(2ul, s_checkMarkCount); 3804 EXPECT_EQ(2ul, s_checkMarkCount);
3805 s_checkMarkCount = 0ul; 3805 s_checkMarkCount = 0ul;
3806 } 3806 }
3807 // This forces a GC without stack scanning which results in the objects 3807 // This forces a GC without stack scanning which results in the objects
3808 // being collected. This will also rebuild the above mentioned freelists, 3808 // being collected. This will also rebuild the above mentioned freelists,
3809 // however we don't rely on that below since we don't have any allocations. 3809 // however we don't rely on that below since we don't have any allocations.
3810 clearOutOldGarbage(); 3810 clearOutOldGarbage();
3811 { 3811 {
3812 TestGCScope scope(BlinkGC::HeapPointersOnStack); 3812 TestGCScope scope(BlinkGC::HeapPointersOnStack);
3813 ThreadState::GCForbiddenScope gcScope(ThreadState::current()); 3813 ThreadState::GCForbiddenScope gcScope(ThreadState::current());
3814 Visitor visitor(ThreadState::current(), VisitorMarkingMode::GlobalMarking); 3814 Visitor visitor(ThreadState::current(), Visitor::GlobalMarking);
3815 EXPECT_TRUE(scope.allThreadsParked()); 3815 EXPECT_TRUE(scope.allThreadsParked());
3816 heap.flushHeapDoesNotContainCache(); 3816 heap.flushHeapDoesNotContainCache();
3817 for (size_t i = 0; i < objectAddresses.size(); i++) { 3817 for (size_t i = 0; i < objectAddresses.size(); i++) {
3818 // We would like to assert that checkAndMarkPointer returned false 3818 // We would like to assert that checkAndMarkPointer returned false
3819 // here because the pointers no longer point into a valid object 3819 // here because the pointers no longer point into a valid object
3820 // (it's been freed by the GCs. But checkAndMarkPointer will return 3820 // (it's been freed by the GCs. But checkAndMarkPointer will return
3821 // true for any pointer that points into a heap page, regardless of 3821 // true for any pointer that points into a heap page, regardless of
3822 // whether it points at a valid object (this ensures the 3822 // whether it points at a valid object (this ensures the
3823 // correctness of the page-based on-heap address caches), so we 3823 // correctness of the page-based on-heap address caches), so we
3824 // can't make that assert. 3824 // can't make that assert.
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after
6377 "HeapVector"); 6377 "HeapVector");
6378 static_assert( 6378 static_assert(
6379 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value, 6379 WTF::IsGarbageCollectedType<HeapDeque<Member<IntWrapper>>>::value,
6380 "HeapDeque"); 6380 "HeapDeque");
6381 static_assert(WTF::IsGarbageCollectedType< 6381 static_assert(WTF::IsGarbageCollectedType<
6382 HeapTerminatedArray<Member<IntWrapper>>>::value, 6382 HeapTerminatedArray<Member<IntWrapper>>>::value,
6383 "HeapTerminatedArray"); 6383 "HeapTerminatedArray");
6384 } 6384 }
6385 6385
6386 } // namespace blink 6386 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698