OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | 1760 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); |
1761 } | 1761 } |
1762 | 1762 |
1763 | 1763 |
1764 | 1764 |
1765 Object* LoadStubCompiler::CompileLoadField(JSObject* object, | 1765 Object* LoadStubCompiler::CompileLoadField(JSObject* object, |
1766 JSObject* holder, | 1766 JSObject* holder, |
1767 int index, | 1767 int index, |
1768 String* name) { | 1768 String* name) { |
1769 // ----------- S t a t e ------------- | 1769 // ----------- S t a t e ------------- |
| 1770 // -- eax : receiver |
1770 // -- ecx : name | 1771 // -- ecx : name |
1771 // -- esp[0] : return address | 1772 // -- esp[0] : return address |
1772 // -- esp[4] : receiver | |
1773 // ----------------------------------- | 1773 // ----------------------------------- |
1774 Label miss; | 1774 Label miss; |
1775 | 1775 |
1776 __ mov(eax, Operand(esp, kPointerSize)); | |
1777 GenerateLoadField(object, holder, eax, ebx, edx, index, name, &miss); | 1776 GenerateLoadField(object, holder, eax, ebx, edx, index, name, &miss); |
1778 __ bind(&miss); | 1777 __ bind(&miss); |
1779 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1778 GenerateLoadMiss(masm(), Code::LOAD_IC); |
1780 | 1779 |
1781 // Return the generated code. | 1780 // Return the generated code. |
1782 return GetCode(FIELD, name); | 1781 return GetCode(FIELD, name); |
1783 } | 1782 } |
1784 | 1783 |
1785 | 1784 |
1786 Object* LoadStubCompiler::CompileLoadCallback(String* name, | 1785 Object* LoadStubCompiler::CompileLoadCallback(String* name, |
1787 JSObject* object, | 1786 JSObject* object, |
1788 JSObject* holder, | 1787 JSObject* holder, |
1789 AccessorInfo* callback) { | 1788 AccessorInfo* callback) { |
1790 // ----------- S t a t e ------------- | 1789 // ----------- S t a t e ------------- |
| 1790 // -- eax : receiver |
1791 // -- ecx : name | 1791 // -- ecx : name |
1792 // -- esp[0] : return address | 1792 // -- esp[0] : return address |
1793 // -- esp[4] : receiver | |
1794 // ----------------------------------- | 1793 // ----------------------------------- |
1795 Label miss; | 1794 Label miss; |
1796 | 1795 |
1797 __ mov(eax, Operand(esp, kPointerSize)); | |
1798 Failure* failure = Failure::InternalError(); | 1796 Failure* failure = Failure::InternalError(); |
1799 bool success = GenerateLoadCallback(object, holder, eax, ecx, ebx, edx, | 1797 bool success = GenerateLoadCallback(object, holder, eax, ecx, ebx, edx, |
1800 callback, name, &miss, &failure); | 1798 callback, name, &miss, &failure); |
1801 if (!success) return failure; | 1799 if (!success) return failure; |
1802 | 1800 |
1803 __ bind(&miss); | 1801 __ bind(&miss); |
1804 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1802 GenerateLoadMiss(masm(), Code::LOAD_IC); |
1805 | 1803 |
1806 // Return the generated code. | 1804 // Return the generated code. |
1807 return GetCode(CALLBACKS, name); | 1805 return GetCode(CALLBACKS, name); |
1808 } | 1806 } |
1809 | 1807 |
1810 | 1808 |
1811 Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, | 1809 Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, |
1812 JSObject* holder, | 1810 JSObject* holder, |
1813 Object* value, | 1811 Object* value, |
1814 String* name) { | 1812 String* name) { |
1815 // ----------- S t a t e ------------- | 1813 // ----------- S t a t e ------------- |
| 1814 // -- eax : receiver |
1816 // -- ecx : name | 1815 // -- ecx : name |
1817 // -- esp[0] : return address | 1816 // -- esp[0] : return address |
1818 // -- esp[4] : receiver | |
1819 // ----------------------------------- | 1817 // ----------------------------------- |
1820 Label miss; | 1818 Label miss; |
1821 | 1819 |
1822 __ mov(eax, Operand(esp, kPointerSize)); | |
1823 GenerateLoadConstant(object, holder, eax, ebx, edx, value, name, &miss); | 1820 GenerateLoadConstant(object, holder, eax, ebx, edx, value, name, &miss); |
1824 __ bind(&miss); | 1821 __ bind(&miss); |
1825 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1822 GenerateLoadMiss(masm(), Code::LOAD_IC); |
1826 | 1823 |
1827 // Return the generated code. | 1824 // Return the generated code. |
1828 return GetCode(CONSTANT_FUNCTION, name); | 1825 return GetCode(CONSTANT_FUNCTION, name); |
1829 } | 1826 } |
1830 | 1827 |
1831 | 1828 |
1832 Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, | 1829 Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, |
1833 JSObject* holder, | 1830 JSObject* holder, |
1834 String* name) { | 1831 String* name) { |
1835 // ----------- S t a t e ------------- | 1832 // ----------- S t a t e ------------- |
| 1833 // -- eax : receiver |
1836 // -- ecx : name | 1834 // -- ecx : name |
1837 // -- esp[0] : return address | 1835 // -- esp[0] : return address |
1838 // -- esp[4] : receiver | |
1839 // ----------------------------------- | 1836 // ----------------------------------- |
1840 Label miss; | 1837 Label miss; |
1841 | 1838 |
1842 LookupResult lookup; | 1839 LookupResult lookup; |
1843 LookupPostInterceptor(holder, name, &lookup); | 1840 LookupPostInterceptor(holder, name, &lookup); |
1844 | 1841 |
1845 __ mov(eax, Operand(esp, kPointerSize)); | |
1846 // TODO(368): Compile in the whole chain: all the interceptors in | 1842 // TODO(368): Compile in the whole chain: all the interceptors in |
1847 // prototypes and ultimate answer. | 1843 // prototypes and ultimate answer. |
1848 GenerateLoadInterceptor(receiver, | 1844 GenerateLoadInterceptor(receiver, |
1849 holder, | 1845 holder, |
1850 &lookup, | 1846 &lookup, |
1851 eax, | 1847 eax, |
1852 ecx, | 1848 ecx, |
1853 edx, | 1849 edx, |
1854 ebx, | 1850 ebx, |
1855 name, | 1851 name, |
1856 &miss); | 1852 &miss); |
1857 | 1853 |
1858 __ bind(&miss); | 1854 __ bind(&miss); |
1859 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1855 GenerateLoadMiss(masm(), Code::LOAD_IC); |
1860 | 1856 |
1861 // Return the generated code. | 1857 // Return the generated code. |
1862 return GetCode(INTERCEPTOR, name); | 1858 return GetCode(INTERCEPTOR, name); |
1863 } | 1859 } |
1864 | 1860 |
1865 | 1861 |
1866 Object* LoadStubCompiler::CompileLoadGlobal(JSObject* object, | 1862 Object* LoadStubCompiler::CompileLoadGlobal(JSObject* object, |
1867 GlobalObject* holder, | 1863 GlobalObject* holder, |
1868 JSGlobalPropertyCell* cell, | 1864 JSGlobalPropertyCell* cell, |
1869 String* name, | 1865 String* name, |
1870 bool is_dont_delete) { | 1866 bool is_dont_delete) { |
1871 // ----------- S t a t e ------------- | 1867 // ----------- S t a t e ------------- |
| 1868 // -- eax : receiver |
1872 // -- ecx : name | 1869 // -- ecx : name |
1873 // -- esp[0] : return address | 1870 // -- esp[0] : return address |
1874 // -- esp[4] : receiver | |
1875 // ----------------------------------- | 1871 // ----------------------------------- |
1876 Label miss; | 1872 Label miss; |
1877 | 1873 |
1878 // Get the receiver from the stack. | |
1879 __ mov(eax, Operand(esp, kPointerSize)); | |
1880 | |
1881 // If the object is the holder then we know that it's a global | 1874 // If the object is the holder then we know that it's a global |
1882 // object which can only happen for contextual loads. In this case, | 1875 // object which can only happen for contextual loads. In this case, |
1883 // the receiver cannot be a smi. | 1876 // the receiver cannot be a smi. |
1884 if (object != holder) { | 1877 if (object != holder) { |
1885 __ test(eax, Immediate(kSmiTagMask)); | 1878 __ test(eax, Immediate(kSmiTagMask)); |
1886 __ j(zero, &miss, not_taken); | 1879 __ j(zero, &miss, not_taken); |
1887 } | 1880 } |
1888 | 1881 |
1889 // Check that the maps haven't changed. | 1882 // Check that the maps haven't changed. |
1890 CheckPrototypes(object, eax, holder, ebx, edx, name, &miss); | 1883 CheckPrototypes(object, eax, holder, ebx, edx, name, &miss); |
1891 | 1884 |
1892 // Get the value from the cell. | 1885 // Get the value from the cell. |
1893 __ mov(eax, Immediate(Handle<JSGlobalPropertyCell>(cell))); | 1886 __ mov(ebx, Immediate(Handle<JSGlobalPropertyCell>(cell))); |
1894 __ mov(eax, FieldOperand(eax, JSGlobalPropertyCell::kValueOffset)); | 1887 __ mov(ebx, FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset)); |
1895 | 1888 |
1896 // Check for deleted property if property can actually be deleted. | 1889 // Check for deleted property if property can actually be deleted. |
1897 if (!is_dont_delete) { | 1890 if (!is_dont_delete) { |
1898 __ cmp(eax, Factory::the_hole_value()); | 1891 __ cmp(ebx, Factory::the_hole_value()); |
1899 __ j(equal, &miss, not_taken); | 1892 __ j(equal, &miss, not_taken); |
1900 } else if (FLAG_debug_code) { | 1893 } else if (FLAG_debug_code) { |
1901 __ cmp(eax, Factory::the_hole_value()); | 1894 __ cmp(ebx, Factory::the_hole_value()); |
1902 __ Check(not_equal, "DontDelete cells can't contain the hole"); | 1895 __ Check(not_equal, "DontDelete cells can't contain the hole"); |
1903 } | 1896 } |
1904 | 1897 |
1905 __ IncrementCounter(&Counters::named_load_global_inline, 1); | 1898 __ IncrementCounter(&Counters::named_load_global_inline, 1); |
| 1899 __ mov(eax, ebx); |
1906 __ ret(0); | 1900 __ ret(0); |
1907 | 1901 |
1908 __ bind(&miss); | 1902 __ bind(&miss); |
1909 __ IncrementCounter(&Counters::named_load_global_inline_miss, 1); | 1903 __ IncrementCounter(&Counters::named_load_global_inline_miss, 1); |
1910 GenerateLoadMiss(masm(), Code::LOAD_IC); | 1904 GenerateLoadMiss(masm(), Code::LOAD_IC); |
1911 | 1905 |
1912 // Return the generated code. | 1906 // Return the generated code. |
1913 return GetCode(NORMAL, name); | 1907 return GetCode(NORMAL, name); |
1914 } | 1908 } |
1915 | 1909 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2258 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 2252 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
2259 | 2253 |
2260 // Return the generated code. | 2254 // Return the generated code. |
2261 return GetCode(); | 2255 return GetCode(); |
2262 } | 2256 } |
2263 | 2257 |
2264 | 2258 |
2265 #undef __ | 2259 #undef __ |
2266 | 2260 |
2267 } } // namespace v8::internal | 2261 } } // namespace v8::internal |
OLD | NEW |