Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index b40288d5a92eb74f0fdf2eab2a558ee00ed0a7e6..dbaa2930046b3039b3499841f7b3cbfb0c1480e8 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -191,6 +191,32 @@ Reduction JSBuiltinReducer::ReduceMathFround(Node* node) { |
} |
+// ES6 draft 10-14-14, section 20.2.2.16. |
+Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { |
+ if (!machine()->HasFloat64Floor()) return NoChange(); |
+ JSCallReduction r(node); |
+ if (r.InputsMatchOne(Type::Number())) { |
+ // Math.floor(a:number) -> Float64Floor(a) |
+ Node* value = graph()->NewNode(machine()->Float64Floor(), r.left()); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
+ |
+// ES6 draft 10-14-14, section 20.2.2.10. |
+Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) { |
+ if (!machine()->HasFloat64Ceil()) return NoChange(); |
+ JSCallReduction r(node); |
+ if (r.InputsMatchOne(Type::Number())) { |
+ // Math.ceil(a:number) -> Float64Ceil(a) |
+ Node* value = graph()->NewNode(machine()->Float64Ceil(), r.left()); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
+ |
Reduction JSBuiltinReducer::Reduce(Node* node) { |
JSCallReduction r(node); |
@@ -207,6 +233,10 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
return ReplaceWithPureReduction(node, ReduceMathImul(node)); |
case kMathFround: |
return ReplaceWithPureReduction(node, ReduceMathFround(node)); |
+ case kMathFloor: |
+ return ReplaceWithPureReduction(node, ReduceMathFloor(node)); |
+ case kMathCeil: |
+ return ReplaceWithPureReduction(node, ReduceMathCeil(node)); |
default: |
break; |
} |