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

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

Issue 739743003: [turbofan] Smartify typing of NumberToInt32 and NumberToUint32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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/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-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 21 matching lines...) Expand all
32 weaken_min_limits_(graph->zone()), 32 weaken_min_limits_(graph->zone()),
33 weaken_max_limits_(graph->zone()) { 33 weaken_max_limits_(graph->zone()) {
34 Zone* zone = this->zone(); 34 Zone* zone = this->zone();
35 Factory* f = zone->isolate()->factory(); 35 Factory* f = zone->isolate()->factory();
36 36
37 Handle<Object> zero = f->NewNumber(0); 37 Handle<Object> zero = f->NewNumber(0);
38 Handle<Object> one = f->NewNumber(1); 38 Handle<Object> one = f->NewNumber(1);
39 Handle<Object> infinity = f->NewNumber(+V8_INFINITY); 39 Handle<Object> infinity = f->NewNumber(+V8_INFINITY);
40 Handle<Object> minusinfinity = f->NewNumber(-V8_INFINITY); 40 Handle<Object> minusinfinity = f->NewNumber(-V8_INFINITY);
41 41
42 Type* number = Type::Number();
43 Type* signed32 = Type::Signed32();
44 Type* unsigned32 = Type::Unsigned32();
45 Type* integral32 = Type::Integral32();
46 Type* object = Type::Object();
47 Type* undefined = Type::Undefined();
48 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone);
49 Type* truncating_to_zero =
50 Type::Union(Type::Union(Type::Constant(infinity, zone),
51 Type::Constant(minusinfinity, zone), zone),
52 nan_or_minuszero, zone);
53
42 negative_signed32 = Type::Union( 54 negative_signed32 = Type::Union(
43 Type::SignedSmall(), Type::OtherSigned32(), zone); 55 Type::SignedSmall(), Type::OtherSigned32(), zone);
44 non_negative_signed32 = Type::Union( 56 non_negative_signed32 = Type::Union(
45 Type::UnsignedSmall(), Type::OtherUnsigned31(), zone); 57 Type::UnsignedSmall(), Type::OtherUnsigned31(), zone);
46 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone); 58 undefined_or_null = Type::Union(Type::Undefined(), Type::Null(), zone);
47 singleton_false = Type::Constant(f->false_value(), zone); 59 singleton_false = Type::Constant(f->false_value(), zone);
48 singleton_true = Type::Constant(f->true_value(), zone); 60 singleton_true = Type::Constant(f->true_value(), zone);
49 singleton_zero = Type::Range(zero, zero, zone); 61 singleton_zero = Type::Range(zero, zero, zone);
50 singleton_one = Type::Range(one, one, zone); 62 singleton_one = Type::Range(one, one, zone);
51 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); 63 zero_or_one = Type::Union(singleton_zero, singleton_one, zone);
52 zeroish = Type::Union( 64 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone);
53 singleton_zero, Type::Union(Type::NaN(), Type::MinusZero(), zone), zone); 65 signed32ish = Type::Union(signed32, truncating_to_zero, zone);
66 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone);
54 falsish = Type::Union(Type::Undetectable(), 67 falsish = Type::Union(Type::Undetectable(),
55 Type::Union(zeroish, undefined_or_null, zone), zone); 68 Type::Union(zeroish, undefined_or_null, zone), zone);
56 integer = Type::Range(minusinfinity, infinity, zone); 69 integer = Type::Range(minusinfinity, infinity, zone);
57 weakint = Type::Union( 70 weakint = Type::Union(integer, nan_or_minuszero, zone);
58 integer, Type::Union(Type::NaN(), Type::MinusZero(), zone), zone);
59
60 Type* number = Type::Number();
61 Type* signed32 = Type::Signed32();
62 Type* unsigned32 = Type::Unsigned32();
63 Type* integral32 = Type::Integral32();
64 Type* object = Type::Object();
65 Type* undefined = Type::Undefined();
66 71
67 number_fun0_ = Type::Function(number, zone); 72 number_fun0_ = Type::Function(number, zone);
68 number_fun1_ = Type::Function(number, number, zone); 73 number_fun1_ = Type::Function(number, number, zone);
69 number_fun2_ = Type::Function(number, number, number, zone); 74 number_fun2_ = Type::Function(number, number, number, zone);
70 weakint_fun1_ = Type::Function(weakint, number, zone); 75 weakint_fun1_ = Type::Function(weakint, number, zone);
71 imul_fun_ = Type::Function(signed32, integral32, integral32, zone); 76 imul_fun_ = Type::Function(signed32, integral32, integral32, zone);
72 clz32_fun_ = Type::Function( 77 clz32_fun_ = Type::Function(
73 Type::Range(zero, f->NewNumber(32), zone), number, zone); 78 Type::Range(zero, f->NewNumber(32), zone), number, zone);
74 random_fun_ = Type::Function(Type::Union( 79 random_fun_ = Type::Function(Type::Union(
75 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone); 80 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 Type* Typer::Visitor::ToString(Type* type, Typer* t) { 465 Type* Typer::Visitor::ToString(Type* type, Typer* t) {
461 if (type->Is(Type::String())) return type; 466 if (type->Is(Type::String())) return type;
462 return Type::String(); 467 return Type::String();
463 } 468 }
464 469
465 470
466 Type* Typer::Visitor::NumberToInt32(Type* type, Typer* t) { 471 Type* Typer::Visitor::NumberToInt32(Type* type, Typer* t) {
467 // TODO(neis): DCHECK(type->Is(Type::Number())); 472 // TODO(neis): DCHECK(type->Is(Type::Number()));
468 if (type->Is(Type::Signed32())) return type; 473 if (type->Is(Type::Signed32())) return type;
469 if (type->Is(t->zeroish)) return t->singleton_zero; 474 if (type->Is(t->zeroish)) return t->singleton_zero;
475 if (type->Is(t->signed32ish)) {
476 return Type::Intersect(Type::Union(type, t->singleton_zero, t->zone()),
477 Type::Signed32(), t->zone());
478 }
470 return Type::Signed32(); 479 return Type::Signed32();
471 } 480 }
472 481
473 482
474 Type* Typer::Visitor::NumberToUint32(Type* type, Typer* t) { 483 Type* Typer::Visitor::NumberToUint32(Type* type, Typer* t) {
475 // TODO(neis): DCHECK(type->Is(Type::Number())); 484 // TODO(neis): DCHECK(type->Is(Type::Number()));
476 if (type->Is(Type::Unsigned32())) return type; 485 if (type->Is(Type::Unsigned32())) return type;
477 if (type->Is(t->zeroish)) return t->singleton_zero; 486 if (type->Is(t->zeroish)) return t->singleton_zero;
487 if (type->Is(t->unsigned32ish)) {
488 return Type::Intersect(Type::Union(type, t->singleton_zero, t->zone()),
489 Type::Unsigned32(), t->zone());
490 }
478 return Type::Unsigned32(); 491 return Type::Unsigned32();
479 } 492 }
480 493
481 494
482 // ----------------------------------------------------------------------------- 495 // -----------------------------------------------------------------------------
483 496
484 497
485 // Control operators. 498 // Control operators.
486 499
487 500
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 return typer_->float64_array_fun_; 1973 return typer_->float64_array_fun_;
1961 } 1974 }
1962 } 1975 }
1963 } 1976 }
1964 return Type::Constant(value, zone()); 1977 return Type::Constant(value, zone());
1965 } 1978 }
1966 1979
1967 } 1980 }
1968 } 1981 }
1969 } // namespace v8::internal::compiler 1982 } // namespace v8::internal::compiler
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