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/simplified-operator.h" | 5 #include "src/compiler/simplified-operator.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/simplified-operator-reducer.h" | 9 #include "src/compiler/simplified-operator-reducer.h" |
10 #include "src/compiler/types.h" | 10 #include "src/compiler/types.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 factory()->species_symbol(), factory()->undefined_value()}; | 371 factory()->species_symbol(), factory()->undefined_value()}; |
372 TRACED_FOREACH(Handle<HeapObject>, object, kHeapObjects) { | 372 TRACED_FOREACH(Handle<HeapObject>, object, kHeapObjects) { |
373 Node* value = HeapConstant(object); | 373 Node* value = HeapConstant(object); |
374 Reduction reduction = Reduce(graph()->NewNode( | 374 Reduction reduction = Reduce(graph()->NewNode( |
375 simplified()->CheckTaggedPointer(), value, effect, control)); | 375 simplified()->CheckTaggedPointer(), value, effect, control)); |
376 ASSERT_TRUE(reduction.Changed()); | 376 ASSERT_TRUE(reduction.Changed()); |
377 EXPECT_EQ(value, reduction.replacement()); | 377 EXPECT_EQ(value, reduction.replacement()); |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
| 381 TEST_F(SimplifiedOperatorReducerTest, |
| 382 CheckTaggedPointerWithCheckTaggedPointer) { |
| 383 Node* param0 = Parameter(0); |
| 384 Node* effect = graph()->start(); |
| 385 Node* control = graph()->start(); |
| 386 Node* value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(), |
| 387 param0, effect, control); |
| 388 Reduction reduction = Reduce(graph()->NewNode( |
| 389 simplified()->CheckTaggedPointer(), value, effect, control)); |
| 390 ASSERT_TRUE(reduction.Changed()); |
| 391 EXPECT_EQ(value, reduction.replacement()); |
| 392 } |
| 393 |
381 // ----------------------------------------------------------------------------- | 394 // ----------------------------------------------------------------------------- |
382 // CheckTaggedSigned | 395 // CheckTaggedSigned |
383 | 396 |
384 TEST_F(SimplifiedOperatorReducerTest, | 397 TEST_F(SimplifiedOperatorReducerTest, |
385 CheckTaggedSignedWithChangeInt31ToTaggedSigned) { | 398 CheckTaggedSignedWithChangeInt31ToTaggedSigned) { |
386 Node* param0 = Parameter(0); | 399 Node* param0 = Parameter(0); |
387 Node* effect = graph()->start(); | 400 Node* effect = graph()->start(); |
388 Node* control = graph()->start(); | 401 Node* control = graph()->start(); |
389 Node* value = | 402 Node* value = |
390 graph()->NewNode(simplified()->ChangeInt31ToTaggedSigned(), param0); | 403 graph()->NewNode(simplified()->ChangeInt31ToTaggedSigned(), param0); |
391 Reduction reduction = Reduce(graph()->NewNode( | 404 Reduction reduction = Reduce(graph()->NewNode( |
392 simplified()->CheckTaggedSigned(), value, effect, control)); | 405 simplified()->CheckTaggedSigned(), value, effect, control)); |
393 ASSERT_TRUE(reduction.Changed()); | 406 ASSERT_TRUE(reduction.Changed()); |
394 EXPECT_EQ(value, reduction.replacement()); | 407 EXPECT_EQ(value, reduction.replacement()); |
395 } | 408 } |
396 | 409 |
397 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithNumberConstant) { | 410 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithNumberConstant) { |
398 Node* effect = graph()->start(); | 411 Node* effect = graph()->start(); |
399 Node* control = graph()->start(); | 412 Node* control = graph()->start(); |
400 Node* value = NumberConstant(1.0); | 413 Node* value = NumberConstant(1.0); |
401 Reduction reduction = Reduce(graph()->NewNode( | 414 Reduction reduction = Reduce(graph()->NewNode( |
402 simplified()->CheckTaggedSigned(), value, effect, control)); | 415 simplified()->CheckTaggedSigned(), value, effect, control)); |
403 ASSERT_TRUE(reduction.Changed()); | 416 ASSERT_TRUE(reduction.Changed()); |
404 EXPECT_EQ(value, reduction.replacement()); | 417 EXPECT_EQ(value, reduction.replacement()); |
405 } | 418 } |
406 | 419 |
| 420 TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithCheckTaggedSigned) { |
| 421 Node* param0 = Parameter(0); |
| 422 Node* effect = graph()->start(); |
| 423 Node* control = graph()->start(); |
| 424 Node* value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(), |
| 425 param0, effect, control); |
| 426 Reduction reduction = Reduce(graph()->NewNode( |
| 427 simplified()->CheckTaggedSigned(), value, effect, control)); |
| 428 ASSERT_TRUE(reduction.Changed()); |
| 429 EXPECT_EQ(value, reduction.replacement()); |
| 430 } |
| 431 |
407 // ----------------------------------------------------------------------------- | 432 // ----------------------------------------------------------------------------- |
408 // NumberAbs | 433 // NumberAbs |
409 | 434 |
410 TEST_F(SimplifiedOperatorReducerTest, NumberAbsWithNumberConstant) { | 435 TEST_F(SimplifiedOperatorReducerTest, NumberAbsWithNumberConstant) { |
411 TRACED_FOREACH(double, n, kFloat64Values) { | 436 TRACED_FOREACH(double, n, kFloat64Values) { |
412 Reduction reduction = | 437 Reduction reduction = |
413 Reduce(graph()->NewNode(simplified()->NumberAbs(), NumberConstant(n))); | 438 Reduce(graph()->NewNode(simplified()->NumberAbs(), NumberConstant(n))); |
414 ASSERT_TRUE(reduction.Changed()); | 439 ASSERT_TRUE(reduction.Changed()); |
415 EXPECT_THAT(reduction.replacement(), IsNumberConstant(std::fabs(n))); | 440 EXPECT_THAT(reduction.replacement(), IsNumberConstant(std::fabs(n))); |
416 } | 441 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 Reduction reduction = Reduce( | 480 Reduction reduction = Reduce( |
456 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n))); | 481 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n))); |
457 ASSERT_TRUE(reduction.Changed()); | 482 ASSERT_TRUE(reduction.Changed()); |
458 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n))); | 483 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n))); |
459 } | 484 } |
460 } | 485 } |
461 | 486 |
462 } // namespace compiler | 487 } // namespace compiler |
463 } // namespace internal | 488 } // namespace internal |
464 } // namespace v8 | 489 } // namespace v8 |
OLD | NEW |