OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1775 // Normally sweeping would not be complete here, but no guarantees. | 1775 // Normally sweeping would not be complete here, but no guarantees. |
1776 | 1776 |
1777 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); | 1777 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); |
1778 | 1778 |
1779 // Waiting for sweeper threads should not change heap size. | 1779 // Waiting for sweeper threads should not change heap size. |
1780 if (collector->sweeping_in_progress()) { | 1780 if (collector->sweeping_in_progress()) { |
1781 collector->EnsureSweepingCompleted(); | 1781 collector->EnsureSweepingCompleted(); |
1782 } | 1782 } |
1783 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); | 1783 CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); |
1784 } | 1784 } |
1785 | 1785 |
Hannes Payer (out of office)
2015/05/26 09:22:29
It would be nice to have test for all the aligned
| |
1786 | 1786 |
1787 TEST(TestAlignmentCalculations) { | |
1788 // Maximum fill amounts should be consistent. | |
1789 int maximum_double_misalignment = kDoubleSize - kPointerSize; | |
1790 int max_word_fill = Heap::GetMaximumFillToAlign(kWordAligned); | |
1791 CHECK_EQ(0, max_word_fill); | |
1792 int max_double_fill = Heap::GetMaximumFillToAlign(kDoubleAligned); | |
1793 CHECK_EQ(maximum_double_misalignment, max_double_fill); | |
1794 int max_double_unaligned_fill = Heap::GetMaximumFillToAlign(kDoubleUnaligned); | |
1795 CHECK_EQ(maximum_double_misalignment, max_double_unaligned_fill); | |
1796 | |
1797 Address base = reinterpret_cast<Address>(NULL); | |
1798 int fill = 0; | |
1799 | |
1800 // Word alignment never requires fill. | |
1801 fill = Heap::GetFillToAlign(base, kWordAligned); | |
1802 CHECK_EQ(0, fill); | |
1803 fill = Heap::GetFillToAlign(base + kPointerSize, kWordAligned); | |
1804 CHECK_EQ(0, fill); | |
1805 | |
1806 // No fill is required when address is double aligned. | |
1807 fill = Heap::GetFillToAlign(base, kDoubleAligned); | |
1808 CHECK_EQ(0, fill); | |
1809 // Fill is required if address is not double aligned. | |
1810 fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleAligned); | |
1811 CHECK_EQ(maximum_double_misalignment, fill); | |
1812 // kDoubleUnaligned has the opposite fill amounts. | |
1813 fill = Heap::GetFillToAlign(base, kDoubleUnaligned); | |
1814 CHECK_EQ(maximum_double_misalignment, fill); | |
1815 fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleUnaligned); | |
1816 CHECK_EQ(0, fill); | |
1817 } | |
1818 | |
1819 | |
1787 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { | 1820 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { |
1788 CcTest::InitializeVM(); | 1821 CcTest::InitializeVM(); |
1789 HeapIterator iterator(CcTest::heap()); | 1822 HeapIterator iterator(CcTest::heap()); |
1790 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); | 1823 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); |
1791 intptr_t size_of_objects_2 = 0; | 1824 intptr_t size_of_objects_2 = 0; |
1792 for (HeapObject* obj = iterator.next(); | 1825 for (HeapObject* obj = iterator.next(); |
1793 obj != NULL; | 1826 obj != NULL; |
1794 obj = iterator.next()) { | 1827 obj = iterator.next()) { |
1795 if (!obj->IsFreeSpace()) { | 1828 if (!obj->IsFreeSpace()) { |
1796 size_of_objects_2 += obj->Size(); | 1829 size_of_objects_2 += obj->Size(); |
(...skipping 3754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5551 size_t counter2 = 2000; | 5584 size_t counter2 = 2000; |
5552 tracer->SampleNewSpaceAllocation(time2, counter2); | 5585 tracer->SampleNewSpaceAllocation(time2, counter2); |
5553 size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000); | 5586 size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000); |
5554 CHECK_EQ(10000, bytes); | 5587 CHECK_EQ(10000, bytes); |
5555 int time3 = 1000; | 5588 int time3 = 1000; |
5556 size_t counter3 = 30000; | 5589 size_t counter3 = 30000; |
5557 tracer->SampleNewSpaceAllocation(time3, counter3); | 5590 tracer->SampleNewSpaceAllocation(time3, counter3); |
5558 bytes = tracer->NewSpaceAllocatedBytesInLast(100); | 5591 bytes = tracer->NewSpaceAllocatedBytesInLast(100); |
5559 CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes); | 5592 CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes); |
5560 } | 5593 } |
OLD | NEW |