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/typer.h" | 5 #include "src/compiler/typer.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 #define DECLARE_CASE(x) \ | 82 #define DECLARE_CASE(x) \ |
83 case IrOpcode::k##x: \ | 83 case IrOpcode::k##x: \ |
84 return UpdateType(node, Type##x(node)); | 84 return UpdateType(node, Type##x(node)); |
85 DECLARE_CASE(Start) | 85 DECLARE_CASE(Start) |
86 DECLARE_CASE(IfException) | 86 DECLARE_CASE(IfException) |
87 // VALUE_OP_LIST without JS_SIMPLE_BINOP_LIST: | 87 // VALUE_OP_LIST without JS_SIMPLE_BINOP_LIST: |
88 COMMON_OP_LIST(DECLARE_CASE) | 88 COMMON_OP_LIST(DECLARE_CASE) |
89 SIMPLIFIED_COMPARE_BINOP_LIST(DECLARE_CASE) | 89 SIMPLIFIED_COMPARE_BINOP_LIST(DECLARE_CASE) |
90 SIMPLIFIED_OTHER_OP_LIST(DECLARE_CASE) | 90 SIMPLIFIED_OTHER_OP_LIST(DECLARE_CASE) |
91 MACHINE_OP_LIST(DECLARE_CASE) | 91 MACHINE_OP_LIST(DECLARE_CASE) |
92 MACHINE_SIMD_OP_LIST(DECLARE_CASE) | |
93 JS_SIMPLE_UNOP_LIST(DECLARE_CASE) | 92 JS_SIMPLE_UNOP_LIST(DECLARE_CASE) |
94 JS_OBJECT_OP_LIST(DECLARE_CASE) | 93 JS_OBJECT_OP_LIST(DECLARE_CASE) |
95 JS_CONTEXT_OP_LIST(DECLARE_CASE) | 94 JS_CONTEXT_OP_LIST(DECLARE_CASE) |
96 JS_OTHER_OP_LIST(DECLARE_CASE) | 95 JS_OTHER_OP_LIST(DECLARE_CASE) |
97 #undef DECLARE_CASE | 96 #undef DECLARE_CASE |
98 | 97 |
99 #define DECLARE_CASE(x) \ | 98 #define DECLARE_CASE(x) \ |
100 case IrOpcode::k##x: \ | 99 case IrOpcode::k##x: \ |
101 return UpdateType(node, TypeBinaryOp(node, x)); | 100 return UpdateType(node, TypeBinaryOp(node, x)); |
102 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE) | 101 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE) |
(...skipping 21 matching lines...) Expand all Loading... |
124 DECLARE_CASE(DeoptimizeUnless) | 123 DECLARE_CASE(DeoptimizeUnless) |
125 DECLARE_CASE(Return) | 124 DECLARE_CASE(Return) |
126 DECLARE_CASE(TailCall) | 125 DECLARE_CASE(TailCall) |
127 DECLARE_CASE(Terminate) | 126 DECLARE_CASE(Terminate) |
128 DECLARE_CASE(OsrNormalEntry) | 127 DECLARE_CASE(OsrNormalEntry) |
129 DECLARE_CASE(OsrLoopEntry) | 128 DECLARE_CASE(OsrLoopEntry) |
130 DECLARE_CASE(Throw) | 129 DECLARE_CASE(Throw) |
131 DECLARE_CASE(End) | 130 DECLARE_CASE(End) |
132 SIMPLIFIED_CHANGE_OP_LIST(DECLARE_CASE) | 131 SIMPLIFIED_CHANGE_OP_LIST(DECLARE_CASE) |
133 SIMPLIFIED_CHECKED_OP_LIST(DECLARE_CASE) | 132 SIMPLIFIED_CHECKED_OP_LIST(DECLARE_CASE) |
| 133 MACHINE_SIMD_OP_LIST(DECLARE_CASE) |
134 #undef DECLARE_CASE | 134 #undef DECLARE_CASE |
135 break; | 135 break; |
136 } | 136 } |
137 return NoChange(); | 137 return NoChange(); |
138 } | 138 } |
139 | 139 |
140 Type* TypeNode(Node* node) { | 140 Type* TypeNode(Node* node) { |
141 switch (node->opcode()) { | 141 switch (node->opcode()) { |
142 #define DECLARE_CASE(x) \ | 142 #define DECLARE_CASE(x) \ |
143 case IrOpcode::k##x: return TypeBinaryOp(node, x##Typer); | 143 case IrOpcode::k##x: return TypeBinaryOp(node, x##Typer); |
144 JS_SIMPLE_BINOP_LIST(DECLARE_CASE) | 144 JS_SIMPLE_BINOP_LIST(DECLARE_CASE) |
145 #undef DECLARE_CASE | 145 #undef DECLARE_CASE |
146 | 146 |
147 #define DECLARE_CASE(x) case IrOpcode::k##x: return Type##x(node); | 147 #define DECLARE_CASE(x) case IrOpcode::k##x: return Type##x(node); |
148 DECLARE_CASE(Start) | 148 DECLARE_CASE(Start) |
149 DECLARE_CASE(IfException) | 149 DECLARE_CASE(IfException) |
150 // VALUE_OP_LIST without JS_SIMPLE_BINOP_LIST: | 150 // VALUE_OP_LIST without JS_SIMPLE_BINOP_LIST: |
151 COMMON_OP_LIST(DECLARE_CASE) | 151 COMMON_OP_LIST(DECLARE_CASE) |
152 SIMPLIFIED_COMPARE_BINOP_LIST(DECLARE_CASE) | 152 SIMPLIFIED_COMPARE_BINOP_LIST(DECLARE_CASE) |
153 SIMPLIFIED_OTHER_OP_LIST(DECLARE_CASE) | 153 SIMPLIFIED_OTHER_OP_LIST(DECLARE_CASE) |
154 MACHINE_OP_LIST(DECLARE_CASE) | 154 MACHINE_OP_LIST(DECLARE_CASE) |
155 MACHINE_SIMD_OP_LIST(DECLARE_CASE) | |
156 JS_SIMPLE_UNOP_LIST(DECLARE_CASE) | 155 JS_SIMPLE_UNOP_LIST(DECLARE_CASE) |
157 JS_OBJECT_OP_LIST(DECLARE_CASE) | 156 JS_OBJECT_OP_LIST(DECLARE_CASE) |
158 JS_CONTEXT_OP_LIST(DECLARE_CASE) | 157 JS_CONTEXT_OP_LIST(DECLARE_CASE) |
159 JS_OTHER_OP_LIST(DECLARE_CASE) | 158 JS_OTHER_OP_LIST(DECLARE_CASE) |
160 #undef DECLARE_CASE | 159 #undef DECLARE_CASE |
161 | 160 |
162 #define DECLARE_CASE(x) \ | 161 #define DECLARE_CASE(x) \ |
163 case IrOpcode::k##x: \ | 162 case IrOpcode::k##x: \ |
164 return TypeBinaryOp(node, x); | 163 return TypeBinaryOp(node, x); |
165 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE) | 164 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_CASE) |
(...skipping 21 matching lines...) Expand all Loading... |
187 DECLARE_CASE(DeoptimizeUnless) | 186 DECLARE_CASE(DeoptimizeUnless) |
188 DECLARE_CASE(Return) | 187 DECLARE_CASE(Return) |
189 DECLARE_CASE(TailCall) | 188 DECLARE_CASE(TailCall) |
190 DECLARE_CASE(Terminate) | 189 DECLARE_CASE(Terminate) |
191 DECLARE_CASE(OsrNormalEntry) | 190 DECLARE_CASE(OsrNormalEntry) |
192 DECLARE_CASE(OsrLoopEntry) | 191 DECLARE_CASE(OsrLoopEntry) |
193 DECLARE_CASE(Throw) | 192 DECLARE_CASE(Throw) |
194 DECLARE_CASE(End) | 193 DECLARE_CASE(End) |
195 SIMPLIFIED_CHANGE_OP_LIST(DECLARE_CASE) | 194 SIMPLIFIED_CHANGE_OP_LIST(DECLARE_CASE) |
196 SIMPLIFIED_CHECKED_OP_LIST(DECLARE_CASE) | 195 SIMPLIFIED_CHECKED_OP_LIST(DECLARE_CASE) |
| 196 MACHINE_SIMD_OP_LIST(DECLARE_CASE) |
197 #undef DECLARE_CASE | 197 #undef DECLARE_CASE |
198 break; | 198 break; |
199 } | 199 } |
200 UNREACHABLE(); | 200 UNREACHABLE(); |
201 return nullptr; | 201 return nullptr; |
202 } | 202 } |
203 | 203 |
204 Type* TypeConstant(Handle<Object> value); | 204 Type* TypeConstant(Handle<Object> value); |
205 | 205 |
206 private: | 206 private: |
207 Typer* typer_; | 207 Typer* typer_; |
208 LoopVariableOptimizer* induction_vars_; | 208 LoopVariableOptimizer* induction_vars_; |
209 ZoneSet<NodeId> weakened_nodes_; | 209 ZoneSet<NodeId> weakened_nodes_; |
210 | 210 |
211 #define DECLARE_METHOD(x) inline Type* Type##x(Node* node); | 211 #define DECLARE_METHOD(x) inline Type* Type##x(Node* node); |
212 DECLARE_METHOD(Start) | 212 DECLARE_METHOD(Start) |
213 DECLARE_METHOD(IfException) | 213 DECLARE_METHOD(IfException) |
214 COMMON_OP_LIST(DECLARE_METHOD) | 214 COMMON_OP_LIST(DECLARE_METHOD) |
215 SIMPLIFIED_COMPARE_BINOP_LIST(DECLARE_METHOD) | 215 SIMPLIFIED_COMPARE_BINOP_LIST(DECLARE_METHOD) |
216 SIMPLIFIED_OTHER_OP_LIST(DECLARE_METHOD) | 216 SIMPLIFIED_OTHER_OP_LIST(DECLARE_METHOD) |
217 MACHINE_OP_LIST(DECLARE_METHOD) | 217 MACHINE_OP_LIST(DECLARE_METHOD) |
218 MACHINE_SIMD_OP_LIST(DECLARE_METHOD) | |
219 JS_OP_LIST(DECLARE_METHOD) | 218 JS_OP_LIST(DECLARE_METHOD) |
220 #undef DECLARE_METHOD | 219 #undef DECLARE_METHOD |
221 | 220 |
222 Type* TypeOrNone(Node* node) { | 221 Type* TypeOrNone(Node* node) { |
223 return NodeProperties::IsTyped(node) ? NodeProperties::GetType(node) | 222 return NodeProperties::IsTyped(node) ? NodeProperties::GetType(node) |
224 : Type::None(); | 223 : Type::None(); |
225 } | 224 } |
226 | 225 |
227 Type* Operand(Node* node, int i) { | 226 Type* Operand(Node* node, int i) { |
228 Node* operand_node = NodeProperties::GetValueInput(node, i); | 227 Node* operand_node = NodeProperties::GetValueInput(node, i); |
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 Type* Typer::Visitor::TypeInt32PairSub(Node* node) { return Type::Internal(); } | 2284 Type* Typer::Visitor::TypeInt32PairSub(Node* node) { return Type::Internal(); } |
2286 | 2285 |
2287 Type* Typer::Visitor::TypeInt32PairMul(Node* node) { return Type::Internal(); } | 2286 Type* Typer::Visitor::TypeInt32PairMul(Node* node) { return Type::Internal(); } |
2288 | 2287 |
2289 Type* Typer::Visitor::TypeWord32PairShl(Node* node) { return Type::Internal(); } | 2288 Type* Typer::Visitor::TypeWord32PairShl(Node* node) { return Type::Internal(); } |
2290 | 2289 |
2291 Type* Typer::Visitor::TypeWord32PairShr(Node* node) { return Type::Internal(); } | 2290 Type* Typer::Visitor::TypeWord32PairShr(Node* node) { return Type::Internal(); } |
2292 | 2291 |
2293 Type* Typer::Visitor::TypeWord32PairSar(Node* node) { return Type::Internal(); } | 2292 Type* Typer::Visitor::TypeWord32PairSar(Node* node) { return Type::Internal(); } |
2294 | 2293 |
2295 // SIMD type methods. | |
2296 | |
2297 #define SIMD_RETURN_SIMD(Name) \ | |
2298 Type* Typer::Visitor::Type##Name(Node* node) { return Type::Simd(); } | |
2299 MACHINE_SIMD_RETURN_SIMD_OP_LIST(SIMD_RETURN_SIMD) | |
2300 MACHINE_SIMD_GENERIC_OP_LIST(SIMD_RETURN_SIMD) | |
2301 #undef SIMD_RETURN_SIMD | |
2302 | |
2303 #define SIMD_RETURN_NUM(Name) \ | |
2304 Type* Typer::Visitor::Type##Name(Node* node) { return Type::Number(); } | |
2305 MACHINE_SIMD_RETURN_NUM_OP_LIST(SIMD_RETURN_NUM) | |
2306 #undef SIMD_RETURN_NUM | |
2307 | |
2308 #define SIMD_RETURN_BOOL(Name) \ | |
2309 Type* Typer::Visitor::Type##Name(Node* node) { return Type::Boolean(); } | |
2310 MACHINE_SIMD_RETURN_BOOL_OP_LIST(SIMD_RETURN_BOOL) | |
2311 #undef SIMD_RETURN_BOOL | |
2312 | |
2313 // Heap constants. | 2294 // Heap constants. |
2314 | 2295 |
2315 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 2296 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
2316 if (value->IsJSTypedArray()) { | 2297 if (value->IsJSTypedArray()) { |
2317 switch (JSTypedArray::cast(*value)->type()) { | 2298 switch (JSTypedArray::cast(*value)->type()) { |
2318 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 2299 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
2319 case kExternal##Type##Array: \ | 2300 case kExternal##Type##Array: \ |
2320 return typer_->cache_.k##Type##Array; | 2301 return typer_->cache_.k##Type##Array; |
2321 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2302 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2322 #undef TYPED_ARRAY_CASE | 2303 #undef TYPED_ARRAY_CASE |
2323 } | 2304 } |
2324 } | 2305 } |
2325 if (Type::IsInteger(*value)) { | 2306 if (Type::IsInteger(*value)) { |
2326 return Type::Range(value->Number(), value->Number(), zone()); | 2307 return Type::Range(value->Number(), value->Number(), zone()); |
2327 } | 2308 } |
2328 return Type::Constant(value, zone()); | 2309 return Type::Constant(value, zone()); |
2329 } | 2310 } |
2330 | 2311 |
2331 } // namespace compiler | 2312 } // namespace compiler |
2332 } // namespace internal | 2313 } // namespace internal |
2333 } // namespace v8 | 2314 } // namespace v8 |
OLD | NEW |