OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 Reduction JSBuiltinReducer::ReduceMathLog(Node* node) { | 187 Reduction JSBuiltinReducer::ReduceMathLog(Node* node) { |
188 JSCallReduction r(node); | 188 JSCallReduction r(node); |
189 if (r.InputsMatchOne(Type::Number())) { | 189 if (r.InputsMatchOne(Type::Number())) { |
190 // Math.log(a:number) -> NumberLog(a) | 190 // Math.log(a:number) -> NumberLog(a) |
191 Node* value = graph()->NewNode(simplified()->NumberLog(), r.left()); | 191 Node* value = graph()->NewNode(simplified()->NumberLog(), r.left()); |
192 return Replace(value); | 192 return Replace(value); |
193 } | 193 } |
194 return NoChange(); | 194 return NoChange(); |
195 } | 195 } |
196 | 196 |
| 197 // ES6 section 20.2.2.21 Math.log1p ( x ) |
| 198 Reduction JSBuiltinReducer::ReduceMathLog1p(Node* node) { |
| 199 JSCallReduction r(node); |
| 200 if (r.InputsMatchOne(Type::Number())) { |
| 201 // Math.log1p(a:number) -> NumberLog1p(a) |
| 202 Node* value = graph()->NewNode(simplified()->NumberLog1p(), r.left()); |
| 203 return Replace(value); |
| 204 } |
| 205 return NoChange(); |
| 206 } |
| 207 |
197 // ES6 section 20.2.2.28 Math.round ( x ) | 208 // ES6 section 20.2.2.28 Math.round ( x ) |
198 Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { | 209 Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { |
199 JSCallReduction r(node); | 210 JSCallReduction r(node); |
200 if (r.InputsMatchOne(Type::Number())) { | 211 if (r.InputsMatchOne(Type::Number())) { |
201 // Math.round(a:number) -> NumberRound(a) | 212 // Math.round(a:number) -> NumberRound(a) |
202 Node* value = graph()->NewNode(simplified()->NumberRound(), r.left()); | 213 Node* value = graph()->NewNode(simplified()->NumberRound(), r.left()); |
203 return Replace(value); | 214 return Replace(value); |
204 } | 215 } |
205 return NoChange(); | 216 return NoChange(); |
206 } | 217 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 break; | 271 break; |
261 case kMathFloor: | 272 case kMathFloor: |
262 reduction = ReduceMathFloor(node); | 273 reduction = ReduceMathFloor(node); |
263 break; | 274 break; |
264 case kMathFround: | 275 case kMathFround: |
265 reduction = ReduceMathFround(node); | 276 reduction = ReduceMathFround(node); |
266 break; | 277 break; |
267 case kMathLog: | 278 case kMathLog: |
268 reduction = ReduceMathLog(node); | 279 reduction = ReduceMathLog(node); |
269 break; | 280 break; |
| 281 case kMathLog1p: |
| 282 reduction = ReduceMathLog1p(node); |
| 283 break; |
270 case kMathRound: | 284 case kMathRound: |
271 reduction = ReduceMathRound(node); | 285 reduction = ReduceMathRound(node); |
272 break; | 286 break; |
273 case kMathSqrt: | 287 case kMathSqrt: |
274 reduction = ReduceMathSqrt(node); | 288 reduction = ReduceMathSqrt(node); |
275 break; | 289 break; |
276 case kMathTrunc: | 290 case kMathTrunc: |
277 reduction = ReduceMathTrunc(node); | 291 reduction = ReduceMathTrunc(node); |
278 break; | 292 break; |
279 case kStringFromCharCode: | 293 case kStringFromCharCode: |
(...skipping 27 matching lines...) Expand all Loading... |
307 } | 321 } |
308 | 322 |
309 | 323 |
310 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 324 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
311 return jsgraph()->simplified(); | 325 return jsgraph()->simplified(); |
312 } | 326 } |
313 | 327 |
314 } // namespace compiler | 328 } // namespace compiler |
315 } // namespace internal | 329 } // namespace internal |
316 } // namespace v8 | 330 } // namespace v8 |
OLD | NEW |