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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // ES6 section 20.2.2.11 Math.clz32 ( x ) | 133 // ES6 section 20.2.2.11 Math.clz32 ( x ) |
134 Reduction JSBuiltinReducer::ReduceMathClz32(Node* node) { | 134 Reduction JSBuiltinReducer::ReduceMathClz32(Node* node) { |
135 JSCallReduction r(node); | 135 JSCallReduction r(node); |
136 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 136 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
137 // Math.clz32(a:plain-primitive) -> NumberClz32(ToUint32(a)) | 137 // Math.clz32(a:plain-primitive) -> NumberClz32(ToUint32(a)) |
138 Node* input = ToUint32(r.GetJSCallInput(0)); | 138 Node* input = ToUint32(r.GetJSCallInput(0)); |
139 Node* value = graph()->NewNode(simplified()->NumberClz32(), input); | 139 Node* value = graph()->NewNode(simplified()->NumberClz32(), input); |
140 return Replace(value); | 140 return Replace(value); |
141 } | 141 } |
142 return NoChange(); | 142 return NoChange(); |
143 } | |
144 | |
145 // ES6 section 20.2.2.14 Math.exp ( x ) | |
146 Reduction JSBuiltinReducer::ReduceMathExp(Node* node) { | |
147 JSCallReduction r(node); | |
148 if (r.InputsMatchOne(Type::PlainPrimitive())) { | |
149 // Math.exp(a:plain-primitive) -> NumberExp(ToNumber(a)) | |
150 Node* input = ToNumber(r.GetJSCallInput(0)); | |
151 Node* value = graph()->NewNode(simplified()->NumberExp(), input); | |
152 return Replace(value); | |
153 } | |
154 return NoChange(); | |
155 } | 143 } |
156 | 144 |
157 // ES6 section 20.2.2.16 Math.floor ( x ) | 145 // ES6 section 20.2.2.16 Math.floor ( x ) |
158 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { | 146 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { |
159 JSCallReduction r(node); | 147 JSCallReduction r(node); |
160 if (r.InputsMatchOne(Type::PlainPrimitive())) { | 148 if (r.InputsMatchOne(Type::PlainPrimitive())) { |
161 // Math.floor(a:plain-primitive) -> NumberFloor(ToNumber(a)) | 149 // Math.floor(a:plain-primitive) -> NumberFloor(ToNumber(a)) |
162 Node* input = ToNumber(r.GetJSCallInput(0)); | 150 Node* input = ToNumber(r.GetJSCallInput(0)); |
163 Node* value = graph()->NewNode(simplified()->NumberFloor(), input); | 151 Node* value = graph()->NewNode(simplified()->NumberFloor(), input); |
164 return Replace(value); | 152 return Replace(value); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 break; | 341 break; |
354 case kMathAtan2: | 342 case kMathAtan2: |
355 reduction = ReduceMathAtan2(node); | 343 reduction = ReduceMathAtan2(node); |
356 break; | 344 break; |
357 case kMathClz32: | 345 case kMathClz32: |
358 reduction = ReduceMathClz32(node); | 346 reduction = ReduceMathClz32(node); |
359 break; | 347 break; |
360 case kMathCeil: | 348 case kMathCeil: |
361 reduction = ReduceMathCeil(node); | 349 reduction = ReduceMathCeil(node); |
362 break; | 350 break; |
363 case kMathExp: | |
364 reduction = ReduceMathExp(node); | |
365 break; | |
366 case kMathFloor: | 351 case kMathFloor: |
367 reduction = ReduceMathFloor(node); | 352 reduction = ReduceMathFloor(node); |
368 break; | 353 break; |
369 case kMathFround: | 354 case kMathFround: |
370 reduction = ReduceMathFround(node); | 355 reduction = ReduceMathFround(node); |
371 break; | 356 break; |
372 case kMathImul: | 357 case kMathImul: |
373 reduction = ReduceMathImul(node); | 358 reduction = ReduceMathImul(node); |
374 break; | 359 break; |
375 case kMathLog: | 360 case kMathLog: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 422 } |
438 | 423 |
439 | 424 |
440 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 425 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
441 return jsgraph()->simplified(); | 426 return jsgraph()->simplified(); |
442 } | 427 } |
443 | 428 |
444 } // namespace compiler | 429 } // namespace compiler |
445 } // namespace internal | 430 } // namespace internal |
446 } // namespace v8 | 431 } // namespace v8 |
OLD | NEW |