| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
| (...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 } else { | 1843 } else { |
| 1844 EmitUint8(0x81); | 1844 EmitUint8(0x81); |
| 1845 EmitOperand(7, Operand(reg)); | 1845 EmitOperand(7, Operand(reg)); |
| 1846 buffer_.EmitObject(object); | 1846 buffer_.EmitObject(object); |
| 1847 } | 1847 } |
| 1848 } | 1848 } |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 | 1851 |
| 1852 // Destroys the value register. | 1852 // Destroys the value register. |
| 1853 void Assembler::StoreIntoObjectFilterNoSmi(Register object, |
| 1854 Register value, |
| 1855 Label* no_update) { |
| 1856 COMPILE_ASSERT((kNewObjectAlignmentOffset == kWordSize) && |
| 1857 (kOldObjectAlignmentOffset == 0), young_alignment); |
| 1858 |
| 1859 // Write-barrier triggers if the value is in the new space (has bit set) and |
| 1860 // the object is in the old space (has bit cleared). |
| 1861 // To check that we could compute value & ~object and skip the write barrier |
| 1862 // if the bit is not set. However we can't destroy the object. |
| 1863 // However to preserve the object we compute negated expression |
| 1864 // ~value | object instead and skip the write barrier if the bit is set. |
| 1865 notl(value); |
| 1866 orl(value, object); |
| 1867 testl(value, Immediate(kNewObjectAlignmentOffset)); |
| 1868 j(NOT_ZERO, no_update, Assembler::kNearJump); |
| 1869 } |
| 1870 |
| 1871 |
| 1872 // Destroys the value register. |
| 1853 void Assembler::StoreIntoObjectFilter(Register object, | 1873 void Assembler::StoreIntoObjectFilter(Register object, |
| 1854 Register value, | 1874 Register value, |
| 1855 Label* no_update) { | 1875 Label* no_update) { |
| 1856 // For the value we are only interested in the new/old bit and the tag bit. | 1876 // For the value we are only interested in the new/old bit and the tag bit. |
| 1857 andl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag)); | 1877 andl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag)); |
| 1858 // Shift the tag bit into the carry. | 1878 // Shift the tag bit into the carry. |
| 1859 shrl(value, Immediate(1)); | 1879 shrl(value, Immediate(1)); |
| 1860 // Add the tag bits together, if the value is not a Smi the addition will | 1880 // Add the tag bits together, if the value is not a Smi the addition will |
| 1861 // overflow into the next bit, leaving us with a zero low bit. | 1881 // overflow into the next bit, leaving us with a zero low bit. |
| 1862 adcl(value, object); | 1882 adcl(value, object); |
| 1863 // Mask out higher, uninteresting bits which were polluted by dest. | 1883 // Mask out higher, uninteresting bits which were polluted by dest. |
| 1864 andl(value, Immediate(kObjectAlignment - 1)); | 1884 andl(value, Immediate(kObjectAlignment - 1)); |
| 1865 // Compare with the expected bit pattern. | 1885 // Compare with the expected bit pattern. |
| 1866 cmpl(value, Immediate( | 1886 cmpl(value, Immediate( |
| 1867 (kNewObjectAlignmentOffset >> 1) + kHeapObjectTag + | 1887 (kNewObjectAlignmentOffset >> 1) + kHeapObjectTag + |
| 1868 kOldObjectAlignmentOffset + kHeapObjectTag)); | 1888 kOldObjectAlignmentOffset + kHeapObjectTag)); |
| 1869 j(NOT_ZERO, no_update, Assembler::kNearJump); | 1889 j(NOT_ZERO, no_update, Assembler::kNearJump); |
| 1870 } | 1890 } |
| 1871 | 1891 |
| 1872 | 1892 |
| 1873 void Assembler::StoreIntoObject(Register object, | 1893 void Assembler::StoreIntoObject(Register object, |
| 1874 const Address& dest, | 1894 const Address& dest, |
| 1875 Register value) { | 1895 Register value, |
| 1896 bool can_value_be_smi) { |
| 1876 ASSERT(object != value); | 1897 ASSERT(object != value); |
| 1877 TraceStoreIntoObject(object, dest, value); | 1898 TraceStoreIntoObject(object, dest, value); |
| 1878 movl(dest, value); | 1899 movl(dest, value); |
| 1879 Label done; | 1900 Label done; |
| 1880 StoreIntoObjectFilter(object, value, &done); | 1901 if (can_value_be_smi) { |
| 1902 StoreIntoObjectFilter(object, value, &done); |
| 1903 } else { |
| 1904 StoreIntoObjectFilterNoSmi(object, value, &done); |
| 1905 } |
| 1881 // A store buffer update is required. | 1906 // A store buffer update is required. |
| 1882 if (value != EAX) pushl(EAX); // Preserve EAX. | 1907 if (value != EAX) pushl(EAX); // Preserve EAX. |
| 1883 leal(EAX, dest); | 1908 leal(EAX, dest); |
| 1884 call(&StubCode::UpdateStoreBufferLabel()); | 1909 call(&StubCode::UpdateStoreBufferLabel()); |
| 1885 if (value != EAX) popl(EAX); // Restore EAX. | 1910 if (value != EAX) popl(EAX); // Restore EAX. |
| 1886 Bind(&done); | 1911 Bind(&done); |
| 1887 } | 1912 } |
| 1888 | 1913 |
| 1889 | 1914 |
| 1890 void Assembler::StoreIntoObjectNoBarrier(Register object, | 1915 void Assembler::StoreIntoObjectNoBarrier(Register object, |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 | 2359 |
| 2335 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2360 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 2336 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2361 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
| 2337 return xmm_reg_names[reg]; | 2362 return xmm_reg_names[reg]; |
| 2338 } | 2363 } |
| 2339 | 2364 |
| 2340 | 2365 |
| 2341 } // namespace dart | 2366 } // namespace dart |
| 2342 | 2367 |
| 2343 #endif // defined TARGET_ARCH_IA32 | 2368 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |