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 hash_value(DeoptimizeKind kind) { return static_cast<size_t>(kind); } |
| 40 |
| 41 |
| 42 std::ostream& operator<<(std::ostream& os, DeoptimizeKind kind) { |
| 43 switch (kind) { |
| 44 case DeoptimizeKind::kEager: |
| 45 return os << "Eager"; |
| 46 case DeoptimizeKind::kSoft: |
| 47 return os << "Soft"; |
| 48 } |
| 49 UNREACHABLE(); |
| 50 return os; |
| 51 } |
| 52 |
| 53 |
| 54 DeoptimizeKind DeoptimizeKindOf(const Operator* const op) { |
| 55 DCHECK_EQ(IrOpcode::kDeoptimize, op->opcode()); |
| 56 return OpParameter<DeoptimizeKind>(op); |
| 57 } |
| 58 |
| 59 |
39 size_t hash_value(IfExceptionHint hint) { return static_cast<size_t>(hint); } | 60 size_t hash_value(IfExceptionHint hint) { return static_cast<size_t>(hint); } |
40 | 61 |
41 | 62 |
42 std::ostream& operator<<(std::ostream& os, IfExceptionHint hint) { | 63 std::ostream& operator<<(std::ostream& os, IfExceptionHint hint) { |
43 switch (hint) { | 64 switch (hint) { |
44 case IfExceptionHint::kLocallyCaught: | 65 case IfExceptionHint::kLocallyCaught: |
45 return os << "Caught"; | 66 return os << "Caught"; |
46 case IfExceptionHint::kLocallyUncaught: | 67 case IfExceptionHint::kLocallyUncaught: |
47 return os << "Uncaught"; | 68 return os << "Uncaught"; |
48 } | 69 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 136 } |
116 | 137 |
117 | 138 |
118 #define CACHED_OP_LIST(V) \ | 139 #define CACHED_OP_LIST(V) \ |
119 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ | 140 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ |
120 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 141 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
121 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 142 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
122 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 143 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
123 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 144 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
124 V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \ | 145 V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \ |
125 V(Deoptimize, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \ | |
126 V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \ | 146 V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \ |
127 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ | 147 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ |
128 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ | 148 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ |
129 V(BeginRegion, Operator::kNoThrow, 0, 1, 0, 0, 1, 0) \ | 149 V(BeginRegion, Operator::kNoThrow, 0, 1, 0, 0, 1, 0) \ |
130 V(FinishRegion, Operator::kNoThrow, 1, 1, 0, 1, 1, 0) | 150 V(FinishRegion, Operator::kNoThrow, 1, 1, 0, 1, 1, 0) |
131 | 151 |
132 | 152 |
133 #define CACHED_RETURN_LIST(V) \ | 153 #define CACHED_RETURN_LIST(V) \ |
134 V(1) \ | 154 V(1) \ |
135 V(2) \ | 155 V(2) \ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 Name##Operator() \ | 244 Name##Operator() \ |
225 : Operator(IrOpcode::k##Name, properties, #Name, value_input_count, \ | 245 : Operator(IrOpcode::k##Name, properties, #Name, value_input_count, \ |
226 effect_input_count, control_input_count, \ | 246 effect_input_count, control_input_count, \ |
227 value_output_count, effect_output_count, \ | 247 value_output_count, effect_output_count, \ |
228 control_output_count) {} \ | 248 control_output_count) {} \ |
229 }; \ | 249 }; \ |
230 Name##Operator k##Name##Operator; | 250 Name##Operator k##Name##Operator; |
231 CACHED_OP_LIST(CACHED) | 251 CACHED_OP_LIST(CACHED) |
232 #undef CACHED | 252 #undef CACHED |
233 | 253 |
| 254 template <DeoptimizeKind kKind> |
| 255 struct DeoptimizeOperator final : public Operator1<DeoptimizeKind> { |
| 256 DeoptimizeOperator() |
| 257 : Operator1<DeoptimizeKind>( // -- |
| 258 IrOpcode::kDeoptimize, Operator::kNoThrow, // opcode |
| 259 "Deoptimize", // name |
| 260 1, 1, 1, 0, 0, 1, // counts |
| 261 kKind) {} // parameter |
| 262 }; |
| 263 DeoptimizeOperator<DeoptimizeKind::kEager> kDeoptimizeEagerOperator; |
| 264 DeoptimizeOperator<DeoptimizeKind::kSoft> kDeoptimizeSoftOperator; |
| 265 |
234 template <IfExceptionHint kCaughtLocally> | 266 template <IfExceptionHint kCaughtLocally> |
235 struct IfExceptionOperator final : public Operator1<IfExceptionHint> { | 267 struct IfExceptionOperator final : public Operator1<IfExceptionHint> { |
236 IfExceptionOperator() | 268 IfExceptionOperator() |
237 : Operator1<IfExceptionHint>( // -- | 269 : Operator1<IfExceptionHint>( // -- |
238 IrOpcode::kIfException, Operator::kKontrol, // opcode | 270 IrOpcode::kIfException, Operator::kKontrol, // opcode |
239 "IfException", // name | 271 "IfException", // name |
240 0, 1, 1, 1, 1, 1, // counts | 272 0, 1, 1, 1, 1, 1, // counts |
241 kCaughtLocally) {} // parameter | 273 kCaughtLocally) {} // parameter |
242 }; | 274 }; |
243 IfExceptionOperator<IfExceptionHint::kLocallyCaught> kIfExceptionCOperator; | 275 IfExceptionOperator<IfExceptionHint::kLocallyCaught> kIfExceptionCOperator; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 case BranchHint::kTrue: | 473 case BranchHint::kTrue: |
442 return &cache_.kBranchTrueOperator; | 474 return &cache_.kBranchTrueOperator; |
443 case BranchHint::kFalse: | 475 case BranchHint::kFalse: |
444 return &cache_.kBranchFalseOperator; | 476 return &cache_.kBranchFalseOperator; |
445 } | 477 } |
446 UNREACHABLE(); | 478 UNREACHABLE(); |
447 return nullptr; | 479 return nullptr; |
448 } | 480 } |
449 | 481 |
450 | 482 |
| 483 const Operator* CommonOperatorBuilder::Deoptimize(DeoptimizeKind kind) { |
| 484 switch (kind) { |
| 485 case DeoptimizeKind::kEager: |
| 486 return &cache_.kDeoptimizeEagerOperator; |
| 487 case DeoptimizeKind::kSoft: |
| 488 return &cache_.kDeoptimizeSoftOperator; |
| 489 } |
| 490 UNREACHABLE(); |
| 491 return nullptr; |
| 492 } |
| 493 |
| 494 |
451 const Operator* CommonOperatorBuilder::IfException(IfExceptionHint hint) { | 495 const Operator* CommonOperatorBuilder::IfException(IfExceptionHint hint) { |
452 switch (hint) { | 496 switch (hint) { |
453 case IfExceptionHint::kLocallyCaught: | 497 case IfExceptionHint::kLocallyCaught: |
454 return &cache_.kIfExceptionCOperator; | 498 return &cache_.kIfExceptionCOperator; |
455 case IfExceptionHint::kLocallyUncaught: | 499 case IfExceptionHint::kLocallyUncaught: |
456 return &cache_.kIfExceptionUOperator; | 500 return &cache_.kIfExceptionUOperator; |
457 } | 501 } |
458 UNREACHABLE(); | 502 UNREACHABLE(); |
459 return nullptr; | 503 return nullptr; |
460 } | 504 } |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 Handle<SharedFunctionInfo> shared_info, | 852 Handle<SharedFunctionInfo> shared_info, |
809 ContextCallingMode context_calling_mode) { | 853 ContextCallingMode context_calling_mode) { |
810 return new (zone()->New(sizeof(FrameStateFunctionInfo))) | 854 return new (zone()->New(sizeof(FrameStateFunctionInfo))) |
811 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info, | 855 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info, |
812 context_calling_mode); | 856 context_calling_mode); |
813 } | 857 } |
814 | 858 |
815 } // namespace compiler | 859 } // namespace compiler |
816 } // namespace internal | 860 } // namespace internal |
817 } // namespace v8 | 861 } // namespace v8 |
OLD | NEW |