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 "src/base/flags.h" | 7 #include "src/base/flags.h" |
8 #include "src/base/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/compiler/graph-reducer.h" | 10 #include "src/compiler/graph-reducer.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*); | 324 static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*); |
325 static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*); | 325 static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*); |
326 | 326 |
327 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); | 327 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); |
328 | 328 |
329 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); | 329 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); |
330 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) | 330 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) |
331 #undef DECLARE_METHOD | 331 #undef DECLARE_METHOD |
332 | 332 |
333 static Type* JSUnaryNotTyper(Type*, Typer*); | 333 static Type* JSUnaryNotTyper(Type*, Typer*); |
| 334 static Type* JSTypeOfTyper(Type*, Typer*); |
334 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); | 335 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); |
335 static Type* JSCallFunctionTyper(Type*, Typer*); | 336 static Type* JSCallFunctionTyper(Type*, Typer*); |
336 | 337 |
337 Reduction UpdateBounds(Node* node, Bounds current) { | 338 Reduction UpdateBounds(Node* node, Bounds current) { |
338 if (NodeProperties::IsTyped(node)) { | 339 if (NodeProperties::IsTyped(node)) { |
339 // Widen the bounds of a previously typed node. | 340 // Widen the bounds of a previously typed node. |
340 Bounds previous = NodeProperties::GetBounds(node); | 341 Bounds previous = NodeProperties::GetBounds(node); |
341 if (node->opcode() == IrOpcode::kPhi) { | 342 if (node->opcode() == IrOpcode::kPhi) { |
342 // Speed up termination in the presence of range types: | 343 // Speed up termination in the presence of range types: |
343 current.upper = Weaken(node, current.upper, previous.upper); | 344 current.upper = Weaken(node, current.upper, previous.upper); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) { | 1205 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) { |
1205 return Invert(ToBoolean(type, t), t); | 1206 return Invert(ToBoolean(type, t), t); |
1206 } | 1207 } |
1207 | 1208 |
1208 | 1209 |
1209 Bounds Typer::Visitor::TypeJSUnaryNot(Node* node) { | 1210 Bounds Typer::Visitor::TypeJSUnaryNot(Node* node) { |
1210 return TypeUnaryOp(node, JSUnaryNotTyper); | 1211 return TypeUnaryOp(node, JSUnaryNotTyper); |
1211 } | 1212 } |
1212 | 1213 |
1213 | 1214 |
| 1215 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { |
| 1216 Factory* const f = t->isolate()->factory(); |
| 1217 if (type->Is(Type::Boolean())) { |
| 1218 return Type::Constant(f->boolean_string(), t->zone()); |
| 1219 } else if (type->Is(Type::Number())) { |
| 1220 return Type::Constant(f->number_string(), t->zone()); |
| 1221 } else if (type->Is(Type::Symbol())) { |
| 1222 return Type::Constant(f->symbol_string(), t->zone()); |
| 1223 } else if (type->Is(Type::Union(Type::Undefined(), Type::Undetectable()))) { |
| 1224 return Type::Constant(f->undefined_string(), t->zone()); |
| 1225 } else if (type->Is(Type::Null())) { |
| 1226 return Type::Constant(f->object_string(), t->zone()); |
| 1227 } |
| 1228 return Type::InternalizedString(); |
| 1229 } |
| 1230 |
| 1231 |
1214 Bounds Typer::Visitor::TypeJSTypeOf(Node* node) { | 1232 Bounds Typer::Visitor::TypeJSTypeOf(Node* node) { |
1215 return Bounds(Type::None(zone()), Type::InternalizedString(zone())); | 1233 return TypeUnaryOp(node, JSTypeOfTyper); |
1216 } | 1234 } |
1217 | 1235 |
1218 | 1236 |
1219 // JS conversion operators. | 1237 // JS conversion operators. |
1220 | 1238 |
1221 | 1239 |
1222 Bounds Typer::Visitor::TypeJSToBoolean(Node* node) { | 1240 Bounds Typer::Visitor::TypeJSToBoolean(Node* node) { |
1223 return TypeUnaryOp(node, ToBoolean); | 1241 return TypeUnaryOp(node, ToBoolean); |
1224 } | 1242 } |
1225 | 1243 |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2389 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2372 #undef TYPED_ARRAY_CASE | 2390 #undef TYPED_ARRAY_CASE |
2373 } | 2391 } |
2374 } | 2392 } |
2375 return Type::Constant(value, zone()); | 2393 return Type::Constant(value, zone()); |
2376 } | 2394 } |
2377 | 2395 |
2378 } // namespace compiler | 2396 } // namespace compiler |
2379 } // namespace internal | 2397 } // namespace internal |
2380 } // namespace v8 | 2398 } // namespace v8 |
OLD | NEW |