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

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

Issue 464283002: [oilpan] Null pointers must be treated as live, since they can't be marked live by strongification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Spelling fix Created 6 years, 4 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 | « no previous file | Source/platform/heap/Visitor.h » ('j') | 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 4207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4218 EXPECT_EQ(2, OffHeapInt::s_destructorCalls); 4218 EXPECT_EQ(2, OffHeapInt::s_destructorCalls);
4219 EXPECT_EQ(2u, map1->size()); 4219 EXPECT_EQ(2u, map1->size());
4220 Iterator i1 = map1->begin(); 4220 Iterator i1 = map1->begin();
4221 EXPECT_TRUE(i1->value.first->value() == 103 || i1->value.first == livingInt) ; 4221 EXPECT_TRUE(i1->value.first->value() == 103 || i1->value.first == livingInt) ;
4222 EXPECT_EQ(livingInt, i1->value.second); 4222 EXPECT_EQ(livingInt, i1->value.second);
4223 ++i1; 4223 ++i1;
4224 EXPECT_TRUE(i1->value.first->value() == 103 || i1->value.first == livingInt) ; 4224 EXPECT_TRUE(i1->value.first->value() == 103 || i1->value.first == livingInt) ;
4225 EXPECT_EQ(livingInt, i1->value.second); 4225 EXPECT_EQ(livingInt, i1->value.second);
4226 } 4226 }
4227 4227
4228 static void addElementsToWeakMap(HeapHashMap<int, WeakMember<IntWrapper> >* map)
4229 {
4230 // Key cannot be zero in hashmap.
4231 for (int i = 1; i < 11; i++)
4232 map->add(i, IntWrapper::create(i));
4233 }
4234
4235 // crbug.com/402426
4236 // If it doesn't assert a concurrent modification to the map, then it's passing.
4237 TEST(HeapTest, RegressNullIsStrongified)
4238 {
4239 Persistent<HeapHashMap<int, WeakMember<IntWrapper> > > map = new HeapHashMap <int, WeakMember<IntWrapper> >();
4240 addElementsToWeakMap(map);
4241 HeapHashMap<int, WeakMember<IntWrapper> >::AddResult result = map->add(800, nullptr);
4242 Heap::collectGarbage(ThreadState::HeapPointersOnStack);
4243 result.storedValue->value = IntWrapper::create(42);
4244 }
4245
4228 TEST(HeapTest, Bind) 4246 TEST(HeapTest, Bind)
4229 { 4247 {
4230 Closure closure = bind(&Bar::trace, Bar::create(), static_cast<Visitor*>(0)) ; 4248 Closure closure = bind(&Bar::trace, Bar::create(), static_cast<Visitor*>(0)) ;
4231 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 4249 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
4232 // The closure should have a persistent handle to the Bar. 4250 // The closure should have a persistent handle to the Bar.
4233 EXPECT_EQ(1u, Bar::s_live); 4251 EXPECT_EQ(1u, Bar::s_live);
4234 4252
4235 Closure closure2 = bind(&Bar::trace, RawPtr<Bar>(Bar::create()), static_cast <Visitor*>(0)); 4253 Closure closure2 = bind(&Bar::trace, RawPtr<Bar>(Bar::create()), static_cast <Visitor*>(0));
4236 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); 4254 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
4237 // The closure should have a persistent handle to the Bar. 4255 // The closure should have a persistent handle to the Bar.
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
5025 { 5043 {
5026 TraceIfNeededTester<HeapVector<Member<SimpleObject> > >* m_vec = TraceIf NeededTester<HeapVector<Member<SimpleObject> > >::create(); 5044 TraceIfNeededTester<HeapVector<Member<SimpleObject> > >* m_vec = TraceIf NeededTester<HeapVector<Member<SimpleObject> > >::create();
5027 m_vec->obj().append(SimpleObject::create()); 5045 m_vec->obj().append(SimpleObject::create());
5028 visitor.reset(); 5046 visitor.reset();
5029 m_vec->trace(&visitor); 5047 m_vec->trace(&visitor);
5030 EXPECT_EQ(2u, visitor.count()); 5048 EXPECT_EQ(2u, visitor.count());
5031 } 5049 }
5032 } 5050 }
5033 5051
5034 } // namespace blink 5052 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698