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 873598 : OBJECT_CONSTRUCTORS_IMPL(LoadHandler, DataHandler)
23 :
24 436800 : 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 10477 : Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
32 : int config = KindBits::encode(kNormal);
33 10477 : return handle(Smi::FromInt(config), isolate);
34 : }
35 :
36 12698 : Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
37 : int config = KindBits::encode(kGlobal);
38 12698 : return handle(Smi::FromInt(config), isolate);
39 : }
40 :
41 791 : Handle<Smi> LoadHandler::LoadInterceptor(Isolate* isolate) {
42 : int config = KindBits::encode(kInterceptor);
43 791 : return handle(Smi::FromInt(config), isolate);
44 : }
45 :
46 1029167 : Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
47 1029167 : int config = KindBits::encode(kField) |
48 1029167 : IsInobjectBits::encode(field_index.is_inobject()) |
49 1029167 : IsDoubleBits::encode(field_index.is_double()) |
50 2058334 : FieldIndexBits::encode(field_index.index());
51 1029168 : 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 59380 : Handle<Smi> LoadHandler::LoadAccessor(Isolate* isolate, int descriptor) {
60 118760 : int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
61 59380 : return handle(Smi::FromInt(config), isolate);
62 : }
63 :
64 5196 : Handle<Smi> LoadHandler::LoadProxy(Isolate* isolate) {
65 : int config = KindBits::encode(kProxy);
66 5196 : return handle(Smi::FromInt(config), isolate);
67 : }
68 :
69 5602 : Handle<Smi> LoadHandler::LoadNativeDataProperty(Isolate* isolate,
70 : int descriptor) {
71 5602 : int config = KindBits::encode(kNativeDataProperty) |
72 11204 : DescriptorBits::encode(descriptor);
73 5602 : return handle(Smi::FromInt(config), isolate);
74 : }
75 :
76 3534 : Handle<Smi> LoadHandler::LoadApiGetter(Isolate* isolate,
77 : bool holder_is_receiver) {
78 : int config = KindBits::encode(
79 3534 : holder_is_receiver ? kApiGetter : kApiGetterHolderIsPrototype);
80 3535 : return handle(Smi::FromInt(config), isolate);
81 : }
82 :
83 19849 : Handle<Smi> LoadHandler::LoadModuleExport(Isolate* isolate, int index) {
84 : int config =
85 39698 : KindBits::encode(kModuleExport) | ExportsIndexBits::encode(index);
86 19849 : return handle(Smi::FromInt(config), isolate);
87 : }
88 :
89 73896 : Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
90 : int config = KindBits::encode(kNonExistent);
91 73896 : return handle(Smi::FromInt(config), isolate);
92 : }
93 :
94 149301 : 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 298602 : AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS) |
102 149301 : ElementsKindBits::encode(elements_kind) |
103 149301 : ConvertHoleBits::encode(convert_hole_to_undefined) |
104 149301 : IsJsArrayBits::encode(is_js_array);
105 149301 : 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 491326 : OBJECT_CONSTRUCTORS_IMPL(StoreHandler, DataHandler)
117 :
118 245663 : CAST_ACCESSOR(StoreHandler)
119 :
120 41981 : Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
121 : int config = KindBits::encode(kGlobalProxy);
122 41981 : return handle(Smi::FromInt(config), isolate);
123 : }
124 :
125 4486 : Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
126 : int config = KindBits::encode(kNormal);
127 4486 : return handle(Smi::FromInt(config), isolate);
128 : }
129 :
130 448 : Handle<Smi> StoreHandler::StoreProxy(Isolate* isolate) {
131 : int config = KindBits::encode(kProxy);
132 448 : return handle(Smi::FromInt(config), isolate);
133 : }
134 :
135 426688 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, Kind kind,
136 : int descriptor, FieldIndex field_index,
137 : Representation representation) {
138 : FieldRepresentation field_rep;
139 426688 : switch (representation.kind()) {
140 : case Representation::kSmi:
141 : field_rep = kSmi;
142 : break;
143 : case Representation::kDouble:
144 : field_rep = kDouble;
145 1268 : break;
146 : case Representation::kHeapObject:
147 : field_rep = kHeapObject;
148 134282 : break;
149 : case Representation::kTagged:
150 : field_rep = kTagged;
151 4193 : break;
152 : default:
153 0 : UNREACHABLE();
154 : }
155 :
156 : DCHECK(kind == kField || (kind == kConstField && FLAG_track_constant_fields));
157 :
158 426688 : int config = KindBits::encode(kind) |
159 426688 : IsInobjectBits::encode(field_index.is_inobject()) |
160 426688 : FieldRepresentationBits::encode(field_rep) |
161 853376 : DescriptorBits::encode(descriptor) |
162 853376 : FieldIndexBits::encode(field_index.index());
163 426688 : 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 426688 : Kind kind = constness == PropertyConstness::kMutable ? kField : kConstField;
173 426688 : return StoreField(isolate, kind, descriptor, field_index, representation);
174 : }
175 :
176 91180 : Handle<Smi> StoreHandler::StoreNativeDataProperty(Isolate* isolate,
177 : int descriptor) {
178 91180 : int config = KindBits::encode(kNativeDataProperty) |
179 182360 : DescriptorBits::encode(descriptor);
180 91180 : return handle(Smi::FromInt(config), isolate);
181 : }
182 :
183 127671 : Handle<Smi> StoreHandler::StoreAccessor(Isolate* isolate, int descriptor) {
184 255342 : int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
185 127671 : return handle(Smi::FromInt(config), isolate);
186 : }
187 :
188 351 : Handle<Smi> StoreHandler::StoreApiSetter(Isolate* isolate,
189 : bool holder_is_receiver) {
190 : 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_
|