OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 #include "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/base/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 return os; | 29 return os; |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 BranchHint BranchHintOf(const Operator* const op) { | 33 BranchHint BranchHintOf(const Operator* const op) { |
34 DCHECK_EQ(IrOpcode::kBranch, op->opcode()); | 34 DCHECK_EQ(IrOpcode::kBranch, op->opcode()); |
35 return OpParameter<BranchHint>(op); | 35 return OpParameter<BranchHint>(op); |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 size_t CaseIndexOf(const Operator* const op) { | |
40 DCHECK_EQ(IrOpcode::kCase, op->opcode()); | |
41 return OpParameter<size_t>(op); | |
42 } | |
43 | |
44 | |
45 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { | 39 bool operator==(SelectParameters const& lhs, SelectParameters const& rhs) { |
46 return lhs.type() == rhs.type() && lhs.hint() == rhs.hint(); | 40 return lhs.type() == rhs.type() && lhs.hint() == rhs.hint(); |
47 } | 41 } |
48 | 42 |
49 | 43 |
50 bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) { | 44 bool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) { |
51 return !(lhs == rhs); | 45 return !(lhs == rhs); |
52 } | 46 } |
53 | 47 |
54 | 48 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return OpParameter<size_t>(op); | 108 return OpParameter<size_t>(op); |
115 } | 109 } |
116 | 110 |
117 | 111 |
118 #define CACHED_OP_LIST(V) \ | 112 #define CACHED_OP_LIST(V) \ |
119 V(Always, Operator::kPure, 0, 0, 0, 1, 0, 0) \ | 113 V(Always, Operator::kPure, 0, 0, 0, 1, 0, 0) \ |
120 V(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1) \ | 114 V(Dead, Operator::kFoldable, 0, 0, 0, 0, 0, 1) \ |
121 V(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0) \ | 115 V(End, Operator::kKontrol, 0, 0, 1, 0, 0, 0) \ |
122 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 116 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
123 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 117 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
| 118 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
124 V(Throw, Operator::kFoldable, 1, 1, 1, 0, 0, 1) \ | 119 V(Throw, Operator::kFoldable, 1, 1, 1, 0, 0, 1) \ |
125 V(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \ | 120 V(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \ |
126 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ | 121 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ |
127 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) | 122 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) |
128 | 123 |
129 | 124 |
130 #define CACHED_LOOP_LIST(V) \ | 125 #define CACHED_LOOP_LIST(V) \ |
131 V(1) \ | 126 V(1) \ |
132 V(2) | 127 V(2) |
133 | 128 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return &cache_.kBranchTrueOperator; | 244 return &cache_.kBranchTrueOperator; |
250 case BranchHint::kFalse: | 245 case BranchHint::kFalse: |
251 return &cache_.kBranchFalseOperator; | 246 return &cache_.kBranchFalseOperator; |
252 } | 247 } |
253 UNREACHABLE(); | 248 UNREACHABLE(); |
254 return nullptr; | 249 return nullptr; |
255 } | 250 } |
256 | 251 |
257 | 252 |
258 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { | 253 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { |
259 DCHECK_GE(control_output_count, 2u); // Disallow trivial switches. | 254 DCHECK_GE(control_output_count, 3u); // Disallow trivial switches. |
260 return new (zone()) Operator( // -- | 255 return new (zone()) Operator( // -- |
261 IrOpcode::kSwitch, Operator::kKontrol, // opcode | 256 IrOpcode::kSwitch, Operator::kKontrol, // opcode |
262 "Switch", // name | 257 "Switch", // name |
263 1, 0, 1, 0, 0, control_output_count); // counts | 258 1, 0, 1, 0, 0, control_output_count); // counts |
264 } | 259 } |
265 | 260 |
266 | 261 |
267 const Operator* CommonOperatorBuilder::Case(size_t index) { | 262 const Operator* CommonOperatorBuilder::IfValue(int32_t index) { |
268 return new (zone()) Operator1<size_t>( // -- | 263 return new (zone()) Operator1<int32_t>( // -- |
269 IrOpcode::kCase, Operator::kKontrol, // opcode | 264 IrOpcode::kIfValue, Operator::kKontrol, // opcode |
270 "Case", // name | 265 "IfValue", // name |
271 0, 0, 1, 0, 0, 1, // counts | 266 0, 0, 1, 0, 0, 1, // counts |
272 index); // parameter | 267 index); // parameter |
273 } | 268 } |
274 | 269 |
275 | 270 |
276 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) { | 271 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) { |
277 // Outputs are formal parameters, plus context, receiver, and JSFunction. | 272 // Outputs are formal parameters, plus context, receiver, and JSFunction. |
278 const int value_output_count = num_formal_parameters + 3; | 273 const int value_output_count = num_formal_parameters + 3; |
279 return new (zone()) Operator( // -- | 274 return new (zone()) Operator( // -- |
280 IrOpcode::kStart, Operator::kFoldable, // opcode | 275 IrOpcode::kStart, Operator::kFoldable, // opcode |
281 "Start", // name | 276 "Start", // name |
282 0, 0, 0, value_output_count, 1, 1); // counts | 277 0, 0, 0, value_output_count, 1, 1); // counts |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 } else { | 528 } else { |
534 UNREACHABLE(); | 529 UNREACHABLE(); |
535 return nullptr; | 530 return nullptr; |
536 } | 531 } |
537 } | 532 } |
538 | 533 |
539 | 534 |
540 } // namespace compiler | 535 } // namespace compiler |
541 } // namespace internal | 536 } // namespace internal |
542 } // namespace v8 | 537 } // namespace v8 |
OLD | NEW |