Line data Source code
1 : // Copyright 2014 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 : #include "src/compiler/js-operator.h"
6 :
7 : #include <limits>
8 :
9 : #include "src/base/lazy-instance.h"
10 : #include "src/compiler/opcodes.h"
11 : #include "src/compiler/operator.h"
12 : #include "src/handles-inl.h"
13 : #include "src/objects-inl.h"
14 : #include "src/vector-slot-pair.h"
15 :
16 : namespace v8 {
17 : namespace internal {
18 : namespace compiler {
19 :
20 0 : std::ostream& operator<<(std::ostream& os, CallFrequency f) {
21 0 : if (f.IsUnknown()) return os << "unknown";
22 0 : return os << f.value();
23 : }
24 :
25 1065 : CallFrequency CallFrequencyOf(Operator const* op) {
26 : DCHECK(op->opcode() == IrOpcode::kJSCallWithArrayLike ||
27 : op->opcode() == IrOpcode::kJSConstructWithArrayLike);
28 1065 : return OpParameter<CallFrequency>(op);
29 : }
30 :
31 :
32 0 : std::ostream& operator<<(std::ostream& os,
33 : ConstructForwardVarargsParameters const& p) {
34 0 : return os << p.arity() << ", " << p.start_index();
35 : }
36 :
37 511 : ConstructForwardVarargsParameters const& ConstructForwardVarargsParametersOf(
38 : Operator const* op) {
39 : DCHECK_EQ(IrOpcode::kJSConstructForwardVarargs, op->opcode());
40 511 : return OpParameter<ConstructForwardVarargsParameters>(op);
41 : }
42 :
43 0 : bool operator==(ConstructParameters const& lhs,
44 : ConstructParameters const& rhs) {
45 0 : return lhs.arity() == rhs.arity() && lhs.frequency() == rhs.frequency() &&
46 0 : lhs.feedback() == rhs.feedback();
47 : }
48 :
49 0 : bool operator!=(ConstructParameters const& lhs,
50 : ConstructParameters const& rhs) {
51 0 : return !(lhs == rhs);
52 : }
53 :
54 0 : size_t hash_value(ConstructParameters const& p) {
55 0 : return base::hash_combine(p.arity(), p.frequency(), p.feedback());
56 : }
57 :
58 0 : std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) {
59 0 : return os << p.arity() << ", " << p.frequency();
60 : }
61 :
62 130769 : ConstructParameters const& ConstructParametersOf(Operator const* op) {
63 : DCHECK(op->opcode() == IrOpcode::kJSConstruct ||
64 : op->opcode() == IrOpcode::kJSConstructWithSpread);
65 130769 : return OpParameter<ConstructParameters>(op);
66 : }
67 :
68 0 : std::ostream& operator<<(std::ostream& os, CallParameters const& p) {
69 0 : return os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode();
70 : }
71 :
72 1990549 : const CallParameters& CallParametersOf(const Operator* op) {
73 : DCHECK(op->opcode() == IrOpcode::kJSCall ||
74 : op->opcode() == IrOpcode::kJSCallWithSpread);
75 1990549 : return OpParameter<CallParameters>(op);
76 : }
77 :
78 0 : std::ostream& operator<<(std::ostream& os,
79 : CallForwardVarargsParameters const& p) {
80 0 : return os << p.arity() << ", " << p.start_index();
81 : }
82 :
83 455 : CallForwardVarargsParameters const& CallForwardVarargsParametersOf(
84 : Operator const* op) {
85 : DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode());
86 455 : return OpParameter<CallForwardVarargsParameters>(op);
87 : }
88 :
89 :
90 0 : bool operator==(CallRuntimeParameters const& lhs,
91 : CallRuntimeParameters const& rhs) {
92 0 : return lhs.id() == rhs.id() && lhs.arity() == rhs.arity();
93 : }
94 :
95 :
96 0 : bool operator!=(CallRuntimeParameters const& lhs,
97 : CallRuntimeParameters const& rhs) {
98 0 : return !(lhs == rhs);
99 : }
100 :
101 :
102 0 : size_t hash_value(CallRuntimeParameters const& p) {
103 0 : return base::hash_combine(p.id(), p.arity());
104 : }
105 :
106 :
107 0 : std::ostream& operator<<(std::ostream& os, CallRuntimeParameters const& p) {
108 0 : return os << p.id() << ", " << p.arity();
109 : }
110 :
111 :
112 13082381 : const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) {
113 : DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode());
114 13082381 : return OpParameter<CallRuntimeParameters>(op);
115 : }
116 :
117 :
118 0 : ContextAccess::ContextAccess(size_t depth, size_t index, bool immutable)
119 : : immutable_(immutable),
120 : depth_(static_cast<uint16_t>(depth)),
121 912748 : index_(static_cast<uint32_t>(index)) {
122 : DCHECK(depth <= std::numeric_limits<uint16_t>::max());
123 : DCHECK(index <= std::numeric_limits<uint32_t>::max());
124 0 : }
125 :
126 :
127 0 : bool operator==(ContextAccess const& lhs, ContextAccess const& rhs) {
128 0 : return lhs.depth() == rhs.depth() && lhs.index() == rhs.index() &&
129 0 : lhs.immutable() == rhs.immutable();
130 : }
131 :
132 :
133 0 : bool operator!=(ContextAccess const& lhs, ContextAccess const& rhs) {
134 0 : return !(lhs == rhs);
135 : }
136 :
137 :
138 0 : size_t hash_value(ContextAccess const& access) {
139 0 : return base::hash_combine(access.depth(), access.index(), access.immutable());
140 : }
141 :
142 :
143 0 : std::ostream& operator<<(std::ostream& os, ContextAccess const& access) {
144 : return os << access.depth() << ", " << access.index() << ", "
145 0 : << access.immutable();
146 : }
147 :
148 :
149 3347980 : ContextAccess const& ContextAccessOf(Operator const* op) {
150 : DCHECK(op->opcode() == IrOpcode::kJSLoadContext ||
151 : op->opcode() == IrOpcode::kJSStoreContext);
152 3347980 : return OpParameter<ContextAccess>(op);
153 : }
154 :
155 0 : CreateFunctionContextParameters::CreateFunctionContextParameters(
156 : Handle<ScopeInfo> scope_info, int slot_count, ScopeType scope_type)
157 : : scope_info_(scope_info),
158 : slot_count_(slot_count),
159 0 : scope_type_(scope_type) {}
160 :
161 0 : bool operator==(CreateFunctionContextParameters const& lhs,
162 : CreateFunctionContextParameters const& rhs) {
163 0 : return lhs.scope_info().location() == rhs.scope_info().location() &&
164 0 : lhs.slot_count() == rhs.slot_count() &&
165 0 : lhs.scope_type() == rhs.scope_type();
166 : }
167 :
168 0 : bool operator!=(CreateFunctionContextParameters const& lhs,
169 : CreateFunctionContextParameters const& rhs) {
170 0 : return !(lhs == rhs);
171 : }
172 :
173 0 : size_t hash_value(CreateFunctionContextParameters const& parameters) {
174 : return base::hash_combine(parameters.scope_info().location(),
175 : parameters.slot_count(),
176 0 : static_cast<int>(parameters.scope_type()));
177 : }
178 :
179 0 : std::ostream& operator<<(std::ostream& os,
180 : CreateFunctionContextParameters const& parameters) {
181 0 : return os << parameters.slot_count() << ", " << parameters.scope_type();
182 : }
183 :
184 64017 : CreateFunctionContextParameters const& CreateFunctionContextParametersOf(
185 : Operator const* op) {
186 : DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, op->opcode());
187 64017 : return OpParameter<CreateFunctionContextParameters>(op);
188 : }
189 :
190 0 : bool operator==(StoreNamedOwnParameters const& lhs,
191 : StoreNamedOwnParameters const& rhs) {
192 0 : return lhs.name().location() == rhs.name().location() &&
193 0 : lhs.feedback() == rhs.feedback();
194 : }
195 :
196 0 : bool operator!=(StoreNamedOwnParameters const& lhs,
197 : StoreNamedOwnParameters const& rhs) {
198 0 : return !(lhs == rhs);
199 : }
200 :
201 0 : size_t hash_value(StoreNamedOwnParameters const& p) {
202 0 : return base::hash_combine(p.name().location(), p.feedback());
203 : }
204 :
205 0 : std::ostream& operator<<(std::ostream& os, StoreNamedOwnParameters const& p) {
206 0 : return os << Brief(*p.name());
207 : }
208 :
209 67424 : StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) {
210 : DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode());
211 67424 : return OpParameter<StoreNamedOwnParameters>(op);
212 : }
213 :
214 0 : bool operator==(FeedbackParameter const& lhs, FeedbackParameter const& rhs) {
215 0 : return lhs.feedback() == rhs.feedback();
216 : }
217 :
218 0 : bool operator!=(FeedbackParameter const& lhs, FeedbackParameter const& rhs) {
219 0 : return !(lhs == rhs);
220 : }
221 :
222 0 : size_t hash_value(FeedbackParameter const& p) {
223 0 : return base::hash_combine(p.feedback());
224 : }
225 :
226 0 : std::ostream& operator<<(std::ostream& os, FeedbackParameter const& p) {
227 0 : return os;
228 : }
229 :
230 173097 : FeedbackParameter const& FeedbackParameterOf(const Operator* op) {
231 : DCHECK(op->opcode() == IrOpcode::kJSCreateEmptyLiteralArray ||
232 : op->opcode() == IrOpcode::kJSInstanceOf ||
233 : op->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
234 : op->opcode() == IrOpcode::kJSStoreInArrayLiteral);
235 173097 : return OpParameter<FeedbackParameter>(op);
236 : }
237 :
238 0 : bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) {
239 0 : return lhs.name().location() == rhs.name().location() &&
240 0 : lhs.language_mode() == rhs.language_mode() &&
241 0 : lhs.feedback() == rhs.feedback();
242 : }
243 :
244 :
245 0 : bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) {
246 0 : return !(lhs == rhs);
247 : }
248 :
249 :
250 0 : size_t hash_value(NamedAccess const& p) {
251 : return base::hash_combine(p.name().location(), p.language_mode(),
252 0 : p.feedback());
253 : }
254 :
255 :
256 0 : std::ostream& operator<<(std::ostream& os, NamedAccess const& p) {
257 0 : return os << Brief(*p.name()) << ", " << p.language_mode();
258 : }
259 :
260 :
261 2105673 : NamedAccess const& NamedAccessOf(const Operator* op) {
262 : DCHECK(op->opcode() == IrOpcode::kJSLoadNamed ||
263 : op->opcode() == IrOpcode::kJSStoreNamed);
264 2105673 : return OpParameter<NamedAccess>(op);
265 : }
266 :
267 :
268 0 : std::ostream& operator<<(std::ostream& os, PropertyAccess const& p) {
269 0 : return os << p.language_mode() << ", " << p.feedback();
270 : }
271 :
272 :
273 0 : bool operator==(PropertyAccess const& lhs, PropertyAccess const& rhs) {
274 0 : return lhs.language_mode() == rhs.language_mode() &&
275 0 : lhs.feedback() == rhs.feedback();
276 : }
277 :
278 :
279 0 : bool operator!=(PropertyAccess const& lhs, PropertyAccess const& rhs) {
280 0 : return !(lhs == rhs);
281 : }
282 :
283 :
284 106292 : PropertyAccess const& PropertyAccessOf(const Operator* op) {
285 : DCHECK(op->opcode() == IrOpcode::kJSHasProperty ||
286 : op->opcode() == IrOpcode::kJSLoadProperty ||
287 : op->opcode() == IrOpcode::kJSStoreProperty);
288 106292 : return OpParameter<PropertyAccess>(op);
289 : }
290 :
291 :
292 0 : size_t hash_value(PropertyAccess const& p) {
293 0 : return base::hash_combine(p.language_mode(), p.feedback());
294 : }
295 :
296 :
297 0 : bool operator==(LoadGlobalParameters const& lhs,
298 : LoadGlobalParameters const& rhs) {
299 0 : return lhs.name().location() == rhs.name().location() &&
300 0 : lhs.feedback() == rhs.feedback() &&
301 0 : lhs.typeof_mode() == rhs.typeof_mode();
302 : }
303 :
304 :
305 0 : bool operator!=(LoadGlobalParameters const& lhs,
306 : LoadGlobalParameters const& rhs) {
307 0 : return !(lhs == rhs);
308 : }
309 :
310 :
311 0 : size_t hash_value(LoadGlobalParameters const& p) {
312 0 : return base::hash_combine(p.name().location(), p.typeof_mode());
313 : }
314 :
315 :
316 0 : std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) {
317 0 : return os << Brief(*p.name()) << ", " << p.typeof_mode();
318 : }
319 :
320 :
321 1289944 : const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
322 : DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode());
323 1289944 : return OpParameter<LoadGlobalParameters>(op);
324 : }
325 :
326 :
327 0 : bool operator==(StoreGlobalParameters const& lhs,
328 : StoreGlobalParameters const& rhs) {
329 0 : return lhs.language_mode() == rhs.language_mode() &&
330 0 : lhs.name().location() == rhs.name().location() &&
331 0 : lhs.feedback() == rhs.feedback();
332 : }
333 :
334 :
335 0 : bool operator!=(StoreGlobalParameters const& lhs,
336 : StoreGlobalParameters const& rhs) {
337 0 : return !(lhs == rhs);
338 : }
339 :
340 :
341 0 : size_t hash_value(StoreGlobalParameters const& p) {
342 : return base::hash_combine(p.language_mode(), p.name().location(),
343 0 : p.feedback());
344 : }
345 :
346 :
347 0 : std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) {
348 0 : return os << p.language_mode() << ", " << Brief(*p.name());
349 : }
350 :
351 :
352 429787 : const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
353 : DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode());
354 429787 : return OpParameter<StoreGlobalParameters>(op);
355 : }
356 :
357 :
358 59904 : CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
359 : DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode());
360 59904 : return OpParameter<CreateArgumentsType>(op);
361 : }
362 :
363 :
364 0 : bool operator==(CreateArrayParameters const& lhs,
365 : CreateArrayParameters const& rhs) {
366 0 : return lhs.arity() == rhs.arity() &&
367 0 : lhs.site().address() == rhs.site().address();
368 : }
369 :
370 :
371 0 : bool operator!=(CreateArrayParameters const& lhs,
372 : CreateArrayParameters const& rhs) {
373 0 : return !(lhs == rhs);
374 : }
375 :
376 :
377 0 : size_t hash_value(CreateArrayParameters const& p) {
378 0 : return base::hash_combine(p.arity(), p.site().address());
379 : }
380 :
381 :
382 0 : std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) {
383 : os << p.arity();
384 : Handle<AllocationSite> site;
385 0 : if (p.site().ToHandle(&site)) os << ", " << Brief(*site);
386 0 : return os;
387 : }
388 :
389 3299 : const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) {
390 : DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode());
391 3299 : return OpParameter<CreateArrayParameters>(op);
392 : }
393 :
394 0 : bool operator==(CreateArrayIteratorParameters const& lhs,
395 : CreateArrayIteratorParameters const& rhs) {
396 0 : return lhs.kind() == rhs.kind();
397 : }
398 :
399 0 : bool operator!=(CreateArrayIteratorParameters const& lhs,
400 : CreateArrayIteratorParameters const& rhs) {
401 0 : return !(lhs == rhs);
402 : }
403 :
404 0 : size_t hash_value(CreateArrayIteratorParameters const& p) {
405 0 : return static_cast<size_t>(p.kind());
406 : }
407 :
408 0 : std::ostream& operator<<(std::ostream& os,
409 : CreateArrayIteratorParameters const& p) {
410 0 : return os << p.kind();
411 : }
412 :
413 1657 : const CreateArrayIteratorParameters& CreateArrayIteratorParametersOf(
414 : const Operator* op) {
415 : DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, op->opcode());
416 1657 : return OpParameter<CreateArrayIteratorParameters>(op);
417 : }
418 :
419 0 : bool operator==(CreateCollectionIteratorParameters const& lhs,
420 : CreateCollectionIteratorParameters const& rhs) {
421 0 : return lhs.collection_kind() == rhs.collection_kind() &&
422 0 : lhs.iteration_kind() == rhs.iteration_kind();
423 : }
424 :
425 0 : bool operator!=(CreateCollectionIteratorParameters const& lhs,
426 : CreateCollectionIteratorParameters const& rhs) {
427 0 : return !(lhs == rhs);
428 : }
429 :
430 0 : size_t hash_value(CreateCollectionIteratorParameters const& p) {
431 0 : return base::hash_combine(static_cast<size_t>(p.collection_kind()),
432 0 : static_cast<size_t>(p.iteration_kind()));
433 : }
434 :
435 0 : std::ostream& operator<<(std::ostream& os,
436 : CreateCollectionIteratorParameters const& p) {
437 0 : return os << p.collection_kind() << " " << p.iteration_kind();
438 : }
439 :
440 211 : const CreateCollectionIteratorParameters& CreateCollectionIteratorParametersOf(
441 : const Operator* op) {
442 : DCHECK_EQ(IrOpcode::kJSCreateCollectionIterator, op->opcode());
443 211 : return OpParameter<CreateCollectionIteratorParameters>(op);
444 : }
445 :
446 0 : bool operator==(CreateBoundFunctionParameters const& lhs,
447 : CreateBoundFunctionParameters const& rhs) {
448 0 : return lhs.arity() == rhs.arity() &&
449 0 : lhs.map().location() == rhs.map().location();
450 : }
451 :
452 0 : bool operator!=(CreateBoundFunctionParameters const& lhs,
453 : CreateBoundFunctionParameters const& rhs) {
454 0 : return !(lhs == rhs);
455 : }
456 :
457 0 : size_t hash_value(CreateBoundFunctionParameters const& p) {
458 0 : return base::hash_combine(p.arity(), p.map().location());
459 : }
460 :
461 0 : std::ostream& operator<<(std::ostream& os,
462 : CreateBoundFunctionParameters const& p) {
463 : os << p.arity();
464 0 : if (!p.map().is_null()) os << ", " << Brief(*p.map());
465 0 : return os;
466 : }
467 :
468 250 : const CreateBoundFunctionParameters& CreateBoundFunctionParametersOf(
469 : const Operator* op) {
470 : DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, op->opcode());
471 250 : return OpParameter<CreateBoundFunctionParameters>(op);
472 : }
473 :
474 0 : bool operator==(CreateClosureParameters const& lhs,
475 : CreateClosureParameters const& rhs) {
476 0 : return lhs.allocation() == rhs.allocation() &&
477 0 : lhs.code().location() == rhs.code().location() &&
478 0 : lhs.feedback_cell().location() == rhs.feedback_cell().location() &&
479 0 : lhs.shared_info().location() == rhs.shared_info().location();
480 : }
481 :
482 :
483 0 : bool operator!=(CreateClosureParameters const& lhs,
484 : CreateClosureParameters const& rhs) {
485 0 : return !(lhs == rhs);
486 : }
487 :
488 :
489 0 : size_t hash_value(CreateClosureParameters const& p) {
490 : return base::hash_combine(p.allocation(), p.shared_info().location(),
491 0 : p.feedback_cell().location());
492 : }
493 :
494 :
495 0 : std::ostream& operator<<(std::ostream& os, CreateClosureParameters const& p) {
496 0 : return os << p.allocation() << ", " << Brief(*p.shared_info()) << ", "
497 0 : << Brief(*p.feedback_cell()) << ", " << Brief(*p.code());
498 : }
499 :
500 :
501 1348841 : const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
502 : DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode());
503 1348841 : return OpParameter<CreateClosureParameters>(op);
504 : }
505 :
506 :
507 0 : bool operator==(CreateLiteralParameters const& lhs,
508 : CreateLiteralParameters const& rhs) {
509 0 : return lhs.constant().location() == rhs.constant().location() &&
510 0 : lhs.feedback() == rhs.feedback() && lhs.length() == rhs.length() &&
511 0 : lhs.flags() == rhs.flags();
512 : }
513 :
514 :
515 0 : bool operator!=(CreateLiteralParameters const& lhs,
516 : CreateLiteralParameters const& rhs) {
517 0 : return !(lhs == rhs);
518 : }
519 :
520 :
521 0 : size_t hash_value(CreateLiteralParameters const& p) {
522 : return base::hash_combine(p.constant().location(), p.feedback(), p.length(),
523 0 : p.flags());
524 : }
525 :
526 :
527 0 : std::ostream& operator<<(std::ostream& os, CreateLiteralParameters const& p) {
528 0 : return os << Brief(*p.constant()) << ", " << p.length() << ", " << p.flags();
529 : }
530 :
531 :
532 86041 : const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) {
533 : DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray ||
534 : op->opcode() == IrOpcode::kJSCreateLiteralObject ||
535 : op->opcode() == IrOpcode::kJSCreateLiteralRegExp);
536 86041 : return OpParameter<CreateLiteralParameters>(op);
537 : }
538 :
539 0 : bool operator==(CloneObjectParameters const& lhs,
540 : CloneObjectParameters const& rhs) {
541 0 : return lhs.feedback() == rhs.feedback() && lhs.flags() == rhs.flags();
542 : }
543 :
544 0 : bool operator!=(CloneObjectParameters const& lhs,
545 : CloneObjectParameters const& rhs) {
546 0 : return !(lhs == rhs);
547 : }
548 :
549 0 : size_t hash_value(CloneObjectParameters const& p) {
550 0 : return base::hash_combine(p.feedback(), p.flags());
551 : }
552 :
553 0 : std::ostream& operator<<(std::ostream& os, CloneObjectParameters const& p) {
554 0 : return os << p.flags();
555 : }
556 :
557 94 : const CloneObjectParameters& CloneObjectParametersOf(const Operator* op) {
558 : DCHECK(op->opcode() == IrOpcode::kJSCloneObject);
559 94 : return OpParameter<CloneObjectParameters>(op);
560 : }
561 :
562 0 : size_t hash_value(ForInMode mode) { return static_cast<uint8_t>(mode); }
563 :
564 0 : std::ostream& operator<<(std::ostream& os, ForInMode mode) {
565 0 : switch (mode) {
566 : case ForInMode::kUseEnumCacheKeysAndIndices:
567 0 : return os << "UseEnumCacheKeysAndIndices";
568 : case ForInMode::kUseEnumCacheKeys:
569 0 : return os << "UseEnumCacheKeys";
570 : case ForInMode::kGeneric:
571 0 : return os << "Generic";
572 : }
573 0 : UNREACHABLE();
574 : }
575 :
576 4178 : ForInMode ForInModeOf(Operator const* op) {
577 : DCHECK(op->opcode() == IrOpcode::kJSForInNext ||
578 : op->opcode() == IrOpcode::kJSForInPrepare);
579 4178 : return OpParameter<ForInMode>(op);
580 : }
581 :
582 74323 : BinaryOperationHint BinaryOperationHintOf(const Operator* op) {
583 : DCHECK_EQ(IrOpcode::kJSAdd, op->opcode());
584 74323 : return OpParameter<BinaryOperationHint>(op);
585 : }
586 :
587 687153 : CompareOperationHint CompareOperationHintOf(const Operator* op) {
588 : DCHECK(op->opcode() == IrOpcode::kJSEqual ||
589 : op->opcode() == IrOpcode::kJSStrictEqual ||
590 : op->opcode() == IrOpcode::kJSLessThan ||
591 : op->opcode() == IrOpcode::kJSGreaterThan ||
592 : op->opcode() == IrOpcode::kJSLessThanOrEqual ||
593 : op->opcode() == IrOpcode::kJSGreaterThanOrEqual);
594 687153 : return OpParameter<CompareOperationHint>(op);
595 : }
596 :
597 : #define CACHED_OP_LIST(V) \
598 : V(BitwiseOr, Operator::kNoProperties, 2, 1) \
599 : V(BitwiseXor, Operator::kNoProperties, 2, 1) \
600 : V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
601 : V(ShiftLeft, Operator::kNoProperties, 2, 1) \
602 : V(ShiftRight, Operator::kNoProperties, 2, 1) \
603 : V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
604 : V(Subtract, Operator::kNoProperties, 2, 1) \
605 : V(Multiply, Operator::kNoProperties, 2, 1) \
606 : V(Divide, Operator::kNoProperties, 2, 1) \
607 : V(Modulus, Operator::kNoProperties, 2, 1) \
608 : V(Exponentiate, Operator::kNoProperties, 2, 1) \
609 : V(BitwiseNot, Operator::kNoProperties, 1, 1) \
610 : V(Decrement, Operator::kNoProperties, 1, 1) \
611 : V(Increment, Operator::kNoProperties, 1, 1) \
612 : V(Negate, Operator::kNoProperties, 1, 1) \
613 : V(ToLength, Operator::kNoProperties, 1, 1) \
614 : V(ToName, Operator::kNoProperties, 1, 1) \
615 : V(ToNumber, Operator::kNoProperties, 1, 1) \
616 : V(ToNumberConvertBigInt, Operator::kNoProperties, 1, 1) \
617 : V(ToNumeric, Operator::kNoProperties, 1, 1) \
618 : V(ToObject, Operator::kFoldable, 1, 1) \
619 : V(ToString, Operator::kNoProperties, 1, 1) \
620 : V(Create, Operator::kNoProperties, 2, 1) \
621 : V(CreateIterResultObject, Operator::kEliminatable, 2, 1) \
622 : V(CreateStringIterator, Operator::kEliminatable, 1, 1) \
623 : V(CreateKeyValueArray, Operator::kEliminatable, 2, 1) \
624 : V(CreatePromise, Operator::kEliminatable, 0, 1) \
625 : V(CreateTypedArray, Operator::kNoProperties, 5, 1) \
626 : V(CreateObject, Operator::kNoProperties, 1, 1) \
627 : V(ObjectIsArray, Operator::kNoProperties, 1, 1) \
628 : V(HasInPrototypeChain, Operator::kNoProperties, 2, 1) \
629 : V(OrdinaryHasInstance, Operator::kNoProperties, 2, 1) \
630 : V(ForInEnumerate, Operator::kNoProperties, 1, 1) \
631 : V(AsyncFunctionEnter, Operator::kNoProperties, 2, 1) \
632 : V(AsyncFunctionReject, Operator::kNoDeopt | Operator::kNoThrow, 3, 1) \
633 : V(AsyncFunctionResolve, Operator::kNoDeopt | Operator::kNoThrow, 3, 1) \
634 : V(LoadMessage, Operator::kNoThrow | Operator::kNoWrite, 0, 1) \
635 : V(StoreMessage, Operator::kNoRead | Operator::kNoThrow, 1, 0) \
636 : V(GeneratorRestoreContinuation, Operator::kNoThrow, 1, 1) \
637 : V(GeneratorRestoreContext, Operator::kNoThrow, 1, 1) \
638 : V(GeneratorRestoreInputOrDebugPos, Operator::kNoThrow, 1, 1) \
639 : V(StackCheck, Operator::kNoWrite, 0, 0) \
640 : V(Debugger, Operator::kNoProperties, 0, 0) \
641 : V(FulfillPromise, Operator::kNoDeopt | Operator::kNoThrow, 2, 1) \
642 : V(PerformPromiseThen, Operator::kNoDeopt | Operator::kNoThrow, 4, 1) \
643 : V(PromiseResolve, Operator::kNoProperties, 2, 1) \
644 : V(RejectPromise, Operator::kNoDeopt | Operator::kNoThrow, 3, 1) \
645 : V(ResolvePromise, Operator::kNoDeopt | Operator::kNoThrow, 2, 1) \
646 : V(GetSuperConstructor, Operator::kNoWrite, 1, 1) \
647 : V(ParseInt, Operator::kNoProperties, 2, 1) \
648 : V(RegExpTest, Operator::kNoProperties, 2, 1)
649 :
650 : #define BINARY_OP_LIST(V) V(Add)
651 :
652 : #define COMPARE_OP_LIST(V) \
653 : V(Equal, Operator::kNoProperties) \
654 : V(StrictEqual, Operator::kPure) \
655 : V(LessThan, Operator::kNoProperties) \
656 : V(GreaterThan, Operator::kNoProperties) \
657 : V(LessThanOrEqual, Operator::kNoProperties) \
658 : V(GreaterThanOrEqual, Operator::kNoProperties)
659 :
660 25924 : struct JSOperatorGlobalCache final {
661 : #define CACHED_OP(Name, properties, value_input_count, value_output_count) \
662 : struct Name##Operator final : public Operator { \
663 : Name##Operator() \
664 : : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \
665 : value_input_count, Operator::ZeroIfPure(properties), \
666 : Operator::ZeroIfEliminatable(properties), \
667 : value_output_count, Operator::ZeroIfPure(properties), \
668 : Operator::ZeroIfNoThrow(properties)) {} \
669 : }; \
670 : Name##Operator k##Name##Operator;
671 2436856 : CACHED_OP_LIST(CACHED_OP)
672 : #undef CACHED_OP
673 :
674 : #define BINARY_OP(Name) \
675 : template <BinaryOperationHint kHint> \
676 : struct Name##Operator final : public Operator1<BinaryOperationHint> { \
677 : Name##Operator() \
678 : : Operator1<BinaryOperationHint>(IrOpcode::kJS##Name, \
679 : Operator::kNoProperties, "JS" #Name, \
680 : 2, 1, 1, 1, 1, 2, kHint) {} \
681 : }; \
682 : Name##Operator<BinaryOperationHint::kNone> k##Name##NoneOperator; \
683 : Name##Operator<BinaryOperationHint::kSignedSmall> \
684 : k##Name##SignedSmallOperator; \
685 : Name##Operator<BinaryOperationHint::kSignedSmallInputs> \
686 : k##Name##SignedSmallInputsOperator; \
687 : Name##Operator<BinaryOperationHint::kSigned32> k##Name##Signed32Operator; \
688 : Name##Operator<BinaryOperationHint::kNumber> k##Name##NumberOperator; \
689 : Name##Operator<BinaryOperationHint::kNumberOrOddball> \
690 : k##Name##NumberOrOddballOperator; \
691 : Name##Operator<BinaryOperationHint::kString> k##Name##StringOperator; \
692 : Name##Operator<BinaryOperationHint::kBigInt> k##Name##BigIntOperator; \
693 : Name##Operator<BinaryOperationHint::kAny> k##Name##AnyOperator;
694 466632 : BINARY_OP_LIST(BINARY_OP)
695 : #undef BINARY_OP
696 :
697 : #define COMPARE_OP(Name, properties) \
698 : template <CompareOperationHint kHint> \
699 : struct Name##Operator final : public Operator1<CompareOperationHint> { \
700 : Name##Operator() \
701 : : Operator1<CompareOperationHint>( \
702 : IrOpcode::kJS##Name, properties, "JS" #Name, 2, 1, 1, 1, 1, \
703 : Operator::ZeroIfNoThrow(properties), kHint) {} \
704 : }; \
705 : Name##Operator<CompareOperationHint::kNone> k##Name##NoneOperator; \
706 : Name##Operator<CompareOperationHint::kSignedSmall> \
707 : k##Name##SignedSmallOperator; \
708 : Name##Operator<CompareOperationHint::kNumber> k##Name##NumberOperator; \
709 : Name##Operator<CompareOperationHint::kNumberOrOddball> \
710 : k##Name##NumberOrOddballOperator; \
711 : Name##Operator<CompareOperationHint::kInternalizedString> \
712 : k##Name##InternalizedStringOperator; \
713 : Name##Operator<CompareOperationHint::kString> k##Name##StringOperator; \
714 : Name##Operator<CompareOperationHint::kSymbol> k##Name##SymbolOperator; \
715 : Name##Operator<CompareOperationHint::kBigInt> k##Name##BigIntOperator; \
716 : Name##Operator<CompareOperationHint::kReceiver> k##Name##ReceiverOperator; \
717 : Name##Operator<CompareOperationHint::kReceiverOrNullOrUndefined> \
718 : k##Name##ReceiverOrNullOrUndefinedOperator; \
719 : Name##Operator<CompareOperationHint::kAny> k##Name##AnyOperator;
720 3421968 : COMPARE_OP_LIST(COMPARE_OP)
721 : #undef COMPARE_OP
722 : };
723 :
724 : namespace {
725 1884119 : DEFINE_LAZY_LEAKY_OBJECT_GETTER(JSOperatorGlobalCache, GetJSOperatorGlobalCache)
726 : }
727 :
728 1858193 : JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
729 1858193 : : cache_(*GetJSOperatorGlobalCache()), zone_(zone) {}
730 :
731 : #define CACHED_OP(Name, properties, value_input_count, value_output_count) \
732 : const Operator* JSOperatorBuilder::Name() { \
733 : return &cache_.k##Name##Operator; \
734 : }
735 830240 : CACHED_OP_LIST(CACHED_OP)
736 : #undef CACHED_OP
737 :
738 : #define BINARY_OP(Name) \
739 : const Operator* JSOperatorBuilder::Name(BinaryOperationHint hint) { \
740 : switch (hint) { \
741 : case BinaryOperationHint::kNone: \
742 : return &cache_.k##Name##NoneOperator; \
743 : case BinaryOperationHint::kSignedSmall: \
744 : return &cache_.k##Name##SignedSmallOperator; \
745 : case BinaryOperationHint::kSignedSmallInputs: \
746 : return &cache_.k##Name##SignedSmallInputsOperator; \
747 : case BinaryOperationHint::kSigned32: \
748 : return &cache_.k##Name##Signed32Operator; \
749 : case BinaryOperationHint::kNumber: \
750 : return &cache_.k##Name##NumberOperator; \
751 : case BinaryOperationHint::kNumberOrOddball: \
752 : return &cache_.k##Name##NumberOrOddballOperator; \
753 : case BinaryOperationHint::kString: \
754 : return &cache_.k##Name##StringOperator; \
755 : case BinaryOperationHint::kBigInt: \
756 : return &cache_.k##Name##BigIntOperator; \
757 : case BinaryOperationHint::kAny: \
758 : return &cache_.k##Name##AnyOperator; \
759 : } \
760 : UNREACHABLE(); \
761 : return nullptr; \
762 : }
763 290936 : BINARY_OP_LIST(BINARY_OP)
764 : #undef BINARY_OP
765 :
766 : #define COMPARE_OP(Name, ...) \
767 : const Operator* JSOperatorBuilder::Name(CompareOperationHint hint) { \
768 : switch (hint) { \
769 : case CompareOperationHint::kNone: \
770 : return &cache_.k##Name##NoneOperator; \
771 : case CompareOperationHint::kSignedSmall: \
772 : return &cache_.k##Name##SignedSmallOperator; \
773 : case CompareOperationHint::kNumber: \
774 : return &cache_.k##Name##NumberOperator; \
775 : case CompareOperationHint::kNumberOrOddball: \
776 : return &cache_.k##Name##NumberOrOddballOperator; \
777 : case CompareOperationHint::kInternalizedString: \
778 : return &cache_.k##Name##InternalizedStringOperator; \
779 : case CompareOperationHint::kString: \
780 : return &cache_.k##Name##StringOperator; \
781 : case CompareOperationHint::kSymbol: \
782 : return &cache_.k##Name##SymbolOperator; \
783 : case CompareOperationHint::kBigInt: \
784 : return &cache_.k##Name##BigIntOperator; \
785 : case CompareOperationHint::kReceiver: \
786 : return &cache_.k##Name##ReceiverOperator; \
787 : case CompareOperationHint::kReceiverOrNullOrUndefined: \
788 : return &cache_.k##Name##ReceiverOrNullOrUndefinedOperator; \
789 : case CompareOperationHint::kAny: \
790 : return &cache_.k##Name##AnyOperator; \
791 : } \
792 : UNREACHABLE(); \
793 : return nullptr; \
794 : }
795 276088 : COMPARE_OP_LIST(COMPARE_OP)
796 : #undef COMPARE_OP
797 :
798 551 : const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral(
799 : const VectorSlotPair& feedback) {
800 : FeedbackParameter parameters(feedback);
801 : return new (zone()) Operator1<FeedbackParameter>( // --
802 : IrOpcode::kJSStoreDataPropertyInLiteral,
803 : Operator::kNoThrow, // opcode
804 : "JSStoreDataPropertyInLiteral", // name
805 : 4, 1, 1, 0, 1, 0, // counts
806 551 : parameters); // parameter
807 : }
808 :
809 52432 : const Operator* JSOperatorBuilder::StoreInArrayLiteral(
810 : const VectorSlotPair& feedback) {
811 : FeedbackParameter parameters(feedback);
812 : return new (zone()) Operator1<FeedbackParameter>( // --
813 : IrOpcode::kJSStoreInArrayLiteral,
814 : Operator::kNoThrow, // opcode
815 : "JSStoreInArrayLiteral", // name
816 : 3, 1, 1, 0, 1, 1, // counts
817 52432 : parameters); // parameter
818 : }
819 :
820 373 : const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity,
821 : uint32_t start_index) {
822 : CallForwardVarargsParameters parameters(arity, start_index);
823 : return new (zone()) Operator1<CallForwardVarargsParameters>( // --
824 : IrOpcode::kJSCallForwardVarargs, Operator::kNoProperties, // opcode
825 : "JSCallForwardVarargs", // name
826 : parameters.arity(), 1, 1, 1, 1, 2, // counts
827 373 : parameters); // parameter
828 : }
829 :
830 791141 : const Operator* JSOperatorBuilder::Call(size_t arity,
831 : CallFrequency const& frequency,
832 : VectorSlotPair const& feedback,
833 : ConvertReceiverMode convert_mode,
834 : SpeculationMode speculation_mode) {
835 : DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
836 : feedback.IsValid());
837 : CallParameters parameters(arity, frequency, feedback, convert_mode,
838 : speculation_mode);
839 : return new (zone()) Operator1<CallParameters>( // --
840 : IrOpcode::kJSCall, Operator::kNoProperties, // opcode
841 : "JSCall", // name
842 : parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs
843 791141 : parameters); // parameter
844 : }
845 :
846 740 : const Operator* JSOperatorBuilder::CallWithArrayLike(CallFrequency frequency) {
847 : return new (zone()) Operator1<CallFrequency>( // --
848 : IrOpcode::kJSCallWithArrayLike, Operator::kNoProperties, // opcode
849 : "JSCallWithArrayLike", // name
850 : 3, 1, 1, 1, 1, 2, // counts
851 1480 : frequency); // parameter
852 : }
853 :
854 1110 : const Operator* JSOperatorBuilder::CallWithSpread(
855 : uint32_t arity, CallFrequency const& frequency,
856 : VectorSlotPair const& feedback, SpeculationMode speculation_mode) {
857 : DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
858 : feedback.IsValid());
859 : CallParameters parameters(arity, frequency, feedback,
860 : ConvertReceiverMode::kAny, speculation_mode);
861 : return new (zone()) Operator1<CallParameters>( // --
862 : IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode
863 : "JSCallWithSpread", // name
864 : parameters.arity(), 1, 1, 1, 1, 2, // counts
865 1110 : parameters); // parameter
866 : }
867 :
868 197447 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) {
869 197447 : const Runtime::Function* f = Runtime::FunctionForId(id);
870 197447 : return CallRuntime(f, f->nargs);
871 : }
872 :
873 :
874 184032 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id,
875 : size_t arity) {
876 184032 : const Runtime::Function* f = Runtime::FunctionForId(id);
877 184032 : return CallRuntime(f, arity);
878 : }
879 :
880 :
881 381479 : const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f,
882 : size_t arity) {
883 381479 : CallRuntimeParameters parameters(f->function_id, arity);
884 : DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity()));
885 : return new (zone()) Operator1<CallRuntimeParameters>( // --
886 : IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode
887 : "JSCallRuntime", // name
888 381478 : parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs
889 762957 : parameters); // parameter
890 : }
891 :
892 471 : const Operator* JSOperatorBuilder::ConstructForwardVarargs(
893 : size_t arity, uint32_t start_index) {
894 : ConstructForwardVarargsParameters parameters(arity, start_index);
895 : return new (zone()) Operator1<ConstructForwardVarargsParameters>( // --
896 : IrOpcode::kJSConstructForwardVarargs, Operator::kNoProperties, // opcode
897 : "JSConstructForwardVarargs", // name
898 : parameters.arity(), 1, 1, 1, 1, 2, // counts
899 471 : parameters); // parameter
900 : }
901 :
902 43315 : const Operator* JSOperatorBuilder::Construct(uint32_t arity,
903 : CallFrequency frequency,
904 : VectorSlotPair const& feedback) {
905 : ConstructParameters parameters(arity, frequency, feedback);
906 : return new (zone()) Operator1<ConstructParameters>( // --
907 : IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode
908 : "JSConstruct", // name
909 : parameters.arity(), 1, 1, 1, 1, 2, // counts
910 86630 : parameters); // parameter
911 : }
912 :
913 220 : const Operator* JSOperatorBuilder::ConstructWithArrayLike(
914 : CallFrequency frequency) {
915 : return new (zone()) Operator1<CallFrequency>( // --
916 : IrOpcode::kJSConstructWithArrayLike, // opcode
917 : Operator::kNoProperties, // properties
918 : "JSConstructWithArrayLike", // name
919 : 3, 1, 1, 1, 1, 2, // counts
920 440 : frequency); // parameter
921 : }
922 :
923 845 : const Operator* JSOperatorBuilder::ConstructWithSpread(
924 : uint32_t arity, CallFrequency frequency, VectorSlotPair const& feedback) {
925 : ConstructParameters parameters(arity, frequency, feedback);
926 : return new (zone()) Operator1<ConstructParameters>( // --
927 : IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode
928 : "JSConstructWithSpread", // name
929 : parameters.arity(), 1, 1, 1, 1, 2, // counts
930 1690 : parameters); // parameter
931 : }
932 :
933 531017 : const Operator* JSOperatorBuilder::LoadNamed(Handle<Name> name,
934 : const VectorSlotPair& feedback) {
935 : NamedAccess access(LanguageMode::kSloppy, name, feedback);
936 : return new (zone()) Operator1<NamedAccess>( // --
937 : IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
938 : "JSLoadNamed", // name
939 : 1, 1, 1, 1, 1, 2, // counts
940 531017 : access); // parameter
941 : }
942 :
943 43074 : const Operator* JSOperatorBuilder::LoadProperty(
944 : VectorSlotPair const& feedback) {
945 : PropertyAccess access(LanguageMode::kSloppy, feedback);
946 : return new (zone()) Operator1<PropertyAccess>( // --
947 : IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode
948 : "JSLoadProperty", // name
949 : 2, 1, 1, 1, 1, 2, // counts
950 43074 : access); // parameter
951 : }
952 :
953 1606 : const Operator* JSOperatorBuilder::HasProperty(VectorSlotPair const& feedback) {
954 : PropertyAccess access(LanguageMode::kSloppy, feedback);
955 : return new (zone()) Operator1<PropertyAccess>( // --
956 : IrOpcode::kJSHasProperty, Operator::kNoProperties, // opcode
957 : "JSHasProperty", // name
958 : 2, 1, 1, 1, 1, 2, // counts
959 1606 : access); // parameter
960 : }
961 :
962 3894 : const Operator* JSOperatorBuilder::InstanceOf(VectorSlotPair const& feedback) {
963 : FeedbackParameter parameter(feedback);
964 : return new (zone()) Operator1<FeedbackParameter>( // --
965 : IrOpcode::kJSInstanceOf, Operator::kNoProperties, // opcode
966 : "JSInstanceOf", // name
967 : 2, 1, 1, 1, 1, 2, // counts
968 3894 : parameter); // parameter
969 : }
970 :
971 1557 : const Operator* JSOperatorBuilder::ForInNext(ForInMode mode) {
972 : return new (zone()) Operator1<ForInMode>( // --
973 : IrOpcode::kJSForInNext, Operator::kNoProperties, // opcode
974 : "JSForInNext", // name
975 : 4, 1, 1, 1, 1, 2, // counts
976 1557 : mode); // parameter
977 : }
978 :
979 1376 : const Operator* JSOperatorBuilder::ForInPrepare(ForInMode mode) {
980 : return new (zone()) Operator1<ForInMode>( // --
981 : IrOpcode::kJSForInPrepare, // opcode
982 : Operator::kNoWrite | Operator::kNoThrow, // flags
983 : "JSForInPrepare", // name
984 : 1, 1, 1, 3, 1, 1, // counts
985 1376 : mode); // parameter
986 : }
987 :
988 5565 : const Operator* JSOperatorBuilder::GeneratorStore(int register_count) {
989 : return new (zone()) Operator1<int>( // --
990 : IrOpcode::kJSGeneratorStore, Operator::kNoThrow, // opcode
991 : "JSGeneratorStore", // name
992 5565 : 3 + register_count, 1, 1, 0, 1, 0, // counts
993 11130 : register_count); // parameter
994 : }
995 :
996 1133 : int RegisterCountOf(Operator const* op) {
997 : DCHECK_EQ(IrOpcode::kJSCreateAsyncFunctionObject, op->opcode());
998 1133 : return OpParameter<int>(op);
999 : }
1000 :
1001 5355 : int GeneratorStoreValueCountOf(const Operator* op) {
1002 : DCHECK_EQ(IrOpcode::kJSGeneratorStore, op->opcode());
1003 5355 : return OpParameter<int>(op);
1004 : }
1005 :
1006 15103 : const Operator* JSOperatorBuilder::GeneratorRestoreRegister(int index) {
1007 : return new (zone()) Operator1<int>( // --
1008 : IrOpcode::kJSGeneratorRestoreRegister, Operator::kNoThrow, // opcode
1009 : "JSGeneratorRestoreRegister", // name
1010 : 1, 1, 1, 1, 1, 0, // counts
1011 15103 : index); // parameter
1012 : }
1013 :
1014 14480 : int RestoreRegisterIndexOf(const Operator* op) {
1015 : DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, op->opcode());
1016 14480 : return OpParameter<int>(op);
1017 : }
1018 :
1019 104514 : const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
1020 : Handle<Name> name,
1021 : VectorSlotPair const& feedback) {
1022 : NamedAccess access(language_mode, name, feedback);
1023 : return new (zone()) Operator1<NamedAccess>( // --
1024 : IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
1025 : "JSStoreNamed", // name
1026 : 2, 1, 1, 0, 1, 2, // counts
1027 104514 : access); // parameter
1028 : }
1029 :
1030 :
1031 12732 : const Operator* JSOperatorBuilder::StoreProperty(
1032 : LanguageMode language_mode, VectorSlotPair const& feedback) {
1033 : PropertyAccess access(language_mode, feedback);
1034 : return new (zone()) Operator1<PropertyAccess>( // --
1035 : IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
1036 : "JSStoreProperty", // name
1037 : 3, 1, 1, 0, 1, 2, // counts
1038 12732 : access); // parameter
1039 : }
1040 :
1041 32465 : const Operator* JSOperatorBuilder::StoreNamedOwn(
1042 : Handle<Name> name, VectorSlotPair const& feedback) {
1043 : StoreNamedOwnParameters parameters(name, feedback);
1044 : return new (zone()) Operator1<StoreNamedOwnParameters>( // --
1045 : IrOpcode::kJSStoreNamedOwn, Operator::kNoProperties, // opcode
1046 : "JSStoreNamedOwn", // name
1047 : 2, 1, 1, 0, 1, 2, // counts
1048 32465 : parameters); // parameter
1049 : }
1050 :
1051 1014 : const Operator* JSOperatorBuilder::DeleteProperty() {
1052 : return new (zone()) Operator( // --
1053 : IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode
1054 : "JSDeleteProperty", // name
1055 1014 : 3, 1, 1, 1, 1, 2); // counts
1056 : }
1057 :
1058 1237 : const Operator* JSOperatorBuilder::CreateGeneratorObject() {
1059 : return new (zone()) Operator( // --
1060 : IrOpcode::kJSCreateGeneratorObject, Operator::kEliminatable, // opcode
1061 : "JSCreateGeneratorObject", // name
1062 1237 : 2, 1, 1, 1, 1, 0); // counts
1063 : }
1064 :
1065 731080 : const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name,
1066 : const VectorSlotPair& feedback,
1067 : TypeofMode typeof_mode) {
1068 : LoadGlobalParameters parameters(name, feedback, typeof_mode);
1069 : return new (zone()) Operator1<LoadGlobalParameters>( // --
1070 : IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode
1071 : "JSLoadGlobal", // name
1072 : 0, 1, 1, 1, 1, 2, // counts
1073 731080 : parameters); // parameter
1074 : }
1075 :
1076 :
1077 221102 : const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
1078 : const Handle<Name>& name,
1079 : const VectorSlotPair& feedback) {
1080 : StoreGlobalParameters parameters(language_mode, feedback, name);
1081 : return new (zone()) Operator1<StoreGlobalParameters>( // --
1082 : IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode
1083 : "JSStoreGlobal", // name
1084 : 1, 1, 1, 0, 1, 2, // counts
1085 221102 : parameters); // parameter
1086 : }
1087 :
1088 :
1089 457789 : const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index,
1090 : bool immutable) {
1091 : ContextAccess access(depth, index, immutable);
1092 : return new (zone()) Operator1<ContextAccess>( // --
1093 : IrOpcode::kJSLoadContext, // opcode
1094 : Operator::kNoWrite | Operator::kNoThrow, // flags
1095 : "JSLoadContext", // name
1096 : 0, 1, 0, 1, 1, 0, // counts
1097 457789 : access); // parameter
1098 : }
1099 :
1100 :
1101 454959 : const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
1102 : ContextAccess access(depth, index, false);
1103 : return new (zone()) Operator1<ContextAccess>( // --
1104 : IrOpcode::kJSStoreContext, // opcode
1105 : Operator::kNoRead | Operator::kNoThrow, // flags
1106 : "JSStoreContext", // name
1107 : 1, 1, 1, 0, 1, 0, // counts
1108 454959 : access); // parameter
1109 : }
1110 :
1111 294 : const Operator* JSOperatorBuilder::LoadModule(int32_t cell_index) {
1112 : return new (zone()) Operator1<int32_t>( // --
1113 : IrOpcode::kJSLoadModule, // opcode
1114 : Operator::kNoWrite | Operator::kNoThrow, // flags
1115 : "JSLoadModule", // name
1116 : 1, 1, 1, 1, 1, 0, // counts
1117 294 : cell_index); // parameter
1118 : }
1119 :
1120 6948 : const Operator* JSOperatorBuilder::StoreModule(int32_t cell_index) {
1121 : return new (zone()) Operator1<int32_t>( // --
1122 : IrOpcode::kJSStoreModule, // opcode
1123 : Operator::kNoRead | Operator::kNoThrow, // flags
1124 : "JSStoreModule", // name
1125 : 2, 1, 1, 0, 1, 0, // counts
1126 6948 : cell_index); // parameter
1127 : }
1128 :
1129 19441 : const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
1130 : return new (zone()) Operator1<CreateArgumentsType>( // --
1131 : IrOpcode::kJSCreateArguments, Operator::kEliminatable, // opcode
1132 : "JSCreateArguments", // name
1133 : 1, 1, 0, 1, 1, 0, // counts
1134 19441 : type); // parameter
1135 : }
1136 :
1137 1565 : const Operator* JSOperatorBuilder::CreateArray(
1138 : size_t arity, MaybeHandle<AllocationSite> site) {
1139 : // constructor, new_target, arg1, ..., argN
1140 1565 : int const value_input_count = static_cast<int>(arity) + 2;
1141 : CreateArrayParameters parameters(arity, site);
1142 : return new (zone()) Operator1<CreateArrayParameters>( // --
1143 : IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode
1144 : "JSCreateArray", // name
1145 : value_input_count, 1, 1, 1, 1, 2, // counts
1146 3130 : parameters); // parameter
1147 : }
1148 :
1149 908 : const Operator* JSOperatorBuilder::CreateArrayIterator(IterationKind kind) {
1150 : CreateArrayIteratorParameters parameters(kind);
1151 : return new (zone()) Operator1<CreateArrayIteratorParameters>( // --
1152 : IrOpcode::kJSCreateArrayIterator, Operator::kEliminatable, // opcode
1153 : "JSCreateArrayIterator", // name
1154 : 1, 1, 1, 1, 1, 0, // counts
1155 908 : parameters); // parameter
1156 : }
1157 :
1158 1133 : const Operator* JSOperatorBuilder::CreateAsyncFunctionObject(
1159 : int register_count) {
1160 : return new (zone()) Operator1<int>( // --
1161 : IrOpcode::kJSCreateAsyncFunctionObject, // opcode
1162 : Operator::kEliminatable, // flags
1163 : "JSCreateAsyncFunctionObject", // name
1164 : 3, 1, 1, 1, 1, 0, // counts
1165 1133 : register_count); // parameter
1166 : }
1167 :
1168 211 : const Operator* JSOperatorBuilder::CreateCollectionIterator(
1169 : CollectionKind collection_kind, IterationKind iteration_kind) {
1170 : CreateCollectionIteratorParameters parameters(collection_kind,
1171 : iteration_kind);
1172 : return new (zone()) Operator1<CreateCollectionIteratorParameters>(
1173 : IrOpcode::kJSCreateCollectionIterator, Operator::kEliminatable,
1174 211 : "JSCreateCollectionIterator", 1, 1, 1, 1, 1, 0, parameters);
1175 : }
1176 :
1177 117 : const Operator* JSOperatorBuilder::CreateBoundFunction(size_t arity,
1178 : Handle<Map> map) {
1179 : // bound_target_function, bound_this, arg1, ..., argN
1180 117 : int const value_input_count = static_cast<int>(arity) + 2;
1181 : CreateBoundFunctionParameters parameters(arity, map);
1182 : return new (zone()) Operator1<CreateBoundFunctionParameters>( // --
1183 : IrOpcode::kJSCreateBoundFunction, Operator::kEliminatable, // opcode
1184 : "JSCreateBoundFunction", // name
1185 : value_input_count, 1, 1, 1, 1, 0, // counts
1186 234 : parameters); // parameter
1187 : }
1188 :
1189 442142 : const Operator* JSOperatorBuilder::CreateClosure(
1190 : Handle<SharedFunctionInfo> shared_info, Handle<FeedbackCell> feedback_cell,
1191 : Handle<Code> code, AllocationType allocation) {
1192 : CreateClosureParameters parameters(shared_info, feedback_cell, code,
1193 : allocation);
1194 : return new (zone()) Operator1<CreateClosureParameters>( // --
1195 : IrOpcode::kJSCreateClosure, Operator::kEliminatable, // opcode
1196 : "JSCreateClosure", // name
1197 : 0, 1, 1, 1, 1, 0, // counts
1198 442145 : parameters); // parameter
1199 : }
1200 :
1201 9470 : const Operator* JSOperatorBuilder::CreateLiteralArray(
1202 : Handle<ArrayBoilerplateDescription> description,
1203 : VectorSlotPair const& feedback, int literal_flags, int number_of_elements) {
1204 : CreateLiteralParameters parameters(description, feedback, number_of_elements,
1205 : literal_flags);
1206 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1207 : IrOpcode::kJSCreateLiteralArray, // opcode
1208 : Operator::kNoProperties, // properties
1209 : "JSCreateLiteralArray", // name
1210 : 0, 1, 1, 1, 1, 2, // counts
1211 9470 : parameters); // parameter
1212 : }
1213 :
1214 22345 : const Operator* JSOperatorBuilder::CreateEmptyLiteralArray(
1215 : VectorSlotPair const& feedback) {
1216 : FeedbackParameter parameters(feedback);
1217 : return new (zone()) Operator1<FeedbackParameter>( // --
1218 : IrOpcode::kJSCreateEmptyLiteralArray, // opcode
1219 : Operator::kEliminatable, // properties
1220 : "JSCreateEmptyLiteralArray", // name
1221 : 0, 1, 1, 1, 1, 0, // counts
1222 22345 : parameters); // parameter
1223 : }
1224 :
1225 545 : const Operator* JSOperatorBuilder::CreateArrayFromIterable() {
1226 : return new (zone()) Operator( // --
1227 : IrOpcode::kJSCreateArrayFromIterable, // opcode
1228 : Operator::kNoProperties, // properties
1229 : "JSCreateArrayFromIterable", // name
1230 545 : 1, 1, 1, 1, 1, 2); // counts
1231 : }
1232 :
1233 14882 : const Operator* JSOperatorBuilder::CreateLiteralObject(
1234 : Handle<ObjectBoilerplateDescription> constant_properties,
1235 : VectorSlotPair const& feedback, int literal_flags,
1236 : int number_of_properties) {
1237 : CreateLiteralParameters parameters(constant_properties, feedback,
1238 : number_of_properties, literal_flags);
1239 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1240 : IrOpcode::kJSCreateLiteralObject, // opcode
1241 : Operator::kNoProperties, // properties
1242 : "JSCreateLiteralObject", // name
1243 : 0, 1, 1, 1, 1, 2, // counts
1244 14882 : parameters); // parameter
1245 : }
1246 :
1247 78 : const Operator* JSOperatorBuilder::CloneObject(VectorSlotPair const& feedback,
1248 : int literal_flags) {
1249 : CloneObjectParameters parameters(feedback, literal_flags);
1250 : return new (zone()) Operator1<CloneObjectParameters>( // --
1251 : IrOpcode::kJSCloneObject, // opcode
1252 : Operator::kNoProperties, // properties
1253 : "JSCloneObject", // name
1254 : 1, 1, 1, 1, 1, 2, // counts
1255 78 : parameters); // parameter
1256 : }
1257 :
1258 6144 : const Operator* JSOperatorBuilder::CreateEmptyLiteralObject() {
1259 : return new (zone()) Operator( // --
1260 : IrOpcode::kJSCreateEmptyLiteralObject, // opcode
1261 : Operator::kNoProperties, // properties
1262 : "JSCreateEmptyLiteralObject", // name
1263 6144 : 1, 1, 1, 1, 1, 2); // counts
1264 : }
1265 :
1266 6447 : const Operator* JSOperatorBuilder::CreateLiteralRegExp(
1267 : Handle<String> constant_pattern, VectorSlotPair const& feedback,
1268 : int literal_flags) {
1269 : CreateLiteralParameters parameters(constant_pattern, feedback, -1,
1270 : literal_flags);
1271 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1272 : IrOpcode::kJSCreateLiteralRegExp, // opcode
1273 : Operator::kNoProperties, // properties
1274 : "JSCreateLiteralRegExp", // name
1275 : 0, 1, 1, 1, 1, 2, // counts
1276 6447 : parameters); // parameter
1277 : }
1278 :
1279 29728 : const Operator* JSOperatorBuilder::CreateFunctionContext(
1280 : Handle<ScopeInfo> scope_info, int slot_count, ScopeType scope_type) {
1281 : CreateFunctionContextParameters parameters(scope_info, slot_count,
1282 : scope_type);
1283 : return new (zone()) Operator1<CreateFunctionContextParameters>( // --
1284 : IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode
1285 : "JSCreateFunctionContext", // name
1286 : 0, 1, 1, 1, 1, 2, // counts
1287 29728 : parameters); // parameter
1288 : }
1289 :
1290 15653 : const Operator* JSOperatorBuilder::CreateCatchContext(
1291 : const Handle<ScopeInfo>& scope_info) {
1292 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1293 : IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
1294 : "JSCreateCatchContext", // name
1295 : 1, 1, 1, 1, 1, 2, // counts
1296 31306 : scope_info); // parameter
1297 : }
1298 :
1299 493 : const Operator* JSOperatorBuilder::CreateWithContext(
1300 : const Handle<ScopeInfo>& scope_info) {
1301 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1302 : IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode
1303 : "JSCreateWithContext", // name
1304 : 1, 1, 1, 1, 1, 2, // counts
1305 986 : scope_info); // parameter
1306 : }
1307 :
1308 9415 : const Operator* JSOperatorBuilder::CreateBlockContext(
1309 : const Handle<ScopeInfo>& scope_info) {
1310 : return new (zone()) Operator1<Handle<ScopeInfo>>( // --
1311 : IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode
1312 : "JSCreateBlockContext", // name
1313 : 0, 1, 1, 1, 1, 2, // counts
1314 18830 : scope_info); // parameter
1315 : }
1316 :
1317 50314 : Handle<ScopeInfo> ScopeInfoOf(const Operator* op) {
1318 : DCHECK(IrOpcode::kJSCreateBlockContext == op->opcode() ||
1319 : IrOpcode::kJSCreateWithContext == op->opcode() ||
1320 : IrOpcode::kJSCreateCatchContext == op->opcode());
1321 50314 : return OpParameter<Handle<ScopeInfo>>(op);
1322 : }
1323 :
1324 : #undef BINARY_OP_LIST
1325 : #undef CACHED_OP_LIST
1326 : #undef COMPARE_OP_LIST
1327 :
1328 : } // namespace compiler
1329 : } // namespace internal
1330 122036 : } // namespace v8
|