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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 2815663002: Disable collection backing reallocation during pre finalizer (Closed)
Patch Set: fix Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/HeapTest.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
index 37e9aaef365e79ab770e66f8da9db5098621eab5..1d9e62cb1162d22aed21f7cd5bd350ec8832414a 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
@@ -1499,6 +1499,48 @@ class PreFinalizationAllocator
Persistent<IntWrapper>* wrapper_;
};
+class PreFinalizerBackingReallocationForbiddenCheck
+ : public GarbageCollectedFinalized<
+ PreFinalizerBackingReallocationForbiddenCheck> {
+ USING_PRE_FINALIZER(PreFinalizerBackingReallocationForbiddenCheck, Dispose);
+
+ public:
+ PreFinalizerBackingReallocationForbiddenCheck() {
+ vector_.push_back(nullptr);
+ EXPECT_LT(0ul, vector_.Capacity());
+ for (int i = 1; i <= 32; ++i) {
+ map_.insert(i, nullptr);
+ }
+ EXPECT_LT(32ul, map_.Capacity());
+ }
+
+ void Dispose() {
+ vector_.Clear();
+ EXPECT_LT(0ul, vector_.Capacity());
+ for (int i = 1; i <= 32; ++i) {
+ map_.erase(i);
+ }
+ EXPECT_LT(32ul, map_.Capacity());
+ // Clearing is OK inside a pre finalizer.
+ map_.Clear();
+ EXPECT_EQ(0ul, map_.Capacity());
+ }
+
+ DEFINE_INLINE_TRACE() {
+ visitor->Trace(vector_);
+ visitor->Trace(map_);
+ }
+
+ private:
+ HeapVector<Member<IntWrapper>> vector_;
+ HeapHashMap<int, Member<IntWrapper>> map_;
+};
+
+TEST(HeapTest, BackingReallocationForbidden) {
+ new PreFinalizerBackingReallocationForbiddenCheck();
+ PreciselyCollectGarbage();
+}
+
TEST(HeapTest, Transition) {
{
RefCountedAndGarbageCollected::destructor_calls_ = 0;

Powered by Google App Engine
This is Rietveld 408576698