Chromium Code Reviews| Index: src/compiler/js-builtin-reducer.cc |
| diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
| index 063327c92e111ee4f483372d2ad37b710d038a43..75eccb72647cf5a75316841c70d1c5e1e01773b7 100644 |
| --- a/src/compiler/js-builtin-reducer.cc |
| +++ b/src/compiler/js-builtin-reducer.cc |
| @@ -103,6 +103,54 @@ Reduction JSBuiltinReducer::ReduceMathAbs(Node* node) { |
| return NoChange(); |
| } |
| +// ES6 section 20.2.2.2 Math.acos ( x ) |
| +Reduction JSBuiltinReducer::ReduceMathAcos(Node* node) { |
| + JSCallReduction r(node); |
| + if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| + // Math.acos(a:plain-primitive) -> NumberAcos(ToNumber(a)) |
| + Node* input = ToNumber(r.GetJSCallInput(0)); |
| + Node* value = graph()->NewNode(simplified()->NumberAcos(), input); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
| + |
| +// ES6 section 20.2.2.3 Math.acosh ( x ) |
| +Reduction JSBuiltinReducer::ReduceMathAcosh(Node* node) { |
| + JSCallReduction r(node); |
| + if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| + // Math.acosh(a:plain-primitive) -> NumberAcosh(ToNumber(a)) |
| + Node* input = ToNumber(r.GetJSCallInput(0)); |
| + Node* value = graph()->NewNode(simplified()->NumberAcosh(), input); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
| + |
| +// ES6 section 20.2.2.4 Math.asin ( x ) |
| +Reduction JSBuiltinReducer::ReduceMathAsin(Node* node) { |
| + JSCallReduction r(node); |
| + if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| + // Math.asin(a:plain-primitive) -> NumberAsin(ToNumber(a)) |
| + Node* input = ToNumber(r.GetJSCallInput(0)); |
| + Node* value = graph()->NewNode(simplified()->NumberAsin(), input); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
| + |
| +// ES6 section 20.2.2.5 Math.asinh ( x ) |
| +Reduction JSBuiltinReducer::ReduceMathAsinh(Node* node) { |
| + JSCallReduction r(node); |
| + if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| + // Math.asinh(a:plain-primitive) -> NumberAsinh(ToNumber(a)) |
| + Node* input = ToNumber(r.GetJSCallInput(0)); |
| + Node* value = graph()->NewNode(simplified()->NumberAsinh(), input); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
|
Franzi
2016/07/01 09:09:48
This is a lot of code duplication. Can we use a ma
Benedikt Meurer
2016/07/01 10:48:33
Not a macro, but we will unify this whole file usi
|
| + |
| // ES6 section 20.2.2.6 Math.atan ( x ) |
| Reduction JSBuiltinReducer::ReduceMathAtan(Node* node) { |
| JSCallReduction r(node); |
| @@ -115,6 +163,18 @@ Reduction JSBuiltinReducer::ReduceMathAtan(Node* node) { |
| return NoChange(); |
| } |
| +// ES6 section 20.2.2.7 Math.atanh ( x ) |
| +Reduction JSBuiltinReducer::ReduceMathAtanh(Node* node) { |
| + JSCallReduction r(node); |
| + if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| + // Math.atanh(a:plain-primitive) -> NumberAtanh(ToNumber(a)) |
| + Node* input = ToNumber(r.GetJSCallInput(0)); |
| + Node* value = graph()->NewNode(simplified()->NumberAtanh(), input); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
| + |
| // ES6 section 20.2.2.8 Math.atan2 ( y, x ) |
| Reduction JSBuiltinReducer::ReduceMathAtan2(Node* node) { |
| JSCallReduction r(node); |
| @@ -130,17 +190,6 @@ Reduction JSBuiltinReducer::ReduceMathAtan2(Node* node) { |
| return NoChange(); |
| } |
| -// ES6 section 20.2.2.7 Math.atanh ( x ) |
| -Reduction JSBuiltinReducer::ReduceMathAtanh(Node* node) { |
| - JSCallReduction r(node); |
| - if (r.InputsMatchOne(Type::Number())) { |
| - // Math.atanh(a:number) -> NumberAtanh(a) |
| - Node* value = graph()->NewNode(simplified()->NumberAtanh(), r.left()); |
| - return Replace(value); |
| - } |
| - return NoChange(); |
| -} |
| - |
| // ES6 section 20.2.2.10 Math.ceil ( x ) |
| Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) { |
| JSCallReduction r(node); |
| @@ -388,6 +437,18 @@ Reduction JSBuiltinReducer::ReduceMathCbrt(Node* node) { |
| return NoChange(); |
| } |
| +// ES6 section 20.2.2.29 Math.sign ( x ) |
| +Reduction JSBuiltinReducer::ReduceMathSign(Node* node) { |
| + JSCallReduction r(node); |
| + if (r.InputsMatchOne(Type::PlainPrimitive())) { |
| + // Math.sign(a:plain-primitive) -> NumberSign(ToNumber(a)) |
| + Node* input = ToNumber(r.GetJSCallInput(0)); |
| + Node* value = graph()->NewNode(simplified()->NumberSign(), input); |
| + return Replace(value); |
| + } |
| + return NoChange(); |
| +} |
| + |
| // ES6 section 20.2.2.30 Math.sin ( x ) |
| Reduction JSBuiltinReducer::ReduceMathSin(Node* node) { |
| JSCallReduction r(node); |
| @@ -482,15 +543,27 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
| case kMathAbs: |
| reduction = ReduceMathAbs(node); |
| break; |
| + case kMathAcos: |
| + reduction = ReduceMathAcos(node); |
| + break; |
| + case kMathAcosh: |
| + reduction = ReduceMathAcosh(node); |
| + break; |
| + case kMathAsin: |
| + reduction = ReduceMathAsin(node); |
| + break; |
| + case kMathAsinh: |
| + reduction = ReduceMathAsinh(node); |
| + break; |
| case kMathAtan: |
| reduction = ReduceMathAtan(node); |
| break; |
| - case kMathAtan2: |
| - reduction = ReduceMathAtan2(node); |
| - break; |
| case kMathAtanh: |
| reduction = ReduceMathAtanh(node); |
| break; |
| + case kMathAtan2: |
| + reduction = ReduceMathAtan2(node); |
| + break; |
| case kMathCbrt: |
| reduction = ReduceMathCbrt(node); |
| break; |
| @@ -545,6 +618,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
| case kMathRound: |
| reduction = ReduceMathRound(node); |
| break; |
| + case kMathSign: |
| + reduction = ReduceMathSign(node); |
| + break; |
| case kMathSin: |
| reduction = ReduceMathSin(node); |
| break; |