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

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

Issue 224903005: Reland "create a function call IC" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments. Created 6 years, 8 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/code-stubs.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 // 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 V(BinaryOpIC) \ 44 V(BinaryOpIC) \
45 V(BinaryOpICWithAllocationSite) \ 45 V(BinaryOpICWithAllocationSite) \
46 V(BinaryOpWithAllocationSite) \ 46 V(BinaryOpWithAllocationSite) \
47 V(StringAdd) \ 47 V(StringAdd) \
48 V(SubString) \ 48 V(SubString) \
49 V(StringCompare) \ 49 V(StringCompare) \
50 V(Compare) \ 50 V(Compare) \
51 V(CompareIC) \ 51 V(CompareIC) \
52 V(CompareNilIC) \ 52 V(CompareNilIC) \
53 V(MathPow) \ 53 V(MathPow) \
54 V(CallIC) \
54 V(FunctionPrototype) \ 55 V(FunctionPrototype) \
55 V(RecordWrite) \ 56 V(RecordWrite) \
56 V(StoreBufferOverflow) \ 57 V(StoreBufferOverflow) \
57 V(RegExpExec) \ 58 V(RegExpExec) \
58 V(Instanceof) \ 59 V(Instanceof) \
59 V(ConvertToDouble) \ 60 V(ConvertToDouble) \
60 V(WriteInt32ToHeapNumber) \ 61 V(WriteInt32ToHeapNumber) \
61 V(StackCheck) \ 62 V(StackCheck) \
62 V(Interrupt) \ 63 V(Interrupt) \
63 V(FastNewClosure) \ 64 V(FastNewClosure) \
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 833
833 virtual int MinorKey() { 834 virtual int MinorKey() {
834 return KindBits::encode(kind_); 835 return KindBits::encode(kind_);
835 } 836 }
836 837
837 private: 838 private:
838 Code::Kind kind_; 839 Code::Kind kind_;
839 }; 840 };
840 841
841 842
843 class CallICStub: public PlatformCodeStub {
844 public:
845 explicit CallICStub(const CallIC::State& state)
846 : state_(state) {}
847
848 bool CallAsMethod() const { return state_.CallAsMethod(); }
849 bool IsGeneric() const {
850 return state_.IsGeneric();
851 }
852 bool ArgumentsMustMatch() const {
853 return state_.ArgumentsMustMatch();
854 }
855 bool IsSloppy() const {
856 return state_.IsSloppy();
857 }
858
859 int arg_count() const { return state_.arg_count(); }
860
861 static int ExtractArgcFromMinorKey(int minor_key) {
862 CallIC::State state((ExtraICState) minor_key);
863 return state.arg_count();
864 }
865
866 virtual void Generate(MacroAssembler* masm);
867
868 virtual Code::Kind GetCodeKind() const V8_OVERRIDE {
869 return Code::CALL_IC;
870 }
871
872 virtual InlineCacheState GetICState() V8_FINAL V8_OVERRIDE {
873 return state_.GetICState();
874 }
875
876 virtual ExtraICState GetExtraICState() V8_FINAL V8_OVERRIDE {
877 return state_.GetExtraICState();
878 }
879
880 protected:
881 virtual int MinorKey() { return GetExtraICState(); }
882 virtual void PrintState(StringStream* stream) V8_FINAL V8_OVERRIDE;
883
884 private:
885 virtual CodeStub::Major MajorKey() { return CallIC; }
886
887 // Code generation helpers.
888 void GenerateMonomorphicCall(MacroAssembler* masm);
889 void GenerateSlowCall(MacroAssembler* masm);
890 void GenerateMiss(MacroAssembler* masm);
891
892 CallIC::State state_;
893 };
894
895
842 class FunctionPrototypeStub: public ICStub { 896 class FunctionPrototypeStub: public ICStub {
843 public: 897 public:
844 explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { } 898 explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { }
845 virtual void Generate(MacroAssembler* masm); 899 virtual void Generate(MacroAssembler* masm);
846 900
847 private: 901 private:
848 virtual CodeStub::Major MajorKey() { return FunctionPrototype; } 902 virtual CodeStub::Major MajorKey() { return FunctionPrototype; }
849 }; 903 };
850 904
851 905
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 }; 1677 };
1624 1678
1625 1679
1626 class CallFunctionStub: public PlatformCodeStub { 1680 class CallFunctionStub: public PlatformCodeStub {
1627 public: 1681 public:
1628 CallFunctionStub(int argc, CallFunctionFlags flags) 1682 CallFunctionStub(int argc, CallFunctionFlags flags)
1629 : argc_(argc), flags_(flags) { } 1683 : argc_(argc), flags_(flags) { }
1630 1684
1631 void Generate(MacroAssembler* masm); 1685 void Generate(MacroAssembler* masm);
1632 1686
1633 virtual void FinishCode(Handle<Code> code) {
1634 code->set_has_function_cache(RecordCallTarget());
1635 }
1636
1637 static int ExtractArgcFromMinorKey(int minor_key) { 1687 static int ExtractArgcFromMinorKey(int minor_key) {
1638 return ArgcBits::decode(minor_key); 1688 return ArgcBits::decode(minor_key);
1639 } 1689 }
1640 1690
1641 private: 1691 private:
1642 int argc_; 1692 int argc_;
1643 CallFunctionFlags flags_; 1693 CallFunctionFlags flags_;
1644 1694
1645 virtual void PrintName(StringStream* stream); 1695 virtual void PrintName(StringStream* stream);
1646 1696
1647 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>. 1697 // Minor key encoding in 32 bits with Bitfield <Type, shift, size>.
1648 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {}; 1698 class FlagBits: public BitField<CallFunctionFlags, 0, 2> {};
1649 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {}; 1699 class ArgcBits: public BitField<unsigned, 2, 32 - 2> {};
1650 1700
1651 Major MajorKey() { return CallFunction; } 1701 Major MajorKey() { return CallFunction; }
1652 int MinorKey() { 1702 int MinorKey() {
1653 // Encode the parameters in a unique 32 bit value. 1703 // Encode the parameters in a unique 32 bit value.
1654 return FlagBits::encode(flags_) | ArgcBits::encode(argc_); 1704 return FlagBits::encode(flags_) | ArgcBits::encode(argc_);
1655 } 1705 }
1656 1706
1657 bool RecordCallTarget() {
1658 return flags_ == RECORD_CALL_TARGET;
1659 }
1660
1661 bool CallAsMethod() { 1707 bool CallAsMethod() {
1662 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL; 1708 return flags_ == CALL_AS_METHOD || flags_ == WRAP_AND_CALL;
1663 } 1709 }
1664 1710
1665 bool NeedsChecks() { 1711 bool NeedsChecks() {
1666 return flags_ != WRAP_AND_CALL; 1712 return flags_ != WRAP_AND_CALL;
1667 } 1713 }
1668 }; 1714 };
1669 1715
1670 1716
1671 class CallConstructStub: public PlatformCodeStub { 1717 class CallConstructStub: public PlatformCodeStub {
1672 public: 1718 public:
1673 explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} 1719 explicit CallConstructStub(CallConstructorFlags flags) : flags_(flags) {}
1674 1720
1675 void Generate(MacroAssembler* masm); 1721 void Generate(MacroAssembler* masm);
1676 1722
1677 virtual void FinishCode(Handle<Code> code) { 1723 virtual void FinishCode(Handle<Code> code) {
1678 code->set_has_function_cache(RecordCallTarget()); 1724 code->set_has_function_cache(RecordCallTarget());
1679 } 1725 }
1680 1726
1681 private: 1727 private:
1682 CallFunctionFlags flags_; 1728 CallConstructorFlags flags_;
1683 1729
1684 virtual void PrintName(StringStream* stream); 1730 virtual void PrintName(StringStream* stream);
1685 1731
1686 Major MajorKey() { return CallConstruct; } 1732 Major MajorKey() { return CallConstruct; }
1687 int MinorKey() { return flags_; } 1733 int MinorKey() { return flags_; }
1688 1734
1689 bool RecordCallTarget() { 1735 bool RecordCallTarget() {
1690 return (flags_ & RECORD_CALL_TARGET) != 0; 1736 return (flags_ & RECORD_CONSTRUCTOR_TARGET) != 0;
1691 }
1692
1693 bool CallAsMethod() {
1694 return (flags_ & CALL_AS_METHOD) != 0;
1695 } 1737 }
1696 }; 1738 };
1697 1739
1698 1740
1699 enum StringIndexFlags { 1741 enum StringIndexFlags {
1700 // Accepts smis or heap numbers. 1742 // Accepts smis or heap numbers.
1701 STRING_INDEX_IS_NUMBER, 1743 STRING_INDEX_IS_NUMBER,
1702 1744
1703 // Accepts smis or heap numbers that are valid array indices 1745 // Accepts smis or heap numbers that are valid array indices
1704 // (ECMA-262 15.4). Invalid indices are reported as being out of 1746 // (ECMA-262 15.4). Invalid indices are reported as being out of
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 2566
2525 2567
2526 class CallDescriptors { 2568 class CallDescriptors {
2527 public: 2569 public:
2528 static void InitializeForIsolate(Isolate* isolate); 2570 static void InitializeForIsolate(Isolate* isolate);
2529 }; 2571 };
2530 2572
2531 } } // namespace v8::internal 2573 } } // namespace v8::internal
2532 2574
2533 #endif // V8_CODE_STUBS_H_ 2575 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698