| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 UndefinedConstant(), p0, context, frame_state, | 257 UndefinedConstant(), p0, context, frame_state, |
| 258 effect, control); | 258 effect, control); |
| 259 Reduction r = Reduce(call); | 259 Reduction r = Reduce(call); |
| 260 | 260 |
| 261 ASSERT_TRUE(r.Changed()); | 261 ASSERT_TRUE(r.Changed()); |
| 262 EXPECT_THAT(r.replacement(), | 262 EXPECT_THAT(r.replacement(), |
| 263 IsNumberClz32(IsNumberToUint32(IsPlainPrimitiveToNumber(p0)))); | 263 IsNumberClz32(IsNumberToUint32(IsPlainPrimitiveToNumber(p0)))); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // ----------------------------------------------------------------------------- | 266 // ----------------------------------------------------------------------------- |
| 267 // Math.cos |
| 268 |
| 269 TEST_F(JSBuiltinReducerTest, MathCosWithNumber) { |
| 270 Node* function = MathFunction("cos"); |
| 271 |
| 272 Node* effect = graph()->start(); |
| 273 Node* control = graph()->start(); |
| 274 Node* context = UndefinedConstant(); |
| 275 Node* frame_state = graph()->start(); |
| 276 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
| 277 Node* p0 = Parameter(t0, 0); |
| 278 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, |
| 279 UndefinedConstant(), p0, context, frame_state, |
| 280 effect, control); |
| 281 Reduction r = Reduce(call); |
| 282 |
| 283 ASSERT_TRUE(r.Changed()); |
| 284 EXPECT_THAT(r.replacement(), IsNumberCos(p0)); |
| 285 } |
| 286 } |
| 287 |
| 288 TEST_F(JSBuiltinReducerTest, MathCosWithPlainPrimitive) { |
| 289 Node* function = MathFunction("cos"); |
| 290 |
| 291 Node* effect = graph()->start(); |
| 292 Node* control = graph()->start(); |
| 293 Node* context = UndefinedConstant(); |
| 294 Node* frame_state = graph()->start(); |
| 295 Node* p0 = Parameter(Type::PlainPrimitive(), 0); |
| 296 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, |
| 297 UndefinedConstant(), p0, context, frame_state, |
| 298 effect, control); |
| 299 Reduction r = Reduce(call); |
| 300 |
| 301 ASSERT_TRUE(r.Changed()); |
| 302 EXPECT_THAT(r.replacement(), IsNumberCos(IsPlainPrimitiveToNumber(p0))); |
| 303 } |
| 304 |
| 305 // ----------------------------------------------------------------------------- |
| 267 // Math.exp | 306 // Math.exp |
| 268 | 307 |
| 269 TEST_F(JSBuiltinReducerTest, MathExpWithNumber) { | 308 TEST_F(JSBuiltinReducerTest, MathExpWithNumber) { |
| 270 Node* function = MathFunction("exp"); | 309 Node* function = MathFunction("exp"); |
| 271 | 310 |
| 272 Node* effect = graph()->start(); | 311 Node* effect = graph()->start(); |
| 273 Node* control = graph()->start(); | 312 Node* control = graph()->start(); |
| 274 Node* context = UndefinedConstant(); | 313 Node* context = UndefinedConstant(); |
| 275 Node* frame_state = graph()->start(); | 314 Node* frame_state = graph()->start(); |
| 276 TRACED_FOREACH(Type*, t0, kNumberTypes) { | 315 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 Reduction r = Reduce(call); | 866 Reduction r = Reduce(call); |
| 828 | 867 |
| 829 ASSERT_TRUE(r.Changed()); | 868 ASSERT_TRUE(r.Changed()); |
| 830 EXPECT_THAT(r.replacement(), | 869 EXPECT_THAT(r.replacement(), |
| 831 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); | 870 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); |
| 832 } | 871 } |
| 833 | 872 |
| 834 } // namespace compiler | 873 } // namespace compiler |
| 835 } // namespace internal | 874 } // namespace internal |
| 836 } // namespace v8 | 875 } // namespace v8 |
| OLD | NEW |