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

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

Issue 1157933002: Oilpan: introduce eager finalization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove HeapIndexTrait + tidy up 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
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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 1760
1761 CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack ); 1761 CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack );
1762 if (testPagesAllocated) 1762 if (testPagesAllocated)
1763 EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1)); 1763 EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1));
1764 1764
1765 for (size_t i = 0; i < persistentCount; i++) { 1765 for (size_t i = 0; i < persistentCount; i++) {
1766 delete persistents[i]; 1766 delete persistents[i];
1767 persistents[i] = 0; 1767 persistents[i] = 0;
1768 } 1768 }
1769 1769
1770 uint8_t* address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySi zedObject>(0, 100)); 1770 uint8_t* address = reinterpret_cast<uint8_t*>(Heap::allocate<DynamicallySize dObject>(100));
1771 for (int i = 0; i < 100; i++) 1771 for (int i = 0; i < 100; i++)
1772 address[i] = i; 1772 address[i] = i;
1773 address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject >(address, 100000)); 1773 address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject >(address, 100000));
1774 for (int i = 0; i < 100; i++) 1774 for (int i = 0; i < 100; i++)
1775 EXPECT_EQ(address[i], i); 1775 EXPECT_EQ(address[i], i);
1776 address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject >(address, 50)); 1776 address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject >(address, 50));
1777 for (int i = 0; i < 50; i++) 1777 for (int i = 0; i < 50; i++)
1778 EXPECT_EQ(address[i], i); 1778 EXPECT_EQ(address[i], i);
1779 // This should be equivalent to free(address). 1779 // This should be equivalent to free(address).
1780 EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<DynamicallySizedObjec t>(address, 0)), 0ul); 1780 EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<DynamicallySizedObjec t>(address, 0)), 0ul);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep, Heap::ForcedGC); 1865 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep, Heap::ForcedGC);
1866 EXPECT_EQ(10, LargeHeapObject::s_destructorCalls); 1866 EXPECT_EQ(10, LargeHeapObject::s_destructorCalls);
1867 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith Sweep, Heap::ForcedGC); 1867 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith Sweep, Heap::ForcedGC);
1868 EXPECT_EQ(22, LargeHeapObject::s_destructorCalls); 1868 EXPECT_EQ(22, LargeHeapObject::s_destructorCalls);
1869 } 1869 }
1870 1870
1871 class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFi nalizedEagerObjectBase> { 1871 class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFi nalizedEagerObjectBase> {
1872 public: 1872 public:
1873 virtual ~SimpleFinalizedEagerObjectBase() { } 1873 virtual ~SimpleFinalizedEagerObjectBase() { }
1874 DEFINE_INLINE_TRACE() { } 1874 DEFINE_INLINE_TRACE() { }
1875
1875 EAGERLY_FINALIZE(); 1876 EAGERLY_FINALIZE();
1876 protected: 1877 protected:
1877 SimpleFinalizedEagerObjectBase() { } 1878 SimpleFinalizedEagerObjectBase() { }
1878 }; 1879 };
1879 1880
1880 class SimpleFinalizedEagerObject : public SimpleFinalizedEagerObjectBase { 1881 class SimpleFinalizedEagerObject : public SimpleFinalizedEagerObjectBase {
1881 public: 1882 public:
1882 static SimpleFinalizedEagerObject* create() 1883 static SimpleFinalizedEagerObject* create()
1883 { 1884 {
1884 return new SimpleFinalizedEagerObject(); 1885 return new SimpleFinalizedEagerObject();
(...skipping 4225 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698