| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/operator-properties.h" | 5 #include "src/compiler/operator-properties.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/opcodes.h" | 9 #include "src/compiler/opcodes.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 // static | 15 // static |
| 16 bool OperatorProperties::HasContextInput(const Operator* op) { | 16 bool OperatorProperties::HasContextInput(const Operator* op) { |
| 17 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); | 17 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); |
| 18 return IrOpcode::IsJsOpcode(opcode); | 18 return IrOpcode::IsJsOpcode(opcode); |
| 19 } | 19 } |
| 20 | 20 |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 int OperatorProperties::GetFrameStateInputCount(const Operator* op) { | 23 bool OperatorProperties::HasFrameStateInput(const Operator* op) { |
| 24 switch (op->opcode()) { | 24 switch (op->opcode()) { |
| 25 case IrOpcode::kCheckpoint: | 25 case IrOpcode::kCheckpoint: |
| 26 case IrOpcode::kFrameState: | 26 case IrOpcode::kFrameState: |
| 27 return 1; | 27 return true; |
| 28 case IrOpcode::kJSCallRuntime: { | 28 case IrOpcode::kJSCallRuntime: { |
| 29 const CallRuntimeParameters& p = CallRuntimeParametersOf(op); | 29 const CallRuntimeParameters& p = CallRuntimeParametersOf(op); |
| 30 return Linkage::NeedsFrameStateInput(p.id()) ? 1 : 0; | 30 return Linkage::NeedsFrameStateInput(p.id()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Strict equality cannot lazily deoptimize. | 33 // Strict equality cannot lazily deoptimize. |
| 34 case IrOpcode::kJSStrictEqual: | 34 case IrOpcode::kJSStrictEqual: |
| 35 case IrOpcode::kJSStrictNotEqual: | 35 case IrOpcode::kJSStrictNotEqual: |
| 36 return 0; | 36 return false; |
| 37 | 37 |
| 38 // Binary operations | 38 // Binary operations |
| 39 case IrOpcode::kJSAdd: | 39 case IrOpcode::kJSAdd: |
| 40 case IrOpcode::kJSSubtract: | 40 case IrOpcode::kJSSubtract: |
| 41 case IrOpcode::kJSMultiply: | 41 case IrOpcode::kJSMultiply: |
| 42 case IrOpcode::kJSDivide: | 42 case IrOpcode::kJSDivide: |
| 43 case IrOpcode::kJSModulus: | 43 case IrOpcode::kJSModulus: |
| 44 | 44 |
| 45 // Bitwise operations | 45 // Bitwise operations |
| 46 case IrOpcode::kJSBitwiseOr: | 46 case IrOpcode::kJSBitwiseOr: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 // Call operations | 93 // Call operations |
| 94 case IrOpcode::kJSCallConstruct: | 94 case IrOpcode::kJSCallConstruct: |
| 95 case IrOpcode::kJSCallFunction: | 95 case IrOpcode::kJSCallFunction: |
| 96 | 96 |
| 97 // Misc operations | 97 // Misc operations |
| 98 case IrOpcode::kJSConvertReceiver: | 98 case IrOpcode::kJSConvertReceiver: |
| 99 case IrOpcode::kJSForInNext: | 99 case IrOpcode::kJSForInNext: |
| 100 case IrOpcode::kJSForInPrepare: | 100 case IrOpcode::kJSForInPrepare: |
| 101 case IrOpcode::kJSStackCheck: | 101 case IrOpcode::kJSStackCheck: |
| 102 return 1; | 102 return true; |
| 103 | 103 |
| 104 default: | 104 default: |
| 105 return 0; | 105 return false; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 // static | 110 // static |
| 111 int OperatorProperties::GetTotalInputCount(const Operator* op) { | 111 int OperatorProperties::GetTotalInputCount(const Operator* op) { |
| 112 return op->ValueInputCount() + GetContextInputCount(op) + | 112 return op->ValueInputCount() + GetContextInputCount(op) + |
| 113 GetFrameStateInputCount(op) + op->EffectInputCount() + | 113 GetFrameStateInputCount(op) + op->EffectInputCount() + |
| 114 op->ControlInputCount(); | 114 op->ControlInputCount(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 // static | 118 // static |
| 119 bool OperatorProperties::IsBasicBlockBegin(const Operator* op) { | 119 bool OperatorProperties::IsBasicBlockBegin(const Operator* op) { |
| 120 Operator::Opcode const opcode = op->opcode(); | 120 Operator::Opcode const opcode = op->opcode(); |
| 121 return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd || | 121 return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd || |
| 122 opcode == IrOpcode::kDead || opcode == IrOpcode::kLoop || | 122 opcode == IrOpcode::kDead || opcode == IrOpcode::kLoop || |
| 123 opcode == IrOpcode::kMerge || opcode == IrOpcode::kIfTrue || | 123 opcode == IrOpcode::kMerge || opcode == IrOpcode::kIfTrue || |
| 124 opcode == IrOpcode::kIfFalse || opcode == IrOpcode::kIfSuccess || | 124 opcode == IrOpcode::kIfFalse || opcode == IrOpcode::kIfSuccess || |
| 125 opcode == IrOpcode::kIfException || opcode == IrOpcode::kIfValue || | 125 opcode == IrOpcode::kIfException || opcode == IrOpcode::kIfValue || |
| 126 opcode == IrOpcode::kIfDefault; | 126 opcode == IrOpcode::kIfDefault; |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace compiler | 129 } // namespace compiler |
| 130 } // namespace internal | 130 } // namespace internal |
| 131 } // namespace v8 | 131 } // namespace v8 |
| OLD | NEW |