Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/code-stubs.h

Issue 602773003: Eliminate special keyed load string stub in favor of uniform handlers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and ports. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/builtins.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 V(CEntry) \ 32 V(CEntry) \
33 V(CompareIC) \ 33 V(CompareIC) \
34 V(DoubleToI) \ 34 V(DoubleToI) \
35 V(FunctionPrototype) \ 35 V(FunctionPrototype) \
36 V(Instanceof) \ 36 V(Instanceof) \
37 V(InternalArrayConstructor) \ 37 V(InternalArrayConstructor) \
38 V(JSEntry) \ 38 V(JSEntry) \
39 V(KeyedLoadICTrampoline) \ 39 V(KeyedLoadICTrampoline) \
40 V(LoadICTrampoline) \ 40 V(LoadICTrampoline) \
41 V(LoadIndexedInterceptor) \ 41 V(LoadIndexedInterceptor) \
42 V(LoadIndexedString) \
42 V(MathPow) \ 43 V(MathPow) \
43 V(ProfileEntryHook) \ 44 V(ProfileEntryHook) \
44 V(RecordWrite) \ 45 V(RecordWrite) \
45 V(RegExpExec) \ 46 V(RegExpExec) \
46 V(StoreArrayLiteralElement) \ 47 V(StoreArrayLiteralElement) \
47 V(StoreBufferOverflow) \ 48 V(StoreBufferOverflow) \
48 V(StoreElement) \ 49 V(StoreElement) \
49 V(StringCompare) \ 50 V(StringCompare) \
50 V(StubFailureTrampoline) \ 51 V(StubFailureTrampoline) \
51 V(SubString) \ 52 V(SubString) \
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 : PlatformCodeStub(isolate) {} 870 : PlatformCodeStub(isolate) {}
870 871
871 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } 872 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
872 virtual Code::StubType GetStubType() { return Code::FAST; } 873 virtual Code::StubType GetStubType() { return Code::FAST; }
873 874
874 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load); 875 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
875 DEFINE_PLATFORM_CODE_STUB(LoadIndexedInterceptor, PlatformCodeStub); 876 DEFINE_PLATFORM_CODE_STUB(LoadIndexedInterceptor, PlatformCodeStub);
876 }; 877 };
877 878
878 879
880 class LoadIndexedStringStub : public PlatformCodeStub {
881 public:
882 explicit LoadIndexedStringStub(Isolate* isolate)
883 : PlatformCodeStub(isolate) {}
884
885 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
886 virtual Code::StubType GetStubType() { return Code::FAST; }
887
888 DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
889 DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub);
890 };
891
892
879 class HandlerStub : public HydrogenCodeStub { 893 class HandlerStub : public HydrogenCodeStub {
880 public: 894 public:
881 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } 895 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
882 virtual ExtraICState GetExtraICState() const { return kind(); } 896 virtual ExtraICState GetExtraICState() const { return kind(); }
883 virtual InlineCacheState GetICState() const { return MONOMORPHIC; } 897 virtual InlineCacheState GetICState() const { return MONOMORPHIC; }
884 898
885 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) OVERRIDE; 899 virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) OVERRIDE;
886 900
887 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE; 901 virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE;
888 902
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // Accepts smis or heap numbers. 1658 // Accepts smis or heap numbers.
1645 STRING_INDEX_IS_NUMBER, 1659 STRING_INDEX_IS_NUMBER,
1646 1660
1647 // Accepts smis or heap numbers that are valid array indices 1661 // Accepts smis or heap numbers that are valid array indices
1648 // (ECMA-262 15.4). Invalid indices are reported as being out of 1662 // (ECMA-262 15.4). Invalid indices are reported as being out of
1649 // range. 1663 // range.
1650 STRING_INDEX_IS_ARRAY_INDEX 1664 STRING_INDEX_IS_ARRAY_INDEX
1651 }; 1665 };
1652 1666
1653 1667
1668 enum ReceiverCheckMode {
1669 // We don't know anything about the receiver.
1670 RECEIVER_IS_UNKNOWN,
1671
1672 // We know the receiver is a string.
1673 RECEIVER_IS_STRING
1674 };
1675
1676
1654 // Generates code implementing String.prototype.charCodeAt. 1677 // Generates code implementing String.prototype.charCodeAt.
1655 // 1678 //
1656 // Only supports the case when the receiver is a string and the index 1679 // Only supports the case when the receiver is a string and the index
1657 // is a number (smi or heap number) that is a valid index into the 1680 // is a number (smi or heap number) that is a valid index into the
1658 // string. Additional index constraints are specified by the 1681 // string. Additional index constraints are specified by the
1659 // flags. Otherwise, bails out to the provided labels. 1682 // flags. Otherwise, bails out to the provided labels.
1660 // 1683 //
1661 // Register usage: |object| may be changed to another string in a way 1684 // Register usage: |object| may be changed to another string in a way
1662 // that doesn't affect charCodeAt/charAt semantics, |index| is 1685 // that doesn't affect charCodeAt/charAt semantics, |index| is
1663 // preserved, |scratch| and |result| are clobbered. 1686 // preserved, |scratch| and |result| are clobbered.
1664 class StringCharCodeAtGenerator { 1687 class StringCharCodeAtGenerator {
1665 public: 1688 public:
1666 StringCharCodeAtGenerator(Register object, 1689 StringCharCodeAtGenerator(Register object, Register index, Register result,
1667 Register index, 1690 Label* receiver_not_string, Label* index_not_number,
1668 Register result,
1669 Label* receiver_not_string,
1670 Label* index_not_number,
1671 Label* index_out_of_range, 1691 Label* index_out_of_range,
1672 StringIndexFlags index_flags) 1692 StringIndexFlags index_flags,
1693 ReceiverCheckMode check_mode = RECEIVER_IS_UNKNOWN)
1673 : object_(object), 1694 : object_(object),
1674 index_(index), 1695 index_(index),
1675 result_(result), 1696 result_(result),
1676 receiver_not_string_(receiver_not_string), 1697 receiver_not_string_(receiver_not_string),
1677 index_not_number_(index_not_number), 1698 index_not_number_(index_not_number),
1678 index_out_of_range_(index_out_of_range), 1699 index_out_of_range_(index_out_of_range),
1679 index_flags_(index_flags) { 1700 index_flags_(index_flags),
1701 check_mode_(check_mode) {
1680 DCHECK(!result_.is(object_)); 1702 DCHECK(!result_.is(object_));
1681 DCHECK(!result_.is(index_)); 1703 DCHECK(!result_.is(index_));
1682 } 1704 }
1683 1705
1684 // Generates the fast case code. On the fallthrough path |result| 1706 // Generates the fast case code. On the fallthrough path |result|
1685 // register contains the result. 1707 // register contains the result.
1686 void GenerateFast(MacroAssembler* masm); 1708 void GenerateFast(MacroAssembler* masm);
1687 1709
1688 // Generates the slow case code. Must not be naturally 1710 // Generates the slow case code. Must not be naturally
1689 // reachable. Expected to be put after a ret instruction (e.g., in 1711 // reachable. Expected to be put after a ret instruction (e.g., in
(...skipping 11 matching lines...) Expand all
1701 private: 1723 private:
1702 Register object_; 1724 Register object_;
1703 Register index_; 1725 Register index_;
1704 Register result_; 1726 Register result_;
1705 1727
1706 Label* receiver_not_string_; 1728 Label* receiver_not_string_;
1707 Label* index_not_number_; 1729 Label* index_not_number_;
1708 Label* index_out_of_range_; 1730 Label* index_out_of_range_;
1709 1731
1710 StringIndexFlags index_flags_; 1732 StringIndexFlags index_flags_;
1733 ReceiverCheckMode check_mode_;
1711 1734
1712 Label call_runtime_; 1735 Label call_runtime_;
1713 Label index_not_smi_; 1736 Label index_not_smi_;
1714 Label got_smi_index_; 1737 Label got_smi_index_;
1715 Label exit_; 1738 Label exit_;
1716 1739
1717 DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator); 1740 DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator);
1718 }; 1741 };
1719 1742
1720 1743
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 // Only supports the case when the receiver is a string and the index 1783 // Only supports the case when the receiver is a string and the index
1761 // is a number (smi or heap number) that is a valid index into the 1784 // is a number (smi or heap number) that is a valid index into the
1762 // string. Additional index constraints are specified by the 1785 // string. Additional index constraints are specified by the
1763 // flags. Otherwise, bails out to the provided labels. 1786 // flags. Otherwise, bails out to the provided labels.
1764 // 1787 //
1765 // Register usage: |object| may be changed to another string in a way 1788 // Register usage: |object| may be changed to another string in a way
1766 // that doesn't affect charCodeAt/charAt semantics, |index| is 1789 // that doesn't affect charCodeAt/charAt semantics, |index| is
1767 // preserved, |scratch1|, |scratch2|, and |result| are clobbered. 1790 // preserved, |scratch1|, |scratch2|, and |result| are clobbered.
1768 class StringCharAtGenerator { 1791 class StringCharAtGenerator {
1769 public: 1792 public:
1770 StringCharAtGenerator(Register object, 1793 StringCharAtGenerator(Register object, Register index, Register scratch,
1771 Register index, 1794 Register result, Label* receiver_not_string,
1772 Register scratch, 1795 Label* index_not_number, Label* index_out_of_range,
1773 Register result, 1796 StringIndexFlags index_flags,
1774 Label* receiver_not_string, 1797 ReceiverCheckMode check_mode = RECEIVER_IS_UNKNOWN)
1775 Label* index_not_number, 1798 : char_code_at_generator_(object, index, scratch, receiver_not_string,
1776 Label* index_out_of_range, 1799 index_not_number, index_out_of_range,
1777 StringIndexFlags index_flags)
1778 : char_code_at_generator_(object,
1779 index,
1780 scratch,
1781 receiver_not_string,
1782 index_not_number,
1783 index_out_of_range,
1784 index_flags), 1800 index_flags),
1785 char_from_code_generator_(scratch, result) {} 1801 char_from_code_generator_(scratch, result) {}
1786 1802
1787 // Generates the fast case code. On the fallthrough path |result| 1803 // Generates the fast case code. On the fallthrough path |result|
1788 // register contains the result. 1804 // register contains the result.
1789 void GenerateFast(MacroAssembler* masm) { 1805 void GenerateFast(MacroAssembler* masm) {
1790 char_code_at_generator_.GenerateFast(masm); 1806 char_code_at_generator_.GenerateFast(masm);
1791 char_from_code_generator_.GenerateFast(masm); 1807 char_from_code_generator_.GenerateFast(masm);
1792 } 1808 }
1793 1809
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 2502
2487 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR 2503 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR
2488 #undef DEFINE_PLATFORM_CODE_STUB 2504 #undef DEFINE_PLATFORM_CODE_STUB
2489 #undef DEFINE_HANDLER_CODE_STUB 2505 #undef DEFINE_HANDLER_CODE_STUB
2490 #undef DEFINE_HYDROGEN_CODE_STUB 2506 #undef DEFINE_HYDROGEN_CODE_STUB
2491 #undef DEFINE_CODE_STUB 2507 #undef DEFINE_CODE_STUB
2492 #undef DEFINE_CODE_STUB_BASE 2508 #undef DEFINE_CODE_STUB_BASE
2493 } } // namespace v8::internal 2509 } } // namespace v8::internal
2494 2510
2495 #endif // V8_CODE_STUBS_H_ 2511 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698