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/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 static Type* JSMultiplyRanger(Type::RangeType*, Type::RangeType*, Typer*); | 248 static Type* JSMultiplyRanger(Type::RangeType*, Type::RangeType*, Typer*); |
249 static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*); | 249 static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*); |
250 static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*); | 250 static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*); |
251 | 251 |
252 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); | 252 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); |
253 | 253 |
254 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); | 254 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); |
255 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) | 255 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) |
256 #undef DECLARE_METHOD | 256 #undef DECLARE_METHOD |
257 | 257 |
258 static Type* JSUnaryNotTyper(Type*, Typer*); | |
259 static Type* JSTypeOfTyper(Type*, Typer*); | 258 static Type* JSTypeOfTyper(Type*, Typer*); |
260 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); | 259 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); |
261 static Type* JSCallFunctionTyper(Type*, Typer*); | 260 static Type* JSCallFunctionTyper(Type*, Typer*); |
262 | 261 |
263 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); | 262 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); |
264 | 263 |
265 Reduction UpdateType(Node* node, Type* current) { | 264 Reduction UpdateType(Node* node, Type* current) { |
266 if (NodeProperties::IsTyped(node)) { | 265 if (NodeProperties::IsTyped(node)) { |
267 // Widen the type of a previously typed node. | 266 // Widen the type of a previously typed node. |
268 Type* previous = NodeProperties::GetType(node); | 267 Type* previous = NodeProperties::GetType(node); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 if (lhs->IsRange() && rhs->IsRange()) { | 1135 if (lhs->IsRange() && rhs->IsRange()) { |
1137 return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t); | 1136 return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t); |
1138 } | 1137 } |
1139 return Type::OrderedNumber(); | 1138 return Type::OrderedNumber(); |
1140 } | 1139 } |
1141 | 1140 |
1142 | 1141 |
1143 // JS unary operators. | 1142 // JS unary operators. |
1144 | 1143 |
1145 | 1144 |
1146 Type* Typer::Visitor::JSUnaryNotTyper(Type* type, Typer* t) { | |
1147 return Invert(ToBoolean(type, t), t); | |
1148 } | |
1149 | |
1150 | |
1151 Type* Typer::Visitor::TypeJSUnaryNot(Node* node) { | |
1152 return TypeUnaryOp(node, JSUnaryNotTyper); | |
1153 } | |
1154 | |
1155 | |
1156 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { | 1145 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { |
1157 Factory* const f = t->isolate()->factory(); | 1146 Factory* const f = t->isolate()->factory(); |
1158 if (type->Is(Type::Boolean())) { | 1147 if (type->Is(Type::Boolean())) { |
1159 return Type::Constant(f->boolean_string(), t->zone()); | 1148 return Type::Constant(f->boolean_string(), t->zone()); |
1160 } else if (type->Is(Type::Number())) { | 1149 } else if (type->Is(Type::Number())) { |
1161 return Type::Constant(f->number_string(), t->zone()); | 1150 return Type::Constant(f->number_string(), t->zone()); |
1162 } else if (type->Is(Type::String())) { | 1151 } else if (type->Is(Type::String())) { |
1163 return Type::Constant(f->string_string(), t->zone()); | 1152 return Type::Constant(f->string_string(), t->zone()); |
1164 } else if (type->Is(Type::Symbol())) { | 1153 } else if (type->Is(Type::Symbol())) { |
1165 return Type::Constant(f->symbol_string(), t->zone()); | 1154 return Type::Constant(f->symbol_string(), t->zone()); |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 } | 2406 } |
2418 if (Type::IsInteger(*value)) { | 2407 if (Type::IsInteger(*value)) { |
2419 return Type::Range(value->Number(), value->Number(), zone()); | 2408 return Type::Range(value->Number(), value->Number(), zone()); |
2420 } | 2409 } |
2421 return Type::Constant(value, zone()); | 2410 return Type::Constant(value, zone()); |
2422 } | 2411 } |
2423 | 2412 |
2424 } // namespace compiler | 2413 } // namespace compiler |
2425 } // namespace internal | 2414 } // namespace internal |
2426 } // namespace v8 | 2415 } // namespace v8 |
OLD | NEW |