| 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.exp | |
| 268 | |
| 269 TEST_F(JSBuiltinReducerTest, MathExpWithNumber) { | |
| 270 Node* function = MathFunction("exp"); | |
| 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(), IsNumberExp(p0)); | |
| 285 } | |
| 286 } | |
| 287 | |
| 288 TEST_F(JSBuiltinReducerTest, MathExpWithPlainPrimitive) { | |
| 289 Node* function = MathFunction("exp"); | |
| 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(), IsNumberExp(IsPlainPrimitiveToNumber(p0))); | |
| 303 } | |
| 304 | |
| 305 // ----------------------------------------------------------------------------- | |
| 306 // Math.floor | 267 // Math.floor |
| 307 | 268 |
| 308 TEST_F(JSBuiltinReducerTest, MathFloorWithNumber) { | 269 TEST_F(JSBuiltinReducerTest, MathFloorWithNumber) { |
| 309 Node* function = MathFunction("floor"); | 270 Node* function = MathFunction("floor"); |
| 310 | 271 |
| 311 Node* effect = graph()->start(); | 272 Node* effect = graph()->start(); |
| 312 Node* control = graph()->start(); | 273 Node* control = graph()->start(); |
| 313 Node* context = UndefinedConstant(); | 274 Node* context = UndefinedConstant(); |
| 314 Node* frame_state = graph()->start(); | 275 Node* frame_state = graph()->start(); |
| 315 TRACED_FOREACH(Type*, t0, kNumberTypes) { | 276 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 Reduction r = Reduce(call); | 788 Reduction r = Reduce(call); |
| 828 | 789 |
| 829 ASSERT_TRUE(r.Changed()); | 790 ASSERT_TRUE(r.Changed()); |
| 830 EXPECT_THAT(r.replacement(), | 791 EXPECT_THAT(r.replacement(), |
| 831 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); | 792 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); |
| 832 } | 793 } |
| 833 | 794 |
| 834 } // namespace compiler | 795 } // namespace compiler |
| 835 } // namespace internal | 796 } // namespace internal |
| 836 } // namespace v8 | 797 } // namespace v8 |
| OLD | NEW |