| 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 890 |
| 891 protected: | 891 protected: |
| 892 explicit HandlerStub(Isolate* isolate) : HICStub(isolate) { } | 892 explicit HandlerStub(Isolate* isolate) : HICStub(isolate) { } |
| 893 virtual int NotMissMinorKey() { return bit_field_; } | 893 virtual int NotMissMinorKey() { return bit_field_; } |
| 894 int bit_field_; | 894 int bit_field_; |
| 895 }; | 895 }; |
| 896 | 896 |
| 897 | 897 |
| 898 class LoadFieldStub: public HandlerStub { | 898 class LoadFieldStub: public HandlerStub { |
| 899 public: | 899 public: |
| 900 LoadFieldStub(Isolate* isolate, | 900 LoadFieldStub(Isolate* isolate, FieldIndex index) |
| 901 bool inobject, | 901 : HandlerStub(isolate), index_(index) { |
| 902 int index, Representation representation) | 902 Initialize(Code::LOAD_IC); |
| 903 : HandlerStub(isolate) { | |
| 904 Initialize(Code::LOAD_IC, inobject, index, representation); | |
| 905 } | 903 } |
| 906 | 904 |
| 907 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 905 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 908 | 906 |
| 909 virtual void InitializeInterfaceDescriptor( | 907 virtual void InitializeInterfaceDescriptor( |
| 910 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 908 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 911 | 909 |
| 912 Representation representation() { | 910 Representation representation() { |
| 913 if (unboxed_double()) return Representation::Double(); | 911 if (unboxed_double()) return Representation::Double(); |
| 914 return Representation::Tagged(); | 912 return Representation::Tagged(); |
| 915 } | 913 } |
| 916 | 914 |
| 917 virtual Code::Kind kind() const { | 915 virtual Code::Kind kind() const { |
| 918 return KindBits::decode(bit_field_); | 916 return KindBits::decode(bit_field_); |
| 919 } | 917 } |
| 920 | 918 |
| 921 bool is_inobject() { | 919 FieldIndex index() const { return index_; } |
| 922 return InobjectBits::decode(bit_field_); | |
| 923 } | |
| 924 | |
| 925 int offset() { | |
| 926 int index = IndexBits::decode(bit_field_); | |
| 927 int offset = index * kPointerSize; | |
| 928 if (is_inobject()) return offset; | |
| 929 return FixedArray::kHeaderSize + offset; | |
| 930 } | |
| 931 | 920 |
| 932 bool unboxed_double() { | 921 bool unboxed_double() { |
| 933 return UnboxedDoubleBits::decode(bit_field_); | 922 return index_.is_double(); |
| 934 } | 923 } |
| 935 | 924 |
| 936 virtual Code::StubType GetStubType() { return Code::FAST; } | 925 virtual Code::StubType GetStubType() { return Code::FAST; } |
| 937 | 926 |
| 938 protected: | 927 protected: |
| 939 explicit LoadFieldStub(Isolate* isolate) : HandlerStub(isolate) { } | 928 explicit LoadFieldStub(Isolate* isolate); |
| 940 | 929 |
| 941 void Initialize(Code::Kind kind, | 930 void Initialize(Code::Kind kind) { |
| 942 bool inobject, | 931 int property_index_key = index_.GetLoadFieldStubKey(); |
| 943 int index, | 932 // Save a copy of the essence of the property index into the bit field to |
| 944 Representation representation) { | 933 // make sure that hashing of unique stubs works correctly.. |
| 945 bit_field_ = KindBits::encode(kind) | 934 bit_field_ = KindBits::encode(kind) | |
| 946 | InobjectBits::encode(inobject) | 935 EncodedLoadFieldByIndexBits::encode(property_index_key); |
| 947 | IndexBits::encode(index) | |
| 948 | UnboxedDoubleBits::encode(representation.IsDouble()); | |
| 949 } | 936 } |
| 950 | 937 |
| 951 private: | 938 private: |
| 952 STATIC_ASSERT(KindBits::kSize == 4); | 939 STATIC_ASSERT(KindBits::kSize == 4); |
| 953 class InobjectBits: public BitField<bool, 4, 1> {}; | 940 class EncodedLoadFieldByIndexBits: public BitField<int, 4, 13> {}; |
| 954 class IndexBits: public BitField<int, 5, 11> {}; | |
| 955 class UnboxedDoubleBits: public BitField<bool, 16, 1> {}; | |
| 956 virtual CodeStub::Major MajorKey() { return LoadField; } | 941 virtual CodeStub::Major MajorKey() { return LoadField; } |
| 942 FieldIndex index_; |
| 957 }; | 943 }; |
| 958 | 944 |
| 959 | 945 |
| 960 class StringLengthStub: public HandlerStub { | 946 class StringLengthStub: public HandlerStub { |
| 961 public: | 947 public: |
| 962 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) { | 948 explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) { |
| 963 Initialize(Code::LOAD_IC); | 949 Initialize(Code::LOAD_IC); |
| 964 } | 950 } |
| 965 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 951 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
| 966 virtual void InitializeInterfaceDescriptor( | 952 virtual void InitializeInterfaceDescriptor( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; | 1077 virtual void Generate(MacroAssembler* masm) V8_OVERRIDE; |
| 1092 virtual Major MajorKey() V8_OVERRIDE { return CallApiGetter; } | 1078 virtual Major MajorKey() V8_OVERRIDE { return CallApiGetter; } |
| 1093 virtual int MinorKey() V8_OVERRIDE { return 0; } | 1079 virtual int MinorKey() V8_OVERRIDE { return 0; } |
| 1094 | 1080 |
| 1095 DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub); | 1081 DISALLOW_COPY_AND_ASSIGN(CallApiGetterStub); |
| 1096 }; | 1082 }; |
| 1097 | 1083 |
| 1098 | 1084 |
| 1099 class KeyedLoadFieldStub: public LoadFieldStub { | 1085 class KeyedLoadFieldStub: public LoadFieldStub { |
| 1100 public: | 1086 public: |
| 1101 KeyedLoadFieldStub(Isolate* isolate, | 1087 KeyedLoadFieldStub(Isolate* isolate, FieldIndex index) |
| 1102 bool inobject, | 1088 : LoadFieldStub(isolate, index) { |
| 1103 int index, Representation representation) | 1089 Initialize(Code::KEYED_LOAD_IC); |
| 1104 : LoadFieldStub(isolate) { | |
| 1105 Initialize(Code::KEYED_LOAD_IC, inobject, index, representation); | |
| 1106 } | 1090 } |
| 1107 | 1091 |
| 1108 virtual void InitializeInterfaceDescriptor( | 1092 virtual void InitializeInterfaceDescriptor( |
| 1109 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 1093 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
| 1110 | 1094 |
| 1111 private: | 1095 private: |
| 1112 virtual CodeStub::Major MajorKey() { return KeyedLoadField; } | 1096 virtual CodeStub::Major MajorKey() { return KeyedLoadField; } |
| 1113 }; | 1097 }; |
| 1114 | 1098 |
| 1115 | 1099 |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 | 2459 |
| 2476 | 2460 |
| 2477 class CallDescriptors { | 2461 class CallDescriptors { |
| 2478 public: | 2462 public: |
| 2479 static void InitializeForIsolate(Isolate* isolate); | 2463 static void InitializeForIsolate(Isolate* isolate); |
| 2480 }; | 2464 }; |
| 2481 | 2465 |
| 2482 } } // namespace v8::internal | 2466 } } // namespace v8::internal |
| 2483 | 2467 |
| 2484 #endif // V8_CODE_STUBS_H_ | 2468 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |