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

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

Issue 911663002: Revert of Oilpan: Rename heap classes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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/Heap.cpp ('k') | Source/platform/heap/ThreadState.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 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 SimpleFinalizedObject::create(); 1796 SimpleFinalizedObject::create();
1797 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep); 1797 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep);
1798 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); 1798 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
1799 for (int i = 0; i < 10000; i++) 1799 for (int i = 0; i < 10000; i++)
1800 SimpleFinalizedObject::create(); 1800 SimpleFinalizedObject::create();
1801 EXPECT_EQ(1000, SimpleFinalizedObject::s_destructorCalls); 1801 EXPECT_EQ(1000, SimpleFinalizedObject::s_destructorCalls);
1802 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith Sweep); 1802 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith Sweep);
1803 EXPECT_EQ(11000, SimpleFinalizedObject::s_destructorCalls); 1803 EXPECT_EQ(11000, SimpleFinalizedObject::s_destructorCalls);
1804 } 1804 }
1805 1805
1806 TEST(HeapTest, LazySweepingLargeObjectPages) 1806 TEST(HeapTest, LazySweepingLargeObjects)
1807 { 1807 {
1808 clearOutOldGarbage(); 1808 clearOutOldGarbage();
1809 1809
1810 LargeHeapObject::s_destructorCalls = 0; 1810 LargeHeapObject::s_destructorCalls = 0;
1811 EXPECT_EQ(0, LargeHeapObject::s_destructorCalls); 1811 EXPECT_EQ(0, LargeHeapObject::s_destructorCalls);
1812 for (int i = 0; i < 10; i++) 1812 for (int i = 0; i < 10; i++)
1813 LargeHeapObject::create(); 1813 LargeHeapObject::create();
1814 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep); 1814 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep);
1815 for (int i = 0; i < 10; i++) { 1815 for (int i = 0; i < 10; i++) {
1816 LargeHeapObject::create(); 1816 LargeHeapObject::create();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 EXPECT_NE(info, ThreadState::current()->findGCInfo(reinterpret_cast<Addr ess>(object.get()) + sizeof(LargeHeapObject))); 2081 EXPECT_NE(info, ThreadState::current()->findGCInfo(reinterpret_cast<Addr ess>(object.get()) + sizeof(LargeHeapObject)));
2082 EXPECT_NE(info, ThreadState::current()->findGCInfo(reinterpret_cast<Addr ess>(object.get()) - 1)); 2082 EXPECT_NE(info, ThreadState::current()->findGCInfo(reinterpret_cast<Addr ess>(object.get()) - 1));
2083 #endif 2083 #endif
2084 clearOutOldGarbage(); 2084 clearOutOldGarbage();
2085 size_t afterAllocation = Heap::allocatedSpace(); 2085 size_t afterAllocation = Heap::allocatedSpace();
2086 { 2086 {
2087 object->set(0, 'a'); 2087 object->set(0, 'a');
2088 EXPECT_EQ('a', object->get(0)); 2088 EXPECT_EQ('a', object->get(0));
2089 object->set(object->length() - 1, 'b'); 2089 object->set(object->length() - 1, 'b');
2090 EXPECT_EQ('b', object->get(object->length() - 1)); 2090 EXPECT_EQ('b', object->get(object->length() - 1));
2091 size_t expectedLargeHeapObjectPayloadSize = BaseHeap::allocationSize FromSize(sizeof(LargeHeapObject)); 2091 size_t expectedLargeHeapObjectPayloadSize = ThreadHeap::allocationSi zeFromSize(sizeof(LargeHeapObject));
2092 size_t expectedObjectPayloadSize = expectedLargeHeapObjectPayloadSiz e + sizeof(IntWrapper); 2092 size_t expectedObjectPayloadSize = expectedLargeHeapObjectPayloadSiz e + sizeof(IntWrapper);
2093 size_t actualObjectPayloadSize = Heap::objectPayloadSizeForTesting() - initialObjectPayloadSize; 2093 size_t actualObjectPayloadSize = Heap::objectPayloadSizeForTesting() - initialObjectPayloadSize;
2094 CheckWithSlack(expectedObjectPayloadSize, actualObjectPayloadSize, s lack); 2094 CheckWithSlack(expectedObjectPayloadSize, actualObjectPayloadSize, s lack);
2095 // There is probably space for the IntWrapper in a heap page without 2095 // There is probably space for the IntWrapper in a heap page without
2096 // allocating extra pages. However, the IntWrapper allocation might cause 2096 // allocating extra pages. However, the IntWrapper allocation might cause
2097 // the addition of a heap page. 2097 // the addition of a heap page.
2098 size_t largeObjectAllocationSize = sizeof(LargeObjectPage) + expecte dLargeHeapObjectPayloadSize; 2098 size_t largeObjectAllocationSize = sizeof(LargeObject) + expectedLar geHeapObjectPayloadSize;
2099 size_t allocatedSpaceLowerBound = initialAllocatedSpace + largeObjec tAllocationSize; 2099 size_t allocatedSpaceLowerBound = initialAllocatedSpace + largeObjec tAllocationSize;
2100 size_t allocatedSpaceUpperBound = allocatedSpaceLowerBound + slack + blinkPageSize; 2100 size_t allocatedSpaceUpperBound = allocatedSpaceLowerBound + slack + blinkPageSize;
2101 EXPECT_LE(allocatedSpaceLowerBound, afterAllocation); 2101 EXPECT_LE(allocatedSpaceLowerBound, afterAllocation);
2102 EXPECT_LE(afterAllocation, allocatedSpaceUpperBound); 2102 EXPECT_LE(afterAllocation, allocatedSpaceUpperBound);
2103 EXPECT_EQ(0, IntWrapper::s_destructorCalls); 2103 EXPECT_EQ(0, IntWrapper::s_destructorCalls);
2104 EXPECT_EQ(0, LargeHeapObject::s_destructorCalls); 2104 EXPECT_EQ(0, LargeHeapObject::s_destructorCalls);
2105 for (int i = 0; i < 10; i++) 2105 for (int i = 0; i < 10; i++)
2106 object = LargeHeapObject::create(); 2106 object = LargeHeapObject::create();
2107 } 2107 }
2108 clearOutOldGarbage(); 2108 clearOutOldGarbage();
(...skipping 3456 matching lines...) Expand 10 before | Expand all | Expand 10 after
5565 5565
5566 TEST(HeapTest, StackGrowthDirection) 5566 TEST(HeapTest, StackGrowthDirection)
5567 { 5567 {
5568 // The implementation of marking probes stack usage as it runs, 5568 // The implementation of marking probes stack usage as it runs,
5569 // and has a builtin assumption that the stack grows towards 5569 // and has a builtin assumption that the stack grows towards
5570 // lower addresses. 5570 // lower addresses.
5571 EXPECT_EQ(GrowsTowardsLower, stackGrowthDirection()); 5571 EXPECT_EQ(GrowsTowardsLower, stackGrowthDirection());
5572 } 5572 }
5573 5573
5574 } // namespace blink 5574 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.cpp ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698