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 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
1786 | 1786 |
1787 TEST(TestAlignmentCalculations) { | 1787 TEST(TestAlignmentCalculations) { |
1788 // Maximum fill amounts are consistent. | 1788 // Maximum fill amounts should be consistent. |
1789 int maximum_double_misalignment = kDoubleSize - kPointerSize; | 1789 int maximum_double_misalignment = kDoubleSize - kPointerSize; |
1790 int maximum_simd128_misalignment = kSimd128Size - kPointerSize; | |
1791 int max_word_fill = Heap::GetMaximumFillToAlign(kWordAligned); | 1790 int max_word_fill = Heap::GetMaximumFillToAlign(kWordAligned); |
1792 CHECK_EQ(0, max_word_fill); | 1791 CHECK_EQ(0, max_word_fill); |
1793 int max_double_fill = Heap::GetMaximumFillToAlign(kDoubleAligned); | 1792 int max_double_fill = Heap::GetMaximumFillToAlign(kDoubleAligned); |
1794 CHECK_EQ(maximum_double_misalignment, max_double_fill); | 1793 CHECK_EQ(maximum_double_misalignment, max_double_fill); |
1795 int max_double_unaligned_fill = Heap::GetMaximumFillToAlign(kDoubleUnaligned); | 1794 int max_double_unaligned_fill = Heap::GetMaximumFillToAlign(kDoubleUnaligned); |
1796 CHECK_EQ(maximum_double_misalignment, max_double_unaligned_fill); | 1795 CHECK_EQ(maximum_double_misalignment, max_double_unaligned_fill); |
1797 int max_simd128_unaligned_fill = | |
1798 Heap::GetMaximumFillToAlign(kSimd128Unaligned); | |
1799 CHECK_EQ(maximum_simd128_misalignment, max_simd128_unaligned_fill); | |
1800 | 1796 |
1801 Address base = reinterpret_cast<Address>(NULL); | 1797 Address base = reinterpret_cast<Address>(NULL); |
1802 int fill = 0; | 1798 int fill = 0; |
1803 | 1799 |
1804 // Word alignment never requires fill. | 1800 // Word alignment never requires fill. |
1805 fill = Heap::GetFillToAlign(base, kWordAligned); | 1801 fill = Heap::GetFillToAlign(base, kWordAligned); |
1806 CHECK_EQ(0, fill); | 1802 CHECK_EQ(0, fill); |
1807 fill = Heap::GetFillToAlign(base + kPointerSize, kWordAligned); | 1803 fill = Heap::GetFillToAlign(base + kPointerSize, kWordAligned); |
1808 CHECK_EQ(0, fill); | 1804 CHECK_EQ(0, fill); |
1809 | 1805 |
1810 // No fill is required when address is double aligned. | 1806 // No fill is required when address is double aligned. |
1811 fill = Heap::GetFillToAlign(base, kDoubleAligned); | 1807 fill = Heap::GetFillToAlign(base, kDoubleAligned); |
1812 CHECK_EQ(0, fill); | 1808 CHECK_EQ(0, fill); |
1813 // Fill is required if address is not double aligned. | 1809 // Fill is required if address is not double aligned. |
1814 fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleAligned); | 1810 fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleAligned); |
1815 CHECK_EQ(maximum_double_misalignment, fill); | 1811 CHECK_EQ(maximum_double_misalignment, fill); |
1816 // kDoubleUnaligned has the opposite fill amounts. | 1812 // kDoubleUnaligned has the opposite fill amounts. |
1817 fill = Heap::GetFillToAlign(base, kDoubleUnaligned); | 1813 fill = Heap::GetFillToAlign(base, kDoubleUnaligned); |
1818 CHECK_EQ(maximum_double_misalignment, fill); | 1814 CHECK_EQ(maximum_double_misalignment, fill); |
1819 fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleUnaligned); | 1815 fill = Heap::GetFillToAlign(base + kPointerSize, kDoubleUnaligned); |
1820 CHECK_EQ(0, fill); | 1816 CHECK_EQ(0, fill); |
1821 | |
1822 // 128 bit SIMD types have 2 or 4 possible alignments, depending on platform. | |
1823 fill = Heap::GetFillToAlign(base, kSimd128Unaligned); | |
1824 CHECK_EQ((3 * kPointerSize) & kSimd128AlignmentMask, fill); | |
1825 fill = Heap::GetFillToAlign(base + kPointerSize, kSimd128Unaligned); | |
1826 CHECK_EQ((2 * kPointerSize) & kSimd128AlignmentMask, fill); | |
1827 fill = Heap::GetFillToAlign(base + 2 * kPointerSize, kSimd128Unaligned); | |
1828 CHECK_EQ(kPointerSize, fill); | |
1829 fill = Heap::GetFillToAlign(base + 3 * kPointerSize, kSimd128Unaligned); | |
1830 CHECK_EQ(0, fill); | |
1831 } | 1817 } |
1832 | 1818 |
1833 | 1819 |
1834 static HeapObject* NewSpaceAllocateAligned(int size, | 1820 static HeapObject* NewSpaceAllocateAligned(int size, |
1835 AllocationAlignment alignment) { | 1821 AllocationAlignment alignment) { |
1836 Heap* heap = CcTest::heap(); | 1822 Heap* heap = CcTest::heap(); |
1837 AllocationResult allocation = | 1823 AllocationResult allocation = |
1838 heap->new_space()->AllocateRawAligned(size, alignment); | 1824 heap->new_space()->AllocateRawAligned(size, alignment); |
1839 HeapObject* obj = NULL; | 1825 HeapObject* obj = NULL; |
1840 allocation.To(&obj); | 1826 allocation.To(&obj); |
1841 heap->CreateFillerObjectAt(obj->address(), size); | 1827 heap->CreateFillerObjectAt(obj->address(), size); |
1842 return obj; | 1828 return obj; |
1843 } | 1829 } |
1844 | 1830 |
1845 | 1831 |
1846 // Get new space allocation into the desired alignment. | |
1847 static Address AlignNewSpace(AllocationAlignment alignment, int offset) { | |
1848 Address* top_addr = CcTest::heap()->new_space()->allocation_top_address(); | |
1849 int fill = Heap::GetFillToAlign(*top_addr, alignment); | |
1850 if (fill) { | |
1851 NewSpaceAllocateAligned(fill + offset, kWordAligned); | |
1852 } | |
1853 return *top_addr; | |
1854 } | |
1855 | |
1856 | |
1857 TEST(TestAlignedAllocation) { | 1832 TEST(TestAlignedAllocation) { |
1858 // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. | 1833 // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. |
1859 const intptr_t double_misalignment = kDoubleSize - kPointerSize; | 1834 const intptr_t double_misalignment = kDoubleSize - kPointerSize; |
1860 Address* top_addr = CcTest::heap()->new_space()->allocation_top_address(); | |
1861 Address start; | |
1862 HeapObject* obj; | |
1863 HeapObject* filler; | |
1864 if (double_misalignment) { | 1835 if (double_misalignment) { |
1865 // Allocate a pointer sized object that must be double aligned at an | 1836 Address* top_addr = CcTest::heap()->new_space()->allocation_top_address(); |
1866 // aligned address. | 1837 // Align the top for the first test. |
1867 start = AlignNewSpace(kDoubleAligned, 0); | 1838 if (!IsAddressAligned(*top_addr, kDoubleAlignment)) |
1868 obj = NewSpaceAllocateAligned(kPointerSize, kDoubleAligned); | 1839 NewSpaceAllocateAligned(kPointerSize, kWordAligned); |
1869 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); | 1840 |
1870 // There is no filler. | 1841 // Allocate a pointer sized object that must be double aligned. |
| 1842 Address start = *top_addr; |
| 1843 HeapObject* obj1 = NewSpaceAllocateAligned(kPointerSize, kDoubleAligned); |
| 1844 CHECK(IsAddressAligned(obj1->address(), kDoubleAlignment)); |
| 1845 // Only the object was allocated. |
1871 CHECK_EQ(kPointerSize, *top_addr - start); | 1846 CHECK_EQ(kPointerSize, *top_addr - start); |
| 1847 // top is now misaligned. |
| 1848 // Allocate a second pointer sized object that must be double aligned. |
| 1849 HeapObject* obj2 = NewSpaceAllocateAligned(kPointerSize, kDoubleAligned); |
| 1850 CHECK(IsAddressAligned(obj2->address(), kDoubleAlignment)); |
| 1851 // There should be a filler object in between the two objects. |
| 1852 CHECK(HeapObject::FromAddress(start + kPointerSize)->IsFiller()); |
| 1853 // Two objects and a filler object were allocated. |
| 1854 CHECK_EQ(2 * kPointerSize + double_misalignment, *top_addr - start); |
1872 | 1855 |
1873 // Allocate a second pointer sized object that must be double aligned at an | 1856 // Similarly for kDoubleUnaligned. top is misaligned. |
1874 // unaligned address. | 1857 start = *top_addr; |
1875 start = AlignNewSpace(kDoubleAligned, kPointerSize); | 1858 obj1 = NewSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); |
1876 obj = NewSpaceAllocateAligned(kPointerSize, kDoubleAligned); | 1859 CHECK(IsAddressAligned(obj1->address(), kDoubleAlignment, kPointerSize)); |
1877 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); | |
1878 // There is a filler object before the object. | |
1879 filler = HeapObject::FromAddress(start); | |
1880 CHECK(obj != filler && filler->IsFiller() && | |
1881 filler->Size() == kPointerSize); | |
1882 CHECK_EQ(kPointerSize + double_misalignment, *top_addr - start); | |
1883 | |
1884 // Similarly for kDoubleUnaligned. | |
1885 start = AlignNewSpace(kDoubleUnaligned, 0); | |
1886 obj = NewSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); | |
1887 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); | |
1888 CHECK_EQ(kPointerSize, *top_addr - start); | 1860 CHECK_EQ(kPointerSize, *top_addr - start); |
1889 start = AlignNewSpace(kDoubleUnaligned, kPointerSize); | 1861 obj2 = NewSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); |
1890 obj = NewSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); | 1862 CHECK(IsAddressAligned(obj2->address(), kDoubleAlignment, kPointerSize)); |
1891 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); | 1863 CHECK(HeapObject::FromAddress(start + kPointerSize)->IsFiller()); |
1892 // There is a filler object before the object. | 1864 CHECK_EQ(2 * kPointerSize + double_misalignment, *top_addr - start); |
1893 filler = HeapObject::FromAddress(start); | |
1894 CHECK(obj != filler && filler->IsFiller() && | |
1895 filler->Size() == kPointerSize); | |
1896 CHECK_EQ(kPointerSize + double_misalignment, *top_addr - start); | |
1897 } | |
1898 | |
1899 // Now test SIMD alignment. There are 2 or 4 possible alignments, depending | |
1900 // on platform. | |
1901 start = AlignNewSpace(kSimd128Unaligned, 0); | |
1902 obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
1903 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
1904 // There is no filler. | |
1905 CHECK_EQ(kPointerSize, *top_addr - start); | |
1906 start = AlignNewSpace(kSimd128Unaligned, kPointerSize); | |
1907 obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
1908 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
1909 // There is a filler object before the object. | |
1910 filler = HeapObject::FromAddress(start); | |
1911 CHECK(obj != filler && filler->IsFiller() && | |
1912 filler->Size() == kSimd128Size - kPointerSize); | |
1913 CHECK_EQ(kPointerSize + kSimd128Size - kPointerSize, *top_addr - start); | |
1914 | |
1915 if (double_misalignment) { | |
1916 // Test the 2 other alignments possible on 32 bit platforms. | |
1917 start = AlignNewSpace(kSimd128Unaligned, 2 * kPointerSize); | |
1918 obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
1919 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
1920 // There is a filler object before the object. | |
1921 filler = HeapObject::FromAddress(start); | |
1922 CHECK(obj != filler && filler->IsFiller() && | |
1923 filler->Size() == 2 * kPointerSize); | |
1924 CHECK_EQ(kPointerSize + 2 * kPointerSize, *top_addr - start); | |
1925 start = AlignNewSpace(kSimd128Unaligned, 3 * kPointerSize); | |
1926 obj = NewSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
1927 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
1928 // There is a filler object before the object. | |
1929 filler = HeapObject::FromAddress(start); | |
1930 CHECK(obj != filler && filler->IsFiller() && | |
1931 filler->Size() == kPointerSize); | |
1932 CHECK_EQ(kPointerSize + kPointerSize, *top_addr - start); | |
1933 } | 1865 } |
1934 } | 1866 } |
1935 | 1867 |
1936 | 1868 |
| 1869 // Force allocation to happen from the free list, at a desired misalignment. |
| 1870 static Address SetUpFreeListAllocation(int misalignment) { |
| 1871 Heap* heap = CcTest::heap(); |
| 1872 OldSpace* old_space = heap->old_space(); |
| 1873 Address top = old_space->top(); |
| 1874 // First, allocate enough filler to get the linear area into the desired |
| 1875 // misalignment. |
| 1876 const intptr_t maximum_misalignment = 2 * kPointerSize; |
| 1877 const intptr_t maximum_misalignment_mask = maximum_misalignment - 1; |
| 1878 intptr_t top_alignment = OffsetFrom(top) & maximum_misalignment_mask; |
| 1879 int filler_size = misalignment - static_cast<int>(top_alignment); |
| 1880 if (filler_size < 0) filler_size += maximum_misalignment; |
| 1881 if (filler_size) { |
| 1882 // Create the filler object. |
| 1883 AllocationResult allocation = old_space->AllocateRawUnaligned(filler_size); |
| 1884 HeapObject* obj = NULL; |
| 1885 allocation.To(&obj); |
| 1886 heap->CreateFillerObjectAt(obj->address(), filler_size); |
| 1887 } |
| 1888 top = old_space->top(); |
| 1889 old_space->EmptyAllocationInfo(); |
| 1890 return top; |
| 1891 } |
| 1892 |
| 1893 |
1937 static HeapObject* OldSpaceAllocateAligned(int size, | 1894 static HeapObject* OldSpaceAllocateAligned(int size, |
1938 AllocationAlignment alignment) { | 1895 AllocationAlignment alignment) { |
1939 Heap* heap = CcTest::heap(); | 1896 Heap* heap = CcTest::heap(); |
1940 AllocationResult allocation = | 1897 AllocationResult allocation = |
1941 heap->old_space()->AllocateRawAligned(size, alignment); | 1898 heap->old_space()->AllocateRawAligned(size, alignment); |
1942 HeapObject* obj = NULL; | 1899 HeapObject* obj = NULL; |
1943 allocation.To(&obj); | 1900 allocation.To(&obj); |
1944 heap->CreateFillerObjectAt(obj->address(), size); | 1901 heap->CreateFillerObjectAt(obj->address(), size); |
1945 return obj; | 1902 return obj; |
1946 } | 1903 } |
1947 | 1904 |
1948 | 1905 |
1949 // Get old space allocation into the desired alignment. | |
1950 static Address AlignOldSpace(AllocationAlignment alignment, int offset) { | |
1951 Address* top_addr = CcTest::heap()->old_space()->allocation_top_address(); | |
1952 int fill = Heap::GetFillToAlign(*top_addr, alignment); | |
1953 int allocation = fill + offset; | |
1954 if (allocation) { | |
1955 OldSpaceAllocateAligned(allocation, kWordAligned); | |
1956 } | |
1957 Address top = *top_addr; | |
1958 // Now force the remaining allocation onto the free list. | |
1959 CcTest::heap()->old_space()->EmptyAllocationInfo(); | |
1960 return top; | |
1961 } | |
1962 | |
1963 | |
1964 // Test the case where allocation must be done from the free list, so filler | 1906 // Test the case where allocation must be done from the free list, so filler |
1965 // may precede or follow the object. | 1907 // may precede or follow the object. |
1966 TEST(TestAlignedOverAllocation) { | 1908 TEST(TestAlignedOverAllocation) { |
1967 // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. | 1909 // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. |
1968 const intptr_t double_misalignment = kDoubleSize - kPointerSize; | 1910 const intptr_t double_misalignment = kDoubleSize - kPointerSize; |
1969 Address start; | |
1970 HeapObject* obj; | |
1971 HeapObject* filler1; | |
1972 HeapObject* filler2; | |
1973 if (double_misalignment) { | 1911 if (double_misalignment) { |
1974 start = AlignOldSpace(kDoubleAligned, 0); | 1912 Address start = SetUpFreeListAllocation(0); |
1975 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); | 1913 HeapObject* obj1 = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); |
1976 // The object is aligned, and a filler object is created after. | 1914 // The object should be aligned, and a filler object should be created. |
1977 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); | 1915 CHECK(IsAddressAligned(obj1->address(), kDoubleAlignment)); |
1978 filler1 = HeapObject::FromAddress(start + kPointerSize); | 1916 CHECK(HeapObject::FromAddress(start)->IsFiller() && |
1979 CHECK(obj != filler1 && filler1->IsFiller() && | 1917 HeapObject::FromAddress(start + kPointerSize)->IsFiller()); |
1980 filler1->Size() == kPointerSize); | |
1981 // Try the opposite alignment case. | 1918 // Try the opposite alignment case. |
1982 start = AlignOldSpace(kDoubleAligned, kPointerSize); | 1919 start = SetUpFreeListAllocation(kPointerSize); |
1983 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); | 1920 HeapObject* obj2 = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); |
1984 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); | 1921 CHECK(IsAddressAligned(obj2->address(), kDoubleAlignment)); |
1985 filler1 = HeapObject::FromAddress(start); | 1922 CHECK(HeapObject::FromAddress(start)->IsFiller() && |
1986 CHECK(obj != filler1); | 1923 HeapObject::FromAddress(start + kPointerSize)->IsFiller()); |
1987 CHECK(filler1->IsFiller()); | |
1988 CHECK(filler1->Size() == kPointerSize); | |
1989 CHECK(obj != filler1 && filler1->IsFiller() && | |
1990 filler1->Size() == kPointerSize); | |
1991 | 1924 |
1992 // Similarly for kDoubleUnaligned. | 1925 // Similarly for kDoubleUnaligned. |
1993 start = AlignOldSpace(kDoubleUnaligned, 0); | 1926 start = SetUpFreeListAllocation(0); |
1994 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); | 1927 obj1 = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); |
1995 // The object is aligned, and a filler object is created after. | 1928 // The object should be aligned, and a filler object should be created. |
1996 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); | 1929 CHECK(IsAddressAligned(obj1->address(), kDoubleAlignment, kPointerSize)); |
1997 filler1 = HeapObject::FromAddress(start + kPointerSize); | 1930 CHECK(HeapObject::FromAddress(start)->IsFiller() && |
1998 CHECK(obj != filler1 && filler1->IsFiller() && | 1931 HeapObject::FromAddress(start + kPointerSize)->IsFiller()); |
1999 filler1->Size() == kPointerSize); | |
2000 // Try the opposite alignment case. | 1932 // Try the opposite alignment case. |
2001 start = AlignOldSpace(kDoubleUnaligned, kPointerSize); | 1933 start = SetUpFreeListAllocation(kPointerSize); |
2002 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); | 1934 obj2 = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); |
2003 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); | 1935 CHECK(IsAddressAligned(obj2->address(), kDoubleAlignment, kPointerSize)); |
2004 filler1 = HeapObject::FromAddress(start); | 1936 CHECK(HeapObject::FromAddress(start)->IsFiller() && |
2005 CHECK(obj != filler1 && filler1->IsFiller() && | 1937 HeapObject::FromAddress(start + kPointerSize)->IsFiller()); |
2006 filler1->Size() == kPointerSize); | |
2007 } | |
2008 | |
2009 // Now test SIMD alignment. There are 2 or 4 possible alignments, depending | |
2010 // on platform. | |
2011 start = AlignOldSpace(kSimd128Unaligned, 0); | |
2012 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
2013 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
2014 // There is a filler object after the object. | |
2015 filler1 = HeapObject::FromAddress(start + kPointerSize); | |
2016 CHECK(obj != filler1 && filler1->IsFiller() && | |
2017 filler1->Size() == kSimd128Size - kPointerSize); | |
2018 start = AlignOldSpace(kSimd128Unaligned, kPointerSize); | |
2019 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
2020 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
2021 // There is a filler object before the object. | |
2022 filler1 = HeapObject::FromAddress(start); | |
2023 CHECK(obj != filler1 && filler1->IsFiller() && | |
2024 filler1->Size() == kSimd128Size - kPointerSize); | |
2025 | |
2026 if (double_misalignment) { | |
2027 // Test the 2 other alignments possible on 32 bit platforms. | |
2028 start = AlignOldSpace(kSimd128Unaligned, 2 * kPointerSize); | |
2029 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
2030 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
2031 // There are filler objects before and after the object. | |
2032 filler1 = HeapObject::FromAddress(start); | |
2033 CHECK(obj != filler1 && filler1->IsFiller() && | |
2034 filler1->Size() == 2 * kPointerSize); | |
2035 filler2 = HeapObject::FromAddress(start + 3 * kPointerSize); | |
2036 CHECK(obj != filler2 && filler2->IsFiller() && | |
2037 filler2->Size() == kPointerSize); | |
2038 start = AlignOldSpace(kSimd128Unaligned, 3 * kPointerSize); | |
2039 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | |
2040 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | |
2041 // There are filler objects before and after the object. | |
2042 filler1 = HeapObject::FromAddress(start); | |
2043 CHECK(obj != filler1 && filler1->IsFiller() && | |
2044 filler1->Size() == kPointerSize); | |
2045 filler2 = HeapObject::FromAddress(start + 2 * kPointerSize); | |
2046 CHECK(obj != filler2 && filler2->IsFiller() && | |
2047 filler2->Size() == 2 * kPointerSize); | |
2048 } | 1938 } |
2049 } | 1939 } |
2050 | 1940 |
2051 | 1941 |
2052 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { | 1942 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { |
2053 CcTest::InitializeVM(); | 1943 CcTest::InitializeVM(); |
2054 HeapIterator iterator(CcTest::heap()); | 1944 HeapIterator iterator(CcTest::heap()); |
2055 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); | 1945 intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); |
2056 intptr_t size_of_objects_2 = 0; | 1946 intptr_t size_of_objects_2 = 0; |
2057 for (HeapObject* obj = iterator.next(); | 1947 for (HeapObject* obj = iterator.next(); |
(...skipping 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5899 size_t counter2 = 2000; | 5789 size_t counter2 = 2000; |
5900 tracer->SampleAllocation(time2, counter2, counter2); | 5790 tracer->SampleAllocation(time2, counter2, counter2); |
5901 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5791 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
5902 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); | 5792 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); |
5903 int time3 = 1000; | 5793 int time3 = 1000; |
5904 size_t counter3 = 30000; | 5794 size_t counter3 = 30000; |
5905 tracer->SampleAllocation(time3, counter3, counter3); | 5795 tracer->SampleAllocation(time3, counter3, counter3); |
5906 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5796 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
5907 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); | 5797 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); |
5908 } | 5798 } |
OLD | NEW |