| 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 3502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 Persistent<WithWeakMember> h5; | 3513 Persistent<WithWeakMember> h5; |
| 3514 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); | 3514 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); |
| 3515 ASSERT_EQ(1u, Bar::s_live); // h1 is live. | 3515 ASSERT_EQ(1u, Bar::s_live); // h1 is live. |
| 3516 { | 3516 { |
| 3517 Bar* h2 = Bar::create(); | 3517 Bar* h2 = Bar::create(); |
| 3518 Bar* h3 = Bar::create(); | 3518 Bar* h3 = Bar::create(); |
| 3519 h4 = Weak::create(h2, h3); | 3519 h4 = Weak::create(h2, h3); |
| 3520 h5 = WithWeakMember::create(h2, h3); | 3520 h5 = WithWeakMember::create(h2, h3); |
| 3521 Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::
GCWithSweep, Heap::ForcedGC); | 3521 Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::
GCWithSweep, Heap::ForcedGC); |
| 3522 EXPECT_EQ(5u, Bar::s_live); // The on-stack pointer keeps h3 alive. | 3522 EXPECT_EQ(5u, Bar::s_live); // The on-stack pointer keeps h3 alive. |
| 3523 EXPECT_FALSE(h3->hasBeenFinalized()); |
| 3523 EXPECT_TRUE(h4->strongIsThere()); | 3524 EXPECT_TRUE(h4->strongIsThere()); |
| 3524 EXPECT_TRUE(h4->weakIsThere()); | 3525 EXPECT_TRUE(h4->weakIsThere()); |
| 3525 EXPECT_TRUE(h5->strongIsThere()); | 3526 EXPECT_TRUE(h5->strongIsThere()); |
| 3526 EXPECT_TRUE(h5->weakIsThere()); | 3527 EXPECT_TRUE(h5->weakIsThere()); |
| 3527 } | 3528 } |
| 3528 // h3 is collected, weak pointers from h4 and h5 don't keep it alive. | 3529 // h3 is collected, weak pointers from h4 and h5 don't keep it alive. |
| 3529 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); | 3530 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); |
| 3530 EXPECT_EQ(4u, Bar::s_live); | 3531 EXPECT_EQ(4u, Bar::s_live); |
| 3531 EXPECT_TRUE(h4->strongIsThere()); | 3532 EXPECT_TRUE(h4->strongIsThere()); |
| 3532 EXPECT_FALSE(h4->weakIsThere()); // h3 is gone from weak pointer. | 3533 EXPECT_FALSE(h4->weakIsThere()); // h3 is gone from weak pointer. |
| (...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6110 { | 6111 { |
| 6111 Persistent<ClassWithMember> object = ClassWithMember::create(); | 6112 Persistent<ClassWithMember> object = ClassWithMember::create(); |
| 6112 EXPECT_EQ(0, object->traceCount()); | 6113 EXPECT_EQ(0, object->traceCount()); |
| 6113 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object.
get()); | 6114 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object.
get()); |
| 6114 EXPECT_TRUE(mixin); | 6115 EXPECT_TRUE(mixin); |
| 6115 EXPECT_GT(object->traceCount(), 0); | 6116 EXPECT_GT(object->traceCount(), 0); |
| 6116 EXPECT_GT(mixin->traceCount(), 0); | 6117 EXPECT_GT(mixin->traceCount(), 0); |
| 6117 } | 6118 } |
| 6118 | 6119 |
| 6119 } // namespace blink | 6120 } // namespace blink |
| OLD | NEW |