OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
| 6 #define V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
| 7 |
| 8 #include "src/v8.h" |
| 9 |
| 10 #include "src/compiler/opcodes.h" |
| 11 #include "src/compiler/operator-properties.h" |
| 12 |
| 13 namespace v8 { |
| 14 namespace internal { |
| 15 namespace compiler { |
| 16 |
| 17 inline int OperatorProperties::GetValueOutputCount(Operator* op) { |
| 18 return op->OutputCount(); |
| 19 } |
| 20 |
| 21 inline int OperatorProperties::GetValueInputCount(Operator* op) { |
| 22 return op->InputCount(); |
| 23 } |
| 24 |
| 25 inline int OperatorProperties::GetControlInputCount(Operator* op) { |
| 26 switch (op->opcode()) { |
| 27 case IrOpcode::kPhi: |
| 28 case IrOpcode::kEffectPhi: |
| 29 return 1; |
| 30 #define OPCODE_CASE(x) case IrOpcode::k##x: |
| 31 CONTROL_OP_LIST(OPCODE_CASE) |
| 32 #undef OPCODE_CASE |
| 33 return static_cast<ControlOperator*>(op)->ControlInputCount(); |
| 34 default: |
| 35 // Operators that have write effects must have a control |
| 36 // dependency. Effect dependencies only ensure the correct order of |
| 37 // write/read operations without consideration of control flow. Without an |
| 38 // explicit control dependency writes can be float in the schedule too |
| 39 // early along a path that shouldn't generate a side-effect. |
| 40 return op->HasProperty(Operator::kNoWrite) ? 0 : 1; |
| 41 } |
| 42 return 0; |
| 43 } |
| 44 |
| 45 inline int OperatorProperties::GetEffectInputCount(Operator* op) { |
| 46 if (op->opcode() == IrOpcode::kEffectPhi) { |
| 47 return static_cast<Operator1<int>*>(op)->parameter(); |
| 48 } |
| 49 if (op->HasProperty(Operator::kNoRead) && op->HasProperty(Operator::kNoWrite)) |
| 50 return 0; // no effects. |
| 51 return 1; |
| 52 } |
| 53 |
| 54 inline bool OperatorProperties::HasContextInput(Operator* op) { |
| 55 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); |
| 56 return IrOpcode::IsJsOpcode(opcode); |
| 57 } |
| 58 |
| 59 inline bool OperatorProperties::IsBasicBlockBegin(Operator* op) { |
| 60 uint8_t opcode = op->opcode(); |
| 61 return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd || |
| 62 opcode == IrOpcode::kDead || opcode == IrOpcode::kLoop || |
| 63 opcode == IrOpcode::kMerge || opcode == IrOpcode::kIfTrue || |
| 64 opcode == IrOpcode::kIfFalse; |
| 65 } |
| 66 |
| 67 inline bool OperatorProperties::CanBeScheduled(Operator* op) { return true; } |
| 68 |
| 69 inline bool OperatorProperties::HasFixedSchedulePosition(Operator* op) { |
| 70 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); |
| 71 return (IrOpcode::IsControlOpcode(opcode)) || |
| 72 opcode == IrOpcode::kParameter || opcode == IrOpcode::kEffectPhi || |
| 73 opcode == IrOpcode::kPhi; |
| 74 } |
| 75 |
| 76 inline bool OperatorProperties::IsScheduleRoot(Operator* op) { |
| 77 uint8_t opcode = op->opcode(); |
| 78 return opcode == IrOpcode::kEnd || opcode == IrOpcode::kEffectPhi || |
| 79 opcode == IrOpcode::kPhi; |
| 80 } |
| 81 |
| 82 inline bool OperatorProperties::CanLazilyDeoptimize(Operator* op) { |
| 83 if (op->opcode() == IrOpcode::kCall) { |
| 84 CallOperator* call_op = reinterpret_cast<CallOperator*>(op); |
| 85 CallDescriptor* descriptor = call_op->parameter(); |
| 86 return descriptor->CanLazilyDeoptimize(); |
| 87 } |
| 88 if (op->opcode() == IrOpcode::kJSCallRuntime) { |
| 89 // TODO(jarin) At the moment, we only support lazy deoptimization for |
| 90 // the %DeoptimizeFunction runtime function. |
| 91 Runtime::FunctionId function = |
| 92 reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter(); |
| 93 return function == Runtime::kDeoptimizeFunction; |
| 94 } |
| 95 return false; |
| 96 } |
| 97 } |
| 98 } |
| 99 } // namespace v8::internal::compiler |
| 100 |
| 101 #endif // V8_COMPILER_OPERATOR_PROPERTIES_INL_H_ |
OLD | NEW |