| 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 #include "src/compiler/graph-reducer.h" | 6 #include "src/compiler/graph-reducer.h" |
| 7 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 // ----------------------------------------------------------------------------- | 430 // ----------------------------------------------------------------------------- |
| 431 | 431 |
| 432 // Helper functions that lift a function f on types to a function on bounds, | 432 // Helper functions that lift a function f on types to a function on bounds, |
| 433 // and uses that to type the given node. Note that f is never called with None | 433 // and uses that to type the given node. Note that f is never called with None |
| 434 // as an argument. | 434 // as an argument. |
| 435 | 435 |
| 436 | 436 |
| 437 Bounds Typer::Visitor::TypeUnaryOp(Node* node, UnaryTyperFun f) { | 437 Bounds Typer::Visitor::TypeUnaryOp(Node* node, UnaryTyperFun f) { |
| 438 Bounds input = Operand(node, 0); | 438 Bounds input = Operand(node, 0); |
| 439 Type* upper = input.upper->Is(Type::None()) | 439 Type* upper = |
| 440 ? Type::None() | 440 input.upper->IsInhabited() ? f(input.upper, typer_) : Type::None(); |
| 441 : f(input.upper, typer_); | 441 Type* lower = input.lower->IsInhabited() |
| 442 Type* lower = input.lower->Is(Type::None()) | 442 ? ((input.lower == input.upper || upper->IsConstant()) |
| 443 ? Type::None() | 443 ? upper // TODO(neis): Extend this to Range(x,x), |
| 444 : (input.lower == input.upper || upper->IsConstant()) | 444 // NaN, MinusZero, ...? |
| 445 ? upper // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? | 445 : f(input.lower, typer_)) |
| 446 : f(input.lower, typer_); | 446 : Type::None(); |
| 447 // TODO(neis): Figure out what to do with lower bound. | 447 // TODO(neis): Figure out what to do with lower bound. |
| 448 return Bounds(lower, upper); | 448 return Bounds(lower, upper); |
| 449 } | 449 } |
| 450 | 450 |
| 451 | 451 |
| 452 Bounds Typer::Visitor::TypeBinaryOp(Node* node, BinaryTyperFun f) { | 452 Bounds Typer::Visitor::TypeBinaryOp(Node* node, BinaryTyperFun f) { |
| 453 Bounds left = Operand(node, 0); | 453 Bounds left = Operand(node, 0); |
| 454 Bounds right = Operand(node, 1); | 454 Bounds right = Operand(node, 1); |
| 455 Type* upper = left.upper->Is(Type::None()) || right.upper->Is(Type::None()) | 455 Type* upper = left.upper->IsInhabited() && right.upper->IsInhabited() |
| 456 ? Type::None() | 456 ? f(left.upper, right.upper, typer_) |
| 457 : f(left.upper, right.upper, typer_); | 457 : Type::None(); |
| 458 Type* lower = left.lower->Is(Type::None()) || right.lower->Is(Type::None()) | 458 Type* lower = |
| 459 ? Type::None() | 459 left.lower->IsInhabited() && right.lower->IsInhabited() |
| 460 : ((left.lower == left.upper && right.lower == right.upper) || | 460 ? (((left.lower == left.upper && right.lower == right.upper) || |
| 461 upper->IsConstant()) | 461 upper->IsConstant()) |
| 462 ? upper | 462 ? upper |
| 463 : f(left.lower, right.lower, typer_); | 463 : f(left.lower, right.lower, typer_)) |
| 464 : Type::None(); |
| 464 // TODO(neis): Figure out what to do with lower bound. | 465 // TODO(neis): Figure out what to do with lower bound. |
| 465 return Bounds(lower, upper); | 466 return Bounds(lower, upper); |
| 466 } | 467 } |
| 467 | 468 |
| 468 | 469 |
| 469 Type* Typer::Visitor::Invert(Type* type, Typer* t) { | 470 Type* Typer::Visitor::Invert(Type* type, Typer* t) { |
| 470 if (type->Is(t->singleton_false)) return t->singleton_true; | 471 if (type->Is(t->singleton_false)) return t->singleton_true; |
| 471 if (type->Is(t->singleton_true)) return t->singleton_false; | 472 if (type->Is(t->singleton_true)) return t->singleton_false; |
| 472 return type; | 473 return type; |
| 473 } | 474 } |
| (...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2137 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 2137 #undef TYPED_ARRAY_CASE | 2138 #undef TYPED_ARRAY_CASE |
| 2138 } | 2139 } |
| 2139 } | 2140 } |
| 2140 return Type::Constant(value, zone()); | 2141 return Type::Constant(value, zone()); |
| 2141 } | 2142 } |
| 2142 | 2143 |
| 2143 } // namespace compiler | 2144 } // namespace compiler |
| 2144 } // namespace internal | 2145 } // namespace internal |
| 2145 } // namespace v8 | 2146 } // namespace v8 |
| OLD | NEW |