Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: src/compiler/typer.cc

Issue 904863002: [turbofan] Separate representation type operations from the semantic types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/hydrogen-types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698