Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Side by Side Diff: src/interface-descriptors.cc

Issue 1197703002: Use big-boy Types to annotate interface descriptor parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Latest Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interface-descriptors.h ('k') | src/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interface-descriptors.h" 7 #include "src/interface-descriptors.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 void CallInterfaceDescriptorData::Initialize( 12 namespace {
13 // Constructors for common combined semantic and representation types.
14 Type* SmiType() {
15 return Type::Intersect(Type::SignedSmall(), Type::TaggedSigned());
16 }
17
18
19 Type* UntaggedSigned32() {
20 return Type::Intersect(Type::Signed32(), Type::UntaggedSigned32());
21 }
22
23
24 Type* AnyTagged() {
25 return Type::Intersect(
26 Type::Any(), Type::Union(Type::TaggedPointer(), Type::TaggedSigned()));
27 }
28
29
30 Type* ExternalPointer() {
31 return Type::Intersect(Type::Internal(), Type::UntaggedPointer());
32 }
33 }
34
35
36 Type::FunctionType* CallInterfaceDescriptor::BuildDefaultFunctionType(
37 Isolate* isolate, int parameter_count) {
38 Type::FunctionType* function =
39 Type::FunctionType::New(AnyTagged(), Type::Undefined(), parameter_count,
40 isolate->interface_descriptor_zone());
41 while (parameter_count-- != 0) {
42 function->InitParameter(parameter_count, AnyTagged());
43 }
44 return function;
45 }
46
47
48 void CallInterfaceDescriptorData::InitializePlatformSpecific(
13 int register_parameter_count, Register* registers, 49 int register_parameter_count, Register* registers,
14 Representation* register_param_representations,
15 PlatformInterfaceDescriptor* platform_descriptor) { 50 PlatformInterfaceDescriptor* platform_descriptor) {
16 platform_specific_descriptor_ = platform_descriptor; 51 platform_specific_descriptor_ = platform_descriptor;
17 register_param_count_ = register_parameter_count; 52 register_param_count_ = register_parameter_count;
18 53
19 // An interface descriptor must have a context register. 54 // An interface descriptor must have a context register.
20 DCHECK(register_parameter_count > 0 && 55 DCHECK(register_parameter_count > 0 &&
21 registers[0].is(CallInterfaceDescriptor::ContextRegister())); 56 registers[0].is(CallInterfaceDescriptor::ContextRegister()));
22 57
23 // InterfaceDescriptor owns a copy of the registers array. 58 // InterfaceDescriptor owns a copy of the registers array.
24 register_params_.Reset(NewArray<Register>(register_parameter_count)); 59 register_params_.Reset(NewArray<Register>(register_parameter_count));
25 for (int i = 0; i < register_parameter_count; i++) { 60 for (int i = 0; i < register_parameter_count; i++) {
26 register_params_[i] = registers[i]; 61 register_params_[i] = registers[i];
27 } 62 }
28
29 // If a representations array is specified, then the descriptor owns that as
30 // well.
31 if (register_param_representations != NULL) {
32 register_param_representations_.Reset(
33 NewArray<Representation>(register_parameter_count));
34 for (int i = 0; i < register_parameter_count; i++) {
35 // If there is a context register, the representation must be tagged.
36 DCHECK(
37 i != 0 ||
38 register_param_representations[i].Equals(Representation::Tagged()));
39 register_param_representations_[i] = register_param_representations[i];
40 }
41 }
42 } 63 }
43 64
44
45 const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) const { 65 const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) const {
46 CallInterfaceDescriptorData* start = isolate->call_descriptor_data(0); 66 CallInterfaceDescriptorData* start = isolate->call_descriptor_data(0);
47 size_t index = data_ - start; 67 size_t index = data_ - start;
48 DCHECK(index < CallDescriptors::NUMBER_OF_DESCRIPTORS); 68 DCHECK(index < CallDescriptors::NUMBER_OF_DESCRIPTORS);
49 CallDescriptors::Key key = static_cast<CallDescriptors::Key>(index); 69 CallDescriptors::Key key = static_cast<CallDescriptors::Key>(index);
50 switch (key) { 70 switch (key) {
51 #define DEF_CASE(NAME) \ 71 #define DEF_CASE(NAME) \
52 case CallDescriptors::NAME: \ 72 case CallDescriptors::NAME: \
53 return #NAME " Descriptor"; 73 return #NAME " Descriptor";
54 INTERFACE_DESCRIPTOR_LIST(DEF_CASE) 74 INTERFACE_DESCRIPTOR_LIST(DEF_CASE)
55 #undef DEF_CASE 75 #undef DEF_CASE
56 case CallDescriptors::NUMBER_OF_DESCRIPTORS: 76 case CallDescriptors::NUMBER_OF_DESCRIPTORS:
57 break; 77 break;
58 } 78 }
59 return ""; 79 return "";
60 } 80 }
61 81
62 82
63 void LoadDescriptor::Initialize(CallInterfaceDescriptorData* data) { 83 Type::FunctionType* LoadDescriptor::BuildCallInterfaceDescriptorFunctionType(
84 Isolate* isolate, int paramater_count) {
85 Type::FunctionType* function = Type::FunctionType::New(
86 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
87 function->InitParameter(0, AnyTagged());
88 function->InitParameter(1, AnyTagged());
89 function->InitParameter(2, AnyTagged());
90 function->InitParameter(3, SmiType());
91 return function;
92 }
93
94 void LoadDescriptor::InitializePlatformSpecific(
95 CallInterfaceDescriptorData* data) {
64 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(), 96 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
65 SlotRegister()}; 97 SlotRegister()};
66 Representation representations[] = { 98 data->InitializePlatformSpecific(arraysize(registers), registers);
67 Representation::Tagged(), Representation::Tagged(), 99 }
68 Representation::Tagged(), Representation::Smi()}; 100
69 data->Initialize(arraysize(registers), registers, representations); 101
70 } 102 void StoreDescriptor::InitializePlatformSpecific(
71 103 CallInterfaceDescriptorData* data) {
72
73 void StoreDescriptor::Initialize(CallInterfaceDescriptorData* data) {
74 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(), 104 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
75 ValueRegister()}; 105 ValueRegister()};
76 data->Initialize(arraysize(registers), registers, NULL); 106 data->InitializePlatformSpecific(arraysize(registers), registers);
77 } 107 }
78 108
79 109
80 void StoreTransitionDescriptor::Initialize(CallInterfaceDescriptorData* data) { 110 void StoreTransitionDescriptor::InitializePlatformSpecific(
111 CallInterfaceDescriptorData* data) {
81 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(), 112 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
82 ValueRegister(), MapRegister()}; 113 ValueRegister(), MapRegister()};
83 data->Initialize(arraysize(registers), registers, NULL); 114 data->InitializePlatformSpecific(arraysize(registers), registers);
84 } 115 }
85 116
86 117
87 void ElementTransitionAndStoreDescriptor::Initialize( 118 void ElementTransitionAndStoreDescriptor::InitializePlatformSpecific(
88 CallInterfaceDescriptorData* data) { 119 CallInterfaceDescriptorData* data) {
89 Register registers[] = {ContextRegister(), ValueRegister(), MapRegister(), 120 Register registers[] = {ContextRegister(), ValueRegister(), MapRegister(),
90 NameRegister(), ReceiverRegister()}; 121 NameRegister(), ReceiverRegister()};
91 data->Initialize(arraysize(registers), registers, NULL); 122 data->InitializePlatformSpecific(arraysize(registers), registers);
92 } 123 }
93 124
94 125
95 void InstanceofDescriptor::Initialize(CallInterfaceDescriptorData* data) { 126 void InstanceofDescriptor::InitializePlatformSpecific(
127 CallInterfaceDescriptorData* data) {
96 Register registers[] = {ContextRegister(), left(), right()}; 128 Register registers[] = {ContextRegister(), left(), right()};
97 data->Initialize(arraysize(registers), registers, NULL); 129 data->InitializePlatformSpecific(arraysize(registers), registers);
98 } 130 }
99 131
100 132
101 void MathPowTaggedDescriptor::Initialize(CallInterfaceDescriptorData* data) { 133 void MathPowTaggedDescriptor::InitializePlatformSpecific(
134 CallInterfaceDescriptorData* data) {
102 Register registers[] = {ContextRegister(), exponent()}; 135 Register registers[] = {ContextRegister(), exponent()};
103 data->Initialize(arraysize(registers), registers, NULL); 136 data->InitializePlatformSpecific(arraysize(registers), registers);
104 } 137 }
105 138
106 139
107 void MathPowIntegerDescriptor::Initialize(CallInterfaceDescriptorData* data) { 140 void MathPowIntegerDescriptor::InitializePlatformSpecific(
141 CallInterfaceDescriptorData* data) {
108 Register registers[] = {ContextRegister(), exponent()}; 142 Register registers[] = {ContextRegister(), exponent()};
109 data->Initialize(arraysize(registers), registers, NULL); 143 data->InitializePlatformSpecific(arraysize(registers), registers);
110 } 144 }
111 145
112 146
113 void LoadWithVectorDescriptor::Initialize(CallInterfaceDescriptorData* data) { 147 Type::FunctionType*
148 LoadWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType(
149 Isolate* isolate, int paramater_count) {
150 Type::FunctionType* function = Type::FunctionType::New(
151 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
152 function->InitParameter(0, AnyTagged());
153 function->InitParameter(1, AnyTagged());
154 function->InitParameter(2, AnyTagged());
155 function->InitParameter(3, SmiType());
156 function->InitParameter(4, AnyTagged());
157 return function;
158 }
159
160
161 void LoadWithVectorDescriptor::InitializePlatformSpecific(
162 CallInterfaceDescriptorData* data) {
114 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(), 163 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
115 SlotRegister(), VectorRegister()}; 164 SlotRegister(), VectorRegister()};
116 Representation representations[] = { 165 data->InitializePlatformSpecific(arraysize(registers), registers);
117 Representation::Tagged(), Representation::Tagged(), 166 }
118 Representation::Tagged(), Representation::Smi(), 167
119 Representation::Tagged()}; 168
120 data->Initialize(arraysize(registers), registers, representations); 169 Type::FunctionType*
121 } 170 VectorStoreICDescriptor::BuildCallInterfaceDescriptorFunctionType(
122 171 Isolate* isolate, int paramater_count) {
123 172 Type::FunctionType* function = Type::FunctionType::New(
124 void VectorStoreICDescriptor::Initialize(CallInterfaceDescriptorData* data) { 173 AnyTagged(), Type::Undefined(), 6, isolate->interface_descriptor_zone());
174 function->InitParameter(0, AnyTagged());
175 function->InitParameter(1, AnyTagged());
176 function->InitParameter(2, AnyTagged());
177 function->InitParameter(3, AnyTagged());
178 function->InitParameter(4, SmiType());
179 function->InitParameter(5, AnyTagged());
180 return function;
181 }
182
183
184 void VectorStoreICDescriptor::InitializePlatformSpecific(
185 CallInterfaceDescriptorData* data) {
125 Register registers[] = {ContextRegister(), ReceiverRegister(), 186 Register registers[] = {ContextRegister(), ReceiverRegister(),
126 NameRegister(), ValueRegister(), 187 NameRegister(), ValueRegister(),
127 SlotRegister(), VectorRegister()}; 188 SlotRegister(), VectorRegister()};
128 Representation representations[] = { 189 data->InitializePlatformSpecific(arraysize(registers), registers);
129 Representation::Tagged(), Representation::Tagged(), 190 }
130 Representation::Tagged(), Representation::Tagged(), 191
131 Representation::Smi(), Representation::Tagged()}; 192
132 data->Initialize(arraysize(registers), registers, representations); 193 Type::FunctionType*
133 } 194 VectorStoreICTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType(
134 195 Isolate* isolate, int paramater_count) {
135 196 Type::FunctionType* function = Type::FunctionType::New(
136 void VectorStoreICTrampolineDescriptor::Initialize( 197 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
198 function->InitParameter(0, AnyTagged());
199 function->InitParameter(1, AnyTagged());
200 function->InitParameter(2, AnyTagged());
201 function->InitParameter(3, AnyTagged());
202 function->InitParameter(4, SmiType());
203 return function;
204 }
205
206
207 void VectorStoreICTrampolineDescriptor::InitializePlatformSpecific(
137 CallInterfaceDescriptorData* data) { 208 CallInterfaceDescriptorData* data) {
138 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(), 209 Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
139 ValueRegister(), SlotRegister()}; 210 ValueRegister(), SlotRegister()};
140 Representation representations[] = { 211 data->InitializePlatformSpecific(arraysize(registers), registers);
141 Representation::Tagged(), Representation::Tagged(), 212 }
142 Representation::Tagged(), Representation::Tagged(), 213
143 Representation::Smi()}; 214
144 data->Initialize(arraysize(registers), registers, representations); 215 Type::FunctionType*
145 } 216 ApiGetterDescriptor::BuildCallInterfaceDescriptorFunctionType(
146 217 Isolate* isolate, int paramater_count) {
147 218 Type::FunctionType* function = Type::FunctionType::New(
148 void ApiGetterDescriptor::Initialize(CallInterfaceDescriptorData* data) { 219 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
220 function->InitParameter(0, AnyTagged());
221 function->InitParameter(1, ExternalPointer());
222 return function;
223 }
224
225
226 void ApiGetterDescriptor::InitializePlatformSpecific(
227 CallInterfaceDescriptorData* data) {
149 Register registers[] = {ContextRegister(), function_address()}; 228 Register registers[] = {ContextRegister(), function_address()};
150 Representation representations[] = {Representation::Tagged(), 229 data->InitializePlatformSpecific(arraysize(registers), registers);
151 Representation::External()}; 230 }
152 data->Initialize(arraysize(registers), registers, representations); 231
153 } 232
154 233 void ArgumentsAccessReadDescriptor::InitializePlatformSpecific(
155
156 void ArgumentsAccessReadDescriptor::Initialize(
157 CallInterfaceDescriptorData* data) { 234 CallInterfaceDescriptorData* data) {
158 Register registers[] = {ContextRegister(), index(), parameter_count()}; 235 Register registers[] = {ContextRegister(), index(), parameter_count()};
159 data->Initialize(arraysize(registers), registers, NULL); 236 data->InitializePlatformSpecific(arraysize(registers), registers);
160 } 237 }
161 238
162 239
163 void ContextOnlyDescriptor::Initialize(CallInterfaceDescriptorData* data) { 240 void ContextOnlyDescriptor::InitializePlatformSpecific(
241 CallInterfaceDescriptorData* data) {
164 Register registers[] = {ContextRegister()}; 242 Register registers[] = {ContextRegister()};
165 data->Initialize(arraysize(registers), registers, NULL); 243 data->InitializePlatformSpecific(arraysize(registers), registers);
166 } 244 }
167 245
168 246
169 void GrowArrayElementsDescriptor::Initialize( 247 void GrowArrayElementsDescriptor::InitializePlatformSpecific(
170 CallInterfaceDescriptorData* data) { 248 CallInterfaceDescriptorData* data) {
171 Register registers[] = {ContextRegister(), ObjectRegister(), KeyRegister()}; 249 Register registers[] = {ContextRegister(), ObjectRegister(), KeyRegister()};
172 data->Initialize(arraysize(registers), registers, NULL); 250 data->InitializePlatformSpecific(arraysize(registers), registers);
173 } 251 }
252
253
254 Type::FunctionType*
255 FastCloneShallowArrayDescriptor::BuildCallInterfaceDescriptorFunctionType(
256 Isolate* isolate, int paramater_count) {
257 Type::FunctionType* function = Type::FunctionType::New(
258 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
259 function->InitParameter(0, AnyTagged());
260 function->InitParameter(1, AnyTagged());
261 function->InitParameter(2, SmiType());
262 function->InitParameter(3, AnyTagged());
263 return function;
264 }
265
266
267 Type::FunctionType*
268 CreateAllocationSiteDescriptor::BuildCallInterfaceDescriptorFunctionType(
269 Isolate* isolate, int paramater_count) {
270 Type::FunctionType* function = Type::FunctionType::New(
271 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
272 function->InitParameter(0, AnyTagged());
273 function->InitParameter(1, AnyTagged());
274 function->InitParameter(2, SmiType());
275 return function;
276 }
277
278
279 Type::FunctionType*
280 CreateWeakCellDescriptor::BuildCallInterfaceDescriptorFunctionType(
281 Isolate* isolate, int paramater_count) {
282 Type::FunctionType* function = Type::FunctionType::New(
283 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
284 function->InitParameter(0, AnyTagged());
285 function->InitParameter(1, AnyTagged());
286 function->InitParameter(2, SmiType());
287 function->InitParameter(3, AnyTagged());
288 return function;
289 }
290
291
292 Type::FunctionType*
293 CallFunctionWithFeedbackDescriptor::BuildCallInterfaceDescriptorFunctionType(
294 Isolate* isolate, int paramater_count) {
295 Type::FunctionType* function = Type::FunctionType::New(
296 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
297 function->InitParameter(0, AnyTagged());
298 function->InitParameter(1, Type::Receiver()); // JSFunction
299 function->InitParameter(2, SmiType());
300 return function;
301 }
302
303
304 Type::FunctionType* CallFunctionWithFeedbackAndVectorDescriptor::
305 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
306 int paramater_count) {
307 Type::FunctionType* function = Type::FunctionType::New(
308 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
309 function->InitParameter(0, AnyTagged());
310 function->InitParameter(1, Type::Receiver()); // JSFunction
311 function->InitParameter(2, SmiType());
312 function->InitParameter(3, AnyTagged());
313 return function;
314 }
315
316
317 Type::FunctionType*
318 ArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
319 Isolate* isolate, int paramater_count) {
320 Type::FunctionType* function = Type::FunctionType::New(
321 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
322 function->InitParameter(0, AnyTagged());
323 function->InitParameter(1, Type::Receiver()); // JSFunction
324 function->InitParameter(2, AnyTagged());
325 function->InitParameter(3, UntaggedSigned32());
326 return function;
327 }
328
329
330 Type::FunctionType*
331 InternalArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
332 Isolate* isolate, int paramater_count) {
333 Type::FunctionType* function = Type::FunctionType::New(
334 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
335 function->InitParameter(0, AnyTagged());
336 function->InitParameter(1, Type::Receiver()); // JSFunction
337 function->InitParameter(2, UntaggedSigned32());
338 return function;
339 }
340
341
342 Type::FunctionType*
343 ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType(
344 Isolate* isolate, int paramater_count) {
345 Type::FunctionType* function = Type::FunctionType::New(
346 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
347 function->InitParameter(0, AnyTagged()); // context
348 function->InitParameter(1, Type::Receiver()); // JSFunction
349 function->InitParameter(2, UntaggedSigned32()); // actual number of arguments
350 function->InitParameter(3,
351 UntaggedSigned32()); // expected number of arguments
352 return function;
353 }
354
355
356 Type::FunctionType*
357 ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType(
358 Isolate* isolate, int paramater_count) {
359 Type::FunctionType* function = Type::FunctionType::New(
360 AnyTagged(), Type::Undefined(), 6, isolate->interface_descriptor_zone());
361 function->InitParameter(0, AnyTagged()); // context
362 function->InitParameter(1, AnyTagged()); // callee
363 function->InitParameter(2, AnyTagged()); // call_data
364 function->InitParameter(3, AnyTagged()); // holder
365 function->InitParameter(4, ExternalPointer()); // api_function_address
366 function->InitParameter(5, UntaggedSigned32()); // actual number of arguments
367 return function;
368 }
369
370
371 Type::FunctionType*
372 ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType(
373 Isolate* isolate, int paramater_count) {
374 Type::FunctionType* function = Type::FunctionType::New(
375 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
376 function->InitParameter(0, AnyTagged()); // context
377 function->InitParameter(1, AnyTagged()); // callee
378 function->InitParameter(2, AnyTagged()); // call_data
379 function->InitParameter(3, AnyTagged()); // holder
380 function->InitParameter(4, ExternalPointer()); // api_function_address
381 return function;
382 }
383
384
385 Type::FunctionType*
386 MathRoundVariantDescriptor::BuildCallInterfaceDescriptorFunctionType(
387 Isolate* isolate, int paramater_count) {
388 Type::FunctionType* function = Type::FunctionType::New(
389 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
390 function->InitParameter(0, Type::Receiver());
391 function->InitParameter(1, SmiType());
392 function->InitParameter(2, AnyTagged());
393 return function;
394 }
395
396
174 } // namespace internal 397 } // namespace internal
175 } // namespace v8 398 } // namespace v8
OLDNEW
« no previous file with comments | « src/interface-descriptors.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698