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 1068 : CallFrequency CallFrequencyOf(Operator const* op) {
26 : DCHECK(op->opcode() == IrOpcode::kJSCallWithArrayLike ||
27 : op->opcode() == IrOpcode::kJSConstructWithArrayLike);
28 1068 : 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 510 : ConstructForwardVarargsParameters const& ConstructForwardVarargsParametersOf(
38 : Operator const* op) {
39 : DCHECK_EQ(IrOpcode::kJSConstructForwardVarargs, op->opcode());
40 510 : 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 130475 : ConstructParameters const& ConstructParametersOf(Operator const* op) {
63 : DCHECK(op->opcode() == IrOpcode::kJSConstruct ||
64 : op->opcode() == IrOpcode::kJSConstructWithSpread);
65 130475 : 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 1989493 : const CallParameters& CallParametersOf(const Operator* op) {
73 : DCHECK(op->opcode() == IrOpcode::kJSCall ||
74 : op->opcode() == IrOpcode::kJSCallWithSpread);
75 1989493 : 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 13062244 : const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) {
113 : DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode());
114 13062244 : 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 910338 : 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 3339179 : ContextAccess const& ContextAccessOf(Operator const* op) {
150 : DCHECK(op->opcode() == IrOpcode::kJSLoadContext ||
151 : op->opcode() == IrOpcode::kJSStoreContext);
152 3339179 : 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 63934 : CreateFunctionContextParameters const& CreateFunctionContextParametersOf(
185 : Operator const* op) {
186 : DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, op->opcode());
187 63934 : 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 67288 : StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) {
210 : DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode());
211 67288 : 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 172562 : 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 172562 : 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 2102809 : NamedAccess const& NamedAccessOf(const Operator* op) {
262 : DCHECK(op->opcode() == IrOpcode::kJSLoadNamed ||
263 : op->opcode() == IrOpcode::kJSStoreNamed);
264 2102809 : 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 106147 : PropertyAccess const& PropertyAccessOf(const Operator* op) {
285 : DCHECK(op->opcode() == IrOpcode::kJSHasProperty ||
286 : op->opcode() == IrOpcode::kJSLoadProperty ||
287 : op->opcode() == IrOpcode::kJSStoreProperty);
288 106147 : 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 1289578 : const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
322 : DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode());
323 1289578 : 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 429714 : const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
353 : DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode());
354 429714 : return OpParameter<StoreGlobalParameters>(op);
355 : }
356 :
357 :
358 59715 : CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
359 : DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode());
360 59715 : 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 3279 : const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) {
390 : DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode());
391 3279 : 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 1689 : const CreateArrayIteratorParameters& CreateArrayIteratorParametersOf(
414 : const Operator* op) {
415 : DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, op->opcode());
416 1689 : 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 248 : const CreateBoundFunctionParameters& CreateBoundFunctionParametersOf(
469 : const Operator* op) {
470 : DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, op->opcode());
471 248 : 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 1348229 : const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
502 : DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode());
503 1348229 : 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 85947 : const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) {
533 : DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray ||
534 : op->opcode() == IrOpcode::kJSCreateLiteralObject ||
535 : op->opcode() == IrOpcode::kJSCreateLiteralRegExp);
536 85947 : 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 4190 : ForInMode ForInModeOf(Operator const* op) {
577 : DCHECK(op->opcode() == IrOpcode::kJSForInNext ||
578 : op->opcode() == IrOpcode::kJSForInPrepare);
579 4190 : return OpParameter<ForInMode>(op);
580 : }
581 :
582 74294 : BinaryOperationHint BinaryOperationHintOf(const Operator* op) {
583 : DCHECK_EQ(IrOpcode::kJSAdd, op->opcode());
584 74294 : return OpParameter<BinaryOperationHint>(op);
585 : }
586 :
587 686932 : 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 686932 : 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 25904 : 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 2434976 : 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::kConsOneByteString> \
692 : k##Name##ConsOneByteStringOperator; \
693 : Name##Operator<BinaryOperationHint::kConsTwoByteString> \
694 : k##Name##ConsTwoByteStringOperator; \
695 : Name##Operator<BinaryOperationHint::kConsString> \
696 : k##Name##ConsStringOperator; \
697 : Name##Operator<BinaryOperationHint::kString> k##Name##StringOperator; \
698 : Name##Operator<BinaryOperationHint::kBigInt> k##Name##BigIntOperator; \
699 : Name##Operator<BinaryOperationHint::kAny> k##Name##AnyOperator;
700 621696 : BINARY_OP_LIST(BINARY_OP)
701 : #undef BINARY_OP
702 :
703 : #define COMPARE_OP(Name, properties) \
704 : template <CompareOperationHint kHint> \
705 : struct Name##Operator final : public Operator1<CompareOperationHint> { \
706 : Name##Operator() \
707 : : Operator1<CompareOperationHint>( \
708 : IrOpcode::kJS##Name, properties, "JS" #Name, 2, 1, 1, 1, 1, \
709 : Operator::ZeroIfNoThrow(properties), kHint) {} \
710 : }; \
711 : Name##Operator<CompareOperationHint::kNone> k##Name##NoneOperator; \
712 : Name##Operator<CompareOperationHint::kSignedSmall> \
713 : k##Name##SignedSmallOperator; \
714 : Name##Operator<CompareOperationHint::kNumber> k##Name##NumberOperator; \
715 : Name##Operator<CompareOperationHint::kNumberOrOddball> \
716 : k##Name##NumberOrOddballOperator; \
717 : Name##Operator<CompareOperationHint::kInternalizedString> \
718 : k##Name##InternalizedStringOperator; \
719 : Name##Operator<CompareOperationHint::kString> k##Name##StringOperator; \
720 : Name##Operator<CompareOperationHint::kSymbol> k##Name##SymbolOperator; \
721 : Name##Operator<CompareOperationHint::kBigInt> k##Name##BigIntOperator; \
722 : Name##Operator<CompareOperationHint::kReceiver> k##Name##ReceiverOperator; \
723 : Name##Operator<CompareOperationHint::kReceiverOrNullOrUndefined> \
724 : k##Name##ReceiverOrNullOrUndefinedOperator; \
725 : Name##Operator<CompareOperationHint::kAny> k##Name##AnyOperator;
726 3419328 : COMPARE_OP_LIST(COMPARE_OP)
727 : #undef COMPARE_OP
728 : };
729 :
730 : namespace {
731 1884207 : DEFINE_LAZY_LEAKY_OBJECT_GETTER(JSOperatorGlobalCache, GetJSOperatorGlobalCache)
732 : }
733 :
734 1858301 : JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
735 1858301 : : cache_(*GetJSOperatorGlobalCache()), zone_(zone) {}
736 :
737 : #define CACHED_OP(Name, properties, value_input_count, value_output_count) \
738 : const Operator* JSOperatorBuilder::Name() { \
739 : return &cache_.k##Name##Operator; \
740 : }
741 831521 : CACHED_OP_LIST(CACHED_OP)
742 : #undef CACHED_OP
743 :
744 : #define BINARY_OP(Name) \
745 : const Operator* JSOperatorBuilder::Name(BinaryOperationHint hint) { \
746 : switch (hint) { \
747 : case BinaryOperationHint::kNone: \
748 : return &cache_.k##Name##NoneOperator; \
749 : case BinaryOperationHint::kSignedSmall: \
750 : return &cache_.k##Name##SignedSmallOperator; \
751 : case BinaryOperationHint::kSignedSmallInputs: \
752 : return &cache_.k##Name##SignedSmallInputsOperator; \
753 : case BinaryOperationHint::kSigned32: \
754 : return &cache_.k##Name##Signed32Operator; \
755 : case BinaryOperationHint::kNumber: \
756 : return &cache_.k##Name##NumberOperator; \
757 : case BinaryOperationHint::kNumberOrOddball: \
758 : return &cache_.k##Name##NumberOrOddballOperator; \
759 : case BinaryOperationHint::kConsOneByteString: \
760 : return &cache_.k##Name##ConsOneByteStringOperator; \
761 : case BinaryOperationHint::kConsTwoByteString: \
762 : return &cache_.k##Name##ConsTwoByteStringOperator; \
763 : case BinaryOperationHint::kConsString: \
764 : return &cache_.k##Name##ConsStringOperator; \
765 : case BinaryOperationHint::kString: \
766 : return &cache_.k##Name##StringOperator; \
767 : case BinaryOperationHint::kBigInt: \
768 : return &cache_.k##Name##BigIntOperator; \
769 : case BinaryOperationHint::kAny: \
770 : return &cache_.k##Name##AnyOperator; \
771 : } \
772 : UNREACHABLE(); \
773 : return nullptr; \
774 : }
775 290327 : BINARY_OP_LIST(BINARY_OP)
776 : #undef BINARY_OP
777 :
778 : #define COMPARE_OP(Name, ...) \
779 : const Operator* JSOperatorBuilder::Name(CompareOperationHint hint) { \
780 : switch (hint) { \
781 : case CompareOperationHint::kNone: \
782 : return &cache_.k##Name##NoneOperator; \
783 : case CompareOperationHint::kSignedSmall: \
784 : return &cache_.k##Name##SignedSmallOperator; \
785 : case CompareOperationHint::kNumber: \
786 : return &cache_.k##Name##NumberOperator; \
787 : case CompareOperationHint::kNumberOrOddball: \
788 : return &cache_.k##Name##NumberOrOddballOperator; \
789 : case CompareOperationHint::kInternalizedString: \
790 : return &cache_.k##Name##InternalizedStringOperator; \
791 : case CompareOperationHint::kString: \
792 : return &cache_.k##Name##StringOperator; \
793 : case CompareOperationHint::kSymbol: \
794 : return &cache_.k##Name##SymbolOperator; \
795 : case CompareOperationHint::kBigInt: \
796 : return &cache_.k##Name##BigIntOperator; \
797 : case CompareOperationHint::kReceiver: \
798 : return &cache_.k##Name##ReceiverOperator; \
799 : case CompareOperationHint::kReceiverOrNullOrUndefined: \
800 : return &cache_.k##Name##ReceiverOrNullOrUndefinedOperator; \
801 : case CompareOperationHint::kAny: \
802 : return &cache_.k##Name##AnyOperator; \
803 : } \
804 : UNREACHABLE(); \
805 : return nullptr; \
806 : }
807 275831 : COMPARE_OP_LIST(COMPARE_OP)
808 : #undef COMPARE_OP
809 :
810 551 : const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral(
811 : const VectorSlotPair& feedback) {
812 : FeedbackParameter parameters(feedback);
813 : return new (zone()) Operator1<FeedbackParameter>( // --
814 : IrOpcode::kJSStoreDataPropertyInLiteral,
815 : Operator::kNoThrow, // opcode
816 : "JSStoreDataPropertyInLiteral", // name
817 : 4, 1, 1, 0, 1, 0, // counts
818 551 : parameters); // parameter
819 : }
820 :
821 52196 : const Operator* JSOperatorBuilder::StoreInArrayLiteral(
822 : const VectorSlotPair& feedback) {
823 : FeedbackParameter parameters(feedback);
824 : return new (zone()) Operator1<FeedbackParameter>( // --
825 : IrOpcode::kJSStoreInArrayLiteral,
826 : Operator::kNoThrow, // opcode
827 : "JSStoreInArrayLiteral", // name
828 : 3, 1, 1, 0, 1, 1, // counts
829 52196 : parameters); // parameter
830 : }
831 :
832 373 : const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity,
833 : uint32_t start_index) {
834 : CallForwardVarargsParameters parameters(arity, start_index);
835 : return new (zone()) Operator1<CallForwardVarargsParameters>( // --
836 : IrOpcode::kJSCallForwardVarargs, Operator::kNoProperties, // opcode
837 : "JSCallForwardVarargs", // name
838 : parameters.arity(), 1, 1, 1, 1, 2, // counts
839 373 : parameters); // parameter
840 : }
841 :
842 790627 : const Operator* JSOperatorBuilder::Call(size_t arity,
843 : CallFrequency const& frequency,
844 : VectorSlotPair const& feedback,
845 : ConvertReceiverMode convert_mode,
846 : SpeculationMode speculation_mode) {
847 : DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
848 : feedback.IsValid());
849 : CallParameters parameters(arity, frequency, feedback, convert_mode,
850 : speculation_mode);
851 : return new (zone()) Operator1<CallParameters>( // --
852 : IrOpcode::kJSCall, Operator::kNoProperties, // opcode
853 : "JSCall", // name
854 : parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs
855 790627 : parameters); // parameter
856 : }
857 :
858 743 : const Operator* JSOperatorBuilder::CallWithArrayLike(CallFrequency frequency) {
859 : return new (zone()) Operator1<CallFrequency>( // --
860 : IrOpcode::kJSCallWithArrayLike, Operator::kNoProperties, // opcode
861 : "JSCallWithArrayLike", // name
862 : 3, 1, 1, 1, 1, 2, // counts
863 1486 : frequency); // parameter
864 : }
865 :
866 1116 : const Operator* JSOperatorBuilder::CallWithSpread(
867 : uint32_t arity, CallFrequency const& frequency,
868 : VectorSlotPair const& feedback, SpeculationMode speculation_mode) {
869 : DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
870 : feedback.IsValid());
871 : CallParameters parameters(arity, frequency, feedback,
872 : ConvertReceiverMode::kAny, speculation_mode);
873 : return new (zone()) Operator1<CallParameters>( // --
874 : IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode
875 : "JSCallWithSpread", // name
876 : parameters.arity(), 1, 1, 1, 1, 2, // counts
877 1116 : parameters); // parameter
878 : }
879 :
880 197357 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) {
881 197357 : const Runtime::Function* f = Runtime::FunctionForId(id);
882 197357 : return CallRuntime(f, f->nargs);
883 : }
884 :
885 :
886 184108 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id,
887 : size_t arity) {
888 184108 : const Runtime::Function* f = Runtime::FunctionForId(id);
889 184108 : return CallRuntime(f, arity);
890 : }
891 :
892 :
893 381465 : const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f,
894 : size_t arity) {
895 381465 : CallRuntimeParameters parameters(f->function_id, arity);
896 : DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity()));
897 : return new (zone()) Operator1<CallRuntimeParameters>( // --
898 : IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode
899 : "JSCallRuntime", // name
900 381465 : parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs
901 762930 : parameters); // parameter
902 : }
903 :
904 469 : const Operator* JSOperatorBuilder::ConstructForwardVarargs(
905 : size_t arity, uint32_t start_index) {
906 : ConstructForwardVarargsParameters parameters(arity, start_index);
907 : return new (zone()) Operator1<ConstructForwardVarargsParameters>( // --
908 : IrOpcode::kJSConstructForwardVarargs, Operator::kNoProperties, // opcode
909 : "JSConstructForwardVarargs", // name
910 : parameters.arity(), 1, 1, 1, 1, 2, // counts
911 469 : parameters); // parameter
912 : }
913 :
914 43245 : const Operator* JSOperatorBuilder::Construct(uint32_t arity,
915 : CallFrequency frequency,
916 : VectorSlotPair const& feedback) {
917 : ConstructParameters parameters(arity, frequency, feedback);
918 : return new (zone()) Operator1<ConstructParameters>( // --
919 : IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode
920 : "JSConstruct", // name
921 : parameters.arity(), 1, 1, 1, 1, 2, // counts
922 86490 : parameters); // parameter
923 : }
924 :
925 220 : const Operator* JSOperatorBuilder::ConstructWithArrayLike(
926 : CallFrequency frequency) {
927 : return new (zone()) Operator1<CallFrequency>( // --
928 : IrOpcode::kJSConstructWithArrayLike, // opcode
929 : Operator::kNoProperties, // properties
930 : "JSConstructWithArrayLike", // name
931 : 3, 1, 1, 1, 1, 2, // counts
932 440 : frequency); // parameter
933 : }
934 :
935 818 : const Operator* JSOperatorBuilder::ConstructWithSpread(
936 : uint32_t arity, CallFrequency frequency, VectorSlotPair const& feedback) {
937 : ConstructParameters parameters(arity, frequency, feedback);
938 : return new (zone()) Operator1<ConstructParameters>( // --
939 : IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode
940 : "JSConstructWithSpread", // name
941 : parameters.arity(), 1, 1, 1, 1, 2, // counts
942 1636 : parameters); // parameter
943 : }
944 :
945 530581 : const Operator* JSOperatorBuilder::LoadNamed(Handle<Name> name,
946 : const VectorSlotPair& feedback) {
947 : NamedAccess access(LanguageMode::kSloppy, name, feedback);
948 : return new (zone()) Operator1<NamedAccess>( // --
949 : IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
950 : "JSLoadNamed", // name
951 : 1, 1, 1, 1, 1, 2, // counts
952 530581 : access); // parameter
953 : }
954 :
955 43042 : const Operator* JSOperatorBuilder::LoadProperty(
956 : VectorSlotPair const& feedback) {
957 : PropertyAccess access(LanguageMode::kSloppy, feedback);
958 : return new (zone()) Operator1<PropertyAccess>( // --
959 : IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode
960 : "JSLoadProperty", // name
961 : 2, 1, 1, 1, 1, 2, // counts
962 43042 : access); // parameter
963 : }
964 :
965 1601 : const Operator* JSOperatorBuilder::HasProperty(VectorSlotPair const& feedback) {
966 : PropertyAccess access(LanguageMode::kSloppy, feedback);
967 : return new (zone()) Operator1<PropertyAccess>( // --
968 : IrOpcode::kJSHasProperty, Operator::kNoProperties, // opcode
969 : "JSHasProperty", // name
970 : 2, 1, 1, 1, 1, 2, // counts
971 1601 : access); // parameter
972 : }
973 :
974 3894 : const Operator* JSOperatorBuilder::InstanceOf(VectorSlotPair const& feedback) {
975 : FeedbackParameter parameter(feedback);
976 : return new (zone()) Operator1<FeedbackParameter>( // --
977 : IrOpcode::kJSInstanceOf, Operator::kNoProperties, // opcode
978 : "JSInstanceOf", // name
979 : 2, 1, 1, 1, 1, 2, // counts
980 3894 : parameter); // parameter
981 : }
982 :
983 1560 : const Operator* JSOperatorBuilder::ForInNext(ForInMode mode) {
984 : return new (zone()) Operator1<ForInMode>( // --
985 : IrOpcode::kJSForInNext, Operator::kNoProperties, // opcode
986 : "JSForInNext", // name
987 : 4, 1, 1, 1, 1, 2, // counts
988 1560 : mode); // parameter
989 : }
990 :
991 1386 : const Operator* JSOperatorBuilder::ForInPrepare(ForInMode mode) {
992 : return new (zone()) Operator1<ForInMode>( // --
993 : IrOpcode::kJSForInPrepare, // opcode
994 : Operator::kNoWrite | Operator::kNoThrow, // flags
995 : "JSForInPrepare", // name
996 : 1, 1, 1, 3, 1, 1, // counts
997 1386 : mode); // parameter
998 : }
999 :
1000 5768 : const Operator* JSOperatorBuilder::GeneratorStore(int register_count) {
1001 : return new (zone()) Operator1<int>( // --
1002 : IrOpcode::kJSGeneratorStore, Operator::kNoThrow, // opcode
1003 : "JSGeneratorStore", // name
1004 5768 : 3 + register_count, 1, 1, 0, 1, 0, // counts
1005 11536 : register_count); // parameter
1006 : }
1007 :
1008 1132 : int RegisterCountOf(Operator const* op) {
1009 : DCHECK_EQ(IrOpcode::kJSCreateAsyncFunctionObject, op->opcode());
1010 1132 : return OpParameter<int>(op);
1011 : }
1012 :
1013 5548 : int GeneratorStoreValueCountOf(const Operator* op) {
1014 : DCHECK_EQ(IrOpcode::kJSGeneratorStore, op->opcode());
1015 5548 : return OpParameter<int>(op);
1016 : }
1017 :
1018 15714 : const Operator* JSOperatorBuilder::GeneratorRestoreRegister(int index) {
1019 : return new (zone()) Operator1<int>( // --
1020 : IrOpcode::kJSGeneratorRestoreRegister, Operator::kNoThrow, // opcode
1021 : "JSGeneratorRestoreRegister", // name
1022 : 1, 1, 1, 1, 1, 0, // counts
1023 15714 : index); // parameter
1024 : }
1025 :
1026 15038 : int RestoreRegisterIndexOf(const Operator* op) {
1027 : DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, op->opcode());
1028 15038 : return OpParameter<int>(op);
1029 : }
1030 :
1031 104784 : const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
1032 : Handle<Name> name,
1033 : VectorSlotPair const& feedback) {
1034 : NamedAccess access(language_mode, name, feedback);
1035 : return new (zone()) Operator1<NamedAccess>( // --
1036 : IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
1037 : "JSStoreNamed", // name
1038 : 2, 1, 1, 0, 1, 2, // counts
1039 104784 : access); // parameter
1040 : }
1041 :
1042 :
1043 12699 : const Operator* JSOperatorBuilder::StoreProperty(
1044 : LanguageMode language_mode, VectorSlotPair const& feedback) {
1045 : PropertyAccess access(language_mode, feedback);
1046 : return new (zone()) Operator1<PropertyAccess>( // --
1047 : IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
1048 : "JSStoreProperty", // name
1049 : 3, 1, 1, 0, 1, 2, // counts
1050 12699 : access); // parameter
1051 : }
1052 :
1053 32410 : const Operator* JSOperatorBuilder::StoreNamedOwn(
1054 : Handle<Name> name, VectorSlotPair const& feedback) {
1055 : StoreNamedOwnParameters parameters(name, feedback);
1056 : return new (zone()) Operator1<StoreNamedOwnParameters>( // --
1057 : IrOpcode::kJSStoreNamedOwn, Operator::kNoProperties, // opcode
1058 : "JSStoreNamedOwn", // name
1059 : 2, 1, 1, 0, 1, 2, // counts
1060 32410 : parameters); // parameter
1061 : }
1062 :
1063 970 : const Operator* JSOperatorBuilder::DeleteProperty() {
1064 : return new (zone()) Operator( // --
1065 : IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode
1066 : "JSDeleteProperty", // name
1067 970 : 3, 1, 1, 1, 1, 2); // counts
1068 : }
1069 :
1070 1290 : const Operator* JSOperatorBuilder::CreateGeneratorObject() {
1071 : return new (zone()) Operator( // --
1072 : IrOpcode::kJSCreateGeneratorObject, Operator::kEliminatable, // opcode
1073 : "JSCreateGeneratorObject", // name
1074 1290 : 2, 1, 1, 1, 1, 0); // counts
1075 : }
1076 :
1077 731008 : const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name,
1078 : const VectorSlotPair& feedback,
1079 : TypeofMode typeof_mode) {
1080 : LoadGlobalParameters parameters(name, feedback, typeof_mode);
1081 : return new (zone()) Operator1<LoadGlobalParameters>( // --
1082 : IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode
1083 : "JSLoadGlobal", // name
1084 : 0, 1, 1, 1, 1, 2, // counts
1085 731008 : parameters); // parameter
1086 : }
1087 :
1088 :
1089 221098 : const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
1090 : const Handle<Name>& name,
1091 : const VectorSlotPair& feedback) {
1092 : StoreGlobalParameters parameters(language_mode, feedback, name);
1093 : return new (zone()) Operator1<StoreGlobalParameters>( // --
1094 : IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode
1095 : "JSStoreGlobal", // name
1096 : 1, 1, 1, 0, 1, 2, // counts
1097 221098 : parameters); // parameter
1098 : }
1099 :
1100 :
1101 457122 : const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index,
1102 : bool immutable) {
1103 : ContextAccess access(depth, index, immutable);
1104 : return new (zone()) Operator1<ContextAccess>( // --
1105 : IrOpcode::kJSLoadContext, // opcode
1106 : Operator::kNoWrite | Operator::kNoThrow, // flags
1107 : "JSLoadContext", // name
1108 : 0, 1, 0, 1, 1, 0, // counts
1109 457122 : access); // parameter
1110 : }
1111 :
1112 :
1113 453216 : const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
1114 : ContextAccess access(depth, index, false);
1115 : return new (zone()) Operator1<ContextAccess>( // --
1116 : IrOpcode::kJSStoreContext, // opcode
1117 : Operator::kNoRead | Operator::kNoThrow, // flags
1118 : "JSStoreContext", // name
1119 : 1, 1, 1, 0, 1, 0, // counts
1120 453216 : access); // parameter
1121 : }
1122 :
1123 294 : const Operator* JSOperatorBuilder::LoadModule(int32_t cell_index) {
1124 : return new (zone()) Operator1<int32_t>( // --
1125 : IrOpcode::kJSLoadModule, // opcode
1126 : Operator::kNoWrite | Operator::kNoThrow, // flags
1127 : "JSLoadModule", // name
1128 : 1, 1, 1, 1, 1, 0, // counts
1129 294 : cell_index); // parameter
1130 : }
1131 :
1132 6948 : const Operator* JSOperatorBuilder::StoreModule(int32_t cell_index) {
1133 : return new (zone()) Operator1<int32_t>( // --
1134 : IrOpcode::kJSStoreModule, // opcode
1135 : Operator::kNoRead | Operator::kNoThrow, // flags
1136 : "JSStoreModule", // name
1137 : 2, 1, 1, 0, 1, 0, // counts
1138 6948 : cell_index); // parameter
1139 : }
1140 :
1141 19387 : const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
1142 : return new (zone()) Operator1<CreateArgumentsType>( // --
1143 : IrOpcode::kJSCreateArguments, Operator::kEliminatable, // opcode
1144 : "JSCreateArguments", // name
1145 : 1, 1, 0, 1, 1, 0, // counts
1146 19387 : type); // parameter
1147 : }
1148 :
1149 1555 : const Operator* JSOperatorBuilder::CreateArray(
1150 : size_t arity, MaybeHandle<AllocationSite> site) {
1151 : // constructor, new_target, arg1, ..., argN
1152 1555 : int const value_input_count = static_cast<int>(arity) + 2;
1153 : CreateArrayParameters parameters(arity, site);
1154 : return new (zone()) Operator1<CreateArrayParameters>( // --
1155 : IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode
1156 : "JSCreateArray", // name
1157 : value_input_count, 1, 1, 1, 1, 2, // counts
1158 3110 : parameters); // parameter
1159 : }
1160 :
1161 923 : const Operator* JSOperatorBuilder::CreateArrayIterator(IterationKind kind) {
1162 : CreateArrayIteratorParameters parameters(kind);
1163 : return new (zone()) Operator1<CreateArrayIteratorParameters>( // --
1164 : IrOpcode::kJSCreateArrayIterator, Operator::kEliminatable, // opcode
1165 : "JSCreateArrayIterator", // name
1166 : 1, 1, 1, 1, 1, 0, // counts
1167 923 : parameters); // parameter
1168 : }
1169 :
1170 1132 : const Operator* JSOperatorBuilder::CreateAsyncFunctionObject(
1171 : int register_count) {
1172 : return new (zone()) Operator1<int>( // --
1173 : IrOpcode::kJSCreateAsyncFunctionObject, // opcode
1174 : Operator::kEliminatable, // flags
1175 : "JSCreateAsyncFunctionObject", // name
1176 : 3, 1, 1, 1, 1, 0, // counts
1177 1132 : register_count); // parameter
1178 : }
1179 :
1180 211 : const Operator* JSOperatorBuilder::CreateCollectionIterator(
1181 : CollectionKind collection_kind, IterationKind iteration_kind) {
1182 : CreateCollectionIteratorParameters parameters(collection_kind,
1183 : iteration_kind);
1184 : return new (zone()) Operator1<CreateCollectionIteratorParameters>(
1185 : IrOpcode::kJSCreateCollectionIterator, Operator::kEliminatable,
1186 211 : "JSCreateCollectionIterator", 1, 1, 1, 1, 1, 0, parameters);
1187 : }
1188 :
1189 116 : const Operator* JSOperatorBuilder::CreateBoundFunction(size_t arity,
1190 : Handle<Map> map) {
1191 : // bound_target_function, bound_this, arg1, ..., argN
1192 116 : int const value_input_count = static_cast<int>(arity) + 2;
1193 : CreateBoundFunctionParameters parameters(arity, map);
1194 : return new (zone()) Operator1<CreateBoundFunctionParameters>( // --
1195 : IrOpcode::kJSCreateBoundFunction, Operator::kEliminatable, // opcode
1196 : "JSCreateBoundFunction", // name
1197 : value_input_count, 1, 1, 1, 1, 0, // counts
1198 232 : parameters); // parameter
1199 : }
1200 :
1201 441939 : const Operator* JSOperatorBuilder::CreateClosure(
1202 : Handle<SharedFunctionInfo> shared_info, Handle<FeedbackCell> feedback_cell,
1203 : Handle<Code> code, AllocationType allocation) {
1204 : CreateClosureParameters parameters(shared_info, feedback_cell, code,
1205 : allocation);
1206 : return new (zone()) Operator1<CreateClosureParameters>( // --
1207 : IrOpcode::kJSCreateClosure, Operator::kEliminatable, // opcode
1208 : "JSCreateClosure", // name
1209 : 0, 1, 1, 1, 1, 0, // counts
1210 441939 : parameters); // parameter
1211 : }
1212 :
1213 9451 : const Operator* JSOperatorBuilder::CreateLiteralArray(
1214 : Handle<ArrayBoilerplateDescription> description,
1215 : VectorSlotPair const& feedback, int literal_flags, int number_of_elements) {
1216 : CreateLiteralParameters parameters(description, feedback, number_of_elements,
1217 : literal_flags);
1218 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1219 : IrOpcode::kJSCreateLiteralArray, // opcode
1220 : Operator::kNoProperties, // properties
1221 : "JSCreateLiteralArray", // name
1222 : 0, 1, 1, 1, 1, 2, // counts
1223 9451 : parameters); // parameter
1224 : }
1225 :
1226 22310 : const Operator* JSOperatorBuilder::CreateEmptyLiteralArray(
1227 : VectorSlotPair const& feedback) {
1228 : FeedbackParameter parameters(feedback);
1229 : return new (zone()) Operator1<FeedbackParameter>( // --
1230 : IrOpcode::kJSCreateEmptyLiteralArray, // opcode
1231 : Operator::kEliminatable, // properties
1232 : "JSCreateEmptyLiteralArray", // name
1233 : 0, 1, 1, 1, 1, 0, // counts
1234 22310 : parameters); // parameter
1235 : }
1236 :
1237 545 : const Operator* JSOperatorBuilder::CreateArrayFromIterable() {
1238 : return new (zone()) Operator( // --
1239 : IrOpcode::kJSCreateArrayFromIterable, // opcode
1240 : Operator::kNoProperties, // properties
1241 : "JSCreateArrayFromIterable", // name
1242 545 : 1, 1, 1, 1, 1, 2); // counts
1243 : }
1244 :
1245 14864 : const Operator* JSOperatorBuilder::CreateLiteralObject(
1246 : Handle<ObjectBoilerplateDescription> constant_properties,
1247 : VectorSlotPair const& feedback, int literal_flags,
1248 : int number_of_properties) {
1249 : CreateLiteralParameters parameters(constant_properties, feedback,
1250 : number_of_properties, literal_flags);
1251 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1252 : IrOpcode::kJSCreateLiteralObject, // opcode
1253 : Operator::kNoProperties, // properties
1254 : "JSCreateLiteralObject", // name
1255 : 0, 1, 1, 1, 1, 2, // counts
1256 14864 : parameters); // parameter
1257 : }
1258 :
1259 78 : const Operator* JSOperatorBuilder::CloneObject(VectorSlotPair const& feedback,
1260 : int literal_flags) {
1261 : CloneObjectParameters parameters(feedback, literal_flags);
1262 : return new (zone()) Operator1<CloneObjectParameters>( // --
1263 : IrOpcode::kJSCloneObject, // opcode
1264 : Operator::kNoProperties, // properties
1265 : "JSCloneObject", // name
1266 : 1, 1, 1, 1, 1, 2, // counts
1267 78 : parameters); // parameter
1268 : }
1269 :
1270 6135 : const Operator* JSOperatorBuilder::CreateEmptyLiteralObject() {
1271 : return new (zone()) Operator( // --
1272 : IrOpcode::kJSCreateEmptyLiteralObject, // opcode
1273 : Operator::kNoProperties, // properties
1274 : "JSCreateEmptyLiteralObject", // name
1275 6135 : 1, 1, 1, 1, 1, 2); // counts
1276 : }
1277 :
1278 6439 : const Operator* JSOperatorBuilder::CreateLiteralRegExp(
1279 : Handle<String> constant_pattern, VectorSlotPair const& feedback,
1280 : int literal_flags) {
1281 : CreateLiteralParameters parameters(constant_pattern, feedback, -1,
1282 : literal_flags);
1283 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1284 : IrOpcode::kJSCreateLiteralRegExp, // opcode
1285 : Operator::kNoProperties, // properties
1286 : "JSCreateLiteralRegExp", // name
1287 : 0, 1, 1, 1, 1, 2, // counts
1288 6439 : parameters); // parameter
1289 : }
1290 :
1291 29687 : const Operator* JSOperatorBuilder::CreateFunctionContext(
1292 : Handle<ScopeInfo> scope_info, int slot_count, ScopeType scope_type) {
1293 : CreateFunctionContextParameters parameters(scope_info, slot_count,
1294 : scope_type);
1295 : return new (zone()) Operator1<CreateFunctionContextParameters>( // --
1296 : IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode
1297 : "JSCreateFunctionContext", // name
1298 : 0, 1, 1, 1, 1, 2, // counts
1299 29687 : parameters); // parameter
1300 : }
1301 :
1302 15646 : const Operator* JSOperatorBuilder::CreateCatchContext(
1303 : const Handle<ScopeInfo>& scope_info) {
1304 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1305 : IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
1306 : "JSCreateCatchContext", // name
1307 : 1, 1, 1, 1, 1, 2, // counts
1308 31292 : scope_info); // parameter
1309 : }
1310 :
1311 493 : const Operator* JSOperatorBuilder::CreateWithContext(
1312 : const Handle<ScopeInfo>& scope_info) {
1313 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1314 : IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode
1315 : "JSCreateWithContext", // name
1316 : 1, 1, 1, 1, 1, 2, // counts
1317 986 : scope_info); // parameter
1318 : }
1319 :
1320 9404 : const Operator* JSOperatorBuilder::CreateBlockContext(
1321 : const Handle<ScopeInfo>& scope_info) {
1322 : return new (zone()) Operator1<Handle<ScopeInfo>>( // --
1323 : IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode
1324 : "JSCreateBlockContext", // name
1325 : 0, 1, 1, 1, 1, 2, // counts
1326 18808 : scope_info); // parameter
1327 : }
1328 :
1329 50278 : Handle<ScopeInfo> ScopeInfoOf(const Operator* op) {
1330 : DCHECK(IrOpcode::kJSCreateBlockContext == op->opcode() ||
1331 : IrOpcode::kJSCreateWithContext == op->opcode() ||
1332 : IrOpcode::kJSCreateCatchContext == op->opcode());
1333 50278 : return OpParameter<Handle<ScopeInfo>>(op);
1334 : }
1335 :
1336 : #undef BINARY_OP_LIST
1337 : #undef CACHED_OP_LIST
1338 : #undef COMPARE_OP_LIST
1339 :
1340 : } // namespace compiler
1341 : } // namespace internal
1342 121996 : } // namespace v8
|