| 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 virtual void Generate(MacroAssembler* masm); | 821 virtual void Generate(MacroAssembler* masm); |
| 822 | 822 |
| 823 private: | 823 private: |
| 824 virtual CodeStub::Major MajorKey() const { return MathPow; } | 824 virtual CodeStub::Major MajorKey() const { return MathPow; } |
| 825 virtual int MinorKey() const { return exponent_type_; } | 825 virtual int MinorKey() const { return exponent_type_; } |
| 826 | 826 |
| 827 ExponentType exponent_type_; | 827 ExponentType exponent_type_; |
| 828 }; | 828 }; |
| 829 | 829 |
| 830 | 830 |
| 831 class ICStub: public PlatformCodeStub { | |
| 832 public: | |
| 833 ICStub(Isolate* isolate, Code::Kind kind) | |
| 834 : PlatformCodeStub(isolate), kind_(kind) { } | |
| 835 virtual Code::Kind GetCodeKind() const { return kind_; } | |
| 836 virtual InlineCacheState GetICState() { return MONOMORPHIC; } | |
| 837 | |
| 838 bool Describes(Code* code) { return code->stub_key() == GetKey(); } | |
| 839 | |
| 840 protected: | |
| 841 class KindBits: public BitField<Code::Kind, 0, 4> {}; | |
| 842 Code::Kind kind() const { return kind_; } | |
| 843 | |
| 844 virtual int MinorKey() const { return KindBits::encode(kind_); } | |
| 845 | |
| 846 private: | |
| 847 Code::Kind kind_; | |
| 848 }; | |
| 849 | |
| 850 | |
| 851 class CallICStub: public PlatformCodeStub { | 831 class CallICStub: public PlatformCodeStub { |
| 852 public: | 832 public: |
| 853 CallICStub(Isolate* isolate, const CallIC::State& state) | 833 CallICStub(Isolate* isolate, const CallIC::State& state) |
| 854 : PlatformCodeStub(isolate), state_(state) {} | 834 : PlatformCodeStub(isolate), state_(state) {} |
| 855 | 835 |
| 856 bool CallAsMethod() const { return state_.CallAsMethod(); } | 836 bool CallAsMethod() const { return state_.CallAsMethod(); } |
| 857 | 837 |
| 858 int arg_count() const { return state_.arg_count(); } | 838 int arg_count() const { return state_.arg_count(); } |
| 859 | 839 |
| 860 static int ExtractArgcFromMinorKey(int minor_key) { | 840 static int ExtractArgcFromMinorKey(int minor_key) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 : PlatformCodeStub(isolate) {} | 890 : PlatformCodeStub(isolate) {} |
| 911 virtual void Generate(MacroAssembler* masm); | 891 virtual void Generate(MacroAssembler* masm); |
| 912 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } | 892 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } |
| 913 | 893 |
| 914 private: | 894 private: |
| 915 virtual CodeStub::Major MajorKey() const { return FunctionPrototype; } | 895 virtual CodeStub::Major MajorKey() const { return FunctionPrototype; } |
| 916 virtual int MinorKey() const { return 0; } | 896 virtual int MinorKey() const { return 0; } |
| 917 }; | 897 }; |
| 918 | 898 |
| 919 | 899 |
| 920 class StoreICStub: public ICStub { | 900 class HandlerStub : public HydrogenCodeStub { |
| 921 public: | |
| 922 StoreICStub(Isolate* isolate, Code::Kind kind, StrictMode strict_mode) | |
| 923 : ICStub(isolate, kind), strict_mode_(strict_mode) { } | |
| 924 | |
| 925 protected: | |
| 926 virtual ExtraICState GetExtraICState() const { | |
| 927 return StoreIC::ComputeExtraICState(strict_mode_); | |
| 928 } | |
| 929 | |
| 930 private: | |
| 931 STATIC_ASSERT(KindBits::kSize == 4); | |
| 932 class StrictModeBits: public BitField<bool, 4, 1> {}; | |
| 933 virtual int MinorKey() const { | |
| 934 return KindBits::encode(kind()) | StrictModeBits::encode(strict_mode_); | |
| 935 } | |
| 936 | |
| 937 StrictMode strict_mode_; | |
| 938 }; | |
| 939 | |
| 940 | |
| 941 class HICStub: public HydrogenCodeStub { | |
| 942 public: | |
| 943 explicit HICStub(Isolate* isolate) : HydrogenCodeStub(isolate) { } | |
| 944 virtual Code::Kind GetCodeKind() const { return kind(); } | |
| 945 virtual InlineCacheState GetICState() { return MONOMORPHIC; } | |
| 946 | |
| 947 protected: | |
| 948 class KindBits: public BitField<Code::Kind, 0, 4> {}; | |
| 949 virtual Code::Kind kind() const = 0; | |
| 950 }; | |
| 951 | |
| 952 | |
| 953 class HandlerStub: public HICStub { | |
| 954 public: | 901 public: |
| 955 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } | 902 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } |
| 956 virtual ExtraICState GetExtraICState() const { return kind(); } | 903 virtual ExtraICState GetExtraICState() const { return kind(); } |
| 957 | 904 |
| 958 protected: | 905 protected: |
| 959 explicit HandlerStub(Isolate* isolate) : HICStub(isolate) { } | 906 explicit HandlerStub(Isolate* isolate) |
| 907 : HydrogenCodeStub(isolate), bit_field_(0) {} |
| 960 virtual int NotMissMinorKey() const { return bit_field_; } | 908 virtual int NotMissMinorKey() const { return bit_field_; } |
| 909 virtual Code::Kind kind() const = 0; |
| 961 int bit_field_; | 910 int bit_field_; |
| 962 }; | 911 }; |
| 963 | 912 |
| 964 | 913 |
| 965 class LoadFieldStub: public HandlerStub { | 914 class LoadFieldStub: public HandlerStub { |
| 966 public: | 915 public: |
| 967 LoadFieldStub(Isolate* isolate, FieldIndex index) | 916 LoadFieldStub(Isolate* isolate, FieldIndex index) |
| 968 : HandlerStub(isolate), index_(index) { | 917 : HandlerStub(isolate), index_(index) { |
| 969 Initialize(Code::LOAD_IC); | 918 int property_index_key = index_.GetLoadFieldStubKey(); |
| 919 bit_field_ = EncodedLoadFieldByIndexBits::encode(property_index_key); |
| 970 } | 920 } |
| 971 | 921 |
| 972 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 922 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 973 | 923 |
| 974 virtual void InitializeInterfaceDescriptor( | 924 virtual void InitializeInterfaceDescriptor( |
| 975 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 925 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 976 | 926 |
| 977 Representation representation() { | 927 Representation representation() { |
| 978 if (unboxed_double()) return Representation::Double(); | 928 if (unboxed_double()) return Representation::Double(); |
| 979 return Representation::Tagged(); | 929 return Representation::Tagged(); |
| 980 } | 930 } |
| 981 | 931 |
| 982 virtual Code::Kind kind() const { | |
| 983 return KindBits::decode(bit_field_); | |
| 984 } | |
| 985 | |
| 986 FieldIndex index() const { return index_; } | 932 FieldIndex index() const { return index_; } |
| 987 | 933 bool unboxed_double() { return index_.is_double(); } |
| 988 bool unboxed_double() { | |
| 989 return index_.is_double(); | |
| 990 } | |
| 991 | |
| 992 virtual Code::StubType GetStubType() { return Code::FAST; } | |
| 993 | 934 |
| 994 protected: | 935 protected: |
| 995 explicit LoadFieldStub(Isolate* isolate); | 936 explicit LoadFieldStub(Isolate* isolate); |
| 996 | 937 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 997 void Initialize(Code::Kind kind) { | 938 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 998 int property_index_key = index_.GetLoadFieldStubKey(); | |
| 999 // Save a copy of the essence of the property index into the bit field to | |
| 1000 // make sure that hashing of unique stubs works correctly.. | |
| 1001 bit_field_ = KindBits::encode(kind) | | |
| 1002 EncodedLoadFieldByIndexBits::encode(property_index_key); | |
| 1003 } | |
| 1004 | 939 |
| 1005 private: | 940 private: |
| 1006 STATIC_ASSERT(KindBits::kSize == 4); | 941 class EncodedLoadFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1007 class EncodedLoadFieldByIndexBits: public BitField<int, 4, 13> {}; | |
| 1008 virtual CodeStub::Major MajorKey() const { return LoadField; } | 942 virtual CodeStub::Major MajorKey() const { return LoadField; } |
| 1009 FieldIndex index_; | 943 FieldIndex index_; |
| 1010 }; | 944 }; |
| 1011 | 945 |
| 1012 | 946 |
| 1013 class StringLengthStub: public HandlerStub { | 947 class StringLengthStub: public HandlerStub { |
| 1014 public: | 948 public: |
| 1015 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) { | 949 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {} |
| 1016 Initialize(Code::LOAD_IC); | |
| 1017 } | |
| 1018 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 950 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 1019 virtual void InitializeInterfaceDescriptor( | 951 virtual void InitializeInterfaceDescriptor( |
| 1020 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 952 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1021 | 953 |
| 1022 protected: | 954 protected: |
| 1023 virtual Code::Kind kind() const { | 955 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 1024 return KindBits::decode(bit_field_); | 956 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 1025 } | |
| 1026 | |
| 1027 void Initialize(Code::Kind kind) { | |
| 1028 bit_field_ = KindBits::encode(kind); | |
| 1029 } | |
| 1030 | 957 |
| 1031 private: | 958 private: |
| 1032 virtual CodeStub::Major MajorKey() const { return StringLength; } | 959 virtual CodeStub::Major MajorKey() const { return StringLength; } |
| 1033 }; | 960 }; |
| 1034 | 961 |
| 1035 | 962 |
| 1036 class StoreGlobalStub : public HandlerStub { | 963 class StoreGlobalStub : public HandlerStub { |
| 1037 public: | 964 public: |
| 1038 StoreGlobalStub(Isolate* isolate, bool is_constant, bool check_global) | 965 StoreGlobalStub(Isolate* isolate, bool is_constant, bool check_global) |
| 1039 : HandlerStub(isolate) { | 966 : HandlerStub(isolate) { |
| (...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 | 2467 |
| 2541 | 2468 |
| 2542 class CallDescriptors { | 2469 class CallDescriptors { |
| 2543 public: | 2470 public: |
| 2544 static void InitializeForIsolate(Isolate* isolate); | 2471 static void InitializeForIsolate(Isolate* isolate); |
| 2545 }; | 2472 }; |
| 2546 | 2473 |
| 2547 } } // namespace v8::internal | 2474 } } // namespace v8::internal |
| 2548 | 2475 |
| 2549 #endif // V8_CODE_STUBS_H_ | 2476 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |