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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 int index, | 258 int index, |
259 Register prototype) { | 259 Register prototype) { |
260 __ LoadGlobalFunction(index, prototype); | 260 __ LoadGlobalFunction(index, prototype); |
261 __ LoadGlobalFunctionInitialMap(prototype, prototype); | 261 __ LoadGlobalFunctionInitialMap(prototype, prototype); |
262 // Load the prototype from the initial map. | 262 // Load the prototype from the initial map. |
263 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 263 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
264 } | 264 } |
265 | 265 |
266 | 266 |
267 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( | 267 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
268 MacroAssembler* masm, int index, Register prototype) { | 268 MacroAssembler* masm, int index, Register prototype, Label* miss) { |
| 269 // Check we're still in the same context. |
| 270 __ cmp(Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)), |
| 271 Top::global()); |
| 272 __ j(not_equal, miss); |
269 // Get the global function with the given index. | 273 // Get the global function with the given index. |
270 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); | 274 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); |
271 // Load its initial map. The global functions all have initial maps. | 275 // Load its initial map. The global functions all have initial maps. |
272 __ Set(prototype, Immediate(Handle<Map>(function->initial_map()))); | 276 __ Set(prototype, Immediate(Handle<Map>(function->initial_map()))); |
273 // Load the prototype from the initial map. | 277 // Load the prototype from the initial map. |
274 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 278 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
275 } | 279 } |
276 | 280 |
277 | 281 |
278 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, | 282 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 | 1623 |
1620 const int argc = arguments().immediate(); | 1624 const int argc = arguments().immediate(); |
1621 | 1625 |
1622 Label miss; | 1626 Label miss; |
1623 Label index_out_of_range; | 1627 Label index_out_of_range; |
1624 GenerateNameCheck(name, &miss); | 1628 GenerateNameCheck(name, &miss); |
1625 | 1629 |
1626 // Check that the maps starting from the prototype haven't changed. | 1630 // Check that the maps starting from the prototype haven't changed. |
1627 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1631 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1628 Context::STRING_FUNCTION_INDEX, | 1632 Context::STRING_FUNCTION_INDEX, |
1629 eax); | 1633 eax, |
| 1634 &miss); |
1630 ASSERT(object != holder); | 1635 ASSERT(object != holder); |
1631 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1636 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1632 ebx, edx, edi, name, &miss); | 1637 ebx, edx, edi, name, &miss); |
1633 | 1638 |
1634 Register receiver = ebx; | 1639 Register receiver = ebx; |
1635 Register index = edi; | 1640 Register index = edi; |
1636 Register scratch = edx; | 1641 Register scratch = edx; |
1637 Register result = eax; | 1642 Register result = eax; |
1638 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1643 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
1639 if (argc > 0) { | 1644 if (argc > 0) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 const int argc = arguments().immediate(); | 1693 const int argc = arguments().immediate(); |
1689 | 1694 |
1690 Label miss; | 1695 Label miss; |
1691 Label index_out_of_range; | 1696 Label index_out_of_range; |
1692 | 1697 |
1693 GenerateNameCheck(name, &miss); | 1698 GenerateNameCheck(name, &miss); |
1694 | 1699 |
1695 // Check that the maps starting from the prototype haven't changed. | 1700 // Check that the maps starting from the prototype haven't changed. |
1696 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1701 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1697 Context::STRING_FUNCTION_INDEX, | 1702 Context::STRING_FUNCTION_INDEX, |
1698 eax); | 1703 eax, |
| 1704 &miss); |
1699 ASSERT(object != holder); | 1705 ASSERT(object != holder); |
1700 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1706 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1701 ebx, edx, edi, name, &miss); | 1707 ebx, edx, edi, name, &miss); |
1702 | 1708 |
1703 Register receiver = eax; | 1709 Register receiver = eax; |
1704 Register index = edi; | 1710 Register index = edi; |
1705 Register scratch1 = ebx; | 1711 Register scratch1 = ebx; |
1706 Register scratch2 = edx; | 1712 Register scratch2 = edx; |
1707 Register result = eax; | 1713 Register result = eax; |
1708 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1714 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 case STRING_CHECK: | 1893 case STRING_CHECK: |
1888 if (!function->IsBuiltin()) { | 1894 if (!function->IsBuiltin()) { |
1889 // Calling non-builtins with a value as receiver requires boxing. | 1895 // Calling non-builtins with a value as receiver requires boxing. |
1890 __ jmp(&miss); | 1896 __ jmp(&miss); |
1891 } else { | 1897 } else { |
1892 // Check that the object is a string or a symbol. | 1898 // Check that the object is a string or a symbol. |
1893 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, eax); | 1899 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, eax); |
1894 __ j(above_equal, &miss, not_taken); | 1900 __ j(above_equal, &miss, not_taken); |
1895 // Check that the maps starting from the prototype haven't changed. | 1901 // Check that the maps starting from the prototype haven't changed. |
1896 GenerateDirectLoadGlobalFunctionPrototype( | 1902 GenerateDirectLoadGlobalFunctionPrototype( |
1897 masm(), Context::STRING_FUNCTION_INDEX, eax); | 1903 masm(), Context::STRING_FUNCTION_INDEX, eax, &miss); |
1898 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1904 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1899 ebx, edx, edi, name, &miss); | 1905 ebx, edx, edi, name, &miss); |
1900 } | 1906 } |
1901 break; | 1907 break; |
1902 | 1908 |
1903 case NUMBER_CHECK: { | 1909 case NUMBER_CHECK: { |
1904 if (!function->IsBuiltin()) { | 1910 if (!function->IsBuiltin()) { |
1905 // Calling non-builtins with a value as receiver requires boxing. | 1911 // Calling non-builtins with a value as receiver requires boxing. |
1906 __ jmp(&miss); | 1912 __ jmp(&miss); |
1907 } else { | 1913 } else { |
1908 Label fast; | 1914 Label fast; |
1909 // Check that the object is a smi or a heap number. | 1915 // Check that the object is a smi or a heap number. |
1910 __ test(edx, Immediate(kSmiTagMask)); | 1916 __ test(edx, Immediate(kSmiTagMask)); |
1911 __ j(zero, &fast, taken); | 1917 __ j(zero, &fast, taken); |
1912 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax); | 1918 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax); |
1913 __ j(not_equal, &miss, not_taken); | 1919 __ j(not_equal, &miss, not_taken); |
1914 __ bind(&fast); | 1920 __ bind(&fast); |
1915 // Check that the maps starting from the prototype haven't changed. | 1921 // Check that the maps starting from the prototype haven't changed. |
1916 GenerateDirectLoadGlobalFunctionPrototype( | 1922 GenerateDirectLoadGlobalFunctionPrototype( |
1917 masm(), Context::NUMBER_FUNCTION_INDEX, eax); | 1923 masm(), Context::NUMBER_FUNCTION_INDEX, eax, &miss); |
1918 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1924 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1919 ebx, edx, edi, name, &miss); | 1925 ebx, edx, edi, name, &miss); |
1920 } | 1926 } |
1921 break; | 1927 break; |
1922 } | 1928 } |
1923 | 1929 |
1924 case BOOLEAN_CHECK: { | 1930 case BOOLEAN_CHECK: { |
1925 if (!function->IsBuiltin()) { | 1931 if (!function->IsBuiltin()) { |
1926 // Calling non-builtins with a value as receiver requires boxing. | 1932 // Calling non-builtins with a value as receiver requires boxing. |
1927 __ jmp(&miss); | 1933 __ jmp(&miss); |
1928 } else { | 1934 } else { |
1929 Label fast; | 1935 Label fast; |
1930 // Check that the object is a boolean. | 1936 // Check that the object is a boolean. |
1931 __ cmp(edx, Factory::true_value()); | 1937 __ cmp(edx, Factory::true_value()); |
1932 __ j(equal, &fast, taken); | 1938 __ j(equal, &fast, taken); |
1933 __ cmp(edx, Factory::false_value()); | 1939 __ cmp(edx, Factory::false_value()); |
1934 __ j(not_equal, &miss, not_taken); | 1940 __ j(not_equal, &miss, not_taken); |
1935 __ bind(&fast); | 1941 __ bind(&fast); |
1936 // Check that the maps starting from the prototype haven't changed. | 1942 // Check that the maps starting from the prototype haven't changed. |
1937 GenerateDirectLoadGlobalFunctionPrototype( | 1943 GenerateDirectLoadGlobalFunctionPrototype( |
1938 masm(), Context::BOOLEAN_FUNCTION_INDEX, eax); | 1944 masm(), Context::BOOLEAN_FUNCTION_INDEX, eax, &miss); |
1939 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1945 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1940 ebx, edx, edi, name, &miss); | 1946 ebx, edx, edi, name, &miss); |
1941 } | 1947 } |
1942 break; | 1948 break; |
1943 } | 1949 } |
1944 | 1950 |
1945 default: | 1951 default: |
1946 UNREACHABLE(); | 1952 UNREACHABLE(); |
1947 } | 1953 } |
1948 | 1954 |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2820 // Return the generated code. | 2826 // Return the generated code. |
2821 return GetCode(); | 2827 return GetCode(); |
2822 } | 2828 } |
2823 | 2829 |
2824 | 2830 |
2825 #undef __ | 2831 #undef __ |
2826 | 2832 |
2827 } } // namespace v8::internal | 2833 } } // namespace v8::internal |
2828 | 2834 |
2829 #endif // V8_TARGET_ARCH_IA32 | 2835 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |