| 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 enum LoadHandlerType { |
| 17 kLoadICHandlerForElements = 0, | 17 kLoadICHandlerForElements = 0, |
| 18 kLoadICHandlerForProperties = 1 | 18 kLoadICHandlerForFields = 1, |
| 19 kLoadICHandlerForConstants = 2 |
| 19 }; | 20 }; |
| 20 | 21 |
| 21 class LoadHandlerTypeBit : public BitField<LoadHandlerType, 0, 1> {}; | 22 class LoadHandlerTypeBits : public BitField<LoadHandlerType, 0, 2> {}; |
| 22 | 23 |
| 23 // Encoding for configuration Smis for property loads: | 24 // Encoding for configuration Smis for constants loads (when LoadHandlerTypeBits |
| 25 // contain LoadICHandlerForConstants): |
| 26 class ValueIndexInDescriptorArray |
| 27 : public BitField<int, LoadHandlerTypeBits::kNext, |
| 28 kDescriptorIndexBitCount + 2> {}; |
| 29 // Make sure we don't overflow into the sign bit. |
| 30 STATIC_ASSERT(ValueIndexInDescriptorArray::kNext <= kSmiValueSize - 1); |
| 31 |
| 32 // Encoding for configuration Smis for field loads (when LoadHandlerTypeBits |
| 33 // contain LoadICHandlerForFields): |
| 24 class FieldOffsetIsInobject | 34 class FieldOffsetIsInobject |
| 25 : public BitField<bool, LoadHandlerTypeBit::kNext, 1> {}; | 35 : public BitField<bool, LoadHandlerTypeBits::kNext, 1> {}; |
| 26 class FieldOffsetIsDouble | 36 class FieldOffsetIsDouble |
| 27 : public BitField<bool, FieldOffsetIsInobject::kNext, 1> {}; | 37 : public BitField<bool, FieldOffsetIsInobject::kNext, 1> {}; |
| 28 class FieldOffsetOffset : public BitField<int, FieldOffsetIsDouble::kNext, 27> { | 38 class FieldOffsetOffset : public BitField<int, FieldOffsetIsDouble::kNext, 26> { |
| 29 }; | 39 }; |
| 30 // Make sure we don't overflow into the sign bit. | 40 // Make sure we don't overflow into the sign bit. |
| 31 STATIC_ASSERT(FieldOffsetOffset::kNext <= kSmiValueSize - 1); | 41 STATIC_ASSERT(FieldOffsetOffset::kNext <= kSmiValueSize - 1); |
| 32 | 42 |
| 33 // Encoding for configuration Smis for elements loads: | 43 // Encoding for configuration Smis for elements loads (when LoadHandlerTypeBits |
| 34 class KeyedLoadIsJsArray : public BitField<bool, LoadHandlerTypeBit::kNext, 1> { | 44 // contain LoadICHandlerForElements) |
| 35 }; | 45 class KeyedLoadIsJsArray |
| 46 : public BitField<bool, LoadHandlerTypeBits::kNext, 1> {}; |
| 36 class KeyedLoadConvertHole | 47 class KeyedLoadConvertHole |
| 37 : public BitField<bool, KeyedLoadIsJsArray::kNext, 1> {}; | 48 : public BitField<bool, KeyedLoadIsJsArray::kNext, 1> {}; |
| 38 class KeyedLoadElementsKind | 49 class KeyedLoadElementsKind |
| 39 : public BitField<ElementsKind, KeyedLoadConvertHole::kNext, 8> {}; | 50 : public BitField<ElementsKind, KeyedLoadConvertHole::kNext, 8> {}; |
| 40 // Make sure we don't overflow into the sign bit. | 51 // Make sure we don't overflow into the sign bit. |
| 41 STATIC_ASSERT(KeyedLoadElementsKind::kNext <= kSmiValueSize - 1); | 52 STATIC_ASSERT(KeyedLoadElementsKind::kNext <= kSmiValueSize - 1); |
| 42 | 53 |
| 43 // This class is a collection of factory methods for various Smi-encoded | 54 // This class is a collection of factory methods for various Smi-encoded |
| 44 // IC handlers consumed by respective IC dispatchers. | 55 // IC handlers consumed by respective IC dispatchers. |
| 45 class SmiHandler { | 56 class SmiHandler { |
| 46 public: | 57 public: |
| 47 static inline Handle<Object> MakeLoadFieldHandler(Isolate* isolate, | 58 static inline Handle<Object> MakeLoadFieldHandler(Isolate* isolate, |
| 48 FieldIndex field_index); | 59 FieldIndex field_index); |
| 49 | 60 |
| 61 static inline Handle<Object> MakeLoadConstantHandler(Isolate* isolate, |
| 62 int descriptor); |
| 63 |
| 50 static inline Handle<Object> MakeKeyedLoadHandler( | 64 static inline Handle<Object> MakeKeyedLoadHandler( |
| 51 Isolate* isolate, ElementsKind elements_kind, | 65 Isolate* isolate, ElementsKind elements_kind, |
| 52 bool convert_hole_to_undefined, bool is_js_array); | 66 bool convert_hole_to_undefined, bool is_js_array); |
| 53 }; | 67 }; |
| 54 | 68 |
| 55 } // namespace internal | 69 } // namespace internal |
| 56 } // namespace v8 | 70 } // namespace v8 |
| 57 | 71 |
| 58 #endif // V8_IC_HANDLER_CONFIGURATION_H_ | 72 #endif // V8_IC_HANDLER_CONFIGURATION_H_ |
| OLD | NEW |