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/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 inline bool OperatorProperties::HasEffectInput(Operator* op) { | 26 inline bool OperatorProperties::HasEffectInput(Operator* op) { |
27 return OperatorProperties::GetEffectInputCount(op) > 0; | 27 return OperatorProperties::GetEffectInputCount(op) > 0; |
28 } | 28 } |
29 | 29 |
30 inline bool OperatorProperties::HasControlInput(Operator* op) { | 30 inline bool OperatorProperties::HasControlInput(Operator* op) { |
31 return OperatorProperties::GetControlInputCount(op) > 0; | 31 return OperatorProperties::GetControlInputCount(op) > 0; |
32 } | 32 } |
33 | 33 |
| 34 inline bool OperatorProperties::HasFrameStateInput(Operator* op) { |
| 35 if (!FLAG_turbo_deoptimization) { |
| 36 return false; |
| 37 } |
| 38 |
| 39 switch (op->opcode()) { |
| 40 case IrOpcode::kJSCallFunction: |
| 41 return true; |
| 42 case IrOpcode::kJSCallRuntime: { |
| 43 Runtime::FunctionId function = |
| 44 reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter(); |
| 45 // TODO(jarin) At the moment, we only add frame state for |
| 46 // few chosen runtime functions. |
| 47 switch (function) { |
| 48 case Runtime::kDebugBreak: |
| 49 case Runtime::kDeoptimizeFunction: |
| 50 return true; |
| 51 default: |
| 52 return false; |
| 53 } |
| 54 UNREACHABLE(); |
| 55 } |
| 56 |
| 57 default: |
| 58 return false; |
| 59 } |
| 60 } |
34 | 61 |
35 inline int OperatorProperties::GetValueInputCount(Operator* op) { | 62 inline int OperatorProperties::GetValueInputCount(Operator* op) { |
36 return op->InputCount(); | 63 return op->InputCount(); |
37 } | 64 } |
38 | 65 |
39 inline int OperatorProperties::GetContextInputCount(Operator* op) { | 66 inline int OperatorProperties::GetContextInputCount(Operator* op) { |
40 return OperatorProperties::HasContextInput(op) ? 1 : 0; | 67 return OperatorProperties::HasContextInput(op) ? 1 : 0; |
41 } | 68 } |
42 | 69 |
| 70 inline int OperatorProperties::GetFrameStateInputCount(Operator* op) { |
| 71 return OperatorProperties::HasFrameStateInput(op) ? 1 : 0; |
| 72 } |
| 73 |
43 inline int OperatorProperties::GetEffectInputCount(Operator* op) { | 74 inline int OperatorProperties::GetEffectInputCount(Operator* op) { |
44 if (op->opcode() == IrOpcode::kEffectPhi || | 75 if (op->opcode() == IrOpcode::kEffectPhi || |
45 op->opcode() == IrOpcode::kFinish) { | 76 op->opcode() == IrOpcode::kFinish) { |
46 return static_cast<Operator1<int>*>(op)->parameter(); | 77 return static_cast<Operator1<int>*>(op)->parameter(); |
47 } | 78 } |
48 if (op->HasProperty(Operator::kNoRead) && op->HasProperty(Operator::kNoWrite)) | 79 if (op->HasProperty(Operator::kNoRead) && op->HasProperty(Operator::kNoWrite)) |
49 return 0; // no effects. | 80 return 0; // no effects. |
50 return 1; | 81 return 1; |
51 } | 82 } |
52 | 83 |
(...skipping 17 matching lines...) Expand all Loading... |
70 // write/read operations without consideration of control flow. Without an | 101 // write/read operations without consideration of control flow. Without an |
71 // explicit control dependency writes can be float in the schedule too | 102 // explicit control dependency writes can be float in the schedule too |
72 // early along a path that shouldn't generate a side-effect. | 103 // early along a path that shouldn't generate a side-effect. |
73 return op->HasProperty(Operator::kNoWrite) ? 0 : 1; | 104 return op->HasProperty(Operator::kNoWrite) ? 0 : 1; |
74 } | 105 } |
75 return 0; | 106 return 0; |
76 } | 107 } |
77 | 108 |
78 inline int OperatorProperties::GetTotalInputCount(Operator* op) { | 109 inline int OperatorProperties::GetTotalInputCount(Operator* op) { |
79 return GetValueInputCount(op) + GetContextInputCount(op) + | 110 return GetValueInputCount(op) + GetContextInputCount(op) + |
80 GetEffectInputCount(op) + GetControlInputCount(op); | 111 GetFrameStateInputCount(op) + GetEffectInputCount(op) + |
| 112 GetControlInputCount(op); |
81 } | 113 } |
82 | 114 |
83 // ----------------------------------------------------------------------------- | 115 // ----------------------------------------------------------------------------- |
84 // Output properties. | 116 // Output properties. |
85 | 117 |
86 inline bool OperatorProperties::HasValueOutput(Operator* op) { | 118 inline bool OperatorProperties::HasValueOutput(Operator* op) { |
87 return GetValueOutputCount(op) > 0; | 119 return GetValueOutputCount(op) > 0; |
88 } | 120 } |
89 | 121 |
90 inline bool OperatorProperties::HasEffectOutput(Operator* op) { | 122 inline bool OperatorProperties::HasEffectOutput(Operator* op) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 switch (op->opcode()) { | 167 switch (op->opcode()) { |
136 case IrOpcode::kCall: { | 168 case IrOpcode::kCall: { |
137 CallOperator* call_op = reinterpret_cast<CallOperator*>(op); | 169 CallOperator* call_op = reinterpret_cast<CallOperator*>(op); |
138 CallDescriptor* descriptor = call_op->parameter(); | 170 CallDescriptor* descriptor = call_op->parameter(); |
139 return descriptor->CanLazilyDeoptimize(); | 171 return descriptor->CanLazilyDeoptimize(); |
140 } | 172 } |
141 case IrOpcode::kJSCallRuntime: { | 173 case IrOpcode::kJSCallRuntime: { |
142 Runtime::FunctionId function = | 174 Runtime::FunctionId function = |
143 reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter(); | 175 reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter(); |
144 // TODO(jarin) At the moment, we only support lazy deoptimization for | 176 // TODO(jarin) At the moment, we only support lazy deoptimization for |
145 // the %DeoptimizeFunction runtime function. | 177 // a few chosen runtime functions. |
146 return function == Runtime::kDeoptimizeFunction; | 178 switch (function) { |
| 179 case Runtime::kDebugBreak: |
| 180 case Runtime::kDeoptimizeFunction: |
| 181 return true; |
| 182 default: |
| 183 return false; |
| 184 } |
| 185 UNREACHABLE(); |
147 } | 186 } |
148 | 187 |
149 // JS function calls | 188 // JS function calls |
150 case IrOpcode::kJSCallFunction: | 189 case IrOpcode::kJSCallFunction: |
151 case IrOpcode::kJSCallConstruct: | 190 case IrOpcode::kJSCallConstruct: |
152 | 191 |
153 // Binary operations | 192 // Binary operations |
154 case IrOpcode::kJSBitwiseOr: | 193 case IrOpcode::kJSBitwiseOr: |
155 case IrOpcode::kJSBitwiseXor: | 194 case IrOpcode::kJSBitwiseXor: |
156 case IrOpcode::kJSBitwiseAnd: | 195 case IrOpcode::kJSBitwiseAnd: |
(...skipping 14 matching lines...) Expand all Loading... |
171 default: | 210 default: |
172 return false; | 211 return false; |
173 } | 212 } |
174 return false; | 213 return false; |
175 } | 214 } |
176 } | 215 } |
177 } | 216 } |
178 } // namespace v8::internal::compiler | 217 } // namespace v8::internal::compiler |
179 | 218 |
180 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ | 219 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
OLD | NEW |