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/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 Reduction UpdateBounds(Node* node, Bounds current) { | 252 Reduction UpdateBounds(Node* node, Bounds current) { |
253 if (NodeProperties::IsTyped(node)) { | 253 if (NodeProperties::IsTyped(node)) { |
254 // Widen the bounds of a previously typed node. | 254 // Widen the bounds of a previously typed node. |
255 Bounds previous = NodeProperties::GetBounds(node); | 255 Bounds previous = NodeProperties::GetBounds(node); |
256 if (node->opcode() == IrOpcode::kPhi) { | 256 if (node->opcode() == IrOpcode::kPhi) { |
257 // Speed up termination in the presence of range types: | 257 // Speed up termination in the presence of range types: |
258 current.upper = Weaken(node, current.upper, previous.upper); | 258 current.upper = Weaken(node, current.upper, previous.upper); |
259 current.lower = Weaken(node, current.lower, previous.lower); | 259 current.lower = Weaken(node, current.lower, previous.lower); |
260 } | 260 } |
261 | 261 |
262 // Types should not get less precise. | |
263 DCHECK(previous.lower->Is(current.lower)); | 262 DCHECK(previous.lower->Is(current.lower)); |
264 DCHECK(previous.upper->Is(current.upper)); | 263 DCHECK(previous.upper->Is(current.upper)); |
265 | 264 |
266 NodeProperties::SetBounds(node, current); | 265 NodeProperties::SetBounds(node, current); |
267 if (!(previous.Narrows(current) && current.Narrows(previous))) { | 266 if (!(previous.Narrows(current) && current.Narrows(previous))) { |
268 // If something changed, revisit all uses. | 267 // If something changed, revisit all uses. |
269 return Changed(node); | 268 return Changed(node); |
270 } | 269 } |
271 return NoChange(); | 270 return NoChange(); |
272 } else { | 271 } else { |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 | 1116 |
1118 | 1117 |
1119 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { | 1118 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { |
1120 Factory* const f = t->isolate()->factory(); | 1119 Factory* const f = t->isolate()->factory(); |
1121 if (type->Is(Type::Boolean())) { | 1120 if (type->Is(Type::Boolean())) { |
1122 return Type::Constant(f->boolean_string(), t->zone()); | 1121 return Type::Constant(f->boolean_string(), t->zone()); |
1123 } else if (type->Is(Type::Number())) { | 1122 } else if (type->Is(Type::Number())) { |
1124 return Type::Constant(f->number_string(), t->zone()); | 1123 return Type::Constant(f->number_string(), t->zone()); |
1125 } else if (type->Is(Type::Symbol())) { | 1124 } else if (type->Is(Type::Symbol())) { |
1126 return Type::Constant(f->symbol_string(), t->zone()); | 1125 return Type::Constant(f->symbol_string(), t->zone()); |
1127 } else if (type->Is(Type::Union(Type::Undefined(), Type::Undetectable()))) { | 1126 } else if (type->Is(Type::Union(Type::Undefined(), Type::Undetectable(), |
| 1127 t->zone()))) { |
1128 return Type::Constant(f->undefined_string(), t->zone()); | 1128 return Type::Constant(f->undefined_string(), t->zone()); |
1129 } else if (type->Is(Type::Null())) { | 1129 } else if (type->Is(Type::Null())) { |
1130 return Type::Constant(f->object_string(), t->zone()); | 1130 return Type::Constant(f->object_string(), t->zone()); |
1131 } | 1131 } |
1132 return Type::InternalizedString(); | 1132 return Type::InternalizedString(); |
1133 } | 1133 } |
1134 | 1134 |
1135 | 1135 |
1136 Bounds Typer::Visitor::TypeJSTypeOf(Node* node) { | 1136 Bounds Typer::Visitor::TypeJSTypeOf(Node* node) { |
1137 return TypeUnaryOp(node, JSTypeOfTyper); | 1137 return TypeUnaryOp(node, JSTypeOfTyper); |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2293 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
2294 #undef TYPED_ARRAY_CASE | 2294 #undef TYPED_ARRAY_CASE |
2295 } | 2295 } |
2296 } | 2296 } |
2297 return Type::Constant(value, zone()); | 2297 return Type::Constant(value, zone()); |
2298 } | 2298 } |
2299 | 2299 |
2300 } // namespace compiler | 2300 } // namespace compiler |
2301 } // namespace internal | 2301 } // namespace internal |
2302 } // namespace v8 | 2302 } // namespace v8 |
OLD | NEW |