Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_IC_HANDLER_CONFIGURATION_INL_H_
6 : #define V8_IC_HANDLER_CONFIGURATION_INL_H_
7 :
8 : #include "src/ic/handler-configuration.h"
9 :
10 : #include "src/field-index-inl.h"
11 : #include "src/handles-inl.h"
12 : #include "src/objects-inl.h"
13 : #include "src/objects/data-handler-inl.h"
14 : #include "src/objects/smi.h"
15 :
16 : // Has to be the last include (doesn't have include guards):
17 : #include "src/objects/object-macros.h"
18 :
19 : namespace v8 {
20 : namespace internal {
21 :
22 : OBJECT_CONSTRUCTORS_IMPL(LoadHandler, DataHandler)
23 :
24 : CAST_ACCESSOR(LoadHandler)
25 :
26 : // Decodes kind from Smi-handler.
27 : LoadHandler::Kind LoadHandler::GetHandlerKind(Smi smi_handler) {
28 : return KindBits::decode(smi_handler->value());
29 : }
30 :
31 11037 : Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
32 : int config = KindBits::encode(kNormal);
33 11037 : return handle(Smi::FromInt(config), isolate);
34 : }
35 :
36 12720 : Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
37 : int config = KindBits::encode(kGlobal);
38 12720 : return handle(Smi::FromInt(config), isolate);
39 : }
40 :
41 821 : Handle<Smi> LoadHandler::LoadInterceptor(Isolate* isolate) {
42 : int config = KindBits::encode(kInterceptor);
43 821 : return handle(Smi::FromInt(config), isolate);
44 : }
45 :
46 1096265 : Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
47 1096265 : int config = KindBits::encode(kField) |
48 1096265 : IsInobjectBits::encode(field_index.is_inobject()) |
49 1096265 : IsDoubleBits::encode(field_index.is_double()) |
50 2192530 : FieldIndexBits::encode(field_index.index());
51 1096268 : return handle(Smi::FromInt(config), isolate);
52 : }
53 :
54 0 : Handle<Smi> LoadHandler::LoadConstant(Isolate* isolate, int descriptor) {
55 0 : int config = KindBits::encode(kConstant) | DescriptorBits::encode(descriptor);
56 0 : return handle(Smi::FromInt(config), isolate);
57 : }
58 :
59 66546 : Handle<Smi> LoadHandler::LoadAccessor(Isolate* isolate, int descriptor) {
60 133092 : int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
61 66546 : return handle(Smi::FromInt(config), isolate);
62 : }
63 :
64 5712 : Handle<Smi> LoadHandler::LoadProxy(Isolate* isolate) {
65 : int config = KindBits::encode(kProxy);
66 5712 : return handle(Smi::FromInt(config), isolate);
67 : }
68 :
69 5735 : Handle<Smi> LoadHandler::LoadNativeDataProperty(Isolate* isolate,
70 : int descriptor) {
71 5735 : int config = KindBits::encode(kNativeDataProperty) |
72 11470 : DescriptorBits::encode(descriptor);
73 5735 : return handle(Smi::FromInt(config), isolate);
74 : }
75 :
76 3579 : Handle<Smi> LoadHandler::LoadApiGetter(Isolate* isolate,
77 : bool holder_is_receiver) {
78 3579 : int config = KindBits::encode(
79 3579 : holder_is_receiver ? kApiGetter : kApiGetterHolderIsPrototype);
80 3579 : return handle(Smi::FromInt(config), isolate);
81 : }
82 :
83 19884 : Handle<Smi> LoadHandler::LoadModuleExport(Isolate* isolate, int index) {
84 : int config =
85 39768 : KindBits::encode(kModuleExport) | ExportsIndexBits::encode(index);
86 19884 : return handle(Smi::FromInt(config), isolate);
87 : }
88 :
89 75876 : Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
90 : int config = KindBits::encode(kNonExistent);
91 75876 : return handle(Smi::FromInt(config), isolate);
92 : }
93 :
94 142292 : Handle<Smi> LoadHandler::LoadElement(Isolate* isolate,
95 : ElementsKind elements_kind,
96 : bool convert_hole_to_undefined,
97 : bool is_js_array,
98 : KeyedAccessLoadMode load_mode) {
99 : int config =
100 : KindBits::encode(kElement) |
101 284584 : AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS) |
102 142292 : ElementsKindBits::encode(elements_kind) |
103 142292 : ConvertHoleBits::encode(convert_hole_to_undefined) |
104 142292 : IsJsArrayBits::encode(is_js_array);
105 142292 : return handle(Smi::FromInt(config), isolate);
106 : }
107 :
108 1292 : Handle<Smi> LoadHandler::LoadIndexedString(Isolate* isolate,
109 : KeyedAccessLoadMode load_mode) {
110 : int config =
111 1292 : KindBits::encode(kIndexedString) |
112 2584 : AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS);
113 1292 : return handle(Smi::FromInt(config), isolate);
114 : }
115 :
116 : OBJECT_CONSTRUCTORS_IMPL(StoreHandler, DataHandler)
117 :
118 : CAST_ACCESSOR(StoreHandler)
119 :
120 42086 : Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
121 : int config = KindBits::encode(kGlobalProxy);
122 42086 : return handle(Smi::FromInt(config), isolate);
123 : }
124 :
125 4487 : Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
126 : int config = KindBits::encode(kNormal);
127 4487 : return handle(Smi::FromInt(config), isolate);
128 : }
129 :
130 443 : Handle<Smi> StoreHandler::StoreProxy(Isolate* isolate) {
131 : int config = KindBits::encode(kProxy);
132 443 : return handle(Smi::FromInt(config), isolate);
133 : }
134 :
135 438925 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, Kind kind,
136 : int descriptor, FieldIndex field_index,
137 : Representation representation) {
138 : FieldRepresentation field_rep;
139 438925 : switch (representation.kind()) {
140 : case Representation::kSmi:
141 : field_rep = kSmi;
142 : break;
143 : case Representation::kDouble:
144 : field_rep = kDouble;
145 1304 : break;
146 : case Representation::kHeapObject:
147 : field_rep = kHeapObject;
148 116843 : break;
149 : case Representation::kTagged:
150 : field_rep = kTagged;
151 22487 : break;
152 : default:
153 0 : UNREACHABLE();
154 : }
155 :
156 : DCHECK(kind == kField || (kind == kConstField && FLAG_track_constant_fields));
157 :
158 438925 : int config = KindBits::encode(kind) |
159 438925 : IsInobjectBits::encode(field_index.is_inobject()) |
160 438925 : FieldRepresentationBits::encode(field_rep) |
161 877850 : DescriptorBits::encode(descriptor) |
162 877850 : FieldIndexBits::encode(field_index.index());
163 438924 : return handle(Smi::FromInt(config), isolate);
164 : }
165 :
166 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, int descriptor,
167 : FieldIndex field_index,
168 : PropertyConstness constness,
169 : Representation representation) {
170 : DCHECK_IMPLIES(!FLAG_track_constant_fields,
171 : constness == PropertyConstness::kMutable);
172 438925 : Kind kind = constness == PropertyConstness::kMutable ? kField : kConstField;
173 438925 : return StoreField(isolate, kind, descriptor, field_index, representation);
174 : }
175 :
176 91182 : Handle<Smi> StoreHandler::StoreNativeDataProperty(Isolate* isolate,
177 : int descriptor) {
178 91182 : int config = KindBits::encode(kNativeDataProperty) |
179 182364 : DescriptorBits::encode(descriptor);
180 91182 : return handle(Smi::FromInt(config), isolate);
181 : }
182 :
183 127677 : Handle<Smi> StoreHandler::StoreAccessor(Isolate* isolate, int descriptor) {
184 255354 : int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
185 127677 : return handle(Smi::FromInt(config), isolate);
186 : }
187 :
188 351 : Handle<Smi> StoreHandler::StoreApiSetter(Isolate* isolate,
189 : bool holder_is_receiver) {
190 351 : int config = KindBits::encode(
191 351 : holder_is_receiver ? kApiSetter : kApiSetterHolderIsPrototype);
192 351 : return handle(Smi::FromInt(config), isolate);
193 : }
194 :
195 : } // namespace internal
196 : } // namespace v8
197 :
198 : #include "src/objects/object-macros-undef.h"
199 :
200 : #endif // V8_IC_HANDLER_CONFIGURATION_INL_H_
|