5 #ifndef V8_IC_HANDLER_CONFIGURATION_INL_H_ 6 #define V8_IC_HANDLER_CONFIGURATION_INL_H_ 8 #include "src/ic/handler-configuration.h" 10 #include "src/field-index-inl.h" 11 #include "src/handles-inl.h" 12 #include "src/objects-inl.h" 13 #include "src/objects/smi.h" 16 #include "src/objects/object-macros.h" 21 CAST_ACCESSOR(LoadHandler)
24 LoadHandler::Kind LoadHandler::GetHandlerKind(Smi smi_handler) {
25 return KindBits::decode(smi_handler->value());
28 Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
29 int config = KindBits::encode(kNormal);
30 return handle(Smi::FromInt(config), isolate);
33 Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
34 int config = KindBits::encode(kGlobal);
35 return handle(Smi::FromInt(config), isolate);
38 Handle<Smi> LoadHandler::LoadInterceptor(Isolate* isolate) {
39 int config = KindBits::encode(kInterceptor);
40 return handle(Smi::FromInt(config), isolate);
43 Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
44 int config = KindBits::encode(kField) |
45 IsInobjectBits::encode(field_index.is_inobject()) |
46 IsDoubleBits::encode(field_index.is_double()) |
47 FieldIndexBits::encode(field_index.index());
48 return handle(Smi::FromInt(config), isolate);
51 Handle<Smi> LoadHandler::LoadConstant(Isolate* isolate,
int descriptor) {
52 int config = KindBits::encode(kConstant) | DescriptorBits::encode(descriptor);
53 return handle(Smi::FromInt(config), isolate);
56 Handle<Smi> LoadHandler::LoadAccessor(Isolate* isolate,
int descriptor) {
57 int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
58 return handle(Smi::FromInt(config), isolate);
61 Handle<Smi> LoadHandler::LoadProxy(Isolate* isolate) {
62 int config = KindBits::encode(kProxy);
63 return handle(Smi::FromInt(config), isolate);
66 Handle<Smi> LoadHandler::LoadNativeDataProperty(Isolate* isolate,
68 int config = KindBits::encode(kNativeDataProperty) |
69 DescriptorBits::encode(descriptor);
70 return handle(Smi::FromInt(config), isolate);
73 Handle<Smi> LoadHandler::LoadApiGetter(Isolate* isolate,
74 bool holder_is_receiver) {
75 int config = KindBits::encode(
76 holder_is_receiver ? kApiGetter : kApiGetterHolderIsPrototype);
77 return handle(Smi::FromInt(config), isolate);
80 Handle<Smi> LoadHandler::LoadModuleExport(Isolate* isolate,
int index) {
82 KindBits::encode(kModuleExport) | ExportsIndexBits::encode(index);
83 return handle(Smi::FromInt(config), isolate);
86 Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
87 int config = KindBits::encode(kNonExistent);
88 return handle(Smi::FromInt(config), isolate);
91 Handle<Smi> LoadHandler::LoadElement(Isolate* isolate,
92 ElementsKind elements_kind,
93 bool convert_hole_to_undefined,
95 KeyedAccessLoadMode load_mode) {
97 KindBits::encode(kElement) |
98 AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS) |
99 ElementsKindBits::encode(elements_kind) |
100 ConvertHoleBits::encode(convert_hole_to_undefined) |
101 IsJsArrayBits::encode(is_js_array);
102 return handle(Smi::FromInt(config), isolate);
105 Handle<Smi> LoadHandler::LoadIndexedString(Isolate* isolate,
106 KeyedAccessLoadMode load_mode) {
108 KindBits::encode(kIndexedString) |
109 AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS);
110 return handle(Smi::FromInt(config), isolate);
113 CAST_ACCESSOR(StoreHandler)
115 Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
116 int config = KindBits::encode(kGlobalProxy);
117 return handle(Smi::FromInt(config), isolate);
120 Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
121 int config = KindBits::encode(kNormal);
122 return handle(Smi::FromInt(config), isolate);
125 Handle<Smi> StoreHandler::StoreProxy(Isolate* isolate) {
126 int config = KindBits::encode(kProxy);
127 return handle(Smi::FromInt(config), isolate);
130 Handle<Smi> StoreHandler::StoreField(Isolate* isolate, Kind kind,
131 int descriptor, FieldIndex field_index,
132 Representation representation) {
133 FieldRepresentation field_rep;
134 switch (representation.kind()) {
135 case Representation::kSmi:
138 case Representation::kDouble:
141 case Representation::kHeapObject:
142 field_rep = kHeapObject;
144 case Representation::kTagged:
151 DCHECK(kind == kField || (kind == kConstField && FLAG_track_constant_fields));
153 int config = KindBits::encode(kind) |
154 IsInobjectBits::encode(field_index.is_inobject()) |
155 FieldRepresentationBits::encode(field_rep) |
156 DescriptorBits::encode(descriptor) |
157 FieldIndexBits::encode(field_index.index());
158 return handle(Smi::FromInt(config), isolate);
161 Handle<Smi> StoreHandler::StoreField(Isolate* isolate,
int descriptor,
162 FieldIndex field_index,
163 PropertyConstness constness,
164 Representation representation) {
165 DCHECK_IMPLIES(!FLAG_track_constant_fields,
166 constness == PropertyConstness::kMutable);
167 Kind kind = constness == PropertyConstness::kMutable ? kField : kConstField;
168 return StoreField(isolate, kind, descriptor, field_index, representation);
171 Handle<Smi> StoreHandler::StoreNativeDataProperty(Isolate* isolate,
173 int config = KindBits::encode(kNativeDataProperty) |
174 DescriptorBits::encode(descriptor);
175 return handle(Smi::FromInt(config), isolate);
178 Handle<Smi> StoreHandler::StoreAccessor(Isolate* isolate,
int descriptor) {
179 int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
180 return handle(Smi::FromInt(config), isolate);
183 Handle<Smi> StoreHandler::StoreApiSetter(Isolate* isolate,
184 bool holder_is_receiver) {
185 int config = KindBits::encode(
186 holder_is_receiver ? kApiSetter : kApiSetterHolderIsPrototype);
187 return handle(Smi::FromInt(config), isolate);
193 #include "src/objects/object-macros-undef.h" 195 #endif // V8_IC_HANDLER_CONFIGURATION_INL_H_