| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 protected: | 432 protected: |
| 433 void set_sub_minor_key(uint32_t key) { | 433 void set_sub_minor_key(uint32_t key) { |
| 434 minor_key_ = SubMinorKeyBits::update(minor_key_, key); | 434 minor_key_ = SubMinorKeyBits::update(minor_key_, key); |
| 435 } | 435 } |
| 436 | 436 |
| 437 uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); } | 437 uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); } |
| 438 | 438 |
| 439 static const int kSubMinorKeyBits = kStubMinorKeyBits - 1; | 439 static const int kSubMinorKeyBits = kStubMinorKeyBits - 1; |
| 440 | 440 |
| 441 class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {}; |
| 442 |
| 441 private: | 443 private: |
| 442 class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {}; | |
| 443 class IsMissBits : public BitField<bool, kSubMinorKeyBits, 1> {}; | 444 class IsMissBits : public BitField<bool, kSubMinorKeyBits, 1> {}; |
| 444 | 445 |
| 445 void GenerateLightweightMiss(MacroAssembler* masm); | 446 void GenerateLightweightMiss(MacroAssembler* masm); |
| 446 virtual uint32_t MinorKey() const { | 447 virtual uint32_t MinorKey() const { |
| 447 return IsMissBits::encode(IsUninitialized()) | | 448 return IsMissBits::encode(IsUninitialized()) | |
| 448 SubMinorKeyBits::encode(NotMissMinorKey()); | 449 SubMinorKeyBits::encode(NotMissMinorKey()); |
| 449 } | 450 } |
| 450 }; | 451 }; |
| 451 | 452 |
| 452 | 453 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 class HandlerStub : public HydrogenCodeStub { | 891 class HandlerStub : public HydrogenCodeStub { |
| 891 public: | 892 public: |
| 892 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } | 893 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } |
| 893 virtual ExtraICState GetExtraICState() const { return kind(); } | 894 virtual ExtraICState GetExtraICState() const { return kind(); } |
| 894 virtual InlineCacheState GetICState() const { return MONOMORPHIC; } | 895 virtual InlineCacheState GetICState() const { return MONOMORPHIC; } |
| 895 | 896 |
| 896 virtual void InitializeInterfaceDescriptor( | 897 virtual void InitializeInterfaceDescriptor( |
| 897 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 898 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 898 | 899 |
| 899 protected: | 900 protected: |
| 900 explicit HandlerStub(Isolate* isolate) | 901 explicit HandlerStub(Isolate* isolate) : HydrogenCodeStub(isolate) {} |
| 901 : HydrogenCodeStub(isolate), bit_field_(0) {} | |
| 902 virtual int NotMissMinorKey() const { return bit_field_; } | |
| 903 virtual Code::Kind kind() const = 0; | 902 virtual Code::Kind kind() const = 0; |
| 904 int bit_field_; | 903 |
| 904 private: |
| 905 DISALLOW_COPY_AND_ASSIGN(HandlerStub); |
| 905 }; | 906 }; |
| 906 | 907 |
| 907 | 908 |
| 908 class LoadFieldStub: public HandlerStub { | 909 class LoadFieldStub: public HandlerStub { |
| 909 public: | 910 public: |
| 910 LoadFieldStub(Isolate* isolate, FieldIndex index) | 911 LoadFieldStub(Isolate* isolate, FieldIndex index) : HandlerStub(isolate) { |
| 911 : HandlerStub(isolate), index_(index) { | 912 int property_index_key = index.GetFieldAccessStubKey(); |
| 912 int property_index_key = index_.GetFieldAccessStubKey(); | 913 set_sub_minor_key(LoadFieldByIndexBits::encode(property_index_key)); |
| 913 bit_field_ = EncodedLoadFieldByIndexBits::encode(property_index_key); | |
| 914 } | 914 } |
| 915 | 915 |
| 916 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 916 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 917 | 917 |
| 918 FieldIndex index() const { return index_; } | 918 FieldIndex index() const { |
| 919 int property_index_key = LoadFieldByIndexBits::decode(sub_minor_key()); |
| 920 return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 921 } |
| 919 | 922 |
| 920 protected: | 923 protected: |
| 921 explicit LoadFieldStub(Isolate* isolate); | 924 explicit LoadFieldStub(Isolate* isolate); |
| 922 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 925 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 923 virtual Code::StubType GetStubType() { return Code::FAST; } | 926 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 924 | 927 |
| 925 private: | 928 private: |
| 926 class EncodedLoadFieldByIndexBits : public BitField<int, 0, 13> {}; | |
| 927 virtual Major MajorKey() const V8_OVERRIDE { return LoadField; } | 929 virtual Major MajorKey() const V8_OVERRIDE { return LoadField; } |
| 928 FieldIndex index_; | 930 |
| 931 class LoadFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 932 |
| 933 DISALLOW_COPY_AND_ASSIGN(LoadFieldStub); |
| 929 }; | 934 }; |
| 930 | 935 |
| 931 | 936 |
| 932 class LoadConstantStub : public HandlerStub { | 937 class LoadConstantStub : public HandlerStub { |
| 933 public: | 938 public: |
| 934 LoadConstantStub(Isolate* isolate, int descriptor) : HandlerStub(isolate) { | 939 LoadConstantStub(Isolate* isolate, int constant_index) |
| 935 bit_field_ = descriptor; | 940 : HandlerStub(isolate) { |
| 941 set_sub_minor_key(ConstantIndexBits::encode(constant_index)); |
| 936 } | 942 } |
| 937 | 943 |
| 938 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 944 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 939 | 945 |
| 940 int descriptor() const { return bit_field_; } | 946 int constant_index() const { |
| 947 return ConstantIndexBits::decode(sub_minor_key()); |
| 948 } |
| 941 | 949 |
| 942 protected: | 950 protected: |
| 943 explicit LoadConstantStub(Isolate* isolate); | 951 explicit LoadConstantStub(Isolate* isolate); |
| 944 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 952 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 945 virtual Code::StubType GetStubType() { return Code::FAST; } | 953 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 946 | 954 |
| 947 private: | 955 private: |
| 948 virtual Major MajorKey() const V8_OVERRIDE { return LoadConstant; } | 956 virtual Major MajorKey() const V8_OVERRIDE { return LoadConstant; } |
| 957 |
| 958 class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {}; |
| 959 |
| 960 DISALLOW_COPY_AND_ASSIGN(LoadConstantStub); |
| 949 }; | 961 }; |
| 950 | 962 |
| 951 | 963 |
| 952 class StringLengthStub: public HandlerStub { | 964 class StringLengthStub: public HandlerStub { |
| 953 public: | 965 public: |
| 954 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {} | 966 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {} |
| 955 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 967 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 956 | 968 |
| 957 protected: | 969 protected: |
| 958 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 970 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 959 virtual Code::StubType GetStubType() { return Code::FAST; } | 971 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 960 | 972 |
| 961 private: | 973 private: |
| 962 virtual Major MajorKey() const V8_OVERRIDE { return StringLength; } | 974 virtual Major MajorKey() const V8_OVERRIDE { return StringLength; } |
| 975 |
| 976 DISALLOW_COPY_AND_ASSIGN(StringLengthStub); |
| 963 }; | 977 }; |
| 964 | 978 |
| 965 | 979 |
| 966 class StoreFieldStub : public HandlerStub { | 980 class StoreFieldStub : public HandlerStub { |
| 967 public: | 981 public: |
| 968 StoreFieldStub(Isolate* isolate, FieldIndex index, | 982 StoreFieldStub(Isolate* isolate, FieldIndex index, |
| 969 Representation representation) | 983 Representation representation) |
| 970 : HandlerStub(isolate), index_(index), representation_(representation) { | 984 : HandlerStub(isolate) { |
| 971 int property_index_key = index_.GetFieldAccessStubKey(); | 985 int property_index_key = index.GetFieldAccessStubKey(); |
| 972 bit_field_ = EncodedStoreFieldByIndexBits::encode(property_index_key) | | 986 uint8_t repr = PropertyDetails::EncodeRepresentation(representation); |
| 973 RepresentationBits::encode( | 987 set_sub_minor_key(StoreFieldByIndexBits::encode(property_index_key) | |
| 974 PropertyDetails::EncodeRepresentation(representation)); | 988 RepresentationBits::encode(repr)); |
| 975 } | 989 } |
| 976 | 990 |
| 977 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 991 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 978 | 992 |
| 979 FieldIndex index() const { return index_; } | 993 FieldIndex index() const { |
| 980 Representation representation() { return representation_; } | 994 int property_index_key = StoreFieldByIndexBits::decode(sub_minor_key()); |
| 995 return FieldIndex::FromFieldAccessStubKey(property_index_key); |
| 996 } |
| 997 |
| 998 Representation representation() { |
| 999 uint8_t repr = RepresentationBits::decode(sub_minor_key()); |
| 1000 return PropertyDetails::DecodeRepresentation(repr); |
| 1001 } |
| 1002 |
| 981 static void InstallDescriptors(Isolate* isolate); | 1003 static void InstallDescriptors(Isolate* isolate); |
| 982 | 1004 |
| 983 protected: | 1005 protected: |
| 984 explicit StoreFieldStub(Isolate* isolate); | 1006 explicit StoreFieldStub(Isolate* isolate); |
| 985 virtual Code::Kind kind() const { return Code::STORE_IC; } | 1007 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 986 virtual Code::StubType GetStubType() { return Code::FAST; } | 1008 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 987 | 1009 |
| 988 private: | 1010 private: |
| 989 class EncodedStoreFieldByIndexBits : public BitField<int, 0, 13> {}; | |
| 990 class RepresentationBits : public BitField<int, 13, 4> {}; | |
| 991 virtual Major MajorKey() const V8_OVERRIDE { return StoreField; } | 1011 virtual Major MajorKey() const V8_OVERRIDE { return StoreField; } |
| 992 FieldIndex index_; | 1012 |
| 993 Representation representation_; | 1013 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
| 1014 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
| 1015 |
| 1016 DISALLOW_COPY_AND_ASSIGN(StoreFieldStub); |
| 994 }; | 1017 }; |
| 995 | 1018 |
| 996 | 1019 |
| 997 class StoreGlobalStub : public HandlerStub { | 1020 class StoreGlobalStub : public HandlerStub { |
| 998 public: | 1021 public: |
| 999 StoreGlobalStub(Isolate* isolate, bool is_constant, bool check_global) | 1022 StoreGlobalStub(Isolate* isolate, bool is_constant, bool check_global) |
| 1000 : HandlerStub(isolate) { | 1023 : HandlerStub(isolate) { |
| 1001 bit_field_ = IsConstantBits::encode(is_constant) | | 1024 set_sub_minor_key(IsConstantBits::encode(is_constant) | |
| 1002 CheckGlobalBits::encode(check_global); | 1025 CheckGlobalBits::encode(check_global)); |
| 1003 } | 1026 } |
| 1004 | 1027 |
| 1005 static Handle<HeapObject> global_placeholder(Isolate* isolate) { | 1028 static Handle<HeapObject> global_placeholder(Isolate* isolate) { |
| 1006 return isolate->factory()->uninitialized_value(); | 1029 return isolate->factory()->uninitialized_value(); |
| 1007 } | 1030 } |
| 1008 | 1031 |
| 1009 Handle<Code> GetCodeCopyFromTemplate(Handle<GlobalObject> global, | 1032 Handle<Code> GetCodeCopyFromTemplate(Handle<GlobalObject> global, |
| 1010 Handle<PropertyCell> cell) { | 1033 Handle<PropertyCell> cell) { |
| 1011 if (check_global()) { | 1034 if (check_global()) { |
| 1012 Code::FindAndReplacePattern pattern; | 1035 Code::FindAndReplacePattern pattern; |
| 1013 pattern.Add(Handle<Map>(global_placeholder(isolate())->map()), global); | 1036 pattern.Add(Handle<Map>(global_placeholder(isolate())->map()), global); |
| 1014 pattern.Add(isolate()->factory()->meta_map(), Handle<Map>(global->map())); | 1037 pattern.Add(isolate()->factory()->meta_map(), Handle<Map>(global->map())); |
| 1015 pattern.Add(isolate()->factory()->global_property_cell_map(), cell); | 1038 pattern.Add(isolate()->factory()->global_property_cell_map(), cell); |
| 1016 return CodeStub::GetCodeCopy(pattern); | 1039 return CodeStub::GetCodeCopy(pattern); |
| 1017 } else { | 1040 } else { |
| 1018 Code::FindAndReplacePattern pattern; | 1041 Code::FindAndReplacePattern pattern; |
| 1019 pattern.Add(isolate()->factory()->global_property_cell_map(), cell); | 1042 pattern.Add(isolate()->factory()->global_property_cell_map(), cell); |
| 1020 return CodeStub::GetCodeCopy(pattern); | 1043 return CodeStub::GetCodeCopy(pattern); |
| 1021 } | 1044 } |
| 1022 } | 1045 } |
| 1023 | 1046 |
| 1024 virtual Code::Kind kind() const { return Code::STORE_IC; } | 1047 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 1025 | 1048 |
| 1026 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 1049 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 1027 | 1050 |
| 1028 bool is_constant() const { | 1051 bool is_constant() const { return IsConstantBits::decode(sub_minor_key()); } |
| 1029 return IsConstantBits::decode(bit_field_); | 1052 |
| 1030 } | 1053 bool check_global() const { return CheckGlobalBits::decode(sub_minor_key()); } |
| 1031 bool check_global() const { | 1054 |
| 1032 return CheckGlobalBits::decode(bit_field_); | |
| 1033 } | |
| 1034 void set_is_constant(bool value) { | 1055 void set_is_constant(bool value) { |
| 1035 bit_field_ = IsConstantBits::update(bit_field_, value); | 1056 set_sub_minor_key(IsConstantBits::update(sub_minor_key(), value)); |
| 1036 } | 1057 } |
| 1037 | 1058 |
| 1038 Representation representation() { | 1059 Representation representation() { |
| 1039 return Representation::FromKind(RepresentationBits::decode(bit_field_)); | 1060 return Representation::FromKind( |
| 1061 RepresentationBits::decode(sub_minor_key())); |
| 1040 } | 1062 } |
| 1063 |
| 1041 void set_representation(Representation r) { | 1064 void set_representation(Representation r) { |
| 1042 bit_field_ = RepresentationBits::update(bit_field_, r.kind()); | 1065 set_sub_minor_key(RepresentationBits::update(sub_minor_key(), r.kind())); |
| 1043 } | 1066 } |
| 1044 | 1067 |
| 1045 private: | 1068 private: |
| 1046 virtual Major MajorKey() const V8_OVERRIDE { return StoreGlobal; } | 1069 virtual Major MajorKey() const V8_OVERRIDE { return StoreGlobal; } |
| 1047 | 1070 |
| 1048 class IsConstantBits: public BitField<bool, 0, 1> {}; | 1071 class IsConstantBits: public BitField<bool, 0, 1> {}; |
| 1049 class RepresentationBits: public BitField<Representation::Kind, 1, 8> {}; | 1072 class RepresentationBits: public BitField<Representation::Kind, 1, 8> {}; |
| 1050 class CheckGlobalBits: public BitField<bool, 9, 1> {}; | 1073 class CheckGlobalBits: public BitField<bool, 9, 1> {}; |
| 1051 | 1074 |
| 1052 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub); | 1075 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub); |
| (...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 | 2624 |
| 2602 void Generate(MacroAssembler* masm); | 2625 void Generate(MacroAssembler* masm); |
| 2603 | 2626 |
| 2604 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2627 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2605 }; | 2628 }; |
| 2606 | 2629 |
| 2607 | 2630 |
| 2608 } } // namespace v8::internal | 2631 } } // namespace v8::internal |
| 2609 | 2632 |
| 2610 #endif // V8_CODE_STUBS_H_ | 2633 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |