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 10729 : Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
32 : int config = KindBits::encode(kNormal);
33 10729 : return handle(Smi::FromInt(config), isolate);
34 : }
35 :
36 12686 : Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
37 : int config = KindBits::encode(kGlobal);
38 12686 : 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 1113685 : Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
47 1113685 : int config = KindBits::encode(kField) |
48 1113685 : IsInobjectBits::encode(field_index.is_inobject()) |
49 1113685 : IsDoubleBits::encode(field_index.is_double()) |
50 2227370 : FieldIndexBits::encode(field_index.index());
51 1113691 : 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 66537 : Handle<Smi> LoadHandler::LoadAccessor(Isolate* isolate, int descriptor) {
60 133074 : int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
61 66537 : return handle(Smi::FromInt(config), isolate);
62 : }
63 :
64 5737 : Handle<Smi> LoadHandler::LoadProxy(Isolate* isolate) {
65 : int config = KindBits::encode(kProxy);
66 5737 : return handle(Smi::FromInt(config), isolate);
67 : }
68 :
69 5845 : Handle<Smi> LoadHandler::LoadNativeDataProperty(Isolate* isolate,
70 : int descriptor) {
71 5845 : int config = KindBits::encode(kNativeDataProperty) |
72 11690 : DescriptorBits::encode(descriptor);
73 5845 : return handle(Smi::FromInt(config), isolate);
74 : }
75 :
76 3581 : Handle<Smi> LoadHandler::LoadApiGetter(Isolate* isolate,
77 : bool holder_is_receiver) {
78 3581 : int config = KindBits::encode(
79 3581 : holder_is_receiver ? kApiGetter : kApiGetterHolderIsPrototype);
80 3581 : 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 76914 : Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
90 : int config = KindBits::encode(kNonExistent);
91 76914 : return handle(Smi::FromInt(config), isolate);
92 : }
93 :
94 147666 : 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 295332 : AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS) |
102 147666 : ElementsKindBits::encode(elements_kind) |
103 147666 : ConvertHoleBits::encode(convert_hole_to_undefined) |
104 147666 : IsJsArrayBits::encode(is_js_array);
105 147666 : return handle(Smi::FromInt(config), isolate);
106 : }
107 :
108 1310 : Handle<Smi> LoadHandler::LoadIndexedString(Isolate* isolate,
109 : KeyedAccessLoadMode load_mode) {
110 : int config =
111 1310 : KindBits::encode(kIndexedString) |
112 2620 : AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS);
113 1310 : return handle(Smi::FromInt(config), isolate);
114 : }
115 :
116 : OBJECT_CONSTRUCTORS_IMPL(StoreHandler, DataHandler)
117 :
118 : CAST_ACCESSOR(StoreHandler)
119 :
120 42135 : Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
121 : int config = KindBits::encode(kGlobalProxy);
122 42135 : return handle(Smi::FromInt(config), isolate);
123 : }
124 :
125 4457 : Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
126 : int config = KindBits::encode(kNormal);
127 4457 : return handle(Smi::FromInt(config), isolate);
128 : }
129 :
130 440 : Handle<Smi> StoreHandler::StoreProxy(Isolate* isolate) {
131 : int config = KindBits::encode(kProxy);
132 440 : return handle(Smi::FromInt(config), isolate);
133 : }
134 :
135 440287 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, Kind kind,
136 : int descriptor, FieldIndex field_index,
137 : Representation representation) {
138 : FieldRepresentation field_rep;
139 440287 : switch (representation.kind()) {
140 : case Representation::kSmi:
141 : field_rep = kSmi;
142 : break;
143 : case Representation::kDouble:
144 : field_rep = kDouble;
145 1326 : break;
146 : case Representation::kHeapObject:
147 : field_rep = kHeapObject;
148 117488 : break;
149 : case Representation::kTagged:
150 : field_rep = kTagged;
151 22148 : break;
152 : default:
153 0 : UNREACHABLE();
154 : }
155 :
156 : DCHECK(kind == kField || (kind == kConstField && FLAG_track_constant_fields));
157 :
158 440287 : int config = KindBits::encode(kind) |
159 440287 : IsInobjectBits::encode(field_index.is_inobject()) |
160 440287 : FieldRepresentationBits::encode(field_rep) |
161 880574 : DescriptorBits::encode(descriptor) |
162 880574 : FieldIndexBits::encode(field_index.index());
163 440285 : 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 : Kind kind = constness == PropertyConstness::kMutable ? kField : kConstField;
173 440286 : return StoreField(isolate, kind, descriptor, field_index, representation);
174 : }
175 :
176 91191 : Handle<Smi> StoreHandler::StoreNativeDataProperty(Isolate* isolate,
177 : int descriptor) {
178 91191 : int config = KindBits::encode(kNativeDataProperty) |
179 182382 : DescriptorBits::encode(descriptor);
180 91191 : return handle(Smi::FromInt(config), isolate);
181 : }
182 :
183 127719 : Handle<Smi> StoreHandler::StoreAccessor(Isolate* isolate, int descriptor) {
184 255438 : int config = KindBits::encode(kAccessor) | DescriptorBits::encode(descriptor);
185 127719 : return handle(Smi::FromInt(config), isolate);
186 : }
187 :
188 359 : Handle<Smi> StoreHandler::StoreApiSetter(Isolate* isolate,
189 : bool holder_is_receiver) {
190 359 : int config = KindBits::encode(
191 359 : holder_is_receiver ? kApiSetter : kApiSetterHolderIsPrototype);
192 359 : 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_
|