deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / src / compiler / common-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/common-operator.h"
6
7 #include "src/assembler.h"
8 #include "src/base/lazy-instance.h"
9 #include "src/compiler/linkage.h"
10 #include "src/compiler/opcodes.h"
11 #include "src/compiler/operator.h"
12 #include "src/unique.h"
13 #include "src/zone.h"
14
15 namespace v8 {
16 namespace internal {
17 namespace compiler {
18
19 std::ostream& operator<<(std::ostream& os, BranchHint hint) {
20   switch (hint) {
21     case BranchHint::kNone:
22       return os << "None";
23     case BranchHint::kTrue:
24       return os << "True";
25     case BranchHint::kFalse:
26       return os << "False";
27   }
28   UNREACHABLE();
29   return os;
30 }
31
32
33 BranchHint BranchHintOf(const Operator* const op) {
34   DCHECK_EQ(IrOpcode::kBranch, op->opcode());
35   return OpParameter<BranchHint>(op);
36 }
37
38
39 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) {
40   return lhs.type() == rhs.type() && lhs.hint() == rhs.hint();
41 }
42
43
44 bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) {
45   return !(lhs == rhs);
46 }
47
48
49 size_t hash_value(SelectParameters const& p) {
50   return base::hash_combine(p.type(), p.hint());
51 }
52
53
54 std::ostream& operator<<(std::ostream& os, SelectParameters const& p) {
55   return os << p.type() << "|" << p.hint();
56 }
57
58
59 SelectParameters const& SelectParametersOf(const Operator* const op) {
60   DCHECK_EQ(IrOpcode::kSelect, op->opcode());
61   return OpParameter<SelectParameters>(op);
62 }
63
64
65 size_t hash_value(OutputFrameStateCombine const& sc) {
66   return base::hash_combine(sc.kind_, sc.parameter_);
67 }
68
69
70 std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) {
71   switch (sc.kind_) {
72     case OutputFrameStateCombine::kPushOutput:
73       if (sc.parameter_ == 0) return os << "Ignore";
74       return os << "Push(" << sc.parameter_ << ")";
75     case OutputFrameStateCombine::kPokeAt:
76       return os << "PokeAt(" << sc.parameter_ << ")";
77   }
78   UNREACHABLE();
79   return os;
80 }
81
82
83 bool operator==(FrameStateCallInfo const& lhs, FrameStateCallInfo const& rhs) {
84   return lhs.type() == rhs.type() && lhs.bailout_id() == rhs.bailout_id() &&
85          lhs.state_combine() == rhs.state_combine();
86 }
87
88
89 bool operator!=(FrameStateCallInfo const& lhs, FrameStateCallInfo const& rhs) {
90   return !(lhs == rhs);
91 }
92
93
94 size_t hash_value(FrameStateCallInfo const& info) {
95   return base::hash_combine(info.type(), info.bailout_id(),
96                             info.state_combine());
97 }
98
99
100 std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) {
101   return os << info.type() << ", " << info.bailout_id() << ", "
102             << info.state_combine();
103 }
104
105
106 size_t ProjectionIndexOf(const Operator* const op) {
107   DCHECK_EQ(IrOpcode::kProjection, op->opcode());
108   return OpParameter<size_t>(op);
109 }
110
111
112 #define CACHED_OP_LIST(V)                                  \
113   V(Always, Operator::kPure, 0, 0, 0, 1, 0, 0)             \
114   V(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1)           \
115   V(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0)             \
116   V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1)          \
117   V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1)         \
118   V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1)       \
119   V(IfException, Operator::kKontrol, 0, 0, 1, 0, 0, 1)     \
120   V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1)       \
121   V(Throw, Operator::kFoldable, 1, 1, 1, 0, 0, 1)          \
122   V(Deoptimize, Operator::kNoThrow, 1, 1, 1, 0, 0, 1)      \
123   V(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1)          \
124   V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \
125   V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1)
126
127
128 #define CACHED_EFFECT_PHI_LIST(V) \
129   V(1)                            \
130   V(2)                            \
131   V(3)                            \
132   V(4)                            \
133   V(5)                            \
134   V(6)
135
136
137 #define CACHED_LOOP_LIST(V) \
138   V(1)                      \
139   V(2)
140
141
142 #define CACHED_MERGE_LIST(V) \
143   V(1)                       \
144   V(2)                       \
145   V(3)                       \
146   V(4)                       \
147   V(5)                       \
148   V(6)                       \
149   V(7)                       \
150   V(8)
151
152
153 #define CACHED_PARAMETER_LIST(V) \
154   V(0)                           \
155   V(1)                           \
156   V(2)                           \
157   V(3)                           \
158   V(4)                           \
159   V(5)                           \
160   V(6)
161
162
163 #define CACHED_PHI_LIST(V) \
164   V(kMachAnyTagged, 1)     \
165   V(kMachAnyTagged, 2)     \
166   V(kMachAnyTagged, 3)     \
167   V(kMachAnyTagged, 4)     \
168   V(kMachAnyTagged, 5)     \
169   V(kMachAnyTagged, 6)     \
170   V(kMachBool, 2)          \
171   V(kMachFloat64, 2)       \
172   V(kMachInt32, 2)
173
174
175 #define CACHED_PROJECTION_LIST(V) \
176   V(0)                            \
177   V(1)
178
179
180 #define CACHED_STATE_VALUES_LIST(V) \
181   V(0)                              \
182   V(1)                              \
183   V(2)                              \
184   V(3)                              \
185   V(4)                              \
186   V(5)                              \
187   V(6)                              \
188   V(7)                              \
189   V(8)                              \
190   V(10)                             \
191   V(11)                             \
192   V(12)                             \
193   V(13)                             \
194   V(14)
195
196
197 struct CommonOperatorGlobalCache FINAL {
198 #define CACHED(Name, properties, value_input_count, effect_input_count,      \
199                control_input_count, value_output_count, effect_output_count, \
200                control_output_count)                                         \
201   struct Name##Operator FINAL : public Operator {                            \
202     Name##Operator()                                                         \
203         : Operator(IrOpcode::k##Name, properties, #Name, value_input_count,  \
204                    effect_input_count, control_input_count,                  \
205                    value_output_count, effect_output_count,                  \
206                    control_output_count) {}                                  \
207   };                                                                         \
208   Name##Operator k##Name##Operator;
209   CACHED_OP_LIST(CACHED)
210 #undef CACHED
211
212   template <BranchHint kBranchHint>
213   struct BranchOperator FINAL : public Operator1<BranchHint> {
214     BranchOperator()
215         : Operator1<BranchHint>(                      // --
216               IrOpcode::kBranch, Operator::kKontrol,  // opcode
217               "Branch",                               // name
218               1, 0, 1, 0, 0, 2,                       // counts
219               kBranchHint) {}                         // parameter
220   };
221   BranchOperator<BranchHint::kNone> kBranchNoneOperator;
222   BranchOperator<BranchHint::kTrue> kBranchTrueOperator;
223   BranchOperator<BranchHint::kFalse> kBranchFalseOperator;
224
225   template <int kEffectInputCount>
226   struct EffectPhiOperator FINAL : public Operator {
227     EffectPhiOperator()
228         : Operator(                                   // --
229               IrOpcode::kEffectPhi, Operator::kPure,  // opcode
230               "EffectPhi",                            // name
231               0, kEffectInputCount, 1, 0, 1, 0) {}    // counts
232   };
233 #define CACHED_EFFECT_PHI(input_count) \
234   EffectPhiOperator<input_count> kEffectPhi##input_count##Operator;
235   CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
236 #undef CACHED_EFFECT_PHI
237
238   template <size_t kInputCount>
239   struct LoopOperator FINAL : public Operator {
240     LoopOperator()
241         : Operator(                                 // --
242               IrOpcode::kLoop, Operator::kKontrol,  // opcode
243               "Loop",                               // name
244               0, 0, kInputCount, 0, 0, 1) {}        // counts
245   };
246 #define CACHED_LOOP(input_count) \
247   LoopOperator<input_count> kLoop##input_count##Operator;
248   CACHED_LOOP_LIST(CACHED_LOOP)
249 #undef CACHED_LOOP
250
251   template <size_t kInputCount>
252   struct MergeOperator FINAL : public Operator {
253     MergeOperator()
254         : Operator(                                  // --
255               IrOpcode::kMerge, Operator::kKontrol,  // opcode
256               "Merge",                               // name
257               0, 0, kInputCount, 0, 0, 1) {}         // counts
258   };
259 #define CACHED_MERGE(input_count) \
260   MergeOperator<input_count> kMerge##input_count##Operator;
261   CACHED_MERGE_LIST(CACHED_MERGE)
262 #undef CACHED_MERGE
263
264   template <MachineType kType, int kInputCount>
265   struct PhiOperator FINAL : public Operator1<MachineType> {
266     PhiOperator()
267         : Operator1<MachineType>(               //--
268               IrOpcode::kPhi, Operator::kPure,  // opcode
269               "Phi",                            // name
270               kInputCount, 0, 1, 1, 0, 0,       // counts
271               kType) {}                         // parameter
272   };
273 #define CACHED_PHI(type, input_count) \
274   PhiOperator<type, input_count> kPhi##type##input_count##Operator;
275   CACHED_PHI_LIST(CACHED_PHI)
276 #undef CACHED_PHI
277
278   template <int kIndex>
279   struct ParameterOperator FINAL : public Operator1<int> {
280     ParameterOperator()
281         : Operator1<int>(                             // --
282               IrOpcode::kParameter, Operator::kPure,  // opcode
283               "Parameter",                            // name
284               1, 0, 0, 1, 0, 0,                       // counts,
285               kIndex) {}                              // parameter
286   };
287 #define CACHED_PARAMETER(index) \
288   ParameterOperator<index> kParameter##index##Operator;
289   CACHED_PARAMETER_LIST(CACHED_PARAMETER)
290 #undef CACHED_PARAMETER
291
292   template <size_t kIndex>
293   struct ProjectionOperator FINAL : public Operator1<size_t> {
294     ProjectionOperator()
295         : Operator1<size_t>(          // --
296               IrOpcode::kProjection,  // opcode
297               Operator::kPure,        // flags
298               "Projection",           // name
299               1, 0, 0, 1, 0, 0,       // counts,
300               kIndex) {}              // parameter
301   };
302 #define CACHED_PROJECTION(index) \
303   ProjectionOperator<index> kProjection##index##Operator;
304   CACHED_PROJECTION_LIST(CACHED_PROJECTION)
305 #undef CACHED_PROJECTION
306
307   template <int kInputCount>
308   struct StateValuesOperator FINAL : public Operator {
309     StateValuesOperator()
310         : Operator(                           // --
311               IrOpcode::kStateValues,         // opcode
312               Operator::kPure,                // flags
313               "StateValues",                  // name
314               kInputCount, 0, 0, 1, 0, 0) {}  // counts
315   };
316 #define CACHED_STATE_VALUES(input_count) \
317   StateValuesOperator<input_count> kStateValues##input_count##Operator;
318   CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
319 #undef CACHED_STATE_VALUES
320 };
321
322
323 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache =
324     LAZY_INSTANCE_INITIALIZER;
325
326
327 CommonOperatorBuilder::CommonOperatorBuilder(Zone* zone)
328     : cache_(kCache.Get()), zone_(zone) {}
329
330
331 #define CACHED(Name, properties, value_input_count, effect_input_count,      \
332                control_input_count, value_output_count, effect_output_count, \
333                control_output_count)                                         \
334   const Operator* CommonOperatorBuilder::Name() {                            \
335     return &cache_.k##Name##Operator;                                        \
336   }
337 CACHED_OP_LIST(CACHED)
338 #undef CACHED
339
340
341 const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
342   switch (hint) {
343     case BranchHint::kNone:
344       return &cache_.kBranchNoneOperator;
345     case BranchHint::kTrue:
346       return &cache_.kBranchTrueOperator;
347     case BranchHint::kFalse:
348       return &cache_.kBranchFalseOperator;
349   }
350   UNREACHABLE();
351   return nullptr;
352 }
353
354
355 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) {
356   DCHECK_GE(control_output_count, 3u);        // Disallow trivial switches.
357   return new (zone()) Operator(               // --
358       IrOpcode::kSwitch, Operator::kKontrol,  // opcode
359       "Switch",                               // name
360       1, 0, 1, 0, 0, control_output_count);   // counts
361 }
362
363
364 const Operator* CommonOperatorBuilder::IfValue(int32_t index) {
365   return new (zone()) Operator1<int32_t>(      // --
366       IrOpcode::kIfValue, Operator::kKontrol,  // opcode
367       "IfValue",                               // name
368       0, 0, 1, 0, 0, 1,                        // counts
369       index);                                  // parameter
370 }
371
372
373 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) {
374   // Outputs are formal parameters, plus context, receiver, and JSFunction.
375   const int value_output_count = num_formal_parameters + 3;
376   return new (zone()) Operator(               // --
377       IrOpcode::kStart, Operator::kFoldable,  // opcode
378       "Start",                                // name
379       0, 0, 0, value_output_count, 1, 1);     // counts
380 }
381
382
383 const Operator* CommonOperatorBuilder::Loop(int control_input_count) {
384   switch (control_input_count) {
385 #define CACHED_LOOP(input_count) \
386   case input_count:              \
387     return &cache_.kLoop##input_count##Operator;
388     CACHED_LOOP_LIST(CACHED_LOOP)
389 #undef CACHED_LOOP
390     default:
391       break;
392   }
393   // Uncached.
394   return new (zone()) Operator(             // --
395       IrOpcode::kLoop, Operator::kKontrol,  // opcode
396       "Loop",                               // name
397       0, 0, control_input_count, 0, 0, 1);  // counts
398 }
399
400
401 const Operator* CommonOperatorBuilder::Merge(int control_input_count) {
402   switch (control_input_count) {
403 #define CACHED_MERGE(input_count) \
404   case input_count:               \
405     return &cache_.kMerge##input_count##Operator;
406     CACHED_MERGE_LIST(CACHED_MERGE)
407 #undef CACHED_MERGE
408     default:
409       break;
410   }
411   // Uncached.
412   return new (zone()) Operator(              // --
413       IrOpcode::kMerge, Operator::kKontrol,  // opcode
414       "Merge",                               // name
415       0, 0, control_input_count, 0, 0, 1);   // counts
416 }
417
418
419 const Operator* CommonOperatorBuilder::Parameter(int index) {
420   switch (index) {
421 #define CACHED_PARAMETER(index) \
422   case index:                   \
423     return &cache_.kParameter##index##Operator;
424     CACHED_PARAMETER_LIST(CACHED_PARAMETER)
425 #undef CACHED_PARAMETER
426     default:
427       break;
428   }
429   // Uncached.
430   return new (zone()) Operator1<int>(         // --
431       IrOpcode::kParameter, Operator::kPure,  // opcode
432       "Parameter",                            // name
433       1, 0, 0, 1, 0, 0,                       // counts
434       index);                                 // parameter
435 }
436
437
438 const Operator* CommonOperatorBuilder::OsrValue(int index) {
439   return new (zone()) Operator1<int>(                // --
440       IrOpcode::kOsrValue, Operator::kNoProperties,  // opcode
441       "OsrValue",                                    // name
442       0, 0, 1, 1, 0, 0,                              // counts
443       index);                                        // parameter
444 }
445
446
447 const Operator* CommonOperatorBuilder::Int32Constant(int32_t value) {
448   return new (zone()) Operator1<int32_t>(         // --
449       IrOpcode::kInt32Constant, Operator::kPure,  // opcode
450       "Int32Constant",                            // name
451       0, 0, 0, 1, 0, 0,                           // counts
452       value);                                     // parameter
453 }
454
455
456 const Operator* CommonOperatorBuilder::Int64Constant(int64_t value) {
457   return new (zone()) Operator1<int64_t>(         // --
458       IrOpcode::kInt64Constant, Operator::kPure,  // opcode
459       "Int64Constant",                            // name
460       0, 0, 0, 1, 0, 0,                           // counts
461       value);                                     // parameter
462 }
463
464
465 const Operator* CommonOperatorBuilder::Float32Constant(volatile float value) {
466   return new (zone())
467       Operator1<float, base::bit_equal_to<float>, base::bit_hash<float>>(  // --
468           IrOpcode::kFloat32Constant, Operator::kPure,  // opcode
469           "Float32Constant",                            // name
470           0, 0, 0, 1, 0, 0,                             // counts
471           value);                                       // parameter
472 }
473
474
475 const Operator* CommonOperatorBuilder::Float64Constant(volatile double value) {
476   return new (zone()) Operator1<double, base::bit_equal_to<double>,
477                                 base::bit_hash<double>>(  // --
478       IrOpcode::kFloat64Constant, Operator::kPure,        // opcode
479       "Float64Constant",                                  // name
480       0, 0, 0, 1, 0, 0,                                   // counts
481       value);                                             // parameter
482 }
483
484
485 const Operator* CommonOperatorBuilder::ExternalConstant(
486     const ExternalReference& value) {
487   return new (zone()) Operator1<ExternalReference>(  // --
488       IrOpcode::kExternalConstant, Operator::kPure,  // opcode
489       "ExternalConstant",                            // name
490       0, 0, 0, 1, 0, 0,                              // counts
491       value);                                        // parameter
492 }
493
494
495 const Operator* CommonOperatorBuilder::NumberConstant(volatile double value) {
496   return new (zone()) Operator1<double, base::bit_equal_to<double>,
497                                 base::bit_hash<double>>(  // --
498       IrOpcode::kNumberConstant, Operator::kPure,         // opcode
499       "NumberConstant",                                   // name
500       0, 0, 0, 1, 0, 0,                                   // counts
501       value);                                             // parameter
502 }
503
504
505 const Operator* CommonOperatorBuilder::HeapConstant(
506     const Unique<HeapObject>& value) {
507   return new (zone()) Operator1<Unique<HeapObject>>(  // --
508       IrOpcode::kHeapConstant, Operator::kPure,       // opcode
509       "HeapConstant",                                 // name
510       0, 0, 0, 1, 0, 0,                               // counts
511       value);                                         // parameter
512 }
513
514
515 const Operator* CommonOperatorBuilder::Select(MachineType type,
516                                               BranchHint hint) {
517   return new (zone()) Operator1<SelectParameters>(  // --
518       IrOpcode::kSelect, Operator::kPure,           // opcode
519       "Select",                                     // name
520       3, 0, 0, 1, 0, 0,                             // counts
521       SelectParameters(type, hint));                // parameter
522 }
523
524
525 const Operator* CommonOperatorBuilder::Phi(MachineType type,
526                                            int value_input_count) {
527   DCHECK(value_input_count > 0);  // Disallow empty phis.
528 #define CACHED_PHI(kType, kValueInputCount)                     \
529   if (kType == type && kValueInputCount == value_input_count) { \
530     return &cache_.kPhi##kType##kValueInputCount##Operator;     \
531   }
532   CACHED_PHI_LIST(CACHED_PHI)
533 #undef CACHED_PHI
534   // Uncached.
535   return new (zone()) Operator1<MachineType>(  // --
536       IrOpcode::kPhi, Operator::kPure,         // opcode
537       "Phi",                                   // name
538       value_input_count, 0, 1, 1, 0, 0,        // counts
539       type);                                   // parameter
540 }
541
542
543 const Operator* CommonOperatorBuilder::EffectPhi(int effect_input_count) {
544   DCHECK(effect_input_count > 0);  // Disallow empty effect phis.
545   switch (effect_input_count) {
546 #define CACHED_EFFECT_PHI(input_count) \
547   case input_count:                    \
548     return &cache_.kEffectPhi##input_count##Operator;
549     CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
550 #undef CACHED_EFFECT_PHI
551     default:
552       break;
553   }
554   // Uncached.
555   return new (zone()) Operator(               // --
556       IrOpcode::kEffectPhi, Operator::kPure,  // opcode
557       "EffectPhi",                            // name
558       0, effect_input_count, 1, 0, 1, 0);     // counts
559 }
560
561
562 const Operator* CommonOperatorBuilder::EffectSet(int arguments) {
563   DCHECK(arguments > 1);                      // Disallow empty/singleton sets.
564   return new (zone()) Operator(               // --
565       IrOpcode::kEffectSet, Operator::kPure,  // opcode
566       "EffectSet",                            // name
567       0, arguments, 0, 0, 1, 0);              // counts
568 }
569
570
571 const Operator* CommonOperatorBuilder::ValueEffect(int arguments) {
572   DCHECK(arguments > 0);                        // Disallow empty value effects.
573   return new (zone()) Operator(                 // --
574       IrOpcode::kValueEffect, Operator::kPure,  // opcode
575       "ValueEffect",                            // name
576       arguments, 0, 0, 0, 1, 0);                // counts
577 }
578
579
580 const Operator* CommonOperatorBuilder::Finish(int arguments) {
581   DCHECK(arguments > 0);                   // Disallow empty finishes.
582   return new (zone()) Operator(            // --
583       IrOpcode::kFinish, Operator::kPure,  // opcode
584       "Finish",                            // name
585       1, arguments, 0, 1, 0, 0);           // counts
586 }
587
588
589 const Operator* CommonOperatorBuilder::StateValues(int arguments) {
590   switch (arguments) {
591 #define CACHED_STATE_VALUES(arguments) \
592   case arguments:                      \
593     return &cache_.kStateValues##arguments##Operator;
594     CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
595 #undef CACHED_STATE_VALUES
596     default:
597       break;
598   }
599   // Uncached.
600   return new (zone()) Operator(                 // --
601       IrOpcode::kStateValues, Operator::kPure,  // opcode
602       "StateValues",                            // name
603       arguments, 0, 0, 1, 0, 0);                // counts
604 }
605
606
607 const Operator* CommonOperatorBuilder::TypedStateValues(
608     const ZoneVector<MachineType>* types) {
609   return new (zone()) Operator1<const ZoneVector<MachineType>*>(  // --
610       IrOpcode::kTypedStateValues, Operator::kPure,               // opcode
611       "TypedStateValues",                                         // name
612       static_cast<int>(types->size()), 0, 0, 1, 0, 0, types);     // counts
613 }
614
615
616 const Operator* CommonOperatorBuilder::FrameState(
617     FrameStateType type, BailoutId bailout_id,
618     OutputFrameStateCombine state_combine, MaybeHandle<JSFunction> jsfunction) {
619   return new (zone()) Operator1<FrameStateCallInfo>(  // --
620       IrOpcode::kFrameState, Operator::kPure,         // opcode
621       "FrameState",                                   // name
622       4, 0, 0, 1, 0, 0,                               // counts
623       FrameStateCallInfo(type, bailout_id, state_combine, jsfunction));
624 }
625
626
627 const Operator* CommonOperatorBuilder::Call(const CallDescriptor* descriptor) {
628   class CallOperator FINAL : public Operator1<const CallDescriptor*> {
629    public:
630     CallOperator(const CallDescriptor* descriptor, const char* mnemonic)
631         : Operator1<const CallDescriptor*>(
632               IrOpcode::kCall, descriptor->properties(), mnemonic,
633               descriptor->InputCount() + descriptor->FrameStateCount(),
634               Operator::ZeroIfPure(descriptor->properties()),
635               Operator::ZeroIfEliminatable(descriptor->properties()),
636               descriptor->ReturnCount(),
637               Operator::ZeroIfPure(descriptor->properties()),
638               Operator::ZeroIfNoThrow(descriptor->properties()), descriptor) {}
639
640     void PrintParameter(std::ostream& os) const OVERRIDE {
641       os << "[" << *parameter() << "]";
642     }
643   };
644   return new (zone()) CallOperator(descriptor, "Call");
645 }
646
647
648 const Operator* CommonOperatorBuilder::Projection(size_t index) {
649   switch (index) {
650 #define CACHED_PROJECTION(index) \
651   case index:                    \
652     return &cache_.kProjection##index##Operator;
653     CACHED_PROJECTION_LIST(CACHED_PROJECTION)
654 #undef CACHED_PROJECTION
655     default:
656       break;
657   }
658   // Uncached.
659   return new (zone()) Operator1<size_t>(         // --
660       IrOpcode::kProjection,                     // opcode
661       Operator::kFoldable | Operator::kNoThrow,  // flags
662       "Projection",                              // name
663       1, 0, 0, 1, 0, 0,                          // counts
664       index);                                    // parameter
665 }
666
667
668 const Operator* CommonOperatorBuilder::ResizeMergeOrPhi(const Operator* op,
669                                                         int size) {
670   if (op->opcode() == IrOpcode::kPhi) {
671     return Phi(OpParameter<MachineType>(op), size);
672   } else if (op->opcode() == IrOpcode::kEffectPhi) {
673     return EffectPhi(size);
674   } else if (op->opcode() == IrOpcode::kMerge) {
675     return Merge(size);
676   } else if (op->opcode() == IrOpcode::kLoop) {
677     return Loop(size);
678   } else {
679     UNREACHABLE();
680     return nullptr;
681   }
682 }
683
684
685 }  // namespace compiler
686 }  // namespace internal
687 }  // namespace v8