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_OPERATOR_PROPERTIES_INL_H_ | 5 #ifndef V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
6 #define V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ | 6 #define V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
7 | 7 |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
11 #include "src/compiler/opcodes.h" | 11 #include "src/compiler/opcodes.h" |
12 #include "src/compiler/operator-properties.h" | 12 #include "src/compiler/operator-properties.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace compiler { | 16 namespace compiler { |
17 | 17 |
18 inline bool OperatorProperties::HasValueInput(const Operator* op) { | |
19 return op->ValueInputCount() > 0; | |
20 } | |
21 | |
22 inline bool OperatorProperties::HasContextInput(const Operator* op) { | 18 inline bool OperatorProperties::HasContextInput(const Operator* op) { |
23 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); | 19 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); |
24 return IrOpcode::IsJsOpcode(opcode); | 20 return IrOpcode::IsJsOpcode(opcode); |
25 } | 21 } |
26 | 22 |
27 inline bool OperatorProperties::HasEffectInput(const Operator* op) { | |
28 return op->EffectInputCount() > 0; | |
29 } | |
30 | |
31 inline bool OperatorProperties::HasControlInput(const Operator* op) { | |
32 return op->ControlInputCount() > 0; | |
33 } | |
34 | |
35 inline bool OperatorProperties::HasFrameStateInput(const Operator* op) { | 23 inline bool OperatorProperties::HasFrameStateInput(const Operator* op) { |
36 if (!FLAG_turbo_deoptimization) { | 24 if (!FLAG_turbo_deoptimization) { |
37 return false; | 25 return false; |
38 } | 26 } |
39 | 27 |
40 switch (op->opcode()) { | 28 switch (op->opcode()) { |
41 case IrOpcode::kFrameState: | 29 case IrOpcode::kFrameState: |
42 return true; | 30 return true; |
43 case IrOpcode::kJSCallRuntime: { | 31 case IrOpcode::kJSCallRuntime: { |
44 const CallRuntimeParameters& p = CallRuntimeParametersOf(op); | 32 const CallRuntimeParameters& p = CallRuntimeParametersOf(op); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 74 |
87 // Other | 75 // Other |
88 case IrOpcode::kJSDeleteProperty: | 76 case IrOpcode::kJSDeleteProperty: |
89 return true; | 77 return true; |
90 | 78 |
91 default: | 79 default: |
92 return false; | 80 return false; |
93 } | 81 } |
94 } | 82 } |
95 | 83 |
96 inline int OperatorProperties::GetValueInputCount(const Operator* op) { | |
97 return op->ValueInputCount(); | |
98 } | |
99 | |
100 inline int OperatorProperties::GetContextInputCount(const Operator* op) { | 84 inline int OperatorProperties::GetContextInputCount(const Operator* op) { |
101 return OperatorProperties::HasContextInput(op) ? 1 : 0; | 85 return OperatorProperties::HasContextInput(op) ? 1 : 0; |
102 } | 86 } |
103 | 87 |
104 inline int OperatorProperties::GetFrameStateInputCount(const Operator* op) { | 88 inline int OperatorProperties::GetFrameStateInputCount(const Operator* op) { |
105 return OperatorProperties::HasFrameStateInput(op) ? 1 : 0; | 89 return OperatorProperties::HasFrameStateInput(op) ? 1 : 0; |
106 } | 90 } |
107 | 91 |
108 inline int OperatorProperties::GetEffectInputCount(const Operator* op) { | |
109 return op->EffectInputCount(); | |
110 } | |
111 | |
112 inline int OperatorProperties::GetControlInputCount(const Operator* op) { | |
113 return op->ControlInputCount(); | |
114 } | |
115 | |
116 inline int OperatorProperties::GetTotalInputCount(const Operator* op) { | 92 inline int OperatorProperties::GetTotalInputCount(const Operator* op) { |
117 return GetValueInputCount(op) + GetContextInputCount(op) + | 93 return op->ValueInputCount() + GetContextInputCount(op) + |
118 GetFrameStateInputCount(op) + GetEffectInputCount(op) + | 94 GetFrameStateInputCount(op) + op->EffectInputCount() + |
119 GetControlInputCount(op); | 95 op->ControlInputCount(); |
120 } | 96 } |
121 | 97 |
122 // ----------------------------------------------------------------------------- | 98 // ----------------------------------------------------------------------------- |
123 // Output properties. | 99 // Output properties. |
124 | 100 |
125 inline bool OperatorProperties::HasValueOutput(const Operator* op) { | |
126 return op->ValueOutputCount() > 0; | |
127 } | |
128 | |
129 inline bool OperatorProperties::HasEffectOutput(const Operator* op) { | |
130 return op->EffectOutputCount() > 0; | |
131 } | |
132 | |
133 inline bool OperatorProperties::HasControlOutput(const Operator* op) { | |
134 return op->ControlOutputCount() > 0; | |
135 } | |
136 | |
137 | |
138 inline int OperatorProperties::GetValueOutputCount(const Operator* op) { | |
139 return op->ValueOutputCount(); | |
140 } | |
141 | |
142 inline int OperatorProperties::GetEffectOutputCount(const Operator* op) { | |
143 return op->EffectOutputCount(); | |
144 } | |
145 | |
146 inline int OperatorProperties::GetControlOutputCount(const Operator* op) { | |
147 return op->ControlOutputCount(); | |
148 } | |
149 | |
150 | |
151 inline bool OperatorProperties::IsBasicBlockBegin(const Operator* op) { | 101 inline bool OperatorProperties::IsBasicBlockBegin(const Operator* op) { |
152 uint8_t opcode = op->opcode(); | 102 uint8_t opcode = op->opcode(); |
153 return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd || | 103 return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd || |
154 opcode == IrOpcode::kDead || opcode == IrOpcode::kLoop || | 104 opcode == IrOpcode::kDead || opcode == IrOpcode::kLoop || |
155 opcode == IrOpcode::kMerge || opcode == IrOpcode::kIfTrue || | 105 opcode == IrOpcode::kMerge || opcode == IrOpcode::kIfTrue || |
156 opcode == IrOpcode::kIfFalse; | 106 opcode == IrOpcode::kIfFalse; |
157 } | 107 } |
158 | 108 |
159 } // namespace compiler | 109 } // namespace compiler |
160 } // namespace internal | 110 } // namespace internal |
161 } // namespace v8 | 111 } // namespace v8 |
162 | 112 |
163 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ | 113 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
OLD | NEW |