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-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 UndefinedConstant(), p0, context, frame_state, | 196 UndefinedConstant(), p0, context, frame_state, |
197 effect, control); | 197 effect, control); |
198 Reduction r = Reduce(call); | 198 Reduction r = Reduce(call); |
199 | 199 |
200 ASSERT_TRUE(r.Changed()); | 200 ASSERT_TRUE(r.Changed()); |
201 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); | 201 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 // ----------------------------------------------------------------------------- | 205 // ----------------------------------------------------------------------------- |
| 206 // Math.atan |
| 207 |
| 208 TEST_F(JSBuiltinReducerTest, MathAtan) { |
| 209 Node* function = MathFunction("atan"); |
| 210 |
| 211 Node* effect = graph()->start(); |
| 212 Node* control = graph()->start(); |
| 213 Node* context = UndefinedConstant(); |
| 214 Node* frame_state = graph()->start(); |
| 215 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
| 216 Node* p0 = Parameter(t0, 0); |
| 217 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, |
| 218 UndefinedConstant(), p0, context, frame_state, |
| 219 effect, control); |
| 220 Reduction r = Reduce(call); |
| 221 |
| 222 ASSERT_TRUE(r.Changed()); |
| 223 EXPECT_THAT(r.replacement(), IsNumberAtan(p0)); |
| 224 } |
| 225 } |
| 226 |
| 227 // ----------------------------------------------------------------------------- |
| 228 // Math.atan2 |
| 229 |
| 230 TEST_F(JSBuiltinReducerTest, MathAtan2) { |
| 231 Node* function = MathFunction("atan2"); |
| 232 |
| 233 Node* effect = graph()->start(); |
| 234 Node* control = graph()->start(); |
| 235 Node* context = UndefinedConstant(); |
| 236 Node* frame_state = graph()->start(); |
| 237 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
| 238 Node* p0 = Parameter(t0, 0); |
| 239 TRACED_FOREACH(Type*, t1, kNumberTypes) { |
| 240 Node* p1 = Parameter(t1, 0); |
| 241 Node* call = graph()->NewNode(javascript()->CallFunction(4), function, |
| 242 UndefinedConstant(), p0, p1, context, |
| 243 frame_state, effect, control); |
| 244 Reduction r = Reduce(call); |
| 245 |
| 246 ASSERT_TRUE(r.Changed()); |
| 247 EXPECT_THAT(r.replacement(), IsNumberAtan2(p0, p1)); |
| 248 } |
| 249 } |
| 250 } |
| 251 |
| 252 // ----------------------------------------------------------------------------- |
206 // Math.log | 253 // Math.log |
207 | 254 |
208 TEST_F(JSBuiltinReducerTest, MathLog) { | 255 TEST_F(JSBuiltinReducerTest, MathLog) { |
209 Node* function = MathFunction("log"); | 256 Node* function = MathFunction("log"); |
210 | 257 |
211 Node* effect = graph()->start(); | 258 Node* effect = graph()->start(); |
212 Node* control = graph()->start(); | 259 Node* control = graph()->start(); |
213 Node* context = UndefinedConstant(); | 260 Node* context = UndefinedConstant(); |
214 Node* frame_state = graph()->start(); | 261 Node* frame_state = graph()->start(); |
215 TRACED_FOREACH(Type*, t0, kNumberTypes) { | 262 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 Reduction r = Reduce(call); | 311 Reduction r = Reduce(call); |
265 | 312 |
266 ASSERT_TRUE(r.Changed()); | 313 ASSERT_TRUE(r.Changed()); |
267 EXPECT_THAT(r.replacement(), IsStringFromCharCode(p0)); | 314 EXPECT_THAT(r.replacement(), IsStringFromCharCode(p0)); |
268 } | 315 } |
269 } | 316 } |
270 | 317 |
271 } // namespace compiler | 318 } // namespace compiler |
272 } // namespace internal | 319 } // namespace internal |
273 } // namespace v8 | 320 } // namespace v8 |
OLD | NEW |