OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 | 1770 |
1771 enum ReceiverCheckMode { | 1771 enum ReceiverCheckMode { |
1772 // We don't know anything about the receiver. | 1772 // We don't know anything about the receiver. |
1773 RECEIVER_IS_UNKNOWN, | 1773 RECEIVER_IS_UNKNOWN, |
1774 | 1774 |
1775 // We know the receiver is a string. | 1775 // We know the receiver is a string. |
1776 RECEIVER_IS_STRING | 1776 RECEIVER_IS_STRING |
1777 }; | 1777 }; |
1778 | 1778 |
1779 | 1779 |
| 1780 enum EmbedMode { |
| 1781 // The code being generated is part of an IC handler, which may MISS |
| 1782 // to an IC in failure cases. |
| 1783 PART_OF_IC_HANDLER, |
| 1784 |
| 1785 NOT_PART_OF_IC_HANDLER |
| 1786 }; |
| 1787 |
| 1788 |
1780 // Generates code implementing String.prototype.charCodeAt. | 1789 // Generates code implementing String.prototype.charCodeAt. |
1781 // | 1790 // |
1782 // Only supports the case when the receiver is a string and the index | 1791 // Only supports the case when the receiver is a string and the index |
1783 // is a number (smi or heap number) that is a valid index into the | 1792 // is a number (smi or heap number) that is a valid index into the |
1784 // string. Additional index constraints are specified by the | 1793 // string. Additional index constraints are specified by the |
1785 // flags. Otherwise, bails out to the provided labels. | 1794 // flags. Otherwise, bails out to the provided labels. |
1786 // | 1795 // |
1787 // Register usage: |object| may be changed to another string in a way | 1796 // Register usage: |object| may be changed to another string in a way |
1788 // that doesn't affect charCodeAt/charAt semantics, |index| is | 1797 // that doesn't affect charCodeAt/charAt semantics, |index| is |
1789 // preserved, |scratch| and |result| are clobbered. | 1798 // preserved, |scratch| and |result| are clobbered. |
(...skipping 16 matching lines...) Expand all Loading... |
1806 DCHECK(!result_.is(index_)); | 1815 DCHECK(!result_.is(index_)); |
1807 } | 1816 } |
1808 | 1817 |
1809 // Generates the fast case code. On the fallthrough path |result| | 1818 // Generates the fast case code. On the fallthrough path |result| |
1810 // register contains the result. | 1819 // register contains the result. |
1811 void GenerateFast(MacroAssembler* masm); | 1820 void GenerateFast(MacroAssembler* masm); |
1812 | 1821 |
1813 // Generates the slow case code. Must not be naturally | 1822 // Generates the slow case code. Must not be naturally |
1814 // reachable. Expected to be put after a ret instruction (e.g., in | 1823 // reachable. Expected to be put after a ret instruction (e.g., in |
1815 // deferred code). Always jumps back to the fast case. | 1824 // deferred code). Always jumps back to the fast case. |
1816 void GenerateSlow(MacroAssembler* masm, | 1825 void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, |
1817 const RuntimeCallHelper& call_helper); | 1826 const RuntimeCallHelper& call_helper); |
1818 | 1827 |
1819 // Skip handling slow case and directly jump to bailout. | 1828 // Skip handling slow case and directly jump to bailout. |
1820 void SkipSlow(MacroAssembler* masm, Label* bailout) { | 1829 void SkipSlow(MacroAssembler* masm, Label* bailout) { |
1821 masm->bind(&index_not_smi_); | 1830 masm->bind(&index_not_smi_); |
1822 masm->bind(&call_runtime_); | 1831 masm->bind(&call_runtime_); |
1823 masm->jmp(bailout); | 1832 masm->jmp(bailout); |
1824 } | 1833 } |
1825 | 1834 |
1826 private: | 1835 private: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 // Generates the fast case code. On the fallthrough path |result| | 1915 // Generates the fast case code. On the fallthrough path |result| |
1907 // register contains the result. | 1916 // register contains the result. |
1908 void GenerateFast(MacroAssembler* masm) { | 1917 void GenerateFast(MacroAssembler* masm) { |
1909 char_code_at_generator_.GenerateFast(masm); | 1918 char_code_at_generator_.GenerateFast(masm); |
1910 char_from_code_generator_.GenerateFast(masm); | 1919 char_from_code_generator_.GenerateFast(masm); |
1911 } | 1920 } |
1912 | 1921 |
1913 // Generates the slow case code. Must not be naturally | 1922 // Generates the slow case code. Must not be naturally |
1914 // reachable. Expected to be put after a ret instruction (e.g., in | 1923 // reachable. Expected to be put after a ret instruction (e.g., in |
1915 // deferred code). Always jumps back to the fast case. | 1924 // deferred code). Always jumps back to the fast case. |
1916 void GenerateSlow(MacroAssembler* masm, | 1925 void GenerateSlow(MacroAssembler* masm, EmbedMode embed_mode, |
1917 const RuntimeCallHelper& call_helper) { | 1926 const RuntimeCallHelper& call_helper) { |
1918 char_code_at_generator_.GenerateSlow(masm, call_helper); | 1927 char_code_at_generator_.GenerateSlow(masm, embed_mode, call_helper); |
1919 char_from_code_generator_.GenerateSlow(masm, call_helper); | 1928 char_from_code_generator_.GenerateSlow(masm, call_helper); |
1920 } | 1929 } |
1921 | 1930 |
1922 // Skip handling slow case and directly jump to bailout. | 1931 // Skip handling slow case and directly jump to bailout. |
1923 void SkipSlow(MacroAssembler* masm, Label* bailout) { | 1932 void SkipSlow(MacroAssembler* masm, Label* bailout) { |
1924 char_code_at_generator_.SkipSlow(masm, bailout); | 1933 char_code_at_generator_.SkipSlow(masm, bailout); |
1925 char_from_code_generator_.SkipSlow(masm, bailout); | 1934 char_from_code_generator_.SkipSlow(masm, bailout); |
1926 } | 1935 } |
1927 | 1936 |
1928 private: | 1937 private: |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 | 2752 |
2744 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR | 2753 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR |
2745 #undef DEFINE_PLATFORM_CODE_STUB | 2754 #undef DEFINE_PLATFORM_CODE_STUB |
2746 #undef DEFINE_HANDLER_CODE_STUB | 2755 #undef DEFINE_HANDLER_CODE_STUB |
2747 #undef DEFINE_HYDROGEN_CODE_STUB | 2756 #undef DEFINE_HYDROGEN_CODE_STUB |
2748 #undef DEFINE_CODE_STUB | 2757 #undef DEFINE_CODE_STUB |
2749 #undef DEFINE_CODE_STUB_BASE | 2758 #undef DEFINE_CODE_STUB_BASE |
2750 } } // namespace v8::internal | 2759 } } // namespace v8::internal |
2751 | 2760 |
2752 #endif // V8_CODE_STUBS_H_ | 2761 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |