Reviewers: Yang,

Description:
[turbofan] Use builtin inlining mechanism for Math.floor.

Also removes the unused Math.ceil case from the typer.

BUG=v8:3952
LOG=n
[email protected]

Please review this at https://codereview.chromium.org/997513002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+1, -57 lines):
  M src/compiler/js-builtin-reducer.h
  M src/compiler/js-builtin-reducer.cc
  M src/compiler/typer.cc
  M src/math.js
  M test/unittests/compiler/js-builtin-reducer-unittest.cc


Index: src/compiler/js-builtin-reducer.cc
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc index f1ed17b358afba2f22b06a5d67414bb22d9bdee2..e2d12f0b5193f600b7f33de08052e242a6f99bb6 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -184,19 +184,6 @@ Reduction JSBuiltinReducer::ReduceMathFround(Node* node) {
 }


-// ES6 draft 10-14-14, section 20.2.2.16.
-Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) {
-  if (!machine()->HasFloat64RoundDown()) return NoChange();
-  JSCallReduction r(node);
-  if (r.InputsMatchOne(Type::Number())) {
-    // Math.floor(a:number) -> Float64RoundDown(a)
- Node* value = graph()->NewNode(machine()->Float64RoundDown(), r.left());
-    return Replace(value);
-  }
-  return NoChange();
-}
-
-
 Reduction JSBuiltinReducer::Reduce(Node* node) {
   JSCallReduction r(node);

@@ -213,8 +200,6 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
       return ReplaceWithPureReduction(node, ReduceMathImul(node));
     case kMathFround:
       return ReplaceWithPureReduction(node, ReduceMathFround(node));
-    case kMathFloor:
-      return ReplaceWithPureReduction(node, ReduceMathFloor(node));
     default:
       break;
   }
Index: src/compiler/js-builtin-reducer.h
diff --git a/src/compiler/js-builtin-reducer.h b/src/compiler/js-builtin-reducer.h index 8e9295170a7fe8a23502b2ba8085eac4b6874e29..60b9e1438a148dbcff8ba5f39f0f6fdf8ea8703d 100644
--- a/src/compiler/js-builtin-reducer.h
+++ b/src/compiler/js-builtin-reducer.h
@@ -31,7 +31,6 @@ class JSBuiltinReducer FINAL : public Reducer {
   Reduction ReduceMathMax(Node* node);
   Reduction ReduceMathImul(Node* node);
   Reduction ReduceMathFround(Node* node);
-  Reduction ReduceMathFloor(Node* node);

   JSGraph* jsgraph() const { return jsgraph_; }
   Graph* graph() const;
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 9934741767140ae4fff9b878d5385edcb7c9c736..1e0efabff3072ebdaedc1a1e22a4485946f5d681 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -2149,12 +2149,8 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
       switch (JSFunction::cast(*value)->shared()->builtin_function_id()) {
         case kMathRandom:
           return typer_->random_fun_;
-        case kMathFloor:
-          return typer_->weakint_fun1_;
         case kMathRound:
           return typer_->weakint_fun1_;
-        case kMathCeil:
-          return typer_->weakint_fun1_;
         // Unary math functions.
         case kMathAbs:  // TODO(rossberg): can't express overloading
         case kMathLog:
Index: src/math.js
diff --git a/src/math.js b/src/math.js
index 83bca9348efd6294b5e606f2a4f8655ec8471e1b..9225aaf9e5d2e4897e1c8a545ff92e4eeb5a69fb 100644
--- a/src/math.js
+++ b/src/math.js
@@ -351,6 +351,7 @@ InstallFunctions($Math, DONT_ENUM, $Array(
 ));

 %SetInlineBuiltinFlag(MathCeil);
+%SetInlineBuiltinFlag(MathFloor);
 %SetInlineBuiltinFlag(MathRandom);

 // Keep reference to original values of some global properties.  This
Index: test/unittests/compiler/js-builtin-reducer-unittest.cc
diff --git a/test/unittests/compiler/js-builtin-reducer-unittest.cc b/test/unittests/compiler/js-builtin-reducer-unittest.cc index 88bb9d12dec59934428dda50333cc81460c00736..ee9f960057cac01127b3a8500f4a40ab142759cf 100644
--- a/test/unittests/compiler/js-builtin-reducer-unittest.cc
+++ b/test/unittests/compiler/js-builtin-reducer-unittest.cc
@@ -223,43 +223,6 @@ TEST_F(JSBuiltinReducerTest, MathFround) {
   }
 }

-
-// -----------------------------------------------------------------------------
-// Math.floor
-
-
-TEST_F(JSBuiltinReducerTest, MathFloorAvailable) {
-  Handle<JSFunction> f = MathFunction("floor");
-
-  TRACED_FOREACH(Type*, t0, kNumberTypes) {
-    Node* p0 = Parameter(t0, 0);
-    Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
-    Node* call =
- graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
-                         fun, UndefinedConstant(), p0);
- Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kFloat64RoundDown);
-
-    ASSERT_TRUE(r.Changed());
-    EXPECT_THAT(r.replacement(), IsFloat64RoundDown(p0));
-  }
-}
-
-
-TEST_F(JSBuiltinReducerTest, MathFloorUnavailable) {
-  Handle<JSFunction> f = MathFunction("floor");
-
-  TRACED_FOREACH(Type*, t0, kNumberTypes) {
-    Node* p0 = Parameter(t0, 0);
-    Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
-    Node* call =
- graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
-                         fun, UndefinedConstant(), p0);
-    Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags);
-
-    ASSERT_FALSE(r.Changed());
-  }
-}
-
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to