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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 __ mov(prototype, Operand(prototype, Context::SlotOffset(index))); | 266 __ mov(prototype, Operand(prototype, Context::SlotOffset(index))); |
267 // Load the initial map. The global functions all have initial maps. | 267 // Load the initial map. The global functions all have initial maps. |
268 __ mov(prototype, | 268 __ mov(prototype, |
269 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | 269 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
270 // Load the prototype from the initial map. | 270 // Load the prototype from the initial map. |
271 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 271 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
272 } | 272 } |
273 | 273 |
274 | 274 |
275 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( | 275 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
276 MacroAssembler* masm, int index, Register prototype) { | 276 MacroAssembler* masm, int index, Register prototype, Label* miss) { |
| 277 // Check we're still in the same context. |
| 278 __ cmp(Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)), |
| 279 Top::global()); |
| 280 __ j(not_equal, miss); |
277 // Get the global function with the given index. | 281 // Get the global function with the given index. |
278 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); | 282 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); |
279 // Load its initial map. The global functions all have initial maps. | 283 // Load its initial map. The global functions all have initial maps. |
280 __ Set(prototype, Immediate(Handle<Map>(function->initial_map()))); | 284 __ Set(prototype, Immediate(Handle<Map>(function->initial_map()))); |
281 // Load the prototype from the initial map. | 285 // Load the prototype from the initial map. |
282 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 286 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
283 } | 287 } |
284 | 288 |
285 | 289 |
286 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, | 290 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 | 1597 |
1594 const int argc = arguments().immediate(); | 1598 const int argc = arguments().immediate(); |
1595 | 1599 |
1596 Label miss; | 1600 Label miss; |
1597 Label index_out_of_range; | 1601 Label index_out_of_range; |
1598 GenerateNameCheck(name, &miss); | 1602 GenerateNameCheck(name, &miss); |
1599 | 1603 |
1600 // Check that the maps starting from the prototype haven't changed. | 1604 // Check that the maps starting from the prototype haven't changed. |
1601 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1605 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1602 Context::STRING_FUNCTION_INDEX, | 1606 Context::STRING_FUNCTION_INDEX, |
1603 eax); | 1607 eax, |
| 1608 &miss); |
1604 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1609 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1605 ebx, edx, edi, name, &miss); | 1610 ebx, edx, edi, name, &miss); |
1606 | 1611 |
1607 Register receiver = ebx; | 1612 Register receiver = ebx; |
1608 Register index = edi; | 1613 Register index = edi; |
1609 Register scratch = edx; | 1614 Register scratch = edx; |
1610 Register result = eax; | 1615 Register result = eax; |
1611 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1616 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
1612 if (argc > 0) { | 1617 if (argc > 0) { |
1613 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); | 1618 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 const int argc = arguments().immediate(); | 1663 const int argc = arguments().immediate(); |
1659 | 1664 |
1660 Label miss; | 1665 Label miss; |
1661 Label index_out_of_range; | 1666 Label index_out_of_range; |
1662 | 1667 |
1663 GenerateNameCheck(name, &miss); | 1668 GenerateNameCheck(name, &miss); |
1664 | 1669 |
1665 // Check that the maps starting from the prototype haven't changed. | 1670 // Check that the maps starting from the prototype haven't changed. |
1666 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1671 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1667 Context::STRING_FUNCTION_INDEX, | 1672 Context::STRING_FUNCTION_INDEX, |
1668 eax); | 1673 eax, |
| 1674 &miss); |
1669 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1675 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1670 ebx, edx, edi, name, &miss); | 1676 ebx, edx, edi, name, &miss); |
1671 | 1677 |
1672 Register receiver = eax; | 1678 Register receiver = eax; |
1673 Register index = edi; | 1679 Register index = edi; |
1674 Register scratch1 = ebx; | 1680 Register scratch1 = ebx; |
1675 Register scratch2 = edx; | 1681 Register scratch2 = edx; |
1676 Register result = eax; | 1682 Register result = eax; |
1677 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1683 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
1678 if (argc > 0) { | 1684 if (argc > 0) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 case STRING_CHECK: | 1792 case STRING_CHECK: |
1787 if (!function->IsBuiltin()) { | 1793 if (!function->IsBuiltin()) { |
1788 // Calling non-builtins with a value as receiver requires boxing. | 1794 // Calling non-builtins with a value as receiver requires boxing. |
1789 __ jmp(&miss); | 1795 __ jmp(&miss); |
1790 } else { | 1796 } else { |
1791 // Check that the object is a string or a symbol. | 1797 // Check that the object is a string or a symbol. |
1792 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, eax); | 1798 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, eax); |
1793 __ j(above_equal, &miss, not_taken); | 1799 __ j(above_equal, &miss, not_taken); |
1794 // Check that the maps starting from the prototype haven't changed. | 1800 // Check that the maps starting from the prototype haven't changed. |
1795 GenerateDirectLoadGlobalFunctionPrototype( | 1801 GenerateDirectLoadGlobalFunctionPrototype( |
1796 masm(), Context::STRING_FUNCTION_INDEX, eax); | 1802 masm(), Context::STRING_FUNCTION_INDEX, eax, &miss); |
1797 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1803 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1798 ebx, edx, edi, name, &miss); | 1804 ebx, edx, edi, name, &miss); |
1799 } | 1805 } |
1800 break; | 1806 break; |
1801 | 1807 |
1802 case NUMBER_CHECK: { | 1808 case NUMBER_CHECK: { |
1803 if (!function->IsBuiltin()) { | 1809 if (!function->IsBuiltin()) { |
1804 // Calling non-builtins with a value as receiver requires boxing. | 1810 // Calling non-builtins with a value as receiver requires boxing. |
1805 __ jmp(&miss); | 1811 __ jmp(&miss); |
1806 } else { | 1812 } else { |
1807 Label fast; | 1813 Label fast; |
1808 // Check that the object is a smi or a heap number. | 1814 // Check that the object is a smi or a heap number. |
1809 __ test(edx, Immediate(kSmiTagMask)); | 1815 __ test(edx, Immediate(kSmiTagMask)); |
1810 __ j(zero, &fast, taken); | 1816 __ j(zero, &fast, taken); |
1811 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax); | 1817 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax); |
1812 __ j(not_equal, &miss, not_taken); | 1818 __ j(not_equal, &miss, not_taken); |
1813 __ bind(&fast); | 1819 __ bind(&fast); |
1814 // Check that the maps starting from the prototype haven't changed. | 1820 // Check that the maps starting from the prototype haven't changed. |
1815 GenerateDirectLoadGlobalFunctionPrototype( | 1821 GenerateDirectLoadGlobalFunctionPrototype( |
1816 masm(), Context::NUMBER_FUNCTION_INDEX, eax); | 1822 masm(), Context::NUMBER_FUNCTION_INDEX, eax, &miss); |
1817 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1823 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1818 ebx, edx, edi, name, &miss); | 1824 ebx, edx, edi, name, &miss); |
1819 } | 1825 } |
1820 break; | 1826 break; |
1821 } | 1827 } |
1822 | 1828 |
1823 case BOOLEAN_CHECK: { | 1829 case BOOLEAN_CHECK: { |
1824 if (!function->IsBuiltin()) { | 1830 if (!function->IsBuiltin()) { |
1825 // Calling non-builtins with a value as receiver requires boxing. | 1831 // Calling non-builtins with a value as receiver requires boxing. |
1826 __ jmp(&miss); | 1832 __ jmp(&miss); |
1827 } else { | 1833 } else { |
1828 Label fast; | 1834 Label fast; |
1829 // Check that the object is a boolean. | 1835 // Check that the object is a boolean. |
1830 __ cmp(edx, Factory::true_value()); | 1836 __ cmp(edx, Factory::true_value()); |
1831 __ j(equal, &fast, taken); | 1837 __ j(equal, &fast, taken); |
1832 __ cmp(edx, Factory::false_value()); | 1838 __ cmp(edx, Factory::false_value()); |
1833 __ j(not_equal, &miss, not_taken); | 1839 __ j(not_equal, &miss, not_taken); |
1834 __ bind(&fast); | 1840 __ bind(&fast); |
1835 // Check that the maps starting from the prototype haven't changed. | 1841 // Check that the maps starting from the prototype haven't changed. |
1836 GenerateDirectLoadGlobalFunctionPrototype( | 1842 GenerateDirectLoadGlobalFunctionPrototype( |
1837 masm(), Context::BOOLEAN_FUNCTION_INDEX, eax); | 1843 masm(), Context::BOOLEAN_FUNCTION_INDEX, eax, &miss); |
1838 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1844 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1839 ebx, edx, edi, name, &miss); | 1845 ebx, edx, edi, name, &miss); |
1840 } | 1846 } |
1841 break; | 1847 break; |
1842 } | 1848 } |
1843 | 1849 |
1844 default: | 1850 default: |
1845 UNREACHABLE(); | 1851 UNREACHABLE(); |
1846 } | 1852 } |
1847 | 1853 |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 // Return the generated code. | 2747 // Return the generated code. |
2742 return GetCode(); | 2748 return GetCode(); |
2743 } | 2749 } |
2744 | 2750 |
2745 | 2751 |
2746 #undef __ | 2752 #undef __ |
2747 | 2753 |
2748 } } // namespace v8::internal | 2754 } } // namespace v8::internal |
2749 | 2755 |
2750 #endif // V8_TARGET_ARCH_IA32 | 2756 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |