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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 Reduction JSBuiltinReducer::ReduceMathImul(Node* node) { | 122 Reduction JSBuiltinReducer::ReduceMathImul(Node* node) { |
123 JSCallReduction r(node); | 123 JSCallReduction r(node); |
124 if (r.InputsMatchTwo(Type::Integral32(), Type::Integral32())) { | 124 if (r.InputsMatchTwo(Type::Integral32(), Type::Integral32())) { |
125 // Math.imul(a:int32, b:int32) -> Int32Mul(a, b) | 125 // Math.imul(a:int32, b:int32) -> Int32Mul(a, b) |
126 Node* value = graph()->NewNode(machine()->Int32Mul(), r.left(), r.right()); | 126 Node* value = graph()->NewNode(machine()->Int32Mul(), r.left(), r.right()); |
127 return Replace(value); | 127 return Replace(value); |
128 } | 128 } |
129 return NoChange(); | 129 return NoChange(); |
130 } | 130 } |
131 | 131 |
| 132 // ES6 draft 08-24-14, section 20.2.2.16. |
| 133 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { |
| 134 JSCallReduction r(node); |
| 135 if (r.InputsMatchOne(Type::Number()) && |
| 136 machine()->Float64RoundDown().IsSupported()) { |
| 137 // Math.floor(a:number) -> Float64RoundDown(a) |
| 138 Node* value = |
| 139 graph()->NewNode(machine()->Float64RoundDown().op(), r.left()); |
| 140 return Replace(value); |
| 141 } |
| 142 return NoChange(); |
| 143 } |
132 | 144 |
133 // ES6 draft 08-24-14, section 20.2.2.17. | 145 // ES6 draft 08-24-14, section 20.2.2.17. |
134 Reduction JSBuiltinReducer::ReduceMathFround(Node* node) { | 146 Reduction JSBuiltinReducer::ReduceMathFround(Node* node) { |
135 JSCallReduction r(node); | 147 JSCallReduction r(node); |
136 if (r.InputsMatchOne(Type::Number())) { | 148 if (r.InputsMatchOne(Type::Number())) { |
137 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a) | 149 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a) |
138 Node* value = | 150 Node* value = |
139 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left()); | 151 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left()); |
140 return Replace(value); | 152 return Replace(value); |
141 } | 153 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 197 |
186 // Dispatch according to the BuiltinFunctionId if present. | 198 // Dispatch according to the BuiltinFunctionId if present. |
187 if (!r.HasBuiltinFunctionId()) return NoChange(); | 199 if (!r.HasBuiltinFunctionId()) return NoChange(); |
188 switch (r.GetBuiltinFunctionId()) { | 200 switch (r.GetBuiltinFunctionId()) { |
189 case kMathMax: | 201 case kMathMax: |
190 reduction = ReduceMathMax(node); | 202 reduction = ReduceMathMax(node); |
191 break; | 203 break; |
192 case kMathImul: | 204 case kMathImul: |
193 reduction = ReduceMathImul(node); | 205 reduction = ReduceMathImul(node); |
194 break; | 206 break; |
| 207 case kMathFloor: |
| 208 reduction = ReduceMathFloor(node); |
| 209 break; |
195 case kMathFround: | 210 case kMathFround: |
196 reduction = ReduceMathFround(node); | 211 reduction = ReduceMathFround(node); |
197 break; | 212 break; |
198 case kMathRound: | 213 case kMathRound: |
199 reduction = ReduceMathRound(node); | 214 reduction = ReduceMathRound(node); |
200 break; | 215 break; |
201 case kMathSqrt: | 216 case kMathSqrt: |
202 reduction = ReduceMathSqrt(node); | 217 reduction = ReduceMathSqrt(node); |
203 break; | 218 break; |
204 default: | 219 default: |
(...skipping 24 matching lines...) Expand all Loading... |
229 } | 244 } |
230 | 245 |
231 | 246 |
232 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 247 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
233 return jsgraph()->simplified(); | 248 return jsgraph()->simplified(); |
234 } | 249 } |
235 | 250 |
236 } // namespace compiler | 251 } // namespace compiler |
237 } // namespace internal | 252 } // namespace internal |
238 } // namespace v8 | 253 } // namespace v8 |
OLD | NEW |