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