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

Unified Diff: src/compiler/typer.cc

Issue 2096403002: [turbofan] Introduce simplified operator NumberAbs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: This time fix the compile error for realz Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/simplified-operator-reducer.cc ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 556efa553192a3b4771b028cab96f5b70f730f56..2bc0bb333f3f8e6749a59fead251ce4bf00a08a3 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -243,6 +243,7 @@ class Typer::Visitor : public Reducer {
static Type* ToNumber(Type*, Typer*);
static Type* ToObject(Type*, Typer*);
static Type* ToString(Type*, Typer*);
+ static Type* NumberAbs(Type*, Typer*);
static Type* NumberCeil(Type*, Typer*);
static Type* NumberFloor(Type*, Typer*);
static Type* NumberRound(Type*, Typer*);
@@ -479,6 +480,34 @@ Type* Typer::Visitor::ToString(Type* type, Typer* t) {
}
// static
+Type* Typer::Visitor::NumberAbs(Type* type, Typer* t) {
+ DCHECK(type->Is(Type::Number()));
+ Factory* const f = t->isolate()->factory();
+ bool const maybe_nan = type->Maybe(Type::NaN());
+ bool const maybe_minuszero = type->Maybe(Type::MinusZero());
+ type = Type::Intersect(type, Type::PlainNumber(), t->zone());
+ double const max = type->Max();
+ double const min = type->Min();
+ if (min < 0) {
+ if (type->Is(t->cache_.kInteger)) {
+ type =
+ Type::Range(0.0, std::max(std::fabs(min), std::fabs(max)), t->zone());
+ } else if (min == max) {
+ type = Type::Constant(f->NewNumber(std::fabs(min)), t->zone());
+ } else {
+ type = Type::PlainNumber();
+ }
+ }
+ if (maybe_minuszero) {
+ type = Type::Union(type, t->cache_.kSingletonZero, t->zone());
+ }
+ if (maybe_nan) {
+ type = Type::Union(type, Type::NaN(), t->zone());
+ }
+ return type;
+}
+
+// static
Type* Typer::Visitor::NumberCeil(Type* type, Typer* t) {
DCHECK(type->Is(Type::Number()));
if (type->Is(t->cache_.kIntegerOrMinusZeroOrNaN)) return type;
@@ -1597,6 +1626,10 @@ Type* Typer::Visitor::TypePlainPrimitiveToFloat64(Node* node) {
Type* Typer::Visitor::TypeNumberImul(Node* node) { return Type::Signed32(); }
+Type* Typer::Visitor::TypeNumberAbs(Node* node) {
+ return TypeUnaryOp(node, NumberAbs);
+}
+
Type* Typer::Visitor::TypeNumberClz32(Node* node) {
return typer_->cache_.kZeroToThirtyTwo;
}
« no previous file with comments | « src/compiler/simplified-operator-reducer.cc ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698