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

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

Issue 1146373002: Oilpan: Validate pointers stored in Persistent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/Handle.h ('k') | no next file » | 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 3503 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 Persistent<WithWeakMember> h5; 3514 Persistent<WithWeakMember> h5;
3515 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC WithSweep, Heap::ForcedGC); 3515 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC WithSweep, Heap::ForcedGC);
3516 ASSERT_EQ(1u, Bar::s_live); // h1 is live. 3516 ASSERT_EQ(1u, Bar::s_live); // h1 is live.
3517 { 3517 {
3518 Bar* h2 = Bar::create(); 3518 Bar* h2 = Bar::create();
3519 Bar* h3 = Bar::create(); 3519 Bar* h3 = Bar::create();
3520 h4 = Weak::create(h2, h3); 3520 h4 = Weak::create(h2, h3);
3521 h5 = WithWeakMember::create(h2, h3); 3521 h5 = WithWeakMember::create(h2, h3);
3522 Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState:: GCWithSweep, Heap::ForcedGC); 3522 Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState:: GCWithSweep, Heap::ForcedGC);
3523 EXPECT_EQ(5u, Bar::s_live); // The on-stack pointer keeps h3 alive. 3523 EXPECT_EQ(5u, Bar::s_live); // The on-stack pointer keeps h3 alive.
3524 EXPECT_FALSE(h3->hasBeenFinalized());
haraken 2015/05/26 06:50:13 OK, now I finally found the cause of the failure o
Yuta Kitamura 2015/05/26 09:26:29 "volatile" can be used, maybe?
3524 EXPECT_TRUE(h4->strongIsThere()); 3525 EXPECT_TRUE(h4->strongIsThere());
3525 EXPECT_TRUE(h4->weakIsThere()); 3526 EXPECT_TRUE(h4->weakIsThere());
3526 EXPECT_TRUE(h5->strongIsThere()); 3527 EXPECT_TRUE(h5->strongIsThere());
3527 EXPECT_TRUE(h5->weakIsThere()); 3528 EXPECT_TRUE(h5->weakIsThere());
3528 } 3529 }
3529 // h3 is collected, weak pointers from h4 and h5 don't keep it alive. 3530 // h3 is collected, weak pointers from h4 and h5 don't keep it alive.
3530 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC WithSweep, Heap::ForcedGC); 3531 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC WithSweep, Heap::ForcedGC);
3531 EXPECT_EQ(4u, Bar::s_live); 3532 EXPECT_EQ(4u, Bar::s_live);
3532 EXPECT_TRUE(h4->strongIsThere()); 3533 EXPECT_TRUE(h4->strongIsThere());
3533 EXPECT_FALSE(h4->weakIsThere()); // h3 is gone from weak pointer. 3534 EXPECT_FALSE(h4->weakIsThere()); // h3 is gone from weak pointer.
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after
6111 { 6112 {
6112 Persistent<ClassWithMember> object = ClassWithMember::create(); 6113 Persistent<ClassWithMember> object = ClassWithMember::create();
6113 EXPECT_EQ(0, object->traceCount()); 6114 EXPECT_EQ(0, object->traceCount());
6114 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object. get()); 6115 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object. get());
6115 EXPECT_TRUE(mixin); 6116 EXPECT_TRUE(mixin);
6116 EXPECT_GT(object->traceCount(), 0); 6117 EXPECT_GT(object->traceCount(), 0);
6117 EXPECT_GT(mixin->traceCount(), 0); 6118 EXPECT_GT(mixin->traceCount(), 0);
6118 } 6119 }
6119 6120
6120 } // namespace blink 6121 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698