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/unique.h" | 10 #include "src/unique.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 int outputs, int controls, const char* mnemonic) | 23 int outputs, int controls, const char* mnemonic) |
24 : Operator1<int>(opcode, properties, inputs, outputs, mnemonic, | 24 : Operator1<int>(opcode, properties, inputs, outputs, mnemonic, |
25 controls) {} | 25 controls) {} |
26 | 26 |
27 virtual void PrintParameter(std::ostream& os) const FINAL {} | 27 virtual void PrintParameter(std::ostream& os) const FINAL {} |
28 }; | 28 }; |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 | 32 |
| 33 std::ostream& operator<<(std::ostream& os, BranchHint hint) { |
| 34 switch (hint) { |
| 35 case BranchHint::kNone: |
| 36 return os << "None"; |
| 37 case BranchHint::kTrue: |
| 38 return os << "True"; |
| 39 case BranchHint::kFalse: |
| 40 return os << "False"; |
| 41 } |
| 42 UNREACHABLE(); |
| 43 return os; |
| 44 } |
| 45 |
| 46 |
| 47 BranchHint BranchHintOf(const Operator* const op) { |
| 48 DCHECK_EQ(IrOpcode::kBranch, op->opcode()); |
| 49 return OpParameter<BranchHint>(op); |
| 50 } |
| 51 |
| 52 |
33 size_t hash_value(OutputFrameStateCombine const& sc) { | 53 size_t hash_value(OutputFrameStateCombine const& sc) { |
34 return base::hash_combine(sc.kind_, sc.parameter_); | 54 return base::hash_combine(sc.kind_, sc.parameter_); |
35 } | 55 } |
36 | 56 |
37 | 57 |
38 std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) { | 58 std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) { |
39 switch (sc.kind_) { | 59 switch (sc.kind_) { |
40 case OutputFrameStateCombine::kPushOutput: | 60 case OutputFrameStateCombine::kPushOutput: |
41 if (sc.parameter_ == 0) return os << "Ignore"; | 61 if (sc.parameter_ == 0) return os << "Ignore"; |
42 return os << "Push(" << sc.parameter_ << ")"; | 62 return os << "Push(" << sc.parameter_ << ")"; |
(...skipping 24 matching lines...) Expand all Loading... |
67 | 87 |
68 std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) { | 88 std::ostream& operator<<(std::ostream& os, FrameStateCallInfo const& info) { |
69 return os << info.type() << ", " << info.bailout_id() << ", " | 89 return os << info.type() << ", " << info.bailout_id() << ", " |
70 << info.state_combine(); | 90 << info.state_combine(); |
71 } | 91 } |
72 | 92 |
73 | 93 |
74 #define SHARED_OP_LIST(V) \ | 94 #define SHARED_OP_LIST(V) \ |
75 V(Dead, Operator::kFoldable, 0, 0) \ | 95 V(Dead, Operator::kFoldable, 0, 0) \ |
76 V(End, Operator::kFoldable, 0, 1) \ | 96 V(End, Operator::kFoldable, 0, 1) \ |
77 V(Branch, Operator::kFoldable, 1, 1) \ | |
78 V(IfTrue, Operator::kFoldable, 0, 1) \ | 97 V(IfTrue, Operator::kFoldable, 0, 1) \ |
79 V(IfFalse, Operator::kFoldable, 0, 1) \ | 98 V(IfFalse, Operator::kFoldable, 0, 1) \ |
80 V(Throw, Operator::kFoldable, 1, 1) \ | 99 V(Throw, Operator::kFoldable, 1, 1) \ |
81 V(Return, Operator::kNoProperties, 1, 1) | 100 V(Return, Operator::kNoProperties, 1, 1) |
82 | 101 |
83 | 102 |
84 struct CommonOperatorBuilderImpl FINAL { | 103 struct CommonOperatorBuilderImpl FINAL { |
85 #define SHARED(Name, properties, value_input_count, control_input_count) \ | 104 #define SHARED(Name, properties, value_input_count, control_input_count) \ |
86 struct Name##Operator FINAL : public ControlOperator { \ | 105 struct Name##Operator FINAL : public ControlOperator { \ |
87 Name##Operator() \ | 106 Name##Operator() \ |
(...skipping 15 matching lines...) Expand all Loading... |
103 | 122 |
104 | 123 |
105 #define SHARED(Name, properties, value_input_count, control_input_count) \ | 124 #define SHARED(Name, properties, value_input_count, control_input_count) \ |
106 const Operator* CommonOperatorBuilder::Name() { \ | 125 const Operator* CommonOperatorBuilder::Name() { \ |
107 return &impl_.k##Name##Operator; \ | 126 return &impl_.k##Name##Operator; \ |
108 } | 127 } |
109 SHARED_OP_LIST(SHARED) | 128 SHARED_OP_LIST(SHARED) |
110 #undef SHARED | 129 #undef SHARED |
111 | 130 |
112 | 131 |
| 132 const Operator* CommonOperatorBuilder::Branch(BranchHint hint) { |
| 133 return new (zone()) Operator1<BranchHint>( |
| 134 IrOpcode::kBranch, Operator::kFoldable, 1, 0, "Branch", hint); |
| 135 } |
| 136 |
| 137 |
113 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) { | 138 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) { |
114 // Outputs are formal parameters, plus context, receiver, and JSFunction. | 139 // Outputs are formal parameters, plus context, receiver, and JSFunction. |
115 const int value_output_count = num_formal_parameters + 3; | 140 const int value_output_count = num_formal_parameters + 3; |
116 return new (zone()) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, | 141 return new (zone()) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, |
117 value_output_count, 0, "Start"); | 142 value_output_count, 0, "Start"); |
118 } | 143 } |
119 | 144 |
120 | 145 |
121 const Operator* CommonOperatorBuilder::Merge(int controls) { | 146 const Operator* CommonOperatorBuilder::Merge(int controls) { |
122 return new (zone()) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, | 147 return new (zone()) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 277 |
253 | 278 |
254 const Operator* CommonOperatorBuilder::Projection(size_t index) { | 279 const Operator* CommonOperatorBuilder::Projection(size_t index) { |
255 return new (zone()) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, | 280 return new (zone()) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, |
256 1, 1, "Projection", index); | 281 1, 1, "Projection", index); |
257 } | 282 } |
258 | 283 |
259 } // namespace compiler | 284 } // namespace compiler |
260 } // namespace internal | 285 } // namespace internal |
261 } // namespace v8 | 286 } // namespace v8 |
OLD | NEW |