| Index: src/compiler/js-builtin-reducer.cc
|
| diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc
|
| index 6d175780aa5485c1864187545d89b9f35703b73a..81d63924e1c4db8e0e63efa779a3def1d536c82f 100644
|
| --- a/src/compiler/js-builtin-reducer.cc
|
| +++ b/src/compiler/js-builtin-reducer.cc
|
| @@ -91,6 +91,18 @@ JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph)
|
| jsgraph_(jsgraph),
|
| type_cache_(TypeCache::Get()) {}
|
|
|
| +// ES6 section 20.2.2.1 Math.abs ( x )
|
| +Reduction JSBuiltinReducer::ReduceMathAbs(Node* node) {
|
| + JSCallReduction r(node);
|
| + if (r.InputsMatchOne(Type::PlainPrimitive())) {
|
| + // Math.abs(a:plain-primitive) -> NumberAbs(ToNumber(a))
|
| + Node* input = ToNumber(r.GetJSCallInput(0));
|
| + Node* value = graph()->NewNode(simplified()->NumberAbs(), input);
|
| + return Replace(value);
|
| + }
|
| + return NoChange();
|
| +}
|
| +
|
| // ES6 section 20.2.2.6 Math.atan ( x )
|
| Reduction JSBuiltinReducer::ReduceMathAtan(Node* node) {
|
| JSCallReduction r(node);
|
| @@ -417,6 +429,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
|
| // Dispatch according to the BuiltinFunctionId if present.
|
| if (!r.HasBuiltinFunctionId()) return NoChange();
|
| switch (r.GetBuiltinFunctionId()) {
|
| + case kMathAbs:
|
| + reduction = ReduceMathAbs(node);
|
| + break;
|
| case kMathAtan:
|
| reduction = ReduceMathAtan(node);
|
| break;
|
|
|