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 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4295 { | 4295 { |
4296 Persistent<HeapHashMap<int, WeakMember<IntWrapper> > > map = new HeapHashMap
<int, WeakMember<IntWrapper> >(); | 4296 Persistent<HeapHashMap<int, WeakMember<IntWrapper> > > map = new HeapHashMap
<int, WeakMember<IntWrapper> >(); |
4297 addElementsToWeakMap(map); | 4297 addElementsToWeakMap(map); |
4298 HeapHashMap<int, WeakMember<IntWrapper> >::AddResult result = map->add(800,
nullptr); | 4298 HeapHashMap<int, WeakMember<IntWrapper> >::AddResult result = map->add(800,
nullptr); |
4299 Heap::collectGarbage(ThreadState::HeapPointersOnStack); | 4299 Heap::collectGarbage(ThreadState::HeapPointersOnStack); |
4300 result.storedValue->value = IntWrapper::create(42); | 4300 result.storedValue->value = IntWrapper::create(42); |
4301 } | 4301 } |
4302 | 4302 |
4303 TEST(HeapTest, Bind) | 4303 TEST(HeapTest, Bind) |
4304 { | 4304 { |
4305 Closure closure = bind(&Bar::trace, Bar::create(), static_cast<Visitor*>(0))
; | 4305 OwnPtr<Closure> closure = bind(&Bar::trace, Bar::create(), static_cast<Visit
or*>(0)); |
4306 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4306 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4307 // The closure should have a persistent handle to the Bar. | 4307 // The closure should have a persistent handle to the Bar. |
4308 EXPECT_EQ(1u, Bar::s_live); | 4308 EXPECT_EQ(1u, Bar::s_live); |
4309 | 4309 |
4310 Closure closure2 = bind(&Bar::trace, RawPtr<Bar>(Bar::create()), static_cast
<Visitor*>(0)); | 4310 OwnPtr<Closure> closure2 = bind(&Bar::trace, RawPtr<Bar>(Bar::create()), sta
tic_cast<Visitor*>(0)); |
4311 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4311 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4312 // The closure should have a persistent handle to the Bar. | 4312 // The closure should have a persistent handle to the Bar. |
4313 EXPECT_EQ(2u, Bar::s_live); | 4313 EXPECT_EQ(2u, Bar::s_live); |
4314 // RawPtr<OffHeapInt> should not make Persistent. | 4314 // RawPtr<OffHeapInt> should not make Persistent. |
4315 Closure closure3 = bind(&OffHeapInt::voidFunction, RawPtr<OffHeapInt>(OffHea
pInt::create(1).get())); | 4315 OwnPtr<Closure> closure3 = bind(&OffHeapInt::voidFunction, RawPtr<OffHeapInt
>(OffHeapInt::create(1).get())); |
4316 | 4316 |
4317 UseMixin::s_traceCount = 0; | 4317 UseMixin::s_traceCount = 0; |
4318 Mixin* mixin = UseMixin::create(); | 4318 Mixin* mixin = UseMixin::create(); |
4319 Closure mixinClosure = bind(&Mixin::trace, mixin, static_cast<Visitor*>(0)); | 4319 OwnPtr<Closure> mixinClosure = bind(&Mixin::trace, mixin, static_cast<Visito
r*>(0)); |
4320 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4320 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4321 // The closure should have a persistent handle to the mixin. | 4321 // The closure should have a persistent handle to the mixin. |
4322 EXPECT_EQ(1, UseMixin::s_traceCount); | 4322 EXPECT_EQ(1, UseMixin::s_traceCount); |
4323 } | 4323 } |
4324 | 4324 |
4325 typedef HeapHashSet<WeakMember<IntWrapper> > WeakSet; | 4325 typedef HeapHashSet<WeakMember<IntWrapper> > WeakSet; |
4326 | 4326 |
4327 // These special traits will remove a set from a map when the set is empty. | 4327 // These special traits will remove a set from a map when the set is empty. |
4328 struct EmptyClearingHashSetTraits : HashTraits<WeakSet> { | 4328 struct EmptyClearingHashSetTraits : HashTraits<WeakSet> { |
4329 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; | 4329 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5390 TEST(HeapTest, NonNodeAllocatingNodeInDestructor) | 5390 TEST(HeapTest, NonNodeAllocatingNodeInDestructor) |
5391 { | 5391 { |
5392 new NonNodeAllocatingNodeInDestructor(); | 5392 new NonNodeAllocatingNodeInDestructor(); |
5393 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 5393 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
5394 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value()); | 5394 EXPECT_EQ(10, (*NonNodeAllocatingNodeInDestructor::s_node)->value()); |
5395 delete NonNodeAllocatingNodeInDestructor::s_node; | 5395 delete NonNodeAllocatingNodeInDestructor::s_node; |
5396 NonNodeAllocatingNodeInDestructor::s_node = 0; | 5396 NonNodeAllocatingNodeInDestructor::s_node = 0; |
5397 } | 5397 } |
5398 | 5398 |
5399 } // namespace blink | 5399 } // namespace blink |
OLD | NEW |