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 975 : CallFrequency CallFrequencyOf(Operator const* op) {
26 : DCHECK(op->opcode() == IrOpcode::kJSCallWithArrayLike ||
27 : op->opcode() == IrOpcode::kJSConstructWithArrayLike);
28 975 : 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 758 : ConstructForwardVarargsParameters const& ConstructForwardVarargsParametersOf(
38 : Operator const* op) {
39 : DCHECK_EQ(IrOpcode::kJSConstructForwardVarargs, op->opcode());
40 758 : return OpParameter<ConstructForwardVarargsParameters>(op);
41 : }
42 :
43 0 : bool operator==(ConstructParameters const& lhs,
44 0 : 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 123148 : ConstructParameters const& ConstructParametersOf(Operator const* op) {
63 : DCHECK(op->opcode() == IrOpcode::kJSConstruct ||
64 : op->opcode() == IrOpcode::kJSConstructWithSpread);
65 123148 : 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 1990209 : const CallParameters& CallParametersOf(const Operator* op) {
73 : DCHECK(op->opcode() == IrOpcode::kJSCall ||
74 : op->opcode() == IrOpcode::kJSCallWithSpread);
75 1990209 : 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 442 : CallForwardVarargsParameters const& CallForwardVarargsParametersOf(
84 : Operator const* op) {
85 : DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode());
86 442 : return OpParameter<CallForwardVarargsParameters>(op);
87 : }
88 :
89 :
90 0 : bool operator==(CallRuntimeParameters const& lhs,
91 0 : 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 12605354 : const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) {
113 : DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode());
114 12605354 : 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 863184 : 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 0 : return os << access.depth() << ", " << access.index() << ", "
145 0 : << access.immutable();
146 : }
147 :
148 :
149 3182211 : ContextAccess const& ContextAccessOf(Operator const* op) {
150 : DCHECK(op->opcode() == IrOpcode::kJSLoadContext ||
151 : op->opcode() == IrOpcode::kJSStoreContext);
152 3182211 : 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 0 : 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 0 : CreateFunctionContextParameters const& parameters) {
181 0 : return os << parameters.slot_count() << ", " << parameters.scope_type();
182 : }
183 :
184 63002 : CreateFunctionContextParameters const& CreateFunctionContextParametersOf(
185 : Operator const* op) {
186 : DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, op->opcode());
187 63002 : 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 65014 : StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) {
210 : DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode());
211 65014 : 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 153720 : 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 153720 : 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 2003524 : NamedAccess const& NamedAccessOf(const Operator* op) {
262 : DCHECK(op->opcode() == IrOpcode::kJSLoadNamed ||
263 : op->opcode() == IrOpcode::kJSStoreNamed);
264 2003524 : 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 103147 : PropertyAccess const& PropertyAccessOf(const Operator* op) {
285 : DCHECK(op->opcode() == IrOpcode::kJSLoadProperty ||
286 : op->opcode() == IrOpcode::kJSStoreProperty);
287 103147 : return OpParameter<PropertyAccess>(op);
288 : }
289 :
290 :
291 0 : size_t hash_value(PropertyAccess const& p) {
292 0 : return base::hash_combine(p.language_mode(), p.feedback());
293 : }
294 :
295 :
296 0 : bool operator==(LoadGlobalParameters const& lhs,
297 0 : LoadGlobalParameters const& rhs) {
298 0 : return lhs.name().location() == rhs.name().location() &&
299 0 : lhs.feedback() == rhs.feedback() &&
300 0 : lhs.typeof_mode() == rhs.typeof_mode();
301 : }
302 :
303 :
304 0 : bool operator!=(LoadGlobalParameters const& lhs,
305 : LoadGlobalParameters const& rhs) {
306 0 : return !(lhs == rhs);
307 : }
308 :
309 :
310 0 : size_t hash_value(LoadGlobalParameters const& p) {
311 0 : return base::hash_combine(p.name().location(), p.typeof_mode());
312 : }
313 :
314 :
315 0 : std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) {
316 0 : return os << Brief(*p.name()) << ", " << p.typeof_mode();
317 : }
318 :
319 :
320 1886206 : const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
321 : DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode());
322 1886206 : return OpParameter<LoadGlobalParameters>(op);
323 : }
324 :
325 :
326 0 : bool operator==(StoreGlobalParameters const& lhs,
327 0 : StoreGlobalParameters const& rhs) {
328 0 : return lhs.language_mode() == rhs.language_mode() &&
329 0 : lhs.name().location() == rhs.name().location() &&
330 0 : lhs.feedback() == rhs.feedback();
331 : }
332 :
333 :
334 0 : bool operator!=(StoreGlobalParameters const& lhs,
335 : StoreGlobalParameters const& rhs) {
336 0 : return !(lhs == rhs);
337 : }
338 :
339 :
340 0 : size_t hash_value(StoreGlobalParameters const& p) {
341 : return base::hash_combine(p.language_mode(), p.name().location(),
342 0 : p.feedback());
343 : }
344 :
345 :
346 0 : std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) {
347 0 : return os << p.language_mode() << ", " << Brief(*p.name());
348 : }
349 :
350 :
351 419858 : const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
352 : DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode());
353 419858 : return OpParameter<StoreGlobalParameters>(op);
354 : }
355 :
356 :
357 59580 : CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
358 : DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode());
359 59580 : return OpParameter<CreateArgumentsType>(op);
360 : }
361 :
362 :
363 0 : bool operator==(CreateArrayParameters const& lhs,
364 0 : CreateArrayParameters const& rhs) {
365 0 : return lhs.arity() == rhs.arity() &&
366 0 : lhs.site().address() == rhs.site().address();
367 : }
368 :
369 :
370 0 : bool operator!=(CreateArrayParameters const& lhs,
371 : CreateArrayParameters const& rhs) {
372 0 : return !(lhs == rhs);
373 : }
374 :
375 :
376 0 : size_t hash_value(CreateArrayParameters const& p) {
377 0 : return base::hash_combine(p.arity(), p.site().address());
378 : }
379 :
380 :
381 0 : std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) {
382 : os << p.arity();
383 : Handle<AllocationSite> site;
384 0 : if (p.site().ToHandle(&site)) os << ", " << Brief(*site);
385 0 : return os;
386 : }
387 :
388 2853 : const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) {
389 : DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode());
390 2853 : return OpParameter<CreateArrayParameters>(op);
391 : }
392 :
393 0 : bool operator==(CreateArrayIteratorParameters const& lhs,
394 : CreateArrayIteratorParameters const& rhs) {
395 0 : return lhs.kind() == rhs.kind();
396 : }
397 :
398 0 : bool operator!=(CreateArrayIteratorParameters const& lhs,
399 : CreateArrayIteratorParameters const& rhs) {
400 0 : return !(lhs == rhs);
401 : }
402 :
403 0 : size_t hash_value(CreateArrayIteratorParameters const& p) {
404 0 : return static_cast<size_t>(p.kind());
405 : }
406 :
407 0 : std::ostream& operator<<(std::ostream& os,
408 : CreateArrayIteratorParameters const& p) {
409 0 : return os << p.kind();
410 : }
411 :
412 2861 : const CreateArrayIteratorParameters& CreateArrayIteratorParametersOf(
413 : const Operator* op) {
414 : DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, op->opcode());
415 2861 : return OpParameter<CreateArrayIteratorParameters>(op);
416 : }
417 :
418 0 : bool operator==(CreateCollectionIteratorParameters const& lhs,
419 0 : CreateCollectionIteratorParameters const& rhs) {
420 0 : return lhs.collection_kind() == rhs.collection_kind() &&
421 0 : lhs.iteration_kind() == rhs.iteration_kind();
422 : }
423 :
424 0 : bool operator!=(CreateCollectionIteratorParameters const& lhs,
425 : CreateCollectionIteratorParameters const& rhs) {
426 0 : return !(lhs == rhs);
427 : }
428 :
429 0 : size_t hash_value(CreateCollectionIteratorParameters const& p) {
430 : return base::hash_combine(static_cast<size_t>(p.collection_kind()),
431 0 : static_cast<size_t>(p.iteration_kind()));
432 : }
433 :
434 0 : std::ostream& operator<<(std::ostream& os,
435 0 : CreateCollectionIteratorParameters const& p) {
436 0 : return os << p.collection_kind() << " " << p.iteration_kind();
437 : }
438 :
439 163 : const CreateCollectionIteratorParameters& CreateCollectionIteratorParametersOf(
440 : const Operator* op) {
441 : DCHECK_EQ(IrOpcode::kJSCreateCollectionIterator, op->opcode());
442 163 : return OpParameter<CreateCollectionIteratorParameters>(op);
443 : }
444 :
445 0 : bool operator==(CreateBoundFunctionParameters const& lhs,
446 0 : CreateBoundFunctionParameters const& rhs) {
447 0 : return lhs.arity() == rhs.arity() &&
448 0 : lhs.map().location() == rhs.map().location();
449 : }
450 :
451 0 : bool operator!=(CreateBoundFunctionParameters const& lhs,
452 : CreateBoundFunctionParameters const& rhs) {
453 0 : return !(lhs == rhs);
454 : }
455 :
456 0 : size_t hash_value(CreateBoundFunctionParameters const& p) {
457 0 : return base::hash_combine(p.arity(), p.map().location());
458 : }
459 :
460 0 : std::ostream& operator<<(std::ostream& os,
461 0 : CreateBoundFunctionParameters const& p) {
462 : os << p.arity();
463 0 : if (!p.map().is_null()) os << ", " << Brief(*p.map());
464 0 : return os;
465 : }
466 :
467 223 : const CreateBoundFunctionParameters& CreateBoundFunctionParametersOf(
468 : const Operator* op) {
469 : DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, op->opcode());
470 223 : return OpParameter<CreateBoundFunctionParameters>(op);
471 : }
472 :
473 0 : bool operator==(CreateClosureParameters const& lhs,
474 0 : CreateClosureParameters const& rhs) {
475 0 : return lhs.pretenure() == rhs.pretenure() &&
476 0 : lhs.code().location() == rhs.code().location() &&
477 0 : lhs.feedback_cell().location() == rhs.feedback_cell().location() &&
478 0 : lhs.shared_info().location() == rhs.shared_info().location();
479 : }
480 :
481 :
482 0 : bool operator!=(CreateClosureParameters const& lhs,
483 : CreateClosureParameters const& rhs) {
484 0 : return !(lhs == rhs);
485 : }
486 :
487 :
488 0 : size_t hash_value(CreateClosureParameters const& p) {
489 : return base::hash_combine(p.pretenure(), p.shared_info().location(),
490 0 : p.feedback_cell().location());
491 : }
492 :
493 :
494 0 : std::ostream& operator<<(std::ostream& os, CreateClosureParameters const& p) {
495 0 : return os << p.pretenure() << ", " << Brief(*p.shared_info()) << ", "
496 0 : << Brief(*p.feedback_cell()) << ", " << Brief(*p.code());
497 : }
498 :
499 :
500 1331340 : const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
501 : DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode());
502 1331340 : return OpParameter<CreateClosureParameters>(op);
503 : }
504 :
505 :
506 0 : bool operator==(CreateLiteralParameters const& lhs,
507 0 : CreateLiteralParameters const& rhs) {
508 0 : return lhs.constant().location() == rhs.constant().location() &&
509 0 : lhs.feedback() == rhs.feedback() && lhs.length() == rhs.length() &&
510 0 : lhs.flags() == rhs.flags();
511 : }
512 :
513 :
514 0 : bool operator!=(CreateLiteralParameters const& lhs,
515 : CreateLiteralParameters const& rhs) {
516 0 : return !(lhs == rhs);
517 : }
518 :
519 :
520 0 : size_t hash_value(CreateLiteralParameters const& p) {
521 0 : return base::hash_combine(p.constant().location(), p.feedback(), p.length(),
522 0 : p.flags());
523 : }
524 :
525 :
526 0 : std::ostream& operator<<(std::ostream& os, CreateLiteralParameters const& p) {
527 0 : return os << Brief(*p.constant()) << ", " << p.length() << ", " << p.flags();
528 : }
529 :
530 :
531 82990 : const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) {
532 : DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray ||
533 : op->opcode() == IrOpcode::kJSCreateLiteralObject ||
534 : op->opcode() == IrOpcode::kJSCreateLiteralRegExp);
535 82990 : return OpParameter<CreateLiteralParameters>(op);
536 : }
537 :
538 0 : bool operator==(CloneObjectParameters const& lhs,
539 0 : CloneObjectParameters const& rhs) {
540 0 : return lhs.feedback() == rhs.feedback() && lhs.flags() == rhs.flags();
541 : }
542 :
543 0 : bool operator!=(CloneObjectParameters const& lhs,
544 : CloneObjectParameters const& rhs) {
545 0 : return !(lhs == rhs);
546 : }
547 :
548 0 : size_t hash_value(CloneObjectParameters const& p) {
549 0 : return base::hash_combine(p.feedback(), p.flags());
550 : }
551 :
552 0 : std::ostream& operator<<(std::ostream& os, CloneObjectParameters const& p) {
553 0 : return os << p.flags();
554 : }
555 :
556 92 : const CloneObjectParameters& CloneObjectParametersOf(const Operator* op) {
557 : DCHECK(op->opcode() == IrOpcode::kJSCloneObject);
558 92 : return OpParameter<CloneObjectParameters>(op);
559 : }
560 :
561 0 : size_t hash_value(ForInMode mode) { return static_cast<uint8_t>(mode); }
562 :
563 0 : std::ostream& operator<<(std::ostream& os, ForInMode mode) {
564 0 : switch (mode) {
565 : case ForInMode::kUseEnumCacheKeysAndIndices:
566 0 : return os << "UseEnumCacheKeysAndIndices";
567 : case ForInMode::kUseEnumCacheKeys:
568 0 : return os << "UseEnumCacheKeys";
569 : case ForInMode::kGeneric:
570 0 : return os << "Generic";
571 : }
572 0 : UNREACHABLE();
573 : }
574 :
575 4211 : ForInMode ForInModeOf(Operator const* op) {
576 : DCHECK(op->opcode() == IrOpcode::kJSForInNext ||
577 : op->opcode() == IrOpcode::kJSForInPrepare);
578 4211 : return OpParameter<ForInMode>(op);
579 : }
580 :
581 71899 : BinaryOperationHint BinaryOperationHintOf(const Operator* op) {
582 : DCHECK_EQ(IrOpcode::kJSAdd, op->opcode());
583 71899 : return OpParameter<BinaryOperationHint>(op);
584 : }
585 :
586 677278 : CompareOperationHint CompareOperationHintOf(const Operator* op) {
587 : DCHECK(op->opcode() == IrOpcode::kJSEqual ||
588 : op->opcode() == IrOpcode::kJSStrictEqual ||
589 : op->opcode() == IrOpcode::kJSLessThan ||
590 : op->opcode() == IrOpcode::kJSGreaterThan ||
591 : op->opcode() == IrOpcode::kJSLessThanOrEqual ||
592 : op->opcode() == IrOpcode::kJSGreaterThanOrEqual);
593 677278 : return OpParameter<CompareOperationHint>(op);
594 : }
595 :
596 : #define CACHED_OP_LIST(V) \
597 : V(BitwiseOr, Operator::kNoProperties, 2, 1) \
598 : V(BitwiseXor, Operator::kNoProperties, 2, 1) \
599 : V(BitwiseAnd, Operator::kNoProperties, 2, 1) \
600 : V(ShiftLeft, Operator::kNoProperties, 2, 1) \
601 : V(ShiftRight, Operator::kNoProperties, 2, 1) \
602 : V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \
603 : V(Subtract, Operator::kNoProperties, 2, 1) \
604 : V(Multiply, Operator::kNoProperties, 2, 1) \
605 : V(Divide, Operator::kNoProperties, 2, 1) \
606 : V(Modulus, Operator::kNoProperties, 2, 1) \
607 : V(Exponentiate, Operator::kNoProperties, 2, 1) \
608 : V(BitwiseNot, Operator::kNoProperties, 1, 1) \
609 : V(Decrement, Operator::kNoProperties, 1, 1) \
610 : V(Increment, Operator::kNoProperties, 1, 1) \
611 : V(Negate, Operator::kNoProperties, 1, 1) \
612 : V(ToLength, Operator::kNoProperties, 1, 1) \
613 : V(ToName, Operator::kNoProperties, 1, 1) \
614 : V(ToNumber, Operator::kNoProperties, 1, 1) \
615 : V(ToNumberConvertBigInt, Operator::kNoProperties, 1, 1) \
616 : V(ToNumeric, Operator::kNoProperties, 1, 1) \
617 : V(ToObject, Operator::kFoldable, 1, 1) \
618 : V(ToString, Operator::kNoProperties, 1, 1) \
619 : V(Create, Operator::kNoProperties, 2, 1) \
620 : V(CreateIterResultObject, Operator::kEliminatable, 2, 1) \
621 : V(CreateStringIterator, Operator::kEliminatable, 1, 1) \
622 : V(CreateKeyValueArray, Operator::kEliminatable, 2, 1) \
623 : V(CreatePromise, Operator::kEliminatable, 0, 1) \
624 : V(CreateTypedArray, Operator::kNoProperties, 5, 1) \
625 : V(CreateObject, Operator::kNoProperties, 1, 1) \
626 : V(ObjectIsArray, Operator::kNoProperties, 1, 1) \
627 : V(HasProperty, Operator::kNoProperties, 2, 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 25149 : 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 2414304 : 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 452682 : 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 3319668 : COMPARE_OP_LIST(COMPARE_OP)
721 : #undef COMPARE_OP
722 : };
723 :
724 : namespace {
725 1846950 : DEFINE_LAZY_LEAKY_OBJECT_GETTER(JSOperatorGlobalCache, GetJSOperatorGlobalCache)
726 : }
727 :
728 1846950 : JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
729 1846950 : : 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 836964 : 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 289373 : 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 274461 : COMPARE_OP_LIST(COMPARE_OP)
796 : #undef COMPARE_OP
797 :
798 539 : const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral(
799 539 : 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 539 : parameters); // parameter
807 : }
808 :
809 43803 : const Operator* JSOperatorBuilder::StoreInArrayLiteral(
810 43803 : 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, 0, // counts
817 43803 : parameters); // parameter
818 : }
819 :
820 366 : const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity,
821 366 : 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 366 : parameters); // parameter
828 : }
829 :
830 790156 : const Operator* JSOperatorBuilder::Call(size_t arity,
831 : CallFrequency const& frequency,
832 : VectorSlotPair const& feedback,
833 : ConvertReceiverMode convert_mode,
834 790156 : 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 790159 : parameters); // parameter
844 : }
845 :
846 1406 : 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 1406 : frequency); // parameter
852 : }
853 :
854 1098 : const Operator* JSOperatorBuilder::CallWithSpread(
855 : uint32_t arity, CallFrequency const& frequency,
856 1098 : 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 1098 : parameters); // parameter
866 : }
867 :
868 193851 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) {
869 193851 : const Runtime::Function* f = Runtime::FunctionForId(id);
870 193851 : return CallRuntime(f, f->nargs);
871 : }
872 :
873 :
874 177746 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id,
875 : size_t arity) {
876 177746 : const Runtime::Function* f = Runtime::FunctionForId(id);
877 177746 : return CallRuntime(f, arity);
878 : }
879 :
880 :
881 371597 : const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f,
882 371597 : size_t arity) {
883 371597 : 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 : parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs
889 743194 : parameters); // parameter
890 : }
891 :
892 720 : const Operator* JSOperatorBuilder::ConstructForwardVarargs(
893 720 : 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 720 : parameters); // parameter
900 : }
901 :
902 40248 : const Operator* JSOperatorBuilder::Construct(uint32_t arity,
903 : CallFrequency frequency,
904 40248 : 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 80496 : parameters); // parameter
911 : }
912 :
913 189 : const Operator* JSOperatorBuilder::ConstructWithArrayLike(
914 189 : 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 378 : frequency); // parameter
921 : }
922 :
923 1047 : const Operator* JSOperatorBuilder::ConstructWithSpread(
924 1047 : 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 2094 : parameters); // parameter
931 : }
932 :
933 513058 : const Operator* JSOperatorBuilder::LoadNamed(Handle<Name> name,
934 513058 : 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 513058 : access); // parameter
941 : }
942 :
943 43238 : const Operator* JSOperatorBuilder::LoadProperty(
944 43238 : 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 43238 : access); // parameter
951 : }
952 :
953 7686 : const Operator* JSOperatorBuilder::InstanceOf(VectorSlotPair const& feedback) {
954 : FeedbackParameter parameter(feedback);
955 : return new (zone()) Operator1<FeedbackParameter>( // --
956 : IrOpcode::kJSInstanceOf, Operator::kNoProperties, // opcode
957 : "JSInstanceOf", // name
958 : 2, 1, 1, 1, 1, 2, // counts
959 3843 : parameter); // parameter
960 : }
961 :
962 1564 : const Operator* JSOperatorBuilder::ForInNext(ForInMode mode) {
963 : return new (zone()) Operator1<ForInMode>( // --
964 : IrOpcode::kJSForInNext, Operator::kNoProperties, // opcode
965 : "JSForInNext", // name
966 : 4, 1, 1, 1, 1, 2, // counts
967 1564 : mode); // parameter
968 : }
969 :
970 1384 : const Operator* JSOperatorBuilder::ForInPrepare(ForInMode mode) {
971 : return new (zone()) Operator1<ForInMode>( // --
972 : IrOpcode::kJSForInPrepare, // opcode
973 : Operator::kNoWrite | Operator::kNoThrow, // flags
974 : "JSForInPrepare", // name
975 : 1, 1, 1, 3, 1, 1, // counts
976 1384 : mode); // parameter
977 : }
978 :
979 7268 : const Operator* JSOperatorBuilder::GeneratorStore(int register_count) {
980 : return new (zone()) Operator1<int>( // --
981 : IrOpcode::kJSGeneratorStore, Operator::kNoThrow, // opcode
982 : "JSGeneratorStore", // name
983 7268 : 3 + register_count, 1, 1, 0, 1, 0, // counts
984 14536 : register_count); // parameter
985 : }
986 :
987 1080 : int RegisterCountOf(Operator const* op) {
988 : DCHECK_EQ(IrOpcode::kJSCreateAsyncFunctionObject, op->opcode());
989 1080 : return OpParameter<int>(op);
990 : }
991 :
992 7014 : int GeneratorStoreValueCountOf(const Operator* op) {
993 : DCHECK_EQ(IrOpcode::kJSGeneratorStore, op->opcode());
994 7014 : return OpParameter<int>(op);
995 : }
996 :
997 16668 : const Operator* JSOperatorBuilder::GeneratorRestoreRegister(int index) {
998 : return new (zone()) Operator1<int>( // --
999 : IrOpcode::kJSGeneratorRestoreRegister, Operator::kNoThrow, // opcode
1000 : "JSGeneratorRestoreRegister", // name
1001 : 1, 1, 1, 1, 1, 0, // counts
1002 16668 : index); // parameter
1003 : }
1004 :
1005 15937 : int RestoreRegisterIndexOf(const Operator* op) {
1006 : DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, op->opcode());
1007 15937 : return OpParameter<int>(op);
1008 : }
1009 :
1010 100178 : const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
1011 : Handle<Name> name,
1012 100178 : VectorSlotPair const& feedback) {
1013 : NamedAccess access(language_mode, name, feedback);
1014 : return new (zone()) Operator1<NamedAccess>( // --
1015 : IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
1016 : "JSStoreNamed", // name
1017 : 2, 1, 1, 0, 1, 2, // counts
1018 100178 : access); // parameter
1019 : }
1020 :
1021 :
1022 11857 : const Operator* JSOperatorBuilder::StoreProperty(
1023 11857 : LanguageMode language_mode, VectorSlotPair const& feedback) {
1024 : PropertyAccess access(language_mode, feedback);
1025 : return new (zone()) Operator1<PropertyAccess>( // --
1026 : IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
1027 : "JSStoreProperty", // name
1028 : 3, 1, 1, 0, 1, 2, // counts
1029 11857 : access); // parameter
1030 : }
1031 :
1032 31410 : const Operator* JSOperatorBuilder::StoreNamedOwn(
1033 31410 : Handle<Name> name, VectorSlotPair const& feedback) {
1034 : StoreNamedOwnParameters parameters(name, feedback);
1035 : return new (zone()) Operator1<StoreNamedOwnParameters>( // --
1036 : IrOpcode::kJSStoreNamedOwn, Operator::kNoProperties, // opcode
1037 : "JSStoreNamedOwn", // name
1038 : 2, 1, 1, 0, 1, 2, // counts
1039 31410 : parameters); // parameter
1040 : }
1041 :
1042 1910 : const Operator* JSOperatorBuilder::DeleteProperty() {
1043 : return new (zone()) Operator( // --
1044 : IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode
1045 : "JSDeleteProperty", // name
1046 955 : 3, 1, 1, 1, 1, 2); // counts
1047 : }
1048 :
1049 2648 : const Operator* JSOperatorBuilder::CreateGeneratorObject() {
1050 : return new (zone()) Operator( // --
1051 : IrOpcode::kJSCreateGeneratorObject, Operator::kEliminatable, // opcode
1052 : "JSCreateGeneratorObject", // name
1053 1324 : 2, 1, 1, 1, 1, 0); // counts
1054 : }
1055 :
1056 1027826 : const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name,
1057 : const VectorSlotPair& feedback,
1058 1027826 : TypeofMode typeof_mode) {
1059 : LoadGlobalParameters parameters(name, feedback, typeof_mode);
1060 : return new (zone()) Operator1<LoadGlobalParameters>( // --
1061 : IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode
1062 : "JSLoadGlobal", // name
1063 : 0, 1, 1, 1, 1, 2, // counts
1064 1027826 : parameters); // parameter
1065 : }
1066 :
1067 :
1068 216149 : const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
1069 : const Handle<Name>& name,
1070 216149 : const VectorSlotPair& feedback) {
1071 : StoreGlobalParameters parameters(language_mode, feedback, name);
1072 : return new (zone()) Operator1<StoreGlobalParameters>( // --
1073 : IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode
1074 : "JSStoreGlobal", // name
1075 : 1, 1, 1, 0, 1, 2, // counts
1076 216149 : parameters); // parameter
1077 : }
1078 :
1079 :
1080 440819 : const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index,
1081 440819 : bool immutable) {
1082 : ContextAccess access(depth, index, immutable);
1083 : return new (zone()) Operator1<ContextAccess>( // --
1084 : IrOpcode::kJSLoadContext, // opcode
1085 : Operator::kNoWrite | Operator::kNoThrow, // flags
1086 : "JSLoadContext", // name
1087 : 0, 1, 0, 1, 1, 0, // counts
1088 440819 : access); // parameter
1089 : }
1090 :
1091 :
1092 844730 : const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
1093 : ContextAccess access(depth, index, false);
1094 : return new (zone()) Operator1<ContextAccess>( // --
1095 : IrOpcode::kJSStoreContext, // opcode
1096 : Operator::kNoRead | Operator::kNoThrow, // flags
1097 : "JSStoreContext", // name
1098 : 1, 1, 1, 0, 1, 0, // counts
1099 422363 : access); // parameter
1100 : }
1101 :
1102 294 : const Operator* JSOperatorBuilder::LoadModule(int32_t cell_index) {
1103 : return new (zone()) Operator1<int32_t>( // --
1104 : IrOpcode::kJSLoadModule, // opcode
1105 : Operator::kNoWrite | Operator::kNoThrow, // flags
1106 : "JSLoadModule", // name
1107 : 1, 1, 1, 1, 1, 0, // counts
1108 294 : cell_index); // parameter
1109 : }
1110 :
1111 6939 : const Operator* JSOperatorBuilder::StoreModule(int32_t cell_index) {
1112 : return new (zone()) Operator1<int32_t>( // --
1113 : IrOpcode::kJSStoreModule, // opcode
1114 : Operator::kNoRead | Operator::kNoThrow, // flags
1115 : "JSStoreModule", // name
1116 : 2, 1, 1, 0, 1, 0, // counts
1117 6939 : cell_index); // parameter
1118 : }
1119 :
1120 19281 : const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
1121 : return new (zone()) Operator1<CreateArgumentsType>( // --
1122 : IrOpcode::kJSCreateArguments, Operator::kEliminatable, // opcode
1123 : "JSCreateArguments", // name
1124 : 1, 1, 0, 1, 1, 0, // counts
1125 19281 : type); // parameter
1126 : }
1127 :
1128 1367 : const Operator* JSOperatorBuilder::CreateArray(
1129 1367 : size_t arity, MaybeHandle<AllocationSite> site) {
1130 : // constructor, new_target, arg1, ..., argN
1131 1367 : int const value_input_count = static_cast<int>(arity) + 2;
1132 : CreateArrayParameters parameters(arity, site);
1133 : return new (zone()) Operator1<CreateArrayParameters>( // --
1134 : IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode
1135 : "JSCreateArray", // name
1136 : value_input_count, 1, 1, 1, 1, 2, // counts
1137 2734 : parameters); // parameter
1138 : }
1139 :
1140 1397 : const Operator* JSOperatorBuilder::CreateArrayIterator(IterationKind kind) {
1141 : CreateArrayIteratorParameters parameters(kind);
1142 : return new (zone()) Operator1<CreateArrayIteratorParameters>( // --
1143 : IrOpcode::kJSCreateArrayIterator, Operator::kEliminatable, // opcode
1144 : "JSCreateArrayIterator", // name
1145 : 1, 1, 1, 1, 1, 0, // counts
1146 1397 : parameters); // parameter
1147 : }
1148 :
1149 1080 : const Operator* JSOperatorBuilder::CreateAsyncFunctionObject(
1150 1080 : int register_count) {
1151 : return new (zone()) Operator1<int>( // --
1152 : IrOpcode::kJSCreateAsyncFunctionObject, // opcode
1153 : Operator::kEliminatable, // flags
1154 : "JSCreateAsyncFunctionObject", // name
1155 : 3, 1, 1, 1, 1, 0, // counts
1156 1080 : register_count); // parameter
1157 : }
1158 :
1159 163 : const Operator* JSOperatorBuilder::CreateCollectionIterator(
1160 163 : CollectionKind collection_kind, IterationKind iteration_kind) {
1161 : CreateCollectionIteratorParameters parameters(collection_kind,
1162 163 : iteration_kind);
1163 : return new (zone()) Operator1<CreateCollectionIteratorParameters>(
1164 : IrOpcode::kJSCreateCollectionIterator, Operator::kEliminatable,
1165 326 : "JSCreateCollectionIterator", 1, 1, 1, 1, 1, 0, parameters);
1166 : }
1167 :
1168 105 : const Operator* JSOperatorBuilder::CreateBoundFunction(size_t arity,
1169 105 : Handle<Map> map) {
1170 : // bound_target_function, bound_this, arg1, ..., argN
1171 105 : int const value_input_count = static_cast<int>(arity) + 2;
1172 : CreateBoundFunctionParameters parameters(arity, map);
1173 : return new (zone()) Operator1<CreateBoundFunctionParameters>( // --
1174 : IrOpcode::kJSCreateBoundFunction, Operator::kEliminatable, // opcode
1175 : "JSCreateBoundFunction", // name
1176 : value_input_count, 1, 1, 1, 1, 0, // counts
1177 210 : parameters); // parameter
1178 : }
1179 :
1180 437240 : const Operator* JSOperatorBuilder::CreateClosure(
1181 : Handle<SharedFunctionInfo> shared_info, Handle<FeedbackCell> feedback_cell,
1182 437240 : Handle<Code> code, PretenureFlag pretenure) {
1183 : CreateClosureParameters parameters(shared_info, feedback_cell, code,
1184 : pretenure);
1185 : return new (zone()) Operator1<CreateClosureParameters>( // --
1186 : IrOpcode::kJSCreateClosure, Operator::kEliminatable, // opcode
1187 : "JSCreateClosure", // name
1188 : 0, 1, 1, 1, 1, 0, // counts
1189 437241 : parameters); // parameter
1190 : }
1191 :
1192 8901 : const Operator* JSOperatorBuilder::CreateLiteralArray(
1193 : Handle<ArrayBoilerplateDescription> description,
1194 8901 : VectorSlotPair const& feedback, int literal_flags, int number_of_elements) {
1195 : CreateLiteralParameters parameters(description, feedback, number_of_elements,
1196 : literal_flags);
1197 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1198 : IrOpcode::kJSCreateLiteralArray, // opcode
1199 : Operator::kNoProperties, // properties
1200 : "JSCreateLiteralArray", // name
1201 : 0, 1, 1, 1, 1, 2, // counts
1202 8901 : parameters); // parameter
1203 : }
1204 :
1205 21661 : const Operator* JSOperatorBuilder::CreateEmptyLiteralArray(
1206 21661 : VectorSlotPair const& feedback) {
1207 : FeedbackParameter parameters(feedback);
1208 : return new (zone()) Operator1<FeedbackParameter>( // --
1209 : IrOpcode::kJSCreateEmptyLiteralArray, // opcode
1210 : Operator::kEliminatable, // properties
1211 : "JSCreateEmptyLiteralArray", // name
1212 : 0, 1, 1, 1, 1, 0, // counts
1213 21661 : parameters); // parameter
1214 : }
1215 :
1216 1068 : const Operator* JSOperatorBuilder::CreateArrayFromIterable() {
1217 : return new (zone()) Operator( // --
1218 : IrOpcode::kJSCreateArrayFromIterable, // opcode
1219 : Operator::kNoProperties, // properties
1220 : "JSCreateArrayFromIterable", // name
1221 534 : 1, 1, 1, 1, 1, 2); // counts
1222 : }
1223 :
1224 14350 : const Operator* JSOperatorBuilder::CreateLiteralObject(
1225 : Handle<ObjectBoilerplateDescription> constant_properties,
1226 : VectorSlotPair const& feedback, int literal_flags,
1227 14350 : int number_of_properties) {
1228 : CreateLiteralParameters parameters(constant_properties, feedback,
1229 : number_of_properties, literal_flags);
1230 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1231 : IrOpcode::kJSCreateLiteralObject, // opcode
1232 : Operator::kNoProperties, // properties
1233 : "JSCreateLiteralObject", // name
1234 : 0, 1, 1, 1, 1, 2, // counts
1235 14350 : parameters); // parameter
1236 : }
1237 :
1238 76 : const Operator* JSOperatorBuilder::CloneObject(VectorSlotPair const& feedback,
1239 76 : int literal_flags) {
1240 : CloneObjectParameters parameters(feedback, literal_flags);
1241 : return new (zone()) Operator1<CloneObjectParameters>( // --
1242 : IrOpcode::kJSCloneObject, // opcode
1243 : Operator::kNoProperties, // properties
1244 : "JSCloneObject", // name
1245 : 1, 1, 1, 1, 1, 2, // counts
1246 76 : parameters); // parameter
1247 : }
1248 :
1249 11862 : const Operator* JSOperatorBuilder::CreateEmptyLiteralObject() {
1250 : return new (zone()) Operator( // --
1251 : IrOpcode::kJSCreateEmptyLiteralObject, // opcode
1252 : Operator::kNoProperties, // properties
1253 : "JSCreateEmptyLiteralObject", // name
1254 5931 : 1, 1, 1, 1, 1, 2); // counts
1255 : }
1256 :
1257 6421 : const Operator* JSOperatorBuilder::CreateLiteralRegExp(
1258 : Handle<String> constant_pattern, VectorSlotPair const& feedback,
1259 6421 : int literal_flags) {
1260 : CreateLiteralParameters parameters(constant_pattern, feedback, -1,
1261 : literal_flags);
1262 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1263 : IrOpcode::kJSCreateLiteralRegExp, // opcode
1264 : Operator::kNoProperties, // properties
1265 : "JSCreateLiteralRegExp", // name
1266 : 0, 1, 1, 1, 1, 2, // counts
1267 6421 : parameters); // parameter
1268 : }
1269 :
1270 29273 : const Operator* JSOperatorBuilder::CreateFunctionContext(
1271 29273 : Handle<ScopeInfo> scope_info, int slot_count, ScopeType scope_type) {
1272 : CreateFunctionContextParameters parameters(scope_info, slot_count,
1273 : scope_type);
1274 : return new (zone()) Operator1<CreateFunctionContextParameters>( // --
1275 : IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode
1276 : "JSCreateFunctionContext", // name
1277 : 0, 1, 1, 1, 1, 2, // counts
1278 29273 : parameters); // parameter
1279 : }
1280 :
1281 14627 : const Operator* JSOperatorBuilder::CreateCatchContext(
1282 14627 : const Handle<ScopeInfo>& scope_info) {
1283 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1284 : IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
1285 : "JSCreateCatchContext", // name
1286 : 1, 1, 1, 1, 1, 2, // counts
1287 29254 : scope_info); // parameter
1288 : }
1289 :
1290 486 : const Operator* JSOperatorBuilder::CreateWithContext(
1291 486 : const Handle<ScopeInfo>& scope_info) {
1292 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1293 : IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode
1294 : "JSCreateWithContext", // name
1295 : 1, 1, 1, 1, 1, 2, // counts
1296 972 : scope_info); // parameter
1297 : }
1298 :
1299 9138 : const Operator* JSOperatorBuilder::CreateBlockContext(
1300 9138 : const Handle<ScopeInfo>& scope_info) {
1301 : return new (zone()) Operator1<Handle<ScopeInfo>>( // --
1302 : IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode
1303 : "JSCreateBlockContext", // name
1304 : 0, 1, 1, 1, 1, 2, // counts
1305 18276 : scope_info); // parameter
1306 : }
1307 :
1308 47710 : Handle<ScopeInfo> ScopeInfoOf(const Operator* op) {
1309 : DCHECK(IrOpcode::kJSCreateBlockContext == op->opcode() ||
1310 : IrOpcode::kJSCreateWithContext == op->opcode() ||
1311 : IrOpcode::kJSCreateCatchContext == op->opcode());
1312 47710 : return OpParameter<Handle<ScopeInfo>>(op);
1313 : }
1314 :
1315 : #undef BINARY_OP_LIST
1316 : #undef CACHED_OP_LIST
1317 : #undef COMPARE_OP_LIST
1318 :
1319 : } // namespace compiler
1320 : } // namespace internal
1321 178779 : } // namespace v8
|