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" |
11 #include "src/utils.h" | 11 #include "src/utils.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 enum LoadHandlerType { | 16 // A set of bit fields representing Smi handlers for loads. |
17 kLoadICHandlerForElements = 0, | 17 class LoadHandler { |
18 kLoadICHandlerForFields = 1, | 18 public: |
19 kLoadICHandlerForConstants = 2 | 19 enum Kind { kForElements, kForFields, kForConstants }; |
20 }; | 20 class KindBits : public BitField<Kind, 0, 2> {}; |
21 | 21 |
22 class LoadHandlerTypeBits : public BitField<LoadHandlerType, 0, 2> {}; | 22 // |
| 23 // Encoding when KindBits contains kForConstants. |
| 24 // |
23 | 25 |
24 // Encoding for configuration Smis for constants loads (when LoadHandlerTypeBits | 26 // +2 here is because each descriptor entry occupies 3 slots in array. |
25 // contain LoadICHandlerForConstants): | 27 class DescriptorValueIndexBits |
26 class ValueIndexInDescriptorArray | 28 : public BitField<unsigned, KindBits::kNext, |
27 : public BitField<int, LoadHandlerTypeBits::kNext, | 29 kDescriptorIndexBitCount + 2> {}; |
28 kDescriptorIndexBitCount + 2> {}; | 30 // Make sure we don't overflow the smi. |
29 // Make sure we don't overflow into the sign bit. | 31 STATIC_ASSERT(DescriptorValueIndexBits::kNext <= kSmiValueSize); |
30 STATIC_ASSERT(ValueIndexInDescriptorArray::kNext <= kSmiValueSize - 1); | |
31 | 32 |
32 // Encoding for configuration Smis for field loads (when LoadHandlerTypeBits | 33 // |
33 // contain LoadICHandlerForFields): | 34 // Encoding when KindBits contains kForFields. |
34 class FieldOffsetIsInobject | 35 // |
35 : public BitField<bool, LoadHandlerTypeBits::kNext, 1> {}; | 36 class IsInobjectBits : public BitField<bool, KindBits::kNext, 1> {}; |
36 class FieldOffsetIsDouble | 37 class IsDoubleBits : public BitField<bool, IsInobjectBits::kNext, 1> {}; |
37 : public BitField<bool, FieldOffsetIsInobject::kNext, 1> {}; | 38 // +1 here is to cover all possible JSObject header sizes. |
38 class FieldOffsetOffset : public BitField<int, FieldOffsetIsDouble::kNext, 26> { | 39 class FieldOffsetBits |
39 }; | 40 : public BitField<unsigned, IsDoubleBits::kNext, |
40 // Make sure we don't overflow into the sign bit. | 41 kDescriptorIndexBitCount + 1 + kPointerSizeLog2> {}; |
41 STATIC_ASSERT(FieldOffsetOffset::kNext <= kSmiValueSize - 1); | 42 // Make sure we don't overflow the smi. |
| 43 STATIC_ASSERT(FieldOffsetBits::kNext <= kSmiValueSize); |
42 | 44 |
43 // Encoding for configuration Smis for elements loads (when LoadHandlerTypeBits | 45 // |
44 // contain LoadICHandlerForElements) | 46 // Encoding when KindBits contains kForElements. |
45 class KeyedLoadIsJsArray | 47 // |
46 : public BitField<bool, LoadHandlerTypeBits::kNext, 1> {}; | 48 class IsJsArrayBits : public BitField<bool, KindBits::kNext, 1> {}; |
47 class KeyedLoadConvertHole | 49 class ConvertHoleBits : public BitField<bool, IsJsArrayBits::kNext, 1> {}; |
48 : public BitField<bool, KeyedLoadIsJsArray::kNext, 1> {}; | 50 class ElementsKindBits |
49 class KeyedLoadElementsKind | 51 : public BitField<ElementsKind, ConvertHoleBits::kNext, 8> {}; |
50 : public BitField<ElementsKind, KeyedLoadConvertHole::kNext, 8> {}; | 52 // Make sure we don't overflow the smi. |
51 // Make sure we don't overflow into the sign bit. | 53 STATIC_ASSERT(ElementsKindBits::kNext <= kSmiValueSize); |
52 STATIC_ASSERT(KeyedLoadElementsKind::kNext <= kSmiValueSize - 1); | |
53 | 54 |
54 // This class is a collection of factory methods for various Smi-encoded | 55 // Creates a Smi-handler for loading a field from fast object. |
55 // IC handlers consumed by respective IC dispatchers. | 56 static inline Handle<Object> LoadField(Isolate* isolate, |
56 class SmiHandler { | 57 FieldIndex field_index); |
57 public: | |
58 static inline Handle<Object> MakeLoadFieldHandler(Isolate* isolate, | |
59 FieldIndex field_index); | |
60 | 58 |
61 static inline Handle<Object> MakeLoadConstantHandler(Isolate* isolate, | 59 // Creates a Smi-handler for loading a constant from fast object. |
62 int descriptor); | 60 static inline Handle<Object> LoadConstant(Isolate* isolate, int descriptor); |
63 | 61 |
64 static inline Handle<Object> MakeKeyedLoadHandler( | 62 // Creates a Smi-handler for loading an element. |
65 Isolate* isolate, ElementsKind elements_kind, | 63 static inline Handle<Object> LoadElement(Isolate* isolate, |
66 bool convert_hole_to_undefined, bool is_js_array); | 64 ElementsKind elements_kind, |
| 65 bool convert_hole_to_undefined, |
| 66 bool is_js_array); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace internal | 69 } // namespace internal |
70 } // namespace v8 | 70 } // namespace v8 |
71 | 71 |
72 #endif // V8_IC_HANDLER_CONFIGURATION_H_ | 72 #endif // V8_IC_HANDLER_CONFIGURATION_H_ |
OLD | NEW |