Commit 0f46c9b4 authored by titzer@chromium.org's avatar titzer@chromium.org

Revert "[turbofan] Compute tighter ranges for modulus in Typer."

This reverts commit 482586747ca6bc0c94cc23f916fd190931d3a836.

TBR=jarin@chromium.org
BUG=

Review URL: https://codereview.chromium.org/702893002

Cr-Commit-Position: refs/heads/master@{#25164}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25164 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9aa536f2
......@@ -232,7 +232,6 @@ class Typer::Visitor : public NullNodeVisitor {
static Type* JSSubtractRanger(Type::RangeType*, Type::RangeType*, Typer*);
static Type* JSMultiplyRanger(Type::RangeType*, Type::RangeType*, Typer*);
static Type* JSDivideRanger(Type::RangeType*, Type::RangeType*, Typer*);
static Type* JSModulusRanger(Type::RangeType*, Type::RangeType*, Typer*);
static Type* JSCompareTyper(Type*, Type*, Typer*);
......@@ -985,57 +984,17 @@ Type* Typer::Visitor::JSDivideTyper(Type* lhs, Type* rhs, Typer* t) {
}
Type* Typer::Visitor::JSModulusRanger(Type::RangeType* lhs,
Type::RangeType* rhs, Typer* t) {
double lmin = lhs->Min()->Number();
double lmax = lhs->Max()->Number();
double rmin = rhs->Min()->Number();
double rmax = rhs->Max()->Number();
double labs = std::max(std::abs(lmin), std::abs(lmax));
double rabs = std::max(std::abs(rmin), std::abs(rmax)) - 1;
double abs = std::min(labs, rabs);
bool maybe_minus_zero = false;
double omin = 0;
double omax = 0;
if (lmin >= 0) { // {lhs} positive.
omin = 0;
omax = abs;
} else if (lmax <= 0) { // {lhs} negative.
omin = 0 - abs;
omax = 0;
maybe_minus_zero = lmin <= omin;
} else {
omin = 0 - abs;
omax = abs;
maybe_minus_zero = lmin <= omin;
}
Factory* f = t->isolate()->factory();
Type* result = Type::Range(f->NewNumber(omin), f->NewNumber(omax), t->zone());
if (maybe_minus_zero)
result = Type::Union(result, Type::MinusZero(), t->zone());
return result;
}
Type* Typer::Visitor::JSModulusTyper(Type* lhs, Type* rhs, Typer* t) {
lhs = ToNumber(lhs, t);
rhs = ToNumber(rhs, t);
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
if (lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) ||
lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) {
// Result maybe NaN.
return Type::Number();
}
lhs = Rangify(lhs, t);
rhs = Rangify(rhs, t);
if (lhs->IsRange() && rhs->IsRange()) {
return JSModulusRanger(lhs->AsRange(), rhs->AsRange(), t);
}
return Type::OrderedNumber();
// Division is tricky, so all we do is try ruling out nan.
// TODO(neis): try ruling out -0 as well?
bool maybe_nan =
lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) ||
((lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) &&
(rhs->Min() == -V8_INFINITY || rhs->Max() == +V8_INFINITY));
return maybe_nan ? Type::Number() : Type::OrderedNumber();
}
......
......@@ -4,7 +4,6 @@
#include <functional>
#include "src/codegen.h"
#include "src/compiler/node-properties-inl.h"
#include "src/compiler/typer.h"
#include "test/cctest/cctest.h"
......@@ -217,12 +216,6 @@ TEST(TypeJSDivide) {
}
TEST(TypeJSModulus) {
TyperTester t;
t.TestBinaryArithOp(t.javascript_.Modulus(), modulo);
}
TEST(TypeJSBitwiseOr) {
TyperTester t;
t.TestBinaryBitOp(t.javascript_.BitwiseOr(), bit_or);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment