| Index: src/compiler/typer.cc
|
| diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
|
| index 0fa2b95ebd3460350def99acdd14b2341d7b1b00..745a43536afeeb6997adb43d468fa559c92cef82 100644
|
| --- a/src/compiler/typer.cc
|
| +++ b/src/compiler/typer.cc
|
| @@ -739,6 +739,11 @@ Type* Typer::Visitor::JSBitwiseAndTyper(Type* lhs, Type* rhs, Typer* t) {
|
| double rmin = rhs->Min();
|
| double lmax = lhs->Max();
|
| double rmax = rhs->Max();
|
| + if (std::min(lmax, rmax) < kMaxInt) {
|
| + Handle<Object> min = f->NewNumber(0);
|
| + Handle<Object> max = f->NewNumber(std::min(lmax, rmax));
|
| + return Type::Range(min, max, t->zone());
|
| + }
|
| // And-ing any two values results in a value no larger than their maximum.
|
| // Even no larger than their minimum if both values are non-negative.
|
| Handle<Object> max = f->NewNumber(
|
| @@ -780,6 +785,7 @@ Type* Typer::Visitor::JSShiftLeftTyper(Type* lhs, Type* rhs, Typer* t) {
|
|
|
| Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) {
|
| lhs = NumberToInt32(ToNumber(lhs, t), t);
|
| + rhs = NumberToInt32(ToNumber(rhs, t), t);
|
| Factory* f = t->isolate()->factory();
|
| if (lhs->Min() >= 0) {
|
| // Right-shifting a non-negative value cannot make it negative, nor larger.
|
| @@ -793,6 +799,12 @@ Type* Typer::Visitor::JSShiftRightTyper(Type* lhs, Type* rhs, Typer* t) {
|
| Handle<Object> max = f->NewNumber(-1);
|
| return Type::Range(min, max, t->zone());
|
| }
|
| + if (rhs->Min() > 0) {
|
| + // Right-shifting by a positve value yields a small integer value.
|
| + Handle<Object> min = f->NewNumber(kMinInt >> static_cast<int>(rhs->Min()));
|
| + Handle<Object> max = f->NewNumber(kMaxInt >> static_cast<int>(rhs->Min()));
|
| + return Type::Range(min, max, t->zone());
|
| + }
|
| return Type::Signed32();
|
| }
|
|
|
|
|