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

Side by Side Diff: test/cctest/test-heap.cc

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

Powered by Google App Engine
This is Rietveld 408576698