[turbofan] Use builtin inlining mechanism for Math.floor.
authorbmeurer <bmeurer@chromium.org>
Tue, 10 Mar 2015 11:59:20 +0000 (04:59 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 10 Mar 2015 11:59:31 +0000 (11:59 +0000)
BUG=v8:3952
LOG=n
R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27098}

src/compiler/js-builtin-reducer.cc
src/compiler/js-builtin-reducer.h
src/math.js
test/unittests/compiler/js-builtin-reducer-unittest.cc

index f1ed17b358afba2f22b06a5d67414bb22d9bdee2..e2d12f0b5193f600b7f33de08052e242a6f99bb6 100644 (file)
@@ -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 8e9295170a7fe8a23502b2ba8085eac4b6874e29..60b9e1438a148dbcff8ba5f39f0f6fdf8ea8703d 100644 (file)
@@ -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 83bca9348efd6294b5e606f2a4f8655ec8471e1b..9225aaf9e5d2e4897e1c8a545ff92e4eeb5a69fb 100644 (file)
@@ -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 88bb9d12dec59934428dda50333cc81460c00736..ee9f960057cac01127b3a8500f4a40ab142759cf 100644 (file)
@@ -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