V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
handler-configuration-inl.h
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/smi.h"
14 
15 // Has to be the last include (doesn't have include guards):
16 #include "src/objects/object-macros.h"
17 
18 namespace v8 {
19 namespace internal {
20 
21 CAST_ACCESSOR(LoadHandler)
22 
23 // Decodes kind from Smi-handler.
24 LoadHandler::Kind LoadHandler::GetHandlerKind(Smi smi_handler) {
25  return KindBits::decode(smi_handler->value());
26 }
27 
28 Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
29  int config = KindBits::encode(kNormal);
30  return handle(Smi::FromInt(config), isolate);
31 }
32 
33 Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
34  int config = KindBits::encode(kGlobal);
35  return handle(Smi::FromInt(config), isolate);
36 }
37 
38 Handle<Smi> LoadHandler::LoadInterceptor(Isolate* isolate) {
39  int config = KindBits::encode(kInterceptor);
40  return handle(Smi::FromInt(config), isolate);
41 }
42 
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);
49 }
50 
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);
54 }
55 
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);
59 }
60 
61 Handle<Smi> LoadHandler::LoadProxy(Isolate* isolate) {
62  int config = KindBits::encode(kProxy);
63  return handle(Smi::FromInt(config), isolate);
64 }
65 
66 Handle<Smi> LoadHandler::LoadNativeDataProperty(Isolate* isolate,
67  int descriptor) {
68  int config = KindBits::encode(kNativeDataProperty) |
69  DescriptorBits::encode(descriptor);
70  return handle(Smi::FromInt(config), isolate);
71 }
72 
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);
78 }
79 
80 Handle<Smi> LoadHandler::LoadModuleExport(Isolate* isolate, int index) {
81  int config =
82  KindBits::encode(kModuleExport) | ExportsIndexBits::encode(index);
83  return handle(Smi::FromInt(config), isolate);
84 }
85 
86 Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
87  int config = KindBits::encode(kNonExistent);
88  return handle(Smi::FromInt(config), isolate);
89 }
90 
91 Handle<Smi> LoadHandler::LoadElement(Isolate* isolate,
92  ElementsKind elements_kind,
93  bool convert_hole_to_undefined,
94  bool is_js_array,
95  KeyedAccessLoadMode load_mode) {
96  int config =
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);
103 }
104 
105 Handle<Smi> LoadHandler::LoadIndexedString(Isolate* isolate,
106  KeyedAccessLoadMode load_mode) {
107  int config =
108  KindBits::encode(kIndexedString) |
109  AllowOutOfBoundsBits::encode(load_mode == LOAD_IGNORE_OUT_OF_BOUNDS);
110  return handle(Smi::FromInt(config), isolate);
111 }
112 
113 CAST_ACCESSOR(StoreHandler)
114 
115 Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
116  int config = KindBits::encode(kGlobalProxy);
117  return handle(Smi::FromInt(config), isolate);
118 }
119 
120 Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
121  int config = KindBits::encode(kNormal);
122  return handle(Smi::FromInt(config), isolate);
123 }
124 
125 Handle<Smi> StoreHandler::StoreProxy(Isolate* isolate) {
126  int config = KindBits::encode(kProxy);
127  return handle(Smi::FromInt(config), isolate);
128 }
129 
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:
136  field_rep = kSmi;
137  break;
138  case Representation::kDouble:
139  field_rep = kDouble;
140  break;
141  case Representation::kHeapObject:
142  field_rep = kHeapObject;
143  break;
144  case Representation::kTagged:
145  field_rep = kTagged;
146  break;
147  default:
148  UNREACHABLE();
149  }
150 
151  DCHECK(kind == kField || (kind == kConstField && FLAG_track_constant_fields));
152 
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);
159 }
160 
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);
169 }
170 
171 Handle<Smi> StoreHandler::StoreNativeDataProperty(Isolate* isolate,
172  int descriptor) {
173  int config = KindBits::encode(kNativeDataProperty) |
174  DescriptorBits::encode(descriptor);
175  return handle(Smi::FromInt(config), isolate);
176 }
177 
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);
181 }
182 
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);
188 }
189 
190 } // namespace internal
191 } // namespace v8
192 
193 #include "src/objects/object-macros-undef.h"
194 
195 #endif // V8_IC_HANDLER_CONFIGURATION_INL_H_
Definition: libplatform.h:13