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

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

Issue 786703002: [turbofan] Improve typing of JSToNumber. (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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 Type* number = Type::Number(); 156 Type* number = Type::Number();
157 Type* signed32 = Type::Signed32(); 157 Type* signed32 = Type::Signed32();
158 Type* unsigned32 = Type::Unsigned32(); 158 Type* unsigned32 = Type::Unsigned32();
159 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone); 159 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone);
160 Type* truncating_to_zero = 160 Type* truncating_to_zero =
161 Type::Union(Type::Union(Type::Constant(infinity, zone), 161 Type::Union(Type::Union(Type::Constant(infinity, zone),
162 Type::Constant(minusinfinity, zone), zone), 162 Type::Constant(minusinfinity, zone), zone),
163 nan_or_minuszero, zone); 163 nan_or_minuszero, zone);
164 164
165 boolean_or_number = Type::Union(Type::Boolean(), Type::Number(), zone);
166 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone);
167 undefined_or_number = Type::Union(Type::Undefined(), Type::Number(), zone);
165 negative_signed32 = Type::Union( 168 negative_signed32 = Type::Union(
166 Type::SignedSmall(), Type::OtherSigned32(), zone); 169 Type::SignedSmall(), Type::OtherSigned32(), zone);
167 non_negative_signed32 = Type::Union( 170 non_negative_signed32 = Type::Union(
168 Type::UnsignedSmall(), Type::OtherUnsigned31(), zone); 171 Type::UnsignedSmall(), Type::OtherUnsigned31(), zone);
169 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone);
170 singleton_false = Type::Constant(f->false_value(), zone); 172 singleton_false = Type::Constant(f->false_value(), zone);
171 singleton_true = Type::Constant(f->true_value(), zone); 173 singleton_true = Type::Constant(f->true_value(), zone);
172 singleton_zero = Type::Range(zero, zero, zone); 174 singleton_zero = Type::Range(zero, zero, zone);
173 singleton_one = Type::Range(one, one, zone); 175 singleton_one = Type::Range(one, one, zone);
174 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); 176 zero_or_one = Type::Union(singleton_zero, singleton_one, zone);
175 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); 177 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone);
176 signed32ish = Type::Union(signed32, truncating_to_zero, zone); 178 signed32ish = Type::Union(signed32, truncating_to_zero, zone);
177 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone); 179 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone);
178 falsish = Type::Union(Type::Undetectable(), 180 falsish = Type::Union(Type::Undetectable(),
179 Type::Union(zeroish, undefined_or_null, zone), zone); 181 Type::Union(zeroish, undefined_or_null, zone), zone);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 if (type->Is(Type::DetectableReceiver())) return t->singleton_true; 515 if (type->Is(Type::DetectableReceiver())) return t->singleton_true;
514 if (type->Is(Type::OrderedNumber()) && (type->Max() < 0 || 0 < type->Min())) { 516 if (type->Is(Type::OrderedNumber()) && (type->Max() < 0 || 0 < type->Min())) {
515 return t->singleton_true; // Ruled out nan, -0 and +0. 517 return t->singleton_true; // Ruled out nan, -0 and +0.
516 } 518 }
517 return Type::Boolean(); 519 return Type::Boolean();
518 } 520 }
519 521
520 522
521 Type* Typer::Visitor::ToNumber(Type* type, Typer* t) { 523 Type* Typer::Visitor::ToNumber(Type* type, Typer* t) {
522 if (type->Is(Type::Number())) return type; 524 if (type->Is(Type::Number())) return type;
525 if (type->Is(Type::Null())) return t->singleton_zero;
523 if (type->Is(Type::Undefined())) return Type::NaN(); 526 if (type->Is(Type::Undefined())) return Type::NaN();
527 if (type->Is(t->undefined_or_null)) {
528 return Type::Union(Type::NaN(), t->singleton_zero, t->zone());
529 }
530 if (type->Is(t->undefined_or_number)) {
531 return Type::Union(Type::Intersect(type, Type::Number(), t->zone()),
532 Type::NaN(), t->zone());
533 }
524 if (type->Is(t->singleton_false)) return t->singleton_zero; 534 if (type->Is(t->singleton_false)) return t->singleton_zero;
525 if (type->Is(t->singleton_true)) return t->singleton_one; 535 if (type->Is(t->singleton_true)) return t->singleton_one;
526 if (type->Is(Type::Boolean())) return t->zero_or_one; 536 if (type->Is(Type::Boolean())) return t->zero_or_one;
537 if (type->Is(t->boolean_or_number)) {
538 return Type::Union(Type::Intersect(type, Type::Number(), t->zone()),
539 t->zero_or_one, t->zone());
540 }
527 return Type::Number(); 541 return Type::Number();
528 } 542 }
529 543
530 544
531 Type* Typer::Visitor::ToString(Type* type, Typer* t) { 545 Type* Typer::Visitor::ToString(Type* type, Typer* t) {
532 if (type->Is(Type::String())) return type; 546 if (type->Is(Type::String())) return type;
533 return Type::String(); 547 return Type::String();
534 } 548 }
535 549
536 550
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1179
1166 // JS conversion operators. 1180 // JS conversion operators.
1167 1181
1168 1182
1169 Bounds Typer::Visitor::TypeJSToBoolean(Node* node) { 1183 Bounds Typer::Visitor::TypeJSToBoolean(Node* node) {
1170 return Bounds(Type::None(zone()), Type::Boolean(zone())); 1184 return Bounds(Type::None(zone()), Type::Boolean(zone()));
1171 } 1185 }
1172 1186
1173 1187
1174 Bounds Typer::Visitor::TypeJSToNumber(Node* node) { 1188 Bounds Typer::Visitor::TypeJSToNumber(Node* node) {
1175 return Bounds(Type::None(zone()), Type::Number(zone())); 1189 return TypeUnaryOp(node, ToNumber);
1176 } 1190 }
1177 1191
1178 1192
1179 Bounds Typer::Visitor::TypeJSToString(Node* node) { 1193 Bounds Typer::Visitor::TypeJSToString(Node* node) {
1180 return TypeUnaryOp(node, ToString); 1194 return TypeUnaryOp(node, ToString);
1181 } 1195 }
1182 1196
1183 1197
1184 Bounds Typer::Visitor::TypeJSToName(Node* node) { 1198 Bounds Typer::Visitor::TypeJSToName(Node* node) {
1185 return Bounds(Type::None(), Type::Name()); 1199 return Bounds(Type::None(), Type::Name());
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 return typer_->cache_->Get(kFloat64ArrayFunc); 2088 return typer_->cache_->Get(kFloat64ArrayFunc);
2075 } 2089 }
2076 } 2090 }
2077 } 2091 }
2078 return Type::Constant(value, zone()); 2092 return Type::Constant(value, zone());
2079 } 2093 }
2080 2094
2081 } // namespace compiler 2095 } // namespace compiler
2082 } // namespace internal 2096 } // namespace internal
2083 } // namespace v8 2097 } // 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