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/objects-inl.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 39221 : Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
17 : int config = KindBits::encode(kNormal);
18 39221 : return handle(Smi::FromInt(config), isolate);
19 : }
20 :
21 18898 : Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
22 : int config = KindBits::encode(kGlobal);
23 18898 : return handle(Smi::FromInt(config), isolate);
24 : }
25 :
26 20062 : Handle<Smi> LoadHandler::LoadInterceptor(Isolate* isolate) {
27 : int config = KindBits::encode(kInterceptor);
28 20062 : return handle(Smi::FromInt(config), isolate);
29 : }
30 :
31 2055965 : Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
32 2055965 : int config = KindBits::encode(kField) |
33 2055965 : IsInobjectBits::encode(field_index.is_inobject()) |
34 2055965 : IsDoubleBits::encode(field_index.is_double()) |
35 4111930 : FieldOffsetBits::encode(field_index.offset());
36 2055965 : return handle(Smi::FromInt(config), isolate);
37 : }
38 :
39 1380082 : Handle<Smi> LoadHandler::LoadConstant(Isolate* isolate, int descriptor) {
40 1380082 : int config = KindBits::encode(kConstant) | IsAccessorInfoBits::encode(false) |
41 2760164 : DescriptorBits::encode(descriptor);
42 1380082 : return handle(Smi::FromInt(config), isolate);
43 : }
44 :
45 96135 : Handle<Smi> LoadHandler::LoadAccessor(Isolate* isolate, int descriptor) {
46 96135 : int config = KindBits::encode(kAccessor) | IsAccessorInfoBits::encode(false) |
47 192270 : DescriptorBits::encode(descriptor);
48 96135 : return handle(Smi::FromInt(config), isolate);
49 : }
50 :
51 17898 : Handle<Smi> LoadHandler::LoadApiGetter(Isolate* isolate, int descriptor) {
52 17898 : int config = KindBits::encode(kConstant) | IsAccessorInfoBits::encode(true) |
53 35796 : DescriptorBits::encode(descriptor);
54 17898 : return handle(Smi::FromInt(config), isolate);
55 : }
56 :
57 55822 : Handle<Smi> LoadHandler::EnableAccessCheckOnReceiver(Isolate* isolate,
58 : Handle<Smi> smi_handler) {
59 : int config = smi_handler->value();
60 : #ifdef DEBUG
61 : Kind kind = KindBits::decode(config);
62 : DCHECK_NE(kElement, kind);
63 : #endif
64 111644 : config = DoAccessCheckOnReceiverBits::update(config, true);
65 55822 : return handle(Smi::FromInt(config), isolate);
66 : }
67 :
68 2130 : Handle<Smi> LoadHandler::EnableLookupOnReceiver(Isolate* isolate,
69 : Handle<Smi> smi_handler) {
70 : int config = smi_handler->value();
71 : #ifdef DEBUG
72 : Kind kind = KindBits::decode(config);
73 : DCHECK_NE(kElement, kind);
74 : #endif
75 4260 : config = LookupOnReceiverBits::update(config, true);
76 2130 : return handle(Smi::FromInt(config), isolate);
77 : }
78 :
79 277616 : Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
80 : int config = KindBits::encode(kNonExistent);
81 277616 : return handle(Smi::FromInt(config), isolate);
82 : }
83 :
84 428024 : Handle<Smi> LoadHandler::LoadElement(Isolate* isolate,
85 : ElementsKind elements_kind,
86 : bool convert_hole_to_undefined,
87 : bool is_js_array) {
88 : int config = KindBits::encode(kElement) |
89 428024 : ElementsKindBits::encode(elements_kind) |
90 428024 : ConvertHoleBits::encode(convert_hole_to_undefined) |
91 428024 : IsJsArrayBits::encode(is_js_array);
92 428024 : return handle(Smi::FromInt(config), isolate);
93 : }
94 :
95 24055 : Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
96 : int config = KindBits::encode(kStoreNormal);
97 24055 : return handle(Smi::FromInt(config), isolate);
98 : }
99 :
100 1515680 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, Kind kind,
101 : int descriptor, FieldIndex field_index,
102 : Representation representation,
103 : bool extend_storage) {
104 : StoreHandler::FieldRepresentation field_rep;
105 1515680 : switch (representation.kind()) {
106 : case Representation::kSmi:
107 : field_rep = StoreHandler::kSmi;
108 : break;
109 : case Representation::kDouble:
110 : field_rep = StoreHandler::kDouble;
111 5821 : break;
112 : case Representation::kHeapObject:
113 : field_rep = StoreHandler::kHeapObject;
114 991772 : break;
115 : case Representation::kTagged:
116 : field_rep = StoreHandler::kTagged;
117 34719 : break;
118 : default:
119 0 : UNREACHABLE();
120 : return Handle<Smi>::null();
121 : }
122 :
123 : DCHECK(kind == kStoreField || kind == kTransitionToField ||
124 : (kind == kStoreConstField && FLAG_track_constant_fields));
125 : DCHECK_IMPLIES(extend_storage, kind == kTransitionToField);
126 : DCHECK_IMPLIES(field_index.is_inobject(), !extend_storage);
127 :
128 1515680 : int config = StoreHandler::KindBits::encode(kind) |
129 1515680 : StoreHandler::ExtendStorageBits::encode(extend_storage) |
130 1515680 : StoreHandler::IsInobjectBits::encode(field_index.is_inobject()) |
131 1515680 : StoreHandler::FieldRepresentationBits::encode(field_rep) |
132 3031360 : StoreHandler::DescriptorBits::encode(descriptor) |
133 3031360 : StoreHandler::FieldOffsetBits::encode(field_index.offset());
134 : return handle(Smi::FromInt(config), isolate);
135 : }
136 :
137 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, int descriptor,
138 : FieldIndex field_index,
139 : PropertyConstness constness,
140 : Representation representation) {
141 : DCHECK_IMPLIES(!FLAG_track_constant_fields, constness == kMutable);
142 329326 : Kind kind = constness == kMutable ? kStoreField : kStoreConstField;
143 : return StoreField(isolate, kind, descriptor, field_index, representation,
144 329326 : false);
145 : }
146 :
147 : Handle<Smi> StoreHandler::TransitionToField(Isolate* isolate, int descriptor,
148 : FieldIndex field_index,
149 : Representation representation,
150 : bool extend_storage) {
151 : return StoreField(isolate, kTransitionToField, descriptor, field_index,
152 1186354 : representation, extend_storage);
153 : }
154 :
155 75212 : Handle<Smi> StoreHandler::TransitionToConstant(Isolate* isolate,
156 : int descriptor) {
157 : DCHECK(!FLAG_track_constant_fields);
158 : int config =
159 75212 : StoreHandler::KindBits::encode(StoreHandler::kTransitionToConstant) |
160 150424 : StoreHandler::DescriptorBits::encode(descriptor);
161 75212 : return handle(Smi::FromInt(config), isolate);
162 : }
163 :
164 : } // namespace internal
165 : } // namespace v8
166 :
167 : #endif // V8_IC_HANDLER_CONFIGURATION_INL_H_
|