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