Commit 1982186b authored by bmeurer's avatar bmeurer Committed by Commit bot

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

BUG=v8:3952
LOG=n
R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27098}
parent 39d32910
......@@ -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;
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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
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