| 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 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 Immediate(Handle<SharedFunctionInfo>(function->shared()))); | 1355 Immediate(Handle<SharedFunctionInfo>(function->shared()))); |
| 1356 __ j(not_equal, miss, not_taken); | 1356 __ j(not_equal, miss, not_taken); |
| 1357 } else { | 1357 } else { |
| 1358 __ cmp(Operand(edi), Immediate(Handle<JSFunction>(function))); | 1358 __ cmp(Operand(edi), Immediate(Handle<JSFunction>(function))); |
| 1359 __ j(not_equal, miss, not_taken); | 1359 __ j(not_equal, miss, not_taken); |
| 1360 } | 1360 } |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 | 1363 |
| 1364 MaybeObject* CallStubCompiler::GenerateMissBranch() { | 1364 MaybeObject* CallStubCompiler::GenerateMissBranch() { |
| 1365 MaybeObject* maybe_obj = StubCache::ComputeCallMiss(arguments().immediate(), |
| 1366 kind_); |
| 1365 Object* obj; | 1367 Object* obj; |
| 1366 { MaybeObject* maybe_obj = | 1368 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1367 StubCache::ComputeCallMiss(arguments().immediate(), kind_); | |
| 1368 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
| 1369 } | |
| 1370 __ jmp(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); | 1369 __ jmp(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); |
| 1371 return obj; | 1370 return obj; |
| 1372 } | 1371 } |
| 1373 | 1372 |
| 1374 | 1373 |
| 1375 MUST_USE_RESULT MaybeObject* CallStubCompiler::CompileCallField( | 1374 MUST_USE_RESULT MaybeObject* CallStubCompiler::CompileCallField( |
| 1376 JSObject* object, | 1375 JSObject* object, |
| 1377 JSObject* holder, | 1376 JSObject* holder, |
| 1378 int index, | 1377 int index, |
| 1379 String* name) { | 1378 String* name) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 // -- ... | 1677 // -- ... |
| 1679 // -- esp[(argc + 1) * 4] : receiver | 1678 // -- esp[(argc + 1) * 4] : receiver |
| 1680 // ----------------------------------- | 1679 // ----------------------------------- |
| 1681 | 1680 |
| 1682 // If object is not a string, bail out to regular call. | 1681 // If object is not a string, bail out to regular call. |
| 1683 if (!object->IsString() || cell != NULL) return Heap::undefined_value(); | 1682 if (!object->IsString() || cell != NULL) return Heap::undefined_value(); |
| 1684 | 1683 |
| 1685 const int argc = arguments().immediate(); | 1684 const int argc = arguments().immediate(); |
| 1686 | 1685 |
| 1687 Label miss; | 1686 Label miss; |
| 1687 Label name_miss; |
| 1688 Label index_out_of_range; | 1688 Label index_out_of_range; |
| 1689 Label* index_out_of_range_label = &index_out_of_range; |
| 1689 | 1690 |
| 1690 GenerateNameCheck(name, &miss); | 1691 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) { |
| 1692 index_out_of_range_label = &miss; |
| 1693 } |
| 1694 |
| 1695 GenerateNameCheck(name, &name_miss); |
| 1691 | 1696 |
| 1692 // Check that the maps starting from the prototype haven't changed. | 1697 // Check that the maps starting from the prototype haven't changed. |
| 1693 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1698 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
| 1694 Context::STRING_FUNCTION_INDEX, | 1699 Context::STRING_FUNCTION_INDEX, |
| 1695 eax, | 1700 eax, |
| 1696 &miss); | 1701 &miss); |
| 1697 ASSERT(object != holder); | 1702 ASSERT(object != holder); |
| 1698 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1703 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
| 1699 ebx, edx, edi, name, &miss); | 1704 ebx, edx, edi, name, &miss); |
| 1700 | 1705 |
| 1701 Register receiver = ebx; | 1706 Register receiver = ebx; |
| 1702 Register index = edi; | 1707 Register index = edi; |
| 1703 Register scratch = edx; | 1708 Register scratch = edx; |
| 1704 Register result = eax; | 1709 Register result = eax; |
| 1705 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1710 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
| 1706 if (argc > 0) { | 1711 if (argc > 0) { |
| 1707 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); | 1712 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); |
| 1708 } else { | 1713 } else { |
| 1709 __ Set(index, Immediate(Factory::undefined_value())); | 1714 __ Set(index, Immediate(Factory::undefined_value())); |
| 1710 } | 1715 } |
| 1711 | 1716 |
| 1712 StringCharCodeAtGenerator char_code_at_generator(receiver, | 1717 StringCharCodeAtGenerator char_code_at_generator(receiver, |
| 1713 index, | 1718 index, |
| 1714 scratch, | 1719 scratch, |
| 1715 result, | 1720 result, |
| 1716 &miss, // When not a string. | 1721 &miss, // When not a string. |
| 1717 &miss, // When not a number. | 1722 &miss, // When not a number. |
| 1718 &index_out_of_range, | 1723 index_out_of_range_label, |
| 1719 STRING_INDEX_IS_NUMBER); | 1724 STRING_INDEX_IS_NUMBER); |
| 1720 char_code_at_generator.GenerateFast(masm()); | 1725 char_code_at_generator.GenerateFast(masm()); |
| 1721 __ ret((argc + 1) * kPointerSize); | 1726 __ ret((argc + 1) * kPointerSize); |
| 1722 | 1727 |
| 1723 StubRuntimeCallHelper call_helper; | 1728 StubRuntimeCallHelper call_helper; |
| 1724 char_code_at_generator.GenerateSlow(masm(), call_helper); | 1729 char_code_at_generator.GenerateSlow(masm(), call_helper); |
| 1725 | 1730 |
| 1726 __ bind(&index_out_of_range); | 1731 if (index_out_of_range.is_linked()) { |
| 1727 __ Set(eax, Immediate(Factory::nan_value())); | 1732 __ bind(&index_out_of_range); |
| 1728 __ ret((argc + 1) * kPointerSize); | 1733 __ Set(eax, Immediate(Factory::nan_value())); |
| 1734 __ ret((argc + 1) * kPointerSize); |
| 1735 } |
| 1729 | 1736 |
| 1730 __ bind(&miss); | 1737 __ bind(&miss); |
| 1738 // Restore function name in ecx. |
| 1739 __ Set(ecx, Immediate(Handle<String>(name))); |
| 1740 __ bind(&name_miss); |
| 1731 Object* obj; | 1741 Object* obj; |
| 1732 { MaybeObject* maybe_obj = GenerateMissBranch(); | 1742 { MaybeObject* maybe_obj = GenerateMissBranch(); |
| 1733 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1743 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1734 } | 1744 } |
| 1735 | 1745 |
| 1736 // Return the generated code. | 1746 // Return the generated code. |
| 1737 return GetCode(function); | 1747 return GetCode(function); |
| 1738 } | 1748 } |
| 1739 | 1749 |
| 1740 | 1750 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1751 // -- ... | 1761 // -- ... |
| 1752 // -- esp[(argc + 1) * 4] : receiver | 1762 // -- esp[(argc + 1) * 4] : receiver |
| 1753 // ----------------------------------- | 1763 // ----------------------------------- |
| 1754 | 1764 |
| 1755 // If object is not a string, bail out to regular call. | 1765 // If object is not a string, bail out to regular call. |
| 1756 if (!object->IsString() || cell != NULL) return Heap::undefined_value(); | 1766 if (!object->IsString() || cell != NULL) return Heap::undefined_value(); |
| 1757 | 1767 |
| 1758 const int argc = arguments().immediate(); | 1768 const int argc = arguments().immediate(); |
| 1759 | 1769 |
| 1760 Label miss; | 1770 Label miss; |
| 1771 Label name_miss; |
| 1761 Label index_out_of_range; | 1772 Label index_out_of_range; |
| 1773 Label* index_out_of_range_label = &index_out_of_range; |
| 1762 | 1774 |
| 1763 GenerateNameCheck(name, &miss); | 1775 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) { |
| 1776 index_out_of_range_label = &miss; |
| 1777 } |
| 1778 |
| 1779 GenerateNameCheck(name, &name_miss); |
| 1764 | 1780 |
| 1765 // Check that the maps starting from the prototype haven't changed. | 1781 // Check that the maps starting from the prototype haven't changed. |
| 1766 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1782 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
| 1767 Context::STRING_FUNCTION_INDEX, | 1783 Context::STRING_FUNCTION_INDEX, |
| 1768 eax, | 1784 eax, |
| 1769 &miss); | 1785 &miss); |
| 1770 ASSERT(object != holder); | 1786 ASSERT(object != holder); |
| 1771 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1787 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
| 1772 ebx, edx, edi, name, &miss); | 1788 ebx, edx, edi, name, &miss); |
| 1773 | 1789 |
| 1774 Register receiver = eax; | 1790 Register receiver = eax; |
| 1775 Register index = edi; | 1791 Register index = edi; |
| 1776 Register scratch1 = ebx; | 1792 Register scratch1 = ebx; |
| 1777 Register scratch2 = edx; | 1793 Register scratch2 = edx; |
| 1778 Register result = eax; | 1794 Register result = eax; |
| 1779 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1795 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
| 1780 if (argc > 0) { | 1796 if (argc > 0) { |
| 1781 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); | 1797 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); |
| 1782 } else { | 1798 } else { |
| 1783 __ Set(index, Immediate(Factory::undefined_value())); | 1799 __ Set(index, Immediate(Factory::undefined_value())); |
| 1784 } | 1800 } |
| 1785 | 1801 |
| 1786 StringCharAtGenerator char_at_generator(receiver, | 1802 StringCharAtGenerator char_at_generator(receiver, |
| 1787 index, | 1803 index, |
| 1788 scratch1, | 1804 scratch1, |
| 1789 scratch2, | 1805 scratch2, |
| 1790 result, | 1806 result, |
| 1791 &miss, // When not a string. | 1807 &miss, // When not a string. |
| 1792 &miss, // When not a number. | 1808 &miss, // When not a number. |
| 1793 &index_out_of_range, | 1809 index_out_of_range_label, |
| 1794 STRING_INDEX_IS_NUMBER); | 1810 STRING_INDEX_IS_NUMBER); |
| 1795 char_at_generator.GenerateFast(masm()); | 1811 char_at_generator.GenerateFast(masm()); |
| 1796 __ ret((argc + 1) * kPointerSize); | 1812 __ ret((argc + 1) * kPointerSize); |
| 1797 | 1813 |
| 1798 StubRuntimeCallHelper call_helper; | 1814 StubRuntimeCallHelper call_helper; |
| 1799 char_at_generator.GenerateSlow(masm(), call_helper); | 1815 char_at_generator.GenerateSlow(masm(), call_helper); |
| 1800 | 1816 |
| 1801 __ bind(&index_out_of_range); | 1817 if (index_out_of_range.is_linked()) { |
| 1802 __ Set(eax, Immediate(Factory::empty_string())); | 1818 __ bind(&index_out_of_range); |
| 1803 __ ret((argc + 1) * kPointerSize); | 1819 __ Set(eax, Immediate(Factory::empty_string())); |
| 1820 __ ret((argc + 1) * kPointerSize); |
| 1821 } |
| 1804 | 1822 |
| 1805 __ bind(&miss); | 1823 __ bind(&miss); |
| 1824 // Restore function name in ecx. |
| 1825 __ Set(ecx, Immediate(Handle<String>(name))); |
| 1826 __ bind(&name_miss); |
| 1806 Object* obj; | 1827 Object* obj; |
| 1807 { MaybeObject* maybe_obj = GenerateMissBranch(); | 1828 { MaybeObject* maybe_obj = GenerateMissBranch(); |
| 1808 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1829 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 1809 } | 1830 } |
| 1810 | 1831 |
| 1811 // Return the generated code. | 1832 // Return the generated code. |
| 1812 return GetCode(function); | 1833 return GetCode(function); |
| 1813 } | 1834 } |
| 1814 | 1835 |
| 1815 | 1836 |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3283 // Return the generated code. | 3304 // Return the generated code. |
| 3284 return GetCode(); | 3305 return GetCode(); |
| 3285 } | 3306 } |
| 3286 | 3307 |
| 3287 | 3308 |
| 3288 #undef __ | 3309 #undef __ |
| 3289 | 3310 |
| 3290 } } // namespace v8::internal | 3311 } } // namespace v8::internal |
| 3291 | 3312 |
| 3292 #endif // V8_TARGET_ARCH_IA32 | 3313 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |