53bd16c0afbdab90cdf42f61de63a402a2dcbc3d
[platform/upstream/nodejs.git] / deps / v8 / src / compiler / operator-properties.cc
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
3 // found in the LICENSE file.
4
5 #include "src/compiler/operator-properties.h"
6
7 #include "src/compiler/js-operator.h"
8 #include "src/compiler/linkage.h"
9 #include "src/compiler/opcodes.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14
15 // static
16 bool OperatorProperties::HasContextInput(const Operator* op) {
17   IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode());
18   return IrOpcode::IsJsOpcode(opcode);
19 }
20
21
22 // static
23 bool OperatorProperties::HasFrameStateInput(const Operator* op) {
24   if (!FLAG_turbo_deoptimization) {
25     return false;
26   }
27   switch (op->opcode()) {
28     case IrOpcode::kFrameState:
29       return true;
30     case IrOpcode::kJSCallRuntime: {
31       const CallRuntimeParameters& p = CallRuntimeParametersOf(op);
32       return Linkage::NeedsFrameState(p.id());
33     }
34
35     // Strict equality cannot lazily deoptimize.
36     case IrOpcode::kJSStrictEqual:
37     case IrOpcode::kJSStrictNotEqual:
38       return false;
39
40     // Calls
41     case IrOpcode::kJSCallFunction:
42     case IrOpcode::kJSCallConstruct:
43
44     // Compare operations
45     case IrOpcode::kJSEqual:
46     case IrOpcode::kJSGreaterThan:
47     case IrOpcode::kJSGreaterThanOrEqual:
48     case IrOpcode::kJSHasProperty:
49     case IrOpcode::kJSInstanceOf:
50     case IrOpcode::kJSLessThan:
51     case IrOpcode::kJSLessThanOrEqual:
52     case IrOpcode::kJSNotEqual:
53
54     // Binary operations
55     case IrOpcode::kJSAdd:
56     case IrOpcode::kJSBitwiseAnd:
57     case IrOpcode::kJSBitwiseOr:
58     case IrOpcode::kJSBitwiseXor:
59     case IrOpcode::kJSDivide:
60     case IrOpcode::kJSModulus:
61     case IrOpcode::kJSMultiply:
62     case IrOpcode::kJSShiftLeft:
63     case IrOpcode::kJSShiftRight:
64     case IrOpcode::kJSShiftRightLogical:
65     case IrOpcode::kJSSubtract:
66
67     // Context operations
68     case IrOpcode::kJSCreateWithContext:
69
70     // Conversions
71     case IrOpcode::kJSToObject:
72     case IrOpcode::kJSToNumber:
73     case IrOpcode::kJSToName:
74
75     // Properties
76     case IrOpcode::kJSLoadNamed:
77     case IrOpcode::kJSLoadProperty:
78     case IrOpcode::kJSStoreNamed:
79     case IrOpcode::kJSStoreProperty:
80     case IrOpcode::kJSDeleteProperty:
81       return true;
82
83     default:
84       return false;
85   }
86 }
87
88
89 // static
90 int OperatorProperties::GetTotalInputCount(const Operator* op) {
91   return op->ValueInputCount() + GetContextInputCount(op) +
92          GetFrameStateInputCount(op) + op->EffectInputCount() +
93          op->ControlInputCount();
94 }
95
96
97 // static
98 bool OperatorProperties::IsBasicBlockBegin(const Operator* op) {
99   Operator::Opcode const opcode = op->opcode();
100   return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd ||
101          opcode == IrOpcode::kDead || opcode == IrOpcode::kLoop ||
102          opcode == IrOpcode::kMerge || opcode == IrOpcode::kIfTrue ||
103          opcode == IrOpcode::kIfFalse || opcode == IrOpcode::kIfValue ||
104          opcode == IrOpcode::kIfDefault;
105 }
106
107 }  // namespace compiler
108 }  // namespace internal
109 }  // namespace v8