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

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

Issue 807663006: [turbofan] Improve typing of ToBoolean. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | « src/compiler/typer.h ('k') | no next file » | 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-inl.h" 6 #include "src/compiler/graph-inl.h"
7 #include "src/compiler/graph-reducer.h" 7 #include "src/compiler/graph-reducer.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 singleton_zero = Type::Range(zero, zero, zone); 180 singleton_zero = Type::Range(zero, zero, zone);
181 singleton_one = Type::Range(one, one, zone); 181 singleton_one = Type::Range(one, one, zone);
182 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); 182 zero_or_one = Type::Union(singleton_zero, singleton_one, zone);
183 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); 183 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone);
184 signed32ish = Type::Union(signed32, truncating_to_zero, zone); 184 signed32ish = Type::Union(signed32, truncating_to_zero, zone);
185 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone); 185 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone);
186 falsish = Type::Union(Type::Undetectable(), 186 falsish = Type::Union(Type::Undetectable(),
187 Type::Union(Type::Union(singleton_false, zeroish, zone), 187 Type::Union(Type::Union(singleton_false, zeroish, zone),
188 undefined_or_null, zone), 188 undefined_or_null, zone),
189 zone); 189 zone);
190 truish = Type::Union(
191 singleton_true,
192 Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone), zone);
190 integer = Type::Range(minusinfinity, infinity, zone); 193 integer = Type::Range(minusinfinity, infinity, zone);
191 weakint = Type::Union(integer, nan_or_minuszero, zone); 194 weakint = Type::Union(integer, nan_or_minuszero, zone);
192 195
193 number_fun0_ = Type::Function(number, zone); 196 number_fun0_ = Type::Function(number, zone);
194 number_fun1_ = Type::Function(number, number, zone); 197 number_fun1_ = Type::Function(number, number, zone);
195 number_fun2_ = Type::Function(number, number, number, zone); 198 number_fun2_ = Type::Function(number, number, number, zone);
196 199
197 weakint_fun1_ = Type::Function(weakint, number, zone); 200 weakint_fun1_ = Type::Function(weakint, number, zone);
198 random_fun_ = Type::Function(Type::OrderedNumber(), zone); 201 random_fun_ = Type::Function(Type::OrderedNumber(), zone);
199 202
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 if (type->Is(Type::Primitive()) && !type->Maybe(Type::Receiver())) { 509 if (type->Is(Type::Primitive()) && !type->Maybe(Type::Receiver())) {
507 return type; 510 return type;
508 } 511 }
509 return Type::Primitive(); 512 return Type::Primitive();
510 } 513 }
511 514
512 515
513 Type* Typer::Visitor::ToBoolean(Type* type, Typer* t) { 516 Type* Typer::Visitor::ToBoolean(Type* type, Typer* t) {
514 if (type->Is(Type::Boolean())) return type; 517 if (type->Is(Type::Boolean())) return type;
515 if (type->Is(t->falsish)) return t->singleton_false; 518 if (type->Is(t->falsish)) return t->singleton_false;
516 if (type->Is(Type::DetectableReceiver())) return t->singleton_true; 519 if (type->Is(t->truish)) return t->singleton_true;
517 if (type->Is(Type::OrderedNumber()) && (type->Max() < 0 || 0 < type->Min())) { 520 if (type->Is(Type::PlainNumber()) && (type->Max() < 0 || 0 < type->Min())) {
518 return t->singleton_true; // Ruled out nan, -0 and +0. 521 return t->singleton_true; // Ruled out nan, -0 and +0.
519 } 522 }
520 return Type::Boolean(); 523 return Type::Boolean();
521 } 524 }
522 525
523 526
524 Type* Typer::Visitor::ToNumber(Type* type, Typer* t) { 527 Type* Typer::Visitor::ToNumber(Type* type, Typer* t) {
525 if (type->Is(Type::Number())) return type; 528 if (type->Is(Type::Number())) return type;
526 if (type->Is(Type::Null())) return t->singleton_zero; 529 if (type->Is(Type::Null())) return t->singleton_zero;
527 if (type->Is(Type::Undefined())) return Type::NaN(); 530 if (type->Is(Type::Undefined())) return Type::NaN();
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 // TODO(rossberg): Do we want some ClampedArray type to express this? 2097 // TODO(rossberg): Do we want some ClampedArray type to express this?
2095 break; 2098 break;
2096 } 2099 }
2097 } 2100 }
2098 return Type::Constant(value, zone()); 2101 return Type::Constant(value, zone());
2099 } 2102 }
2100 2103
2101 } // namespace compiler 2104 } // namespace compiler
2102 } // namespace internal 2105 } // namespace internal
2103 } // namespace v8 2106 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/typer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698