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

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

Issue 2227463003: [WIP] NumberToString operator in TF. Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_BuiltinTypingRules
Patch Set: Created 4 years, 4 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 | « src/compiler/operation-typer.h ('k') | src/compiler/simplified-lowering.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/operation-typer.h" 5 #include "src/compiler/operation-typer.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/type-cache.h" 10 #include "src/type-cache.h"
11 #include "src/types.h" 11 #include "src/types.h"
12 12
13 #include "src/objects-inl.h" 13 #include "src/objects-inl.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 namespace compiler { 17 namespace compiler {
18 18
19 OperationTyper::OperationTyper(Isolate* isolate, Zone* zone) 19 OperationTyper::OperationTyper(Isolate* isolate, Zone* zone)
20 : zone_(zone), cache_(TypeCache::Get()) { 20 : isolate_(isolate), zone_(zone), cache_(TypeCache::Get()) {
21 Factory* factory = isolate->factory(); 21 Factory* factory = isolate->factory();
22 infinity_ = Type::Constant(factory->infinity_value(), zone); 22 infinity_ = Type::Constant(factory->infinity_value(), zone);
23 minus_infinity_ = Type::Constant(factory->minus_infinity_value(), zone); 23 minus_infinity_ = Type::Constant(factory->minus_infinity_value(), zone);
24 // Unfortunately, the infinities created in other places might be different 24 // Unfortunately, the infinities created in other places might be different
25 // ones (eg the result of NewNumber in TypeNumberConstant). 25 // ones (eg the result of NewNumber in TypeNumberConstant).
26 Type* truncating_to_zero = 26 Type* truncating_to_zero =
27 Type::Union(Type::Union(infinity_, minus_infinity_, zone), 27 Type::Union(Type::Union(infinity_, minus_infinity_, zone),
28 Type::MinusZeroOrNaN(), zone); 28 Type::MinusZeroOrNaN(), zone);
29 DCHECK(!truncating_to_zero->Maybe(Type::Integral32())); 29 DCHECK(!truncating_to_zero->Maybe(Type::Integral32()));
30 30
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 if (type->Is(Type::Unsigned32())) return type; 478 if (type->Is(Type::Unsigned32())) return type;
479 if (type->Is(cache_.kZeroish)) return cache_.kSingletonZero; 479 if (type->Is(cache_.kZeroish)) return cache_.kSingletonZero;
480 if (type->Is(unsigned32ish_)) { 480 if (type->Is(unsigned32ish_)) {
481 return Type::Intersect(Type::Union(type, cache_.kSingletonZero, zone()), 481 return Type::Intersect(Type::Union(type, cache_.kSingletonZero, zone()),
482 Type::Unsigned32(), zone()); 482 Type::Unsigned32(), zone());
483 } 483 }
484 return Type::Unsigned32(); 484 return Type::Unsigned32();
485 } 485 }
486 486
487 Type* OperationTyper::NumberToString(Type* lhs, Type* rhs) {
488 DCHECK(lhs->Is(Type::Number()));
489 DCHECK(rhs->Is(Type::Unsigned30()));
490 if (!lhs->IsInhabited()) return Type::None();
491 if (lhs->Is(Type::NaN())) {
492 return Type::Constant(factory()->nan_string(), zone());
493 }
494 if (lhs->Is(cache_.kZeroish)) {
495 return Type::Constant(factory()->zero_string(), zone());
496 }
497 if (lhs->Is(infinity_)) {
498 return Type::Constant(factory()->infinity_string(), zone());
499 }
500 if (lhs->Is(minus_infinity_)) {
501 return Type::Constant(factory()->minus_infinity_string(), zone());
502 }
503 return Type::String();
504 }
505
487 Type* OperationTyper::NumberSilenceNaN(Type* type) { 506 Type* OperationTyper::NumberSilenceNaN(Type* type) {
488 DCHECK(type->Is(Type::Number())); 507 DCHECK(type->Is(Type::Number()));
489 // TODO(jarin): This is a terrible hack; we definitely need a dedicated type 508 // TODO(jarin): This is a terrible hack; we definitely need a dedicated type
490 // for the hole (tagged and/or double). Otherwise if the input is the hole 509 // for the hole (tagged and/or double). Otherwise if the input is the hole
491 // NaN constant, we'd just eliminate this node in JSTypedLowering. 510 // NaN constant, we'd just eliminate this node in JSTypedLowering.
492 if (type->Maybe(Type::NaN())) return Type::Number(); 511 if (type->Maybe(Type::NaN())) return Type::Number();
493 return type; 512 return type;
494 } 513 }
495 514
496 Type* OperationTyper::NumberAdd(Type* lhs, Type* rhs) { 515 Type* OperationTyper::NumberAdd(Type* lhs, Type* rhs) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 } 975 }
957 // Type should be non empty, so we know it should be true. 976 // Type should be non empty, so we know it should be true.
958 DCHECK((outcome & kComparisonTrue) != 0); 977 DCHECK((outcome & kComparisonTrue) != 0);
959 return singleton_true(); 978 return singleton_true();
960 } 979 }
961 980
962 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { 981 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) {
963 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); 982 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone());
964 } 983 }
965 984
985 Factory* OperationTyper::factory() const { return isolate()->factory(); }
986
966 } // namespace compiler 987 } // namespace compiler
967 } // namespace internal 988 } // namespace internal
968 } // namespace v8 989 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/operation-typer.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698