OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_IC_HANDLER_CONFIGURATION_H_ | 5 #ifndef V8_IC_HANDLER_CONFIGURATION_H_ |
6 #define V8_IC_HANDLER_CONFIGURATION_H_ | 6 #define V8_IC_HANDLER_CONFIGURATION_H_ |
7 | 7 |
8 #include "src/elements-kind.h" | 8 #include "src/elements-kind.h" |
9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Defines whether negative lookup check should be done on receiver object. | 22 // Defines whether negative lookup check should be done on receiver object. |
23 // Applicable to kForFields, kForConstants and kForNonExistent kinds only when | 23 // Applicable to kForFields, kForConstants and kForNonExistent kinds only when |
24 // loading value from prototype chain. Ignored when loading from holder. | 24 // loading value from prototype chain. Ignored when loading from holder. |
25 class DoNegativeLookupOnReceiverBits | 25 class DoNegativeLookupOnReceiverBits |
26 : public BitField<bool, KindBits::kNext, 1> {}; | 26 : public BitField<bool, KindBits::kNext, 1> {}; |
27 | 27 |
28 // | 28 // |
29 // Encoding when KindBits contains kForConstants. | 29 // Encoding when KindBits contains kForConstants. |
30 // | 30 // |
31 | 31 |
| 32 // Index of a value entry in the descriptor array. |
32 // +2 here is because each descriptor entry occupies 3 slots in array. | 33 // +2 here is because each descriptor entry occupies 3 slots in array. |
33 class DescriptorValueIndexBits | 34 class DescriptorValueIndexBits |
34 : public BitField<unsigned, DoNegativeLookupOnReceiverBits::kNext, | 35 : public BitField<unsigned, DoNegativeLookupOnReceiverBits::kNext, |
35 kDescriptorIndexBitCount + 2> {}; | 36 kDescriptorIndexBitCount + 2> {}; |
36 // Make sure we don't overflow the smi. | 37 // Make sure we don't overflow the smi. |
37 STATIC_ASSERT(DescriptorValueIndexBits::kNext <= kSmiValueSize); | 38 STATIC_ASSERT(DescriptorValueIndexBits::kNext <= kSmiValueSize); |
38 | 39 |
39 // | 40 // |
40 // Encoding when KindBits contains kForFields. | 41 // Encoding when KindBits contains kForFields. |
41 // | 42 // |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Creates a Smi-handler for loading an element. | 95 // Creates a Smi-handler for loading an element. |
95 static inline Handle<Object> LoadElement(Isolate* isolate, | 96 static inline Handle<Object> LoadElement(Isolate* isolate, |
96 ElementsKind elements_kind, | 97 ElementsKind elements_kind, |
97 bool convert_hole_to_undefined, | 98 bool convert_hole_to_undefined, |
98 bool is_js_array); | 99 bool is_js_array); |
99 }; | 100 }; |
100 | 101 |
101 // A set of bit fields representing Smi handlers for stores. | 102 // A set of bit fields representing Smi handlers for stores. |
102 class StoreHandler { | 103 class StoreHandler { |
103 public: | 104 public: |
104 enum Kind { kForElements, kForFields }; | 105 enum Kind { |
105 class KindBits : public BitField<Kind, 0, 1> {}; | 106 kStoreElement, |
| 107 kStoreField, |
| 108 kTransitionToField, |
| 109 kTransitionToConstant |
| 110 }; |
| 111 class KindBits : public BitField<Kind, 0, 2> {}; |
106 | 112 |
107 enum FieldRepresentation { kSmi, kDouble, kHeapObject, kTagged }; | 113 enum FieldRepresentation { kSmi, kDouble, kHeapObject, kTagged }; |
108 | 114 |
| 115 // Applicable to kStoreField, kTransitionToField and kTransitionToConstant |
| 116 // kinds. |
| 117 |
| 118 // Index of a value entry in the descriptor array. |
| 119 // +2 here is because each descriptor entry occupies 3 slots in array. |
| 120 class DescriptorValueIndexBits |
| 121 : public BitField<unsigned, KindBits::kNext, |
| 122 kDescriptorIndexBitCount + 2> {}; |
109 // | 123 // |
110 // Encoding when KindBits contains kForFields. | 124 // Encoding when KindBits contains kTransitionToConstant. |
111 // | 125 // |
112 class IsInobjectBits : public BitField<bool, KindBits::kNext, 1> {}; | 126 |
| 127 // Make sure we don't overflow the smi. |
| 128 STATIC_ASSERT(DescriptorValueIndexBits::kNext <= kSmiValueSize); |
| 129 |
| 130 // |
| 131 // Encoding when KindBits contains kStoreField or kTransitionToField. |
| 132 // |
| 133 class ExtendStorageBits |
| 134 : public BitField<bool, DescriptorValueIndexBits::kNext, 1> {}; |
| 135 class IsInobjectBits : public BitField<bool, ExtendStorageBits::kNext, 1> {}; |
113 class FieldRepresentationBits | 136 class FieldRepresentationBits |
114 : public BitField<FieldRepresentation, IsInobjectBits::kNext, 2> {}; | 137 : public BitField<FieldRepresentation, IsInobjectBits::kNext, 2> {}; |
115 // +2 here is because each descriptor entry occupies 3 slots in array. | |
116 class DescriptorValueIndexBits | |
117 : public BitField<unsigned, FieldRepresentationBits::kNext, | |
118 kDescriptorIndexBitCount + 2> {}; | |
119 // +1 here is to cover all possible JSObject header sizes. | 138 // +1 here is to cover all possible JSObject header sizes. |
120 class FieldOffsetBits | 139 class FieldOffsetBits |
121 : public BitField<unsigned, DescriptorValueIndexBits::kNext, | 140 : public BitField<unsigned, FieldRepresentationBits::kNext, |
122 kDescriptorIndexBitCount + 1 + kPointerSizeLog2> {}; | 141 kDescriptorIndexBitCount + 1 + kPointerSizeLog2> {}; |
123 // Make sure we don't overflow the smi. | 142 // Make sure we don't overflow the smi. |
124 STATIC_ASSERT(FieldOffsetBits::kNext <= kSmiValueSize); | 143 STATIC_ASSERT(FieldOffsetBits::kNext <= kSmiValueSize); |
125 | 144 |
| 145 // The layout of an Tuple3 handler representing a transitioning store |
| 146 // when prototype chain checks do not include non-existing lookups or access |
| 147 // checks. |
| 148 static const int kTransitionCellOffset = Tuple3::kValue1Offset; |
| 149 static const int kSmiHandlerOffset = Tuple3::kValue2Offset; |
| 150 static const int kValidityCellOffset = Tuple3::kValue3Offset; |
| 151 |
| 152 // The layout of an array handler representing a transitioning store |
| 153 // when prototype chain checks include non-existing lookups and access checks. |
| 154 static const int kSmiHandlerIndex = 0; |
| 155 static const int kValidityCellIndex = 1; |
| 156 static const int kTransitionCellIndex = 2; |
| 157 static const int kFirstPrototypeIndex = 3; |
| 158 |
126 // Creates a Smi-handler for storing a field to fast object. | 159 // Creates a Smi-handler for storing a field to fast object. |
127 static inline Handle<Object> StoreField(Isolate* isolate, int descriptor, | 160 static inline Handle<Object> StoreField(Isolate* isolate, int descriptor, |
128 FieldIndex field_index, | 161 FieldIndex field_index, |
129 Representation representation); | 162 Representation representation); |
| 163 |
| 164 // Creates a Smi-handler for transitioning store to a field. |
| 165 static inline Handle<Object> TransitionToField(Isolate* isolate, |
| 166 int descriptor, |
| 167 FieldIndex field_index, |
| 168 Representation representation, |
| 169 bool extend_storage); |
| 170 |
| 171 // Creates a Smi-handler for transitioning store to a constant field (in this |
| 172 // case the only thing that needs to be done is an update of a map). |
| 173 static inline Handle<Object> TransitionToConstant(Isolate* isolate, |
| 174 int descriptor); |
| 175 |
| 176 private: |
| 177 static inline Handle<Object> StoreField(Isolate* isolate, Kind kind, |
| 178 int descriptor, |
| 179 FieldIndex field_index, |
| 180 Representation representation, |
| 181 bool extend_storage); |
130 }; | 182 }; |
131 | 183 |
132 } // namespace internal | 184 } // namespace internal |
133 } // namespace v8 | 185 } // namespace v8 |
134 | 186 |
135 #endif // V8_IC_HANDLER_CONFIGURATION_H_ | 187 #endif // V8_IC_HANDLER_CONFIGURATION_H_ |
OLD | NEW |