Chromium Code Reviews

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 1693833002: Remove strong mode support from binary operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mistake. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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/code-factory.h" 5 #include "src/code-factory.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/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 405 matching lines...)
416 // JSShiftLeft 416 // JSShiftLeft
417 417
418 418
419 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { 419 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) {
420 BinaryOperationHints const hints = BinaryOperationHints::Any(); 420 BinaryOperationHints const hints = BinaryOperationHints::Any();
421 Node* const lhs = Parameter(Type::Signed32()); 421 Node* const lhs = Parameter(Type::Signed32());
422 Node* const context = UndefinedConstant(); 422 Node* const context = UndefinedConstant();
423 Node* const effect = graph()->start(); 423 Node* const effect = graph()->start();
424 Node* const control = graph()->start(); 424 Node* const control = graph()->start();
425 TRACED_FORRANGE(double, rhs, 0, 31) { 425 TRACED_FORRANGE(double, rhs, 0, 31) {
426 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 426 Reduction r = Reduce(graph()->NewNode(
427 Reduction r = Reduce( 427 javascript()->ShiftLeft(hints), lhs, NumberConstant(rhs), context,
428 graph()->NewNode(javascript()->ShiftLeft(language_mode, hints), lhs, 428 EmptyFrameState(), EmptyFrameState(), effect, control));
429 NumberConstant(rhs), context, EmptyFrameState(), 429 ASSERT_TRUE(r.Changed());
430 EmptyFrameState(), effect, control)); 430 EXPECT_THAT(r.replacement(),
431 ASSERT_TRUE(r.Changed()); 431 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs))));
432 EXPECT_THAT(r.replacement(),
433 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs))));
434 }
435 } 432 }
436 } 433 }
437 434
438 435
439 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { 436 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) {
440 BinaryOperationHints const hints = BinaryOperationHints::Any(); 437 BinaryOperationHints const hints = BinaryOperationHints::Any();
441 Node* const lhs = Parameter(Type::Signed32()); 438 Node* const lhs = Parameter(Type::Signed32());
442 Node* const rhs = Parameter(Type::Unsigned32()); 439 Node* const rhs = Parameter(Type::Unsigned32());
443 Node* const context = UndefinedConstant(); 440 Node* const context = UndefinedConstant();
444 Node* const effect = graph()->start(); 441 Node* const effect = graph()->start();
445 Node* const control = graph()->start(); 442 Node* const control = graph()->start();
446 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 443 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs,
447 Reduction r = Reduce(graph()->NewNode( 444 rhs, context, EmptyFrameState(),
448 javascript()->ShiftLeft(language_mode, hints), lhs, rhs, context, 445 EmptyFrameState(), effect, control));
449 EmptyFrameState(), EmptyFrameState(), effect, control)); 446 ASSERT_TRUE(r.Changed());
450 ASSERT_TRUE(r.Changed()); 447 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs));
451 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs));
452 }
453 } 448 }
454 449
455 450
456 // ----------------------------------------------------------------------------- 451 // -----------------------------------------------------------------------------
457 // JSShiftRight 452 // JSShiftRight
458 453
459 454
460 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { 455 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) {
461 BinaryOperationHints const hints = BinaryOperationHints::Any(); 456 BinaryOperationHints const hints = BinaryOperationHints::Any();
462 Node* const lhs = Parameter(Type::Signed32()); 457 Node* const lhs = Parameter(Type::Signed32());
463 Node* const context = UndefinedConstant(); 458 Node* const context = UndefinedConstant();
464 Node* const effect = graph()->start(); 459 Node* const effect = graph()->start();
465 Node* const control = graph()->start(); 460 Node* const control = graph()->start();
466 TRACED_FORRANGE(double, rhs, 0, 31) { 461 TRACED_FORRANGE(double, rhs, 0, 31) {
467 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 462 Reduction r = Reduce(graph()->NewNode(
468 Reduction r = Reduce( 463 javascript()->ShiftRight(hints), lhs, NumberConstant(rhs), context,
469 graph()->NewNode(javascript()->ShiftRight(language_mode, hints), lhs, 464 EmptyFrameState(), EmptyFrameState(), effect, control));
470 NumberConstant(rhs), context, EmptyFrameState(), 465 ASSERT_TRUE(r.Changed());
471 EmptyFrameState(), effect, control)); 466 EXPECT_THAT(r.replacement(),
472 ASSERT_TRUE(r.Changed()); 467 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs))));
473 EXPECT_THAT(r.replacement(),
474 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs))));
475 }
476 } 468 }
477 } 469 }
478 470
479 471
480 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { 472 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) {
481 BinaryOperationHints const hints = BinaryOperationHints::Any(); 473 BinaryOperationHints const hints = BinaryOperationHints::Any();
482 Node* const lhs = Parameter(Type::Signed32()); 474 Node* const lhs = Parameter(Type::Signed32());
483 Node* const rhs = Parameter(Type::Unsigned32()); 475 Node* const rhs = Parameter(Type::Unsigned32());
484 Node* const context = UndefinedConstant(); 476 Node* const context = UndefinedConstant();
485 Node* const effect = graph()->start(); 477 Node* const effect = graph()->start();
486 Node* const control = graph()->start(); 478 Node* const control = graph()->start();
487 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 479 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs,
488 Reduction r = Reduce(graph()->NewNode( 480 rhs, context, EmptyFrameState(),
489 javascript()->ShiftRight(language_mode, hints), lhs, rhs, context, 481 EmptyFrameState(), effect, control));
490 EmptyFrameState(), EmptyFrameState(), effect, control)); 482 ASSERT_TRUE(r.Changed());
491 ASSERT_TRUE(r.Changed()); 483 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs));
492 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs));
493 }
494 } 484 }
495 485
496 486
497 // ----------------------------------------------------------------------------- 487 // -----------------------------------------------------------------------------
498 // JSShiftRightLogical 488 // JSShiftRightLogical
499 489
500 490
501 TEST_F(JSTypedLoweringTest, 491 TEST_F(JSTypedLoweringTest,
502 JSShiftRightLogicalWithUnsigned32AndConstant) { 492 JSShiftRightLogicalWithUnsigned32AndConstant) {
503 BinaryOperationHints const hints = BinaryOperationHints::Any(); 493 BinaryOperationHints const hints = BinaryOperationHints::Any();
504 Node* const lhs = Parameter(Type::Unsigned32()); 494 Node* const lhs = Parameter(Type::Unsigned32());
505 Node* const context = UndefinedConstant(); 495 Node* const context = UndefinedConstant();
506 Node* const effect = graph()->start(); 496 Node* const effect = graph()->start();
507 Node* const control = graph()->start(); 497 Node* const control = graph()->start();
508 TRACED_FORRANGE(double, rhs, 0, 31) { 498 TRACED_FORRANGE(double, rhs, 0, 31) {
509 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 499 Reduction r = Reduce(graph()->NewNode(
510 Reduction r = Reduce(graph()->NewNode( 500 javascript()->ShiftRightLogical(hints), lhs, NumberConstant(rhs),
511 javascript()->ShiftRightLogical(language_mode, hints), lhs, 501 context, EmptyFrameState(), EmptyFrameState(), effect, control));
512 NumberConstant(rhs), context, EmptyFrameState(), EmptyFrameState(), 502 ASSERT_TRUE(r.Changed());
513 effect, control)); 503 EXPECT_THAT(r.replacement(),
514 ASSERT_TRUE(r.Changed()); 504 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs))));
515 EXPECT_THAT(r.replacement(),
516 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs))));
517 }
518 } 505 }
519 } 506 }
520 507
521 508
522 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) { 509 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) {
523 BinaryOperationHints const hints = BinaryOperationHints::Any(); 510 BinaryOperationHints const hints = BinaryOperationHints::Any();
524 Node* const lhs = Parameter(Type::Unsigned32()); 511 Node* const lhs = Parameter(Type::Unsigned32());
525 Node* const rhs = Parameter(Type::Unsigned32()); 512 Node* const rhs = Parameter(Type::Unsigned32());
526 Node* const context = UndefinedConstant(); 513 Node* const context = UndefinedConstant();
527 Node* const effect = graph()->start(); 514 Node* const effect = graph()->start();
528 Node* const control = graph()->start(); 515 Node* const control = graph()->start();
529 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { 516 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints),
530 Reduction r = Reduce(graph()->NewNode( 517 lhs, rhs, context, EmptyFrameState(),
531 javascript()->ShiftRightLogical(language_mode, hints), lhs, rhs, 518 EmptyFrameState(), effect, control));
532 context, EmptyFrameState(), EmptyFrameState(), effect, control)); 519 ASSERT_TRUE(r.Changed());
533 ASSERT_TRUE(r.Changed()); 520 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs));
534 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs));
535 }
536 } 521 }
537 522
538 523
539 // ----------------------------------------------------------------------------- 524 // -----------------------------------------------------------------------------
540 // JSLoadContext 525 // JSLoadContext
541 526
542 527
543 TEST_F(JSTypedLoweringTest, JSLoadContext) { 528 TEST_F(JSTypedLoweringTest, JSLoadContext) {
544 Node* const context = Parameter(Type::Any()); 529 Node* const context = Parameter(Type::Any());
545 Node* const effect = graph()->start(); 530 Node* const effect = graph()->start();
(...skipping 321 matching lines...)
867 } 852 }
868 } 853 }
869 854
870 855
871 // ----------------------------------------------------------------------------- 856 // -----------------------------------------------------------------------------
872 // JSAdd 857 // JSAdd
873 858
874 859
875 TEST_F(JSTypedLoweringTest, JSAddWithString) { 860 TEST_F(JSTypedLoweringTest, JSAddWithString) {
876 BinaryOperationHints const hints = BinaryOperationHints::Any(); 861 BinaryOperationHints const hints = BinaryOperationHints::Any();
877 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
878 Node* lhs = Parameter(Type::String(), 0); 862 Node* lhs = Parameter(Type::String(), 0);
879 Node* rhs = Parameter(Type::String(), 1); 863 Node* rhs = Parameter(Type::String(), 1);
880 Node* context = Parameter(Type::Any(), 2); 864 Node* context = Parameter(Type::Any(), 2);
881 Node* frame_state0 = EmptyFrameState(); 865 Node* frame_state0 = EmptyFrameState();
882 Node* frame_state1 = EmptyFrameState(); 866 Node* frame_state1 = EmptyFrameState();
883 Node* effect = graph()->start(); 867 Node* effect = graph()->start();
884 Node* control = graph()->start(); 868 Node* control = graph()->start();
885 Reduction r = Reduce( 869 Reduction r =
886 graph()->NewNode(javascript()->Add(language_mode, hints), lhs, rhs, 870 Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, context,
887 context, frame_state0, frame_state1, effect, control)); 871 frame_state0, frame_state1, effect, control));
888 ASSERT_TRUE(r.Changed()); 872 ASSERT_TRUE(r.Changed());
889 EXPECT_THAT(r.replacement(), 873 EXPECT_THAT(r.replacement(),
890 IsCall(_, IsHeapConstant(CodeFactory::StringAdd( 874 IsCall(_, IsHeapConstant(CodeFactory::StringAdd(
891 isolate(), STRING_ADD_CHECK_NONE, 875 isolate(), STRING_ADD_CHECK_NONE,
892 NOT_TENURED).code()), 876 NOT_TENURED).code()),
893 lhs, rhs, context, frame_state0, effect, control)); 877 lhs, rhs, context, frame_state0, effect, control));
894 }
895 } 878 }
896 879
897 880
898 // ----------------------------------------------------------------------------- 881 // -----------------------------------------------------------------------------
899 // JSInstanceOf 882 // JSInstanceOf
900 // Test that instanceOf is reduced if and only if the right-hand side is a 883 // Test that instanceOf is reduced if and only if the right-hand side is a
901 // function constant. Functional correctness is ensured elsewhere. 884 // function constant. Functional correctness is ensured elsewhere.
902 885
903 886
904 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { 887 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) {
(...skipping 49 matching lines...)
954 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, 937 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
955 frame_state, effect, control); 938 frame_state, effect, control);
956 Reduction r = Reduce(instanceOf); 939 Reduction r = Reduce(instanceOf);
957 ASSERT_FALSE(r.Changed()); 940 ASSERT_FALSE(r.Changed());
958 ASSERT_EQ(instanceOf, dummy->InputAt(0)); 941 ASSERT_EQ(instanceOf, dummy->InputAt(0));
959 } 942 }
960 943
961 } // namespace compiler 944 } // namespace compiler
962 } // namespace internal 945 } // namespace internal
963 } // namespace v8 946 } // namespace v8
OLDNEW

Powered by Google App Engine