OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ | 5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ |
6 #define V8_COMPILER_COMMON_OPERATOR_H_ | 6 #define V8_COMPILER_COMMON_OPERATOR_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // including JavaScript, mid-level, and low-level. | 58 // including JavaScript, mid-level, and low-level. |
59 // TODO(titzer): Move the mnemonics into SimpleOperator and Operator1 classes. | 59 // TODO(titzer): Move the mnemonics into SimpleOperator and Operator1 classes. |
60 class CommonOperatorBuilder { | 60 class CommonOperatorBuilder { |
61 public: | 61 public: |
62 explicit CommonOperatorBuilder(Zone* zone) : zone_(zone) {} | 62 explicit CommonOperatorBuilder(Zone* zone) : zone_(zone) {} |
63 | 63 |
64 #define CONTROL_OP(name, inputs, controls) \ | 64 #define CONTROL_OP(name, inputs, controls) \ |
65 return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ | 65 return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ |
66 inputs, 0, controls, #name); | 66 inputs, 0, controls, #name); |
67 | 67 |
68 Operator* Start() { CONTROL_OP(Start, 0, 0); } | 68 Operator* Start(int num_formal_parameters) { |
| 69 // Outputs are formal parameters, plus context, receiver, and JSFunction. |
| 70 int outputs = num_formal_parameters + 3; |
| 71 return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, |
| 72 outputs, 0, "Start"); |
| 73 } |
69 Operator* Dead() { CONTROL_OP(Dead, 0, 0); } | 74 Operator* Dead() { CONTROL_OP(Dead, 0, 0); } |
70 Operator* End() { CONTROL_OP(End, 0, 1); } | 75 Operator* End() { CONTROL_OP(End, 0, 1); } |
71 Operator* Branch() { CONTROL_OP(Branch, 1, 1); } | 76 Operator* Branch() { CONTROL_OP(Branch, 1, 1); } |
72 Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } | 77 Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } |
73 Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } | 78 Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } |
74 Operator* Throw() { CONTROL_OP(Throw, 1, 1); } | 79 Operator* Throw() { CONTROL_OP(Throw, 1, 1); } |
75 Operator* LazyDeoptimization() { CONTROL_OP(LazyDeoptimization, 0, 1); } | 80 Operator* LazyDeoptimization() { CONTROL_OP(LazyDeoptimization, 0, 1); } |
76 Operator* Continuation() { CONTROL_OP(Continuation, 0, 1); } | 81 Operator* Continuation() { CONTROL_OP(Continuation, 0, 1); } |
77 | 82 |
78 Operator* Deoptimize() { | 83 Operator* Deoptimize() { |
79 return new (zone_) | 84 return new (zone_) |
80 ControlOperator(IrOpcode::kDeoptimize, 0, 1, 0, 1, "Deoptimize"); | 85 ControlOperator(IrOpcode::kDeoptimize, 0, 1, 0, 1, "Deoptimize"); |
81 } | 86 } |
82 | 87 |
83 Operator* Return() { | 88 Operator* Return() { |
84 return new (zone_) ControlOperator(IrOpcode::kReturn, 0, 1, 0, 1, "Return"); | 89 return new (zone_) ControlOperator(IrOpcode::kReturn, 0, 1, 0, 1, "Return"); |
85 } | 90 } |
86 | 91 |
87 Operator* Merge(int controls) { | 92 Operator* Merge(int controls) { |
88 return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, | 93 return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, |
89 0, controls, "Merge"); | 94 0, controls, "Merge"); |
90 } | 95 } |
91 | 96 |
92 Operator* Loop(int controls) { | 97 Operator* Loop(int controls) { |
93 return new (zone_) ControlOperator(IrOpcode::kLoop, Operator::kFoldable, 0, | 98 return new (zone_) ControlOperator(IrOpcode::kLoop, Operator::kFoldable, 0, |
94 0, controls, "Loop"); | 99 0, controls, "Loop"); |
95 } | 100 } |
96 | 101 |
97 Operator* Parameter(int index) { | 102 Operator* Parameter(int index) { |
98 return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 0, | 103 return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 1, |
99 1, "Parameter", index); | 104 1, "Parameter", index); |
100 } | 105 } |
101 Operator* Int32Constant(int32_t value) { | 106 Operator* Int32Constant(int32_t value) { |
102 return new (zone_) Operator1<int>(IrOpcode::kInt32Constant, Operator::kPure, | 107 return new (zone_) Operator1<int>(IrOpcode::kInt32Constant, Operator::kPure, |
103 0, 1, "Int32Constant", value); | 108 0, 1, "Int32Constant", value); |
104 } | 109 } |
105 Operator* Int64Constant(int64_t value) { | 110 Operator* Int64Constant(int64_t value) { |
106 return new (zone_) | 111 return new (zone_) |
107 Operator1<int64_t>(IrOpcode::kInt64Constant, Operator::kPure, 0, 1, | 112 Operator1<int64_t>(IrOpcode::kInt64Constant, Operator::kPure, 0, 1, |
108 "Int64Constant", value); | 113 "Int64Constant", value); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 282 |
278 template <typename T> | 283 template <typename T> |
279 inline T ValueOf(Operator* op) { | 284 inline T ValueOf(Operator* op) { |
280 return CommonOperatorTraits<T>::ValueOf(op); | 285 return CommonOperatorTraits<T>::ValueOf(op); |
281 } | 286 } |
282 } | 287 } |
283 } | 288 } |
284 } // namespace v8::internal::compiler | 289 } // namespace v8::internal::compiler |
285 | 290 |
286 #endif // V8_COMPILER_COMMON_OPERATOR_H_ | 291 #endif // V8_COMPILER_COMMON_OPERATOR_H_ |
OLD | NEW |