| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| 11 #include "vm/virtual_memory.h" | 11 #include "vm/virtual_memory.h" |
| (...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 | 1832 |
| 1833 ASSEMBLER_TEST_RUN(TestAlignLarge, entry) { | 1833 ASSEMBLER_TEST_RUN(TestAlignLarge, entry) { |
| 1834 typedef int (*TestAlignLarge)(); | 1834 typedef int (*TestAlignLarge)(); |
| 1835 int res = reinterpret_cast<TestAlignLarge>(entry)(); | 1835 int res = reinterpret_cast<TestAlignLarge>(entry)(); |
| 1836 EXPECT_EQ(16, res); // 16 bytes emitted. | 1836 EXPECT_EQ(16, res); // 16 bytes emitted. |
| 1837 } | 1837 } |
| 1838 | 1838 |
| 1839 | 1839 |
| 1840 // Called from assembler_test.cc. |
| 1840 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 1841 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
| 1841 __ pushl(CTX); | 1842 __ pushl(CTX); |
| 1842 __ movl(CTX, Address(ESP, 2 * kWordSize)); | 1843 __ movl(CTX, Address(ESP, 2 * kWordSize)); |
| 1843 __ movl(EAX, Address(ESP, 3 * kWordSize)); | 1844 __ movl(EAX, Address(ESP, 3 * kWordSize)); |
| 1844 __ movl(ECX, Address(ESP, 4 * kWordSize)); | 1845 __ movl(ECX, Address(ESP, 4 * kWordSize)); |
| 1845 __ StoreIntoObject(ECX, | 1846 __ StoreIntoObject(ECX, |
| 1846 FieldAddress(ECX, GrowableObjectArray::data_offset()), | 1847 FieldAddress(ECX, GrowableObjectArray::data_offset()), |
| 1847 EAX); | 1848 EAX); |
| 1848 __ popl(CTX); | 1849 __ popl(CTX); |
| 1849 __ ret(); | 1850 __ ret(); |
| 1850 } | 1851 } |
| 1851 | 1852 |
| 1852 | 1853 |
| 1853 ASSEMBLER_TEST_RUN(StoreIntoObject, entry) { | |
| 1854 typedef void (*StoreData)(RawContext* ctx, | |
| 1855 RawObject* value, | |
| 1856 RawObject* growable_array); | |
| 1857 StoreData test_code = reinterpret_cast<StoreData>(entry); | |
| 1858 | |
| 1859 const Array& old_array = Array::Handle(Array::New(3, Heap::kOld)); | |
| 1860 const Array& new_array = Array::Handle(Array::New(3, Heap::kNew)); | |
| 1861 const GrowableObjectArray& grow_old_array = GrowableObjectArray::Handle( | |
| 1862 GrowableObjectArray::New(old_array, Heap::kOld)); | |
| 1863 const GrowableObjectArray& grow_new_array = GrowableObjectArray::Handle( | |
| 1864 GrowableObjectArray::New(old_array, Heap::kNew)); | |
| 1865 Smi& smi = Smi::Handle(); | |
| 1866 const Context& ctx = Context::Handle(Context::New(0)); | |
| 1867 | |
| 1868 EXPECT(old_array.raw() == grow_old_array.data()); | |
| 1869 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
| 1870 reinterpret_cast<uword>(grow_old_array.raw()) + | |
| 1871 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1872 EXPECT(old_array.raw() == grow_new_array.data()); | |
| 1873 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
| 1874 reinterpret_cast<uword>(grow_new_array.raw()) + | |
| 1875 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1876 | |
| 1877 // Store Smis into the old object. | |
| 1878 for (int i = -32; i < 32; i++) { | |
| 1879 smi = Smi::New(i); | |
| 1880 test_code(ctx.raw(), smi.raw(), grow_old_array.raw()); | |
| 1881 EXPECT(reinterpret_cast<RawArray*>(smi.raw()) == grow_old_array.data()); | |
| 1882 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
| 1883 reinterpret_cast<uword>(grow_old_array.raw()) + | |
| 1884 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1885 } | |
| 1886 | |
| 1887 // Store an old object into the old object. | |
| 1888 test_code(ctx.raw(), old_array.raw(), grow_old_array.raw()); | |
| 1889 EXPECT(old_array.raw() == grow_old_array.data()); | |
| 1890 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
| 1891 reinterpret_cast<uword>(grow_old_array.raw()) + | |
| 1892 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1893 | |
| 1894 // Store a new object into the old object. | |
| 1895 test_code(ctx.raw(), new_array.raw(), grow_old_array.raw()); | |
| 1896 EXPECT(new_array.raw() == grow_old_array.data()); | |
| 1897 EXPECT(Isolate::Current()->store_buffer()->Contains( | |
| 1898 reinterpret_cast<uword>(grow_old_array.raw()) + | |
| 1899 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1900 | |
| 1901 // Store a new object into the new object. | |
| 1902 test_code(ctx.raw(), new_array.raw(), grow_new_array.raw()); | |
| 1903 EXPECT(new_array.raw() == grow_new_array.data()); | |
| 1904 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
| 1905 reinterpret_cast<uword>(grow_new_array.raw()) + | |
| 1906 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1907 | |
| 1908 // Store an old object into the new object. | |
| 1909 test_code(ctx.raw(), old_array.raw(), grow_new_array.raw()); | |
| 1910 EXPECT(old_array.raw() == grow_new_array.data()); | |
| 1911 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
| 1912 reinterpret_cast<uword>(grow_new_array.raw()) + | |
| 1913 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
| 1914 } | |
| 1915 | |
| 1916 | |
| 1917 } // namespace dart | 1854 } // namespace dart |
| 1918 | 1855 |
| 1919 #endif // defined TARGET_ARCH_IA32 | 1856 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |