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 999 : CallFrequency CallFrequencyOf(Operator const* op) {
26 : DCHECK(op->opcode() == IrOpcode::kJSCallWithArrayLike ||
27 : op->opcode() == IrOpcode::kJSConstructWithArrayLike);
28 999 : 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 734 : ConstructForwardVarargsParameters const& ConstructForwardVarargsParametersOf(
38 : Operator const* op) {
39 : DCHECK_EQ(IrOpcode::kJSConstructForwardVarargs, op->opcode());
40 734 : 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 103529 : ConstructParameters const& ConstructParametersOf(Operator const* op) {
63 : DCHECK(op->opcode() == IrOpcode::kJSConstruct ||
64 : op->opcode() == IrOpcode::kJSConstructWithSpread);
65 103529 : 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 1853058 : const CallParameters& CallParametersOf(const Operator* op) {
73 : DCHECK(op->opcode() == IrOpcode::kJSCall ||
74 : op->opcode() == IrOpcode::kJSCallWithSpread);
75 1853058 : 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 12298773 : const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) {
113 : DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode());
114 12298773 : 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 860612 : 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 3199030 : ContextAccess const& ContextAccessOf(Operator const* op) {
150 : DCHECK(op->opcode() == IrOpcode::kJSLoadContext ||
151 : op->opcode() == IrOpcode::kJSStoreContext);
152 3199030 : 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 63505 : CreateFunctionContextParameters const& CreateFunctionContextParametersOf(
185 : Operator const* op) {
186 : DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, op->opcode());
187 63505 : 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 66241 : StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) {
210 : DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode());
211 66241 : 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 150317 : 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 150317 : 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 1820321 : NamedAccess const& NamedAccessOf(const Operator* op) {
262 : DCHECK(op->opcode() == IrOpcode::kJSLoadNamed ||
263 : op->opcode() == IrOpcode::kJSStoreNamed);
264 1820321 : 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 104325 : PropertyAccess const& PropertyAccessOf(const Operator* op) {
285 : DCHECK(op->opcode() == IrOpcode::kJSLoadProperty ||
286 : op->opcode() == IrOpcode::kJSStoreProperty);
287 104325 : 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 1435717 : const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
321 : DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode());
322 1435717 : 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 397140 : const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
352 : DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode());
353 397140 : return OpParameter<StoreGlobalParameters>(op);
354 : }
355 :
356 :
357 59582 : CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
358 : DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode());
359 59582 : 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 3049 : const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) {
389 : DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode());
390 3049 : 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 2632 : const CreateArrayIteratorParameters& CreateArrayIteratorParametersOf(
413 : const Operator* op) {
414 : DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, op->opcode());
415 2632 : 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 164 : const CreateCollectionIteratorParameters& CreateCollectionIteratorParametersOf(
440 : const Operator* op) {
441 : DCHECK_EQ(IrOpcode::kJSCreateCollectionIterator, op->opcode());
442 164 : 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 224 : const CreateBoundFunctionParameters& CreateBoundFunctionParametersOf(
468 : const Operator* op) {
469 : DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, op->opcode());
470 224 : 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 1282460 : const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
501 : DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode());
502 1282460 : 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 82761 : const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) {
532 : DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray ||
533 : op->opcode() == IrOpcode::kJSCreateLiteralObject ||
534 : op->opcode() == IrOpcode::kJSCreateLiteralRegExp);
535 82761 : 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 91 : const CloneObjectParameters& CloneObjectParametersOf(const Operator* op) {
557 : DCHECK(op->opcode() == IrOpcode::kJSCloneObject);
558 91 : 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 4251 : ForInMode ForInModeOf(Operator const* op) {
576 : DCHECK(op->opcode() == IrOpcode::kJSForInNext ||
577 : op->opcode() == IrOpcode::kJSForInPrepare);
578 4251 : return OpParameter<ForInMode>(op);
579 : }
580 :
581 65722 : BinaryOperationHint BinaryOperationHintOf(const Operator* op) {
582 : DCHECK_EQ(IrOpcode::kJSAdd, op->opcode());
583 65722 : return OpParameter<BinaryOperationHint>(op);
584 : }
585 :
586 647384 : 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 647384 : 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 27484 : 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 2638464 : 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 494712 : 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 3627888 : COMPARE_OP_LIST(COMPARE_OP)
721 : #undef COMPARE_OP
722 : };
723 :
724 : namespace {
725 2093111 : DEFINE_LAZY_LEAKY_OBJECT_GETTER(JSOperatorGlobalCache,
726 : GetJSOperatorGlobalCache);
727 : }
728 :
729 2093110 : JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
730 2093110 : : cache_(*GetJSOperatorGlobalCache()), zone_(zone) {}
731 :
732 : #define CACHED_OP(Name, properties, value_input_count, value_output_count) \
733 : const Operator* JSOperatorBuilder::Name() { \
734 : return &cache_.k##Name##Operator; \
735 : }
736 836931 : CACHED_OP_LIST(CACHED_OP)
737 : #undef CACHED_OP
738 :
739 : #define BINARY_OP(Name) \
740 : const Operator* JSOperatorBuilder::Name(BinaryOperationHint hint) { \
741 : switch (hint) { \
742 : case BinaryOperationHint::kNone: \
743 : return &cache_.k##Name##NoneOperator; \
744 : case BinaryOperationHint::kSignedSmall: \
745 : return &cache_.k##Name##SignedSmallOperator; \
746 : case BinaryOperationHint::kSignedSmallInputs: \
747 : return &cache_.k##Name##SignedSmallInputsOperator; \
748 : case BinaryOperationHint::kSigned32: \
749 : return &cache_.k##Name##Signed32Operator; \
750 : case BinaryOperationHint::kNumber: \
751 : return &cache_.k##Name##NumberOperator; \
752 : case BinaryOperationHint::kNumberOrOddball: \
753 : return &cache_.k##Name##NumberOrOddballOperator; \
754 : case BinaryOperationHint::kString: \
755 : return &cache_.k##Name##StringOperator; \
756 : case BinaryOperationHint::kBigInt: \
757 : return &cache_.k##Name##BigIntOperator; \
758 : case BinaryOperationHint::kAny: \
759 : return &cache_.k##Name##AnyOperator; \
760 : } \
761 : UNREACHABLE(); \
762 : return nullptr; \
763 : }
764 284443 : BINARY_OP_LIST(BINARY_OP)
765 : #undef BINARY_OP
766 :
767 : #define COMPARE_OP(Name, ...) \
768 : const Operator* JSOperatorBuilder::Name(CompareOperationHint hint) { \
769 : switch (hint) { \
770 : case CompareOperationHint::kNone: \
771 : return &cache_.k##Name##NoneOperator; \
772 : case CompareOperationHint::kSignedSmall: \
773 : return &cache_.k##Name##SignedSmallOperator; \
774 : case CompareOperationHint::kNumber: \
775 : return &cache_.k##Name##NumberOperator; \
776 : case CompareOperationHint::kNumberOrOddball: \
777 : return &cache_.k##Name##NumberOrOddballOperator; \
778 : case CompareOperationHint::kInternalizedString: \
779 : return &cache_.k##Name##InternalizedStringOperator; \
780 : case CompareOperationHint::kString: \
781 : return &cache_.k##Name##StringOperator; \
782 : case CompareOperationHint::kSymbol: \
783 : return &cache_.k##Name##SymbolOperator; \
784 : case CompareOperationHint::kBigInt: \
785 : return &cache_.k##Name##BigIntOperator; \
786 : case CompareOperationHint::kReceiver: \
787 : return &cache_.k##Name##ReceiverOperator; \
788 : case CompareOperationHint::kReceiverOrNullOrUndefined: \
789 : return &cache_.k##Name##ReceiverOrNullOrUndefinedOperator; \
790 : case CompareOperationHint::kAny: \
791 : return &cache_.k##Name##AnyOperator; \
792 : } \
793 : UNREACHABLE(); \
794 : return nullptr; \
795 : }
796 273424 : COMPARE_OP_LIST(COMPARE_OP)
797 : #undef COMPARE_OP
798 :
799 552 : const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral(
800 552 : const VectorSlotPair& feedback) {
801 : FeedbackParameter parameters(feedback);
802 : return new (zone()) Operator1<FeedbackParameter>( // --
803 : IrOpcode::kJSStoreDataPropertyInLiteral,
804 : Operator::kNoThrow, // opcode
805 : "JSStoreDataPropertyInLiteral", // name
806 : 4, 1, 1, 0, 1, 0, // counts
807 552 : parameters); // parameter
808 : }
809 :
810 42799 : const Operator* JSOperatorBuilder::StoreInArrayLiteral(
811 42799 : const VectorSlotPair& feedback) {
812 : FeedbackParameter parameters(feedback);
813 : return new (zone()) Operator1<FeedbackParameter>( // --
814 : IrOpcode::kJSStoreInArrayLiteral,
815 : Operator::kNoThrow, // opcode
816 : "JSStoreInArrayLiteral", // name
817 : 3, 1, 1, 0, 1, 0, // counts
818 42800 : parameters); // parameter
819 : }
820 :
821 368 : const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity,
822 368 : uint32_t start_index) {
823 : CallForwardVarargsParameters parameters(arity, start_index);
824 : return new (zone()) Operator1<CallForwardVarargsParameters>( // --
825 : IrOpcode::kJSCallForwardVarargs, Operator::kNoProperties, // opcode
826 : "JSCallForwardVarargs", // name
827 : parameters.arity(), 1, 1, 1, 1, 2, // counts
828 368 : parameters); // parameter
829 : }
830 :
831 741606 : const Operator* JSOperatorBuilder::Call(size_t arity,
832 : CallFrequency const& frequency,
833 : VectorSlotPair const& feedback,
834 : ConvertReceiverMode convert_mode,
835 741606 : SpeculationMode speculation_mode) {
836 : DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
837 : feedback.IsValid());
838 : CallParameters parameters(arity, frequency, feedback, convert_mode,
839 : speculation_mode);
840 : return new (zone()) Operator1<CallParameters>( // --
841 : IrOpcode::kJSCall, Operator::kNoProperties, // opcode
842 : "JSCall", // name
843 : parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs
844 741613 : parameters); // parameter
845 : }
846 :
847 1442 : const Operator* JSOperatorBuilder::CallWithArrayLike(CallFrequency frequency) {
848 : return new (zone()) Operator1<CallFrequency>( // --
849 : IrOpcode::kJSCallWithArrayLike, Operator::kNoProperties, // opcode
850 : "JSCallWithArrayLike", // name
851 : 3, 1, 1, 1, 1, 2, // counts
852 1443 : frequency); // parameter
853 : }
854 :
855 1095 : const Operator* JSOperatorBuilder::CallWithSpread(
856 : uint32_t arity, CallFrequency const& frequency,
857 1095 : VectorSlotPair const& feedback, SpeculationMode speculation_mode) {
858 : DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
859 : feedback.IsValid());
860 : CallParameters parameters(arity, frequency, feedback,
861 : ConvertReceiverMode::kAny, speculation_mode);
862 : return new (zone()) Operator1<CallParameters>( // --
863 : IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode
864 : "JSCallWithSpread", // name
865 : parameters.arity(), 1, 1, 1, 1, 2, // counts
866 1095 : parameters); // parameter
867 : }
868 :
869 188157 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) {
870 188157 : const Runtime::Function* f = Runtime::FunctionForId(id);
871 188157 : return CallRuntime(f, f->nargs);
872 : }
873 :
874 :
875 173988 : const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id,
876 : size_t arity) {
877 173988 : const Runtime::Function* f = Runtime::FunctionForId(id);
878 173988 : return CallRuntime(f, arity);
879 : }
880 :
881 :
882 362144 : const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f,
883 362144 : size_t arity) {
884 362144 : CallRuntimeParameters parameters(f->function_id, arity);
885 : DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity()));
886 : return new (zone()) Operator1<CallRuntimeParameters>( // --
887 : IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode
888 : "JSCallRuntime", // name
889 : parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs
890 724288 : parameters); // parameter
891 : }
892 :
893 689 : const Operator* JSOperatorBuilder::ConstructForwardVarargs(
894 689 : size_t arity, uint32_t start_index) {
895 : ConstructForwardVarargsParameters parameters(arity, start_index);
896 : return new (zone()) Operator1<ConstructForwardVarargsParameters>( // --
897 : IrOpcode::kJSConstructForwardVarargs, Operator::kNoProperties, // opcode
898 : "JSConstructForwardVarargs", // name
899 : parameters.arity(), 1, 1, 1, 1, 2, // counts
900 689 : parameters); // parameter
901 : }
902 :
903 40173 : const Operator* JSOperatorBuilder::Construct(uint32_t arity,
904 : CallFrequency frequency,
905 40173 : VectorSlotPair const& feedback) {
906 : ConstructParameters parameters(arity, frequency, feedback);
907 : return new (zone()) Operator1<ConstructParameters>( // --
908 : IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode
909 : "JSConstruct", // name
910 : parameters.arity(), 1, 1, 1, 1, 2, // counts
911 80347 : parameters); // parameter
912 : }
913 :
914 189 : const Operator* JSOperatorBuilder::ConstructWithArrayLike(
915 189 : CallFrequency frequency) {
916 : return new (zone()) Operator1<CallFrequency>( // --
917 : IrOpcode::kJSConstructWithArrayLike, // opcode
918 : Operator::kNoProperties, // properties
919 : "JSConstructWithArrayLike", // name
920 : 3, 1, 1, 1, 1, 2, // counts
921 378 : frequency); // parameter
922 : }
923 :
924 987 : const Operator* JSOperatorBuilder::ConstructWithSpread(
925 987 : uint32_t arity, CallFrequency frequency, VectorSlotPair const& feedback) {
926 : ConstructParameters parameters(arity, frequency, feedback);
927 : return new (zone()) Operator1<ConstructParameters>( // --
928 : IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode
929 : "JSConstructWithSpread", // name
930 : parameters.arity(), 1, 1, 1, 1, 2, // counts
931 1974 : parameters); // parameter
932 : }
933 :
934 505873 : const Operator* JSOperatorBuilder::LoadNamed(Handle<Name> name,
935 505873 : const VectorSlotPair& feedback) {
936 : NamedAccess access(LanguageMode::kSloppy, name, feedback);
937 : return new (zone()) Operator1<NamedAccess>( // --
938 : IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
939 : "JSLoadNamed", // name
940 : 1, 1, 1, 1, 1, 2, // counts
941 505874 : access); // parameter
942 : }
943 :
944 43169 : const Operator* JSOperatorBuilder::LoadProperty(
945 43169 : VectorSlotPair const& feedback) {
946 : PropertyAccess access(LanguageMode::kSloppy, feedback);
947 : return new (zone()) Operator1<PropertyAccess>( // --
948 : IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode
949 : "JSLoadProperty", // name
950 : 2, 1, 1, 1, 1, 2, // counts
951 43169 : access); // parameter
952 : }
953 :
954 7362 : const Operator* JSOperatorBuilder::InstanceOf(VectorSlotPair const& feedback) {
955 : FeedbackParameter parameter(feedback);
956 : return new (zone()) Operator1<FeedbackParameter>( // --
957 : IrOpcode::kJSInstanceOf, Operator::kNoProperties, // opcode
958 : "JSInstanceOf", // name
959 : 2, 1, 1, 1, 1, 2, // counts
960 3681 : parameter); // parameter
961 : }
962 :
963 1577 : const Operator* JSOperatorBuilder::ForInNext(ForInMode mode) {
964 : return new (zone()) Operator1<ForInMode>( // --
965 : IrOpcode::kJSForInNext, Operator::kNoProperties, // opcode
966 : "JSForInNext", // name
967 : 4, 1, 1, 1, 1, 2, // counts
968 1577 : mode); // parameter
969 : }
970 :
971 1391 : const Operator* JSOperatorBuilder::ForInPrepare(ForInMode mode) {
972 : return new (zone()) Operator1<ForInMode>( // --
973 : IrOpcode::kJSForInPrepare, // opcode
974 : Operator::kNoWrite | Operator::kNoThrow, // flags
975 : "JSForInPrepare", // name
976 : 1, 1, 1, 3, 1, 1, // counts
977 1391 : mode); // parameter
978 : }
979 :
980 6270 : const Operator* JSOperatorBuilder::GeneratorStore(int register_count) {
981 : return new (zone()) Operator1<int>( // --
982 : IrOpcode::kJSGeneratorStore, Operator::kNoThrow, // opcode
983 : "JSGeneratorStore", // name
984 6270 : 3 + register_count, 1, 1, 0, 1, 0, // counts
985 12540 : register_count); // parameter
986 : }
987 :
988 1082 : int RegisterCountOf(Operator const* op) {
989 : DCHECK_EQ(IrOpcode::kJSCreateAsyncFunctionObject, op->opcode());
990 1082 : return OpParameter<int>(op);
991 : }
992 :
993 6070 : int GeneratorStoreValueCountOf(const Operator* op) {
994 : DCHECK_EQ(IrOpcode::kJSGeneratorStore, op->opcode());
995 6070 : return OpParameter<int>(op);
996 : }
997 :
998 15627 : const Operator* JSOperatorBuilder::GeneratorRestoreRegister(int index) {
999 : return new (zone()) Operator1<int>( // --
1000 : IrOpcode::kJSGeneratorRestoreRegister, Operator::kNoThrow, // opcode
1001 : "JSGeneratorRestoreRegister", // name
1002 : 1, 1, 1, 1, 1, 0, // counts
1003 15627 : index); // parameter
1004 : }
1005 :
1006 15035 : int RestoreRegisterIndexOf(const Operator* op) {
1007 : DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, op->opcode());
1008 15035 : return OpParameter<int>(op);
1009 : }
1010 :
1011 100467 : const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
1012 : Handle<Name> name,
1013 100467 : VectorSlotPair const& feedback) {
1014 : NamedAccess access(language_mode, name, feedback);
1015 : return new (zone()) Operator1<NamedAccess>( // --
1016 : IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
1017 : "JSStoreNamed", // name
1018 : 2, 1, 1, 0, 1, 2, // counts
1019 100467 : access); // parameter
1020 : }
1021 :
1022 :
1023 12043 : const Operator* JSOperatorBuilder::StoreProperty(
1024 12043 : LanguageMode language_mode, VectorSlotPair const& feedback) {
1025 : PropertyAccess access(language_mode, feedback);
1026 : return new (zone()) Operator1<PropertyAccess>( // --
1027 : IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
1028 : "JSStoreProperty", // name
1029 : 3, 1, 1, 0, 1, 2, // counts
1030 12043 : access); // parameter
1031 : }
1032 :
1033 30677 : const Operator* JSOperatorBuilder::StoreNamedOwn(
1034 30677 : Handle<Name> name, VectorSlotPair const& feedback) {
1035 : StoreNamedOwnParameters parameters(name, feedback);
1036 : return new (zone()) Operator1<StoreNamedOwnParameters>( // --
1037 : IrOpcode::kJSStoreNamedOwn, Operator::kNoProperties, // opcode
1038 : "JSStoreNamedOwn", // name
1039 : 2, 1, 1, 0, 1, 2, // counts
1040 30677 : parameters); // parameter
1041 : }
1042 :
1043 1970 : const Operator* JSOperatorBuilder::DeleteProperty() {
1044 : return new (zone()) Operator( // --
1045 : IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode
1046 : "JSDeleteProperty", // name
1047 985 : 3, 1, 1, 1, 1, 2); // counts
1048 : }
1049 :
1050 2542 : const Operator* JSOperatorBuilder::CreateGeneratorObject() {
1051 : return new (zone()) Operator( // --
1052 : IrOpcode::kJSCreateGeneratorObject, Operator::kEliminatable, // opcode
1053 : "JSCreateGeneratorObject", // name
1054 1271 : 2, 1, 1, 1, 1, 0); // counts
1055 : }
1056 :
1057 1031585 : const Operator* JSOperatorBuilder::LoadGlobal(const Handle<Name>& name,
1058 : const VectorSlotPair& feedback,
1059 1031585 : TypeofMode typeof_mode) {
1060 : LoadGlobalParameters parameters(name, feedback, typeof_mode);
1061 : return new (zone()) Operator1<LoadGlobalParameters>( // --
1062 : IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode
1063 : "JSLoadGlobal", // name
1064 : 0, 1, 1, 1, 1, 2, // counts
1065 1031587 : parameters); // parameter
1066 : }
1067 :
1068 :
1069 210722 : const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
1070 : const Handle<Name>& name,
1071 210722 : const VectorSlotPair& feedback) {
1072 : StoreGlobalParameters parameters(language_mode, feedback, name);
1073 : return new (zone()) Operator1<StoreGlobalParameters>( // --
1074 : IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode
1075 : "JSStoreGlobal", // name
1076 : 1, 1, 1, 0, 1, 2, // counts
1077 210722 : parameters); // parameter
1078 : }
1079 :
1080 :
1081 452946 : const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index,
1082 452946 : bool immutable) {
1083 : ContextAccess access(depth, index, immutable);
1084 : return new (zone()) Operator1<ContextAccess>( // --
1085 : IrOpcode::kJSLoadContext, // opcode
1086 : Operator::kNoWrite | Operator::kNoThrow, // flags
1087 : "JSLoadContext", // name
1088 : 0, 1, 0, 1, 1, 0, // counts
1089 452945 : access); // parameter
1090 : }
1091 :
1092 :
1093 815332 : const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
1094 : ContextAccess access(depth, index, false);
1095 : return new (zone()) Operator1<ContextAccess>( // --
1096 : IrOpcode::kJSStoreContext, // opcode
1097 : Operator::kNoRead | Operator::kNoThrow, // flags
1098 : "JSStoreContext", // name
1099 : 1, 1, 1, 0, 1, 0, // counts
1100 407666 : access); // parameter
1101 : }
1102 :
1103 296 : const Operator* JSOperatorBuilder::LoadModule(int32_t cell_index) {
1104 : return new (zone()) Operator1<int32_t>( // --
1105 : IrOpcode::kJSLoadModule, // opcode
1106 : Operator::kNoWrite | Operator::kNoThrow, // flags
1107 : "JSLoadModule", // name
1108 : 1, 1, 1, 1, 1, 0, // counts
1109 296 : cell_index); // parameter
1110 : }
1111 :
1112 6940 : const Operator* JSOperatorBuilder::StoreModule(int32_t cell_index) {
1113 : return new (zone()) Operator1<int32_t>( // --
1114 : IrOpcode::kJSStoreModule, // opcode
1115 : Operator::kNoRead | Operator::kNoThrow, // flags
1116 : "JSStoreModule", // name
1117 : 2, 1, 1, 0, 1, 0, // counts
1118 6940 : cell_index); // parameter
1119 : }
1120 :
1121 19298 : const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
1122 : return new (zone()) Operator1<CreateArgumentsType>( // --
1123 : IrOpcode::kJSCreateArguments, Operator::kEliminatable, // opcode
1124 : "JSCreateArguments", // name
1125 : 1, 1, 0, 1, 1, 0, // counts
1126 19298 : type); // parameter
1127 : }
1128 :
1129 1458 : const Operator* JSOperatorBuilder::CreateArray(
1130 1458 : size_t arity, MaybeHandle<AllocationSite> site) {
1131 : // constructor, new_target, arg1, ..., argN
1132 1458 : int const value_input_count = static_cast<int>(arity) + 2;
1133 : CreateArrayParameters parameters(arity, site);
1134 : return new (zone()) Operator1<CreateArrayParameters>( // --
1135 : IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode
1136 : "JSCreateArray", // name
1137 : value_input_count, 1, 1, 1, 1, 2, // counts
1138 2916 : parameters); // parameter
1139 : }
1140 :
1141 1333 : const Operator* JSOperatorBuilder::CreateArrayIterator(IterationKind kind) {
1142 : CreateArrayIteratorParameters parameters(kind);
1143 : return new (zone()) Operator1<CreateArrayIteratorParameters>( // --
1144 : IrOpcode::kJSCreateArrayIterator, Operator::kEliminatable, // opcode
1145 : "JSCreateArrayIterator", // name
1146 : 1, 1, 1, 1, 1, 0, // counts
1147 1333 : parameters); // parameter
1148 : }
1149 :
1150 1083 : const Operator* JSOperatorBuilder::CreateAsyncFunctionObject(
1151 1083 : int register_count) {
1152 : return new (zone()) Operator1<int>( // --
1153 : IrOpcode::kJSCreateAsyncFunctionObject, // opcode
1154 : Operator::kEliminatable, // flags
1155 : "JSCreateAsyncFunctionObject", // name
1156 : 3, 1, 1, 1, 1, 0, // counts
1157 1083 : register_count); // parameter
1158 : }
1159 :
1160 164 : const Operator* JSOperatorBuilder::CreateCollectionIterator(
1161 164 : CollectionKind collection_kind, IterationKind iteration_kind) {
1162 : CreateCollectionIteratorParameters parameters(collection_kind,
1163 164 : iteration_kind);
1164 : return new (zone()) Operator1<CreateCollectionIteratorParameters>(
1165 : IrOpcode::kJSCreateCollectionIterator, Operator::kEliminatable,
1166 328 : "JSCreateCollectionIterator", 1, 1, 1, 1, 1, 0, parameters);
1167 : }
1168 :
1169 105 : const Operator* JSOperatorBuilder::CreateBoundFunction(size_t arity,
1170 105 : Handle<Map> map) {
1171 : // bound_target_function, bound_this, arg1, ..., argN
1172 105 : int const value_input_count = static_cast<int>(arity) + 2;
1173 : CreateBoundFunctionParameters parameters(arity, map);
1174 : return new (zone()) Operator1<CreateBoundFunctionParameters>( // --
1175 : IrOpcode::kJSCreateBoundFunction, Operator::kEliminatable, // opcode
1176 : "JSCreateBoundFunction", // name
1177 : value_input_count, 1, 1, 1, 1, 0, // counts
1178 210 : parameters); // parameter
1179 : }
1180 :
1181 420966 : const Operator* JSOperatorBuilder::CreateClosure(
1182 : Handle<SharedFunctionInfo> shared_info, Handle<FeedbackCell> feedback_cell,
1183 420966 : Handle<Code> code, PretenureFlag pretenure) {
1184 : CreateClosureParameters parameters(shared_info, feedback_cell, code,
1185 : pretenure);
1186 : return new (zone()) Operator1<CreateClosureParameters>( // --
1187 : IrOpcode::kJSCreateClosure, Operator::kEliminatable, // opcode
1188 : "JSCreateClosure", // name
1189 : 0, 1, 1, 1, 1, 0, // counts
1190 420968 : parameters); // parameter
1191 : }
1192 :
1193 9114 : const Operator* JSOperatorBuilder::CreateLiteralArray(
1194 : Handle<ArrayBoilerplateDescription> description,
1195 9114 : VectorSlotPair const& feedback, int literal_flags, int number_of_elements) {
1196 : CreateLiteralParameters parameters(description, feedback, number_of_elements,
1197 : literal_flags);
1198 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1199 : IrOpcode::kJSCreateLiteralArray, // opcode
1200 : Operator::kNoProperties, // properties
1201 : "JSCreateLiteralArray", // name
1202 : 0, 1, 1, 1, 1, 2, // counts
1203 9114 : parameters); // parameter
1204 : }
1205 :
1206 21315 : const Operator* JSOperatorBuilder::CreateEmptyLiteralArray(
1207 21315 : VectorSlotPair const& feedback) {
1208 : FeedbackParameter parameters(feedback);
1209 : return new (zone()) Operator1<FeedbackParameter>( // --
1210 : IrOpcode::kJSCreateEmptyLiteralArray, // opcode
1211 : Operator::kEliminatable, // properties
1212 : "JSCreateEmptyLiteralArray", // name
1213 : 0, 1, 1, 1, 1, 0, // counts
1214 21315 : parameters); // parameter
1215 : }
1216 :
1217 1058 : const Operator* JSOperatorBuilder::CreateArrayFromIterable() {
1218 : return new (zone()) Operator( // --
1219 : IrOpcode::kJSCreateArrayFromIterable, // opcode
1220 : Operator::kNoProperties, // properties
1221 : "JSCreateArrayFromIterable", // name
1222 530 : 1, 1, 1, 1, 1, 2); // counts
1223 : }
1224 :
1225 14090 : const Operator* JSOperatorBuilder::CreateLiteralObject(
1226 : Handle<ObjectBoilerplateDescription> constant_properties,
1227 : VectorSlotPair const& feedback, int literal_flags,
1228 14090 : int number_of_properties) {
1229 : CreateLiteralParameters parameters(constant_properties, feedback,
1230 : number_of_properties, literal_flags);
1231 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1232 : IrOpcode::kJSCreateLiteralObject, // opcode
1233 : Operator::kNoProperties, // properties
1234 : "JSCreateLiteralObject", // name
1235 : 0, 1, 1, 1, 1, 2, // counts
1236 14090 : parameters); // parameter
1237 : }
1238 :
1239 75 : const Operator* JSOperatorBuilder::CloneObject(VectorSlotPair const& feedback,
1240 75 : int literal_flags) {
1241 : CloneObjectParameters parameters(feedback, literal_flags);
1242 : return new (zone()) Operator1<CloneObjectParameters>( // --
1243 : IrOpcode::kJSCloneObject, // opcode
1244 : Operator::kNoProperties, // properties
1245 : "JSCloneObject", // name
1246 : 1, 1, 1, 1, 1, 2, // counts
1247 75 : parameters); // parameter
1248 : }
1249 :
1250 12018 : const Operator* JSOperatorBuilder::CreateEmptyLiteralObject() {
1251 : return new (zone()) Operator( // --
1252 : IrOpcode::kJSCreateEmptyLiteralObject, // opcode
1253 : Operator::kNoProperties, // properties
1254 : "JSCreateEmptyLiteralObject", // name
1255 6009 : 1, 1, 1, 1, 1, 2); // counts
1256 : }
1257 :
1258 6466 : const Operator* JSOperatorBuilder::CreateLiteralRegExp(
1259 : Handle<String> constant_pattern, VectorSlotPair const& feedback,
1260 6466 : int literal_flags) {
1261 : CreateLiteralParameters parameters(constant_pattern, feedback, -1,
1262 : literal_flags);
1263 : return new (zone()) Operator1<CreateLiteralParameters>( // --
1264 : IrOpcode::kJSCreateLiteralRegExp, // opcode
1265 : Operator::kNoProperties, // properties
1266 : "JSCreateLiteralRegExp", // name
1267 : 0, 1, 1, 1, 1, 2, // counts
1268 6466 : parameters); // parameter
1269 : }
1270 :
1271 29548 : const Operator* JSOperatorBuilder::CreateFunctionContext(
1272 29548 : Handle<ScopeInfo> scope_info, int slot_count, ScopeType scope_type) {
1273 : CreateFunctionContextParameters parameters(scope_info, slot_count,
1274 : scope_type);
1275 : return new (zone()) Operator1<CreateFunctionContextParameters>( // --
1276 : IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode
1277 : "JSCreateFunctionContext", // name
1278 : 0, 1, 1, 1, 1, 2, // counts
1279 29548 : parameters); // parameter
1280 : }
1281 :
1282 14672 : const Operator* JSOperatorBuilder::CreateCatchContext(
1283 14672 : const Handle<ScopeInfo>& scope_info) {
1284 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1285 : IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
1286 : "JSCreateCatchContext", // name
1287 : 1, 1, 1, 1, 1, 2, // counts
1288 29344 : scope_info); // parameter
1289 : }
1290 :
1291 492 : const Operator* JSOperatorBuilder::CreateWithContext(
1292 492 : const Handle<ScopeInfo>& scope_info) {
1293 : return new (zone()) Operator1<Handle<ScopeInfo>>(
1294 : IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode
1295 : "JSCreateWithContext", // name
1296 : 1, 1, 1, 1, 1, 2, // counts
1297 984 : scope_info); // parameter
1298 : }
1299 :
1300 8849 : const Operator* JSOperatorBuilder::CreateBlockContext(
1301 8849 : const Handle<ScopeInfo>& scope_info) {
1302 : return new (zone()) Operator1<Handle<ScopeInfo>>( // --
1303 : IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode
1304 : "JSCreateBlockContext", // name
1305 : 0, 1, 1, 1, 1, 2, // counts
1306 17698 : scope_info); // parameter
1307 : }
1308 :
1309 47158 : Handle<ScopeInfo> ScopeInfoOf(const Operator* op) {
1310 : DCHECK(IrOpcode::kJSCreateBlockContext == op->opcode() ||
1311 : IrOpcode::kJSCreateWithContext == op->opcode() ||
1312 : IrOpcode::kJSCreateCatchContext == op->opcode());
1313 47158 : return OpParameter<Handle<ScopeInfo>>(op);
1314 : }
1315 :
1316 : #undef BINARY_OP_LIST
1317 : #undef CACHED_OP_LIST
1318 : #undef COMPARE_OP_LIST
1319 :
1320 : } // namespace compiler
1321 : } // namespace internal
1322 183867 : } // namespace v8
|