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/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler/js-operator.h" | |
11 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
12 #include "src/compiler/operator-properties.h" | 11 #include "src/compiler/operator-properties.h" |
13 | 12 |
14 namespace v8 { | 13 namespace v8 { |
15 namespace internal { | 14 namespace internal { |
16 namespace compiler { | 15 namespace compiler { |
17 | 16 |
18 inline bool OperatorProperties::HasValueInput(Operator* op) { | 17 inline bool OperatorProperties::HasValueInput(Operator* op) { |
19 return OperatorProperties::GetValueInputCount(op) > 0; | 18 return OperatorProperties::GetValueInputCount(op) > 0; |
20 } | 19 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 inline int OperatorProperties::GetControlInputCount(Operator* op) { | 52 inline int OperatorProperties::GetControlInputCount(Operator* op) { |
54 switch (op->opcode()) { | 53 switch (op->opcode()) { |
55 case IrOpcode::kPhi: | 54 case IrOpcode::kPhi: |
56 case IrOpcode::kEffectPhi: | 55 case IrOpcode::kEffectPhi: |
57 return 1; | 56 return 1; |
58 #define OPCODE_CASE(x) case IrOpcode::k##x: | 57 #define OPCODE_CASE(x) case IrOpcode::k##x: |
59 CONTROL_OP_LIST(OPCODE_CASE) | 58 CONTROL_OP_LIST(OPCODE_CASE) |
60 #undef OPCODE_CASE | 59 #undef OPCODE_CASE |
61 return static_cast<ControlOperator*>(op)->ControlInputCount(); | 60 return static_cast<ControlOperator*>(op)->ControlInputCount(); |
62 default: | 61 default: |
63 // If a node can lazily deoptimize, it needs control dependency. | |
64 if (CanLazilyDeoptimize(op)) { | |
65 return 1; | |
66 } | |
67 // Operators that have write effects must have a control | 62 // Operators that have write effects must have a control |
68 // dependency. Effect dependencies only ensure the correct order of | 63 // dependency. Effect dependencies only ensure the correct order of |
69 // write/read operations without consideration of control flow. Without an | 64 // write/read operations without consideration of control flow. Without an |
70 // explicit control dependency writes can be float in the schedule too | 65 // explicit control dependency writes can be float in the schedule too |
71 // early along a path that shouldn't generate a side-effect. | 66 // early along a path that shouldn't generate a side-effect. |
72 return op->HasProperty(Operator::kNoWrite) ? 0 : 1; | 67 return op->HasProperty(Operator::kNoWrite) ? 0 : 1; |
73 } | 68 } |
74 return 0; | 69 return 0; |
75 } | 70 } |
76 | 71 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 opcode == IrOpcode::kPhi; | 123 opcode == IrOpcode::kPhi; |
129 } | 124 } |
130 | 125 |
131 inline bool OperatorProperties::IsScheduleRoot(Operator* op) { | 126 inline bool OperatorProperties::IsScheduleRoot(Operator* op) { |
132 uint8_t opcode = op->opcode(); | 127 uint8_t opcode = op->opcode(); |
133 return opcode == IrOpcode::kEnd || opcode == IrOpcode::kEffectPhi || | 128 return opcode == IrOpcode::kEnd || opcode == IrOpcode::kEffectPhi || |
134 opcode == IrOpcode::kPhi; | 129 opcode == IrOpcode::kPhi; |
135 } | 130 } |
136 | 131 |
137 inline bool OperatorProperties::CanLazilyDeoptimize(Operator* op) { | 132 inline bool OperatorProperties::CanLazilyDeoptimize(Operator* op) { |
138 // TODO(jarin) This function allows turning on lazy deoptimization | 133 if (op->opcode() == IrOpcode::kCall) { |
139 // incrementally. It will change as we turn on lazy deopt for | 134 CallOperator* call_op = reinterpret_cast<CallOperator*>(op); |
140 // more nodes. | 135 CallDescriptor* descriptor = call_op->parameter(); |
141 | 136 return descriptor->CanLazilyDeoptimize(); |
142 if (!FLAG_turbo_deoptimization) { | |
143 return false; | |
144 } | 137 } |
145 | 138 if (op->opcode() == IrOpcode::kJSCallRuntime) { |
146 switch (op->opcode()) { | 139 // TODO(jarin) At the moment, we only support lazy deoptimization for |
147 case IrOpcode::kCall: { | 140 // the %DeoptimizeFunction runtime function. |
148 CallOperator* call_op = reinterpret_cast<CallOperator*>(op); | 141 Runtime::FunctionId function = |
149 CallDescriptor* descriptor = call_op->parameter(); | 142 reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter(); |
150 return descriptor->CanLazilyDeoptimize(); | 143 return function == Runtime::kDeoptimizeFunction; |
151 } | |
152 case IrOpcode::kJSCallRuntime: { | |
153 Runtime::FunctionId function = | |
154 reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter(); | |
155 // TODO(jarin) At the moment, we only support lazy deoptimization for | |
156 // the %DeoptimizeFunction runtime function. | |
157 return function == Runtime::kDeoptimizeFunction; | |
158 } | |
159 | |
160 // JS function calls | |
161 case IrOpcode::kJSCallFunction: | |
162 case IrOpcode::kJSCallConstruct: | |
163 | |
164 // Binary operations | |
165 case IrOpcode::kJSBitwiseOr: | |
166 case IrOpcode::kJSBitwiseXor: | |
167 case IrOpcode::kJSBitwiseAnd: | |
168 case IrOpcode::kJSShiftLeft: | |
169 case IrOpcode::kJSShiftRight: | |
170 case IrOpcode::kJSShiftRightLogical: | |
171 case IrOpcode::kJSAdd: | |
172 case IrOpcode::kJSSubtract: | |
173 case IrOpcode::kJSMultiply: | |
174 case IrOpcode::kJSDivide: | |
175 case IrOpcode::kJSModulus: | |
176 case IrOpcode::kJSLoadProperty: | |
177 case IrOpcode::kJSStoreProperty: | |
178 case IrOpcode::kJSLoadNamed: | |
179 case IrOpcode::kJSStoreNamed: | |
180 return true; | |
181 | |
182 default: | |
183 return false; | |
184 } | 144 } |
185 return false; | 145 return false; |
186 } | 146 } |
187 } | 147 } |
188 } | 148 } |
189 } // namespace v8::internal::compiler | 149 } // namespace v8::internal::compiler |
190 | 150 |
191 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ | 151 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
OLD | NEW |