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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
1688 Label index_out_of_range; | 1687 Label index_out_of_range; |
| 1688 Label* index_out_of_range_label = &index_out_of_range; |
| 1689 |
| 1690 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) { |
| 1691 index_out_of_range_label = &miss; |
| 1692 } |
1689 | 1693 |
1690 GenerateNameCheck(name, &miss); | 1694 GenerateNameCheck(name, &miss); |
1691 | 1695 |
1692 // Check that the maps starting from the prototype haven't changed. | 1696 // Check that the maps starting from the prototype haven't changed. |
1693 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1697 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1694 Context::STRING_FUNCTION_INDEX, | 1698 Context::STRING_FUNCTION_INDEX, |
1695 eax, | 1699 eax, |
1696 &miss); | 1700 &miss); |
1697 ASSERT(object != holder); | 1701 ASSERT(object != holder); |
1698 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1702 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1699 ebx, edx, edi, name, &miss); | 1703 ebx, edx, edi, name, &miss); |
1700 | 1704 |
1701 Register receiver = ebx; | 1705 Register receiver = ebx; |
1702 Register index = edi; | 1706 Register index = edi; |
1703 Register scratch = edx; | 1707 Register scratch = edx; |
1704 Register result = eax; | 1708 Register result = eax; |
1705 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1709 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
1706 if (argc > 0) { | 1710 if (argc > 0) { |
1707 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); | 1711 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); |
1708 } else { | 1712 } else { |
1709 __ Set(index, Immediate(Factory::undefined_value())); | 1713 __ Set(index, Immediate(Factory::undefined_value())); |
1710 } | 1714 } |
1711 | 1715 |
1712 StringCharCodeAtGenerator char_code_at_generator(receiver, | 1716 StringCharCodeAtGenerator char_code_at_generator(receiver, |
1713 index, | 1717 index, |
1714 scratch, | 1718 scratch, |
1715 result, | 1719 result, |
1716 &miss, // When not a string. | 1720 &miss, // When not a string. |
1717 &miss, // When not a number. | 1721 &miss, // When not a number. |
1718 &index_out_of_range, | 1722 index_out_of_range_label, |
1719 STRING_INDEX_IS_NUMBER); | 1723 STRING_INDEX_IS_NUMBER); |
1720 char_code_at_generator.GenerateFast(masm()); | 1724 char_code_at_generator.GenerateFast(masm()); |
1721 __ ret((argc + 1) * kPointerSize); | 1725 __ ret((argc + 1) * kPointerSize); |
1722 | 1726 |
1723 StubRuntimeCallHelper call_helper; | 1727 StubRuntimeCallHelper call_helper; |
1724 char_code_at_generator.GenerateSlow(masm(), call_helper); | 1728 char_code_at_generator.GenerateSlow(masm(), call_helper); |
1725 | 1729 |
1726 __ bind(&index_out_of_range); | 1730 if (index_out_of_range.is_linked()) { |
1727 __ Set(eax, Immediate(Factory::nan_value())); | 1731 __ bind(&index_out_of_range); |
1728 __ ret((argc + 1) * kPointerSize); | 1732 __ Set(eax, Immediate(Factory::nan_value())); |
| 1733 __ ret((argc + 1) * kPointerSize); |
| 1734 } |
1729 | 1735 |
1730 __ bind(&miss); | 1736 __ bind(&miss); |
| 1737 if (kind_ == Code::CALL_IC) { |
| 1738 // Restore function name in ecx. |
| 1739 __ Set(ecx, Immediate(Handle<String>(name))); |
| 1740 } |
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 11 matching lines...) Expand all Loading... |
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; |
1761 Label index_out_of_range; | 1771 Label index_out_of_range; |
| 1772 Label* index_out_of_range_label = &index_out_of_range; |
| 1773 |
| 1774 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) { |
| 1775 index_out_of_range_label = &miss; |
| 1776 } |
1762 | 1777 |
1763 GenerateNameCheck(name, &miss); | 1778 GenerateNameCheck(name, &miss); |
1764 | 1779 |
1765 // Check that the maps starting from the prototype haven't changed. | 1780 // Check that the maps starting from the prototype haven't changed. |
1766 GenerateDirectLoadGlobalFunctionPrototype(masm(), | 1781 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1767 Context::STRING_FUNCTION_INDEX, | 1782 Context::STRING_FUNCTION_INDEX, |
1768 eax, | 1783 eax, |
1769 &miss); | 1784 &miss); |
1770 ASSERT(object != holder); | 1785 ASSERT(object != holder); |
1771 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1786 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
(...skipping 11 matching lines...) Expand all Loading... |
1783 __ Set(index, Immediate(Factory::undefined_value())); | 1798 __ Set(index, Immediate(Factory::undefined_value())); |
1784 } | 1799 } |
1785 | 1800 |
1786 StringCharAtGenerator char_at_generator(receiver, | 1801 StringCharAtGenerator char_at_generator(receiver, |
1787 index, | 1802 index, |
1788 scratch1, | 1803 scratch1, |
1789 scratch2, | 1804 scratch2, |
1790 result, | 1805 result, |
1791 &miss, // When not a string. | 1806 &miss, // When not a string. |
1792 &miss, // When not a number. | 1807 &miss, // When not a number. |
1793 &index_out_of_range, | 1808 index_out_of_range_label, |
1794 STRING_INDEX_IS_NUMBER); | 1809 STRING_INDEX_IS_NUMBER); |
1795 char_at_generator.GenerateFast(masm()); | 1810 char_at_generator.GenerateFast(masm()); |
1796 __ ret((argc + 1) * kPointerSize); | 1811 __ ret((argc + 1) * kPointerSize); |
1797 | 1812 |
1798 StubRuntimeCallHelper call_helper; | 1813 StubRuntimeCallHelper call_helper; |
1799 char_at_generator.GenerateSlow(masm(), call_helper); | 1814 char_at_generator.GenerateSlow(masm(), call_helper); |
1800 | 1815 |
1801 __ bind(&index_out_of_range); | 1816 if (index_out_of_range.is_linked()) { |
1802 __ Set(eax, Immediate(Factory::empty_string())); | 1817 __ bind(&index_out_of_range); |
1803 __ ret((argc + 1) * kPointerSize); | 1818 __ Set(eax, Immediate(Factory::empty_string())); |
| 1819 __ ret((argc + 1) * kPointerSize); |
| 1820 } |
1804 | 1821 |
1805 __ bind(&miss); | 1822 __ bind(&miss); |
| 1823 if (kind_ == Code::CALL_IC) { |
| 1824 // Restore function name in ecx. |
| 1825 __ Set(ecx, Immediate(Handle<String>(name))); |
| 1826 } |
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 |