OLD | NEW |
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 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3378 // causes the object start bitmap to be computed which requires the heap | 3378 // causes the object start bitmap to be computed which requires the heap |
3379 // to be in a consistent state (e.g. the free allocation area must be put | 3379 // to be in a consistent state (e.g. the free allocation area must be put |
3380 // into a free list header). However when we call makeConsistentForSweeping
it | 3380 // into a free list header). However when we call makeConsistentForSweeping
it |
3381 // also clears out the freelists so we have to rebuild those before trying | 3381 // also clears out the freelists so we have to rebuild those before trying |
3382 // to allocate anything again. We do this by forcing a GC after doing the | 3382 // to allocate anything again. We do this by forcing a GC after doing the |
3383 // checkAndMarkPointer tests. | 3383 // checkAndMarkPointer tests. |
3384 { | 3384 { |
3385 TestGCScope scope(ThreadState::HeapPointersOnStack); | 3385 TestGCScope scope(ThreadState::HeapPointersOnStack); |
3386 EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not
park all threads. | 3386 EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not
park all threads. |
3387 Heap::prepareForGC(); | 3387 Heap::prepareForGC(); |
| 3388 Heap::flushHeapDoesNotContainCache(); |
3388 for (size_t i = 0; i < objectAddresses.size(); i++) { | 3389 for (size_t i = 0; i < objectAddresses.size(); i++) { |
3389 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, objectAddresses[i]))
; | 3390 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, objectAddresses[i]))
; |
3390 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, endAddresses[i])); | 3391 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, endAddresses[i])); |
3391 } | 3392 } |
3392 EXPECT_EQ(objectAddresses.size() * 2, visitor.count()); | 3393 EXPECT_EQ(objectAddresses.size() * 2, visitor.count()); |
3393 visitor.reset(); | 3394 visitor.reset(); |
3394 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, largeObjectAddress)); | 3395 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, largeObjectAddress)); |
3395 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, largeObjectEndAddress)); | 3396 EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, largeObjectEndAddress)); |
3396 EXPECT_EQ(2ul, visitor.count()); | 3397 EXPECT_EQ(2ul, visitor.count()); |
3397 visitor.reset(); | 3398 visitor.reset(); |
3398 } | 3399 } |
3399 // This forces a GC without stack scanning which results in the objects | 3400 // This forces a GC without stack scanning which results in the objects |
3400 // being collected. This will also rebuild the above mentioned freelists, | 3401 // being collected. This will also rebuild the above mentioned freelists, |
3401 // however we don't rely on that below since we don't have any allocations. | 3402 // however we don't rely on that below since we don't have any allocations. |
3402 clearOutOldGarbage(&initialHeapStats); | 3403 clearOutOldGarbage(&initialHeapStats); |
3403 { | 3404 { |
3404 TestGCScope scope(ThreadState::HeapPointersOnStack); | 3405 TestGCScope scope(ThreadState::HeapPointersOnStack); |
3405 EXPECT_TRUE(scope.allThreadsParked()); | 3406 EXPECT_TRUE(scope.allThreadsParked()); |
3406 Heap::makeConsistentForSweeping(); | 3407 Heap::prepareForGC(); |
| 3408 Heap::flushHeapDoesNotContainCache(); |
3407 for (size_t i = 0; i < objectAddresses.size(); i++) { | 3409 for (size_t i = 0; i < objectAddresses.size(); i++) { |
3408 // We would like to assert that checkAndMarkPointer returned false | 3410 // We would like to assert that checkAndMarkPointer returned false |
3409 // here because the pointers no longer point into a valid object | 3411 // here because the pointers no longer point into a valid object |
3410 // (it's been freed by the GCs. But checkAndMarkPointer will return | 3412 // (it's been freed by the GCs. But checkAndMarkPointer will return |
3411 // true for any pointer that points into a heap page, regardless of | 3413 // true for any pointer that points into a heap page, regardless of |
3412 // whether it points at a valid object (this ensures the | 3414 // whether it points at a valid object (this ensures the |
3413 // correctness of the page-based on-heap address caches), so we | 3415 // correctness of the page-based on-heap address caches), so we |
3414 // can't make that assert. | 3416 // can't make that assert. |
3415 Heap::checkAndMarkPointer(&visitor, objectAddresses[i]); | 3417 Heap::checkAndMarkPointer(&visitor, objectAddresses[i]); |
3416 Heap::checkAndMarkPointer(&visitor, endAddresses[i]); | 3418 Heap::checkAndMarkPointer(&visitor, endAddresses[i]); |
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5395 TEST(HeapTest, NonNodeAllocatingNodeInDestructor) | 5397 TEST(HeapTest, NonNodeAllocatingNodeInDestructor) |
5396 { | 5398 { |
5397 new NonNodeAllocatingNodeInDestructor(); | 5399 new NonNodeAllocatingNodeInDestructor(); |
5398 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 5400 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
5399 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value()); | 5401 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value()); |
5400 delete NonNodeAllocatingNodeInDestructor::s_node; | 5402 delete NonNodeAllocatingNodeInDestructor::s_node; |
5401 NonNodeAllocatingNodeInDestructor::s_node = 0; | 5403 NonNodeAllocatingNodeInDestructor::s_node = 0; |
5402 } | 5404 } |
5403 | 5405 |
5404 } // namespace blink | 5406 } // namespace blink |
OLD | NEW |