| 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/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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 receiver, effect, control)); | 816 receiver, effect, control)); |
| 817 } | 817 } |
| 818 | 818 |
| 819 | 819 |
| 820 // ----------------------------------------------------------------------------- | 820 // ----------------------------------------------------------------------------- |
| 821 // JSAdd | 821 // JSAdd |
| 822 | 822 |
| 823 | 823 |
| 824 TEST_F(JSTypedLoweringTest, JSAddWithString) { | 824 TEST_F(JSTypedLoweringTest, JSAddWithString) { |
| 825 BinaryOperationHints const hints = BinaryOperationHints::Any(); | 825 BinaryOperationHints const hints = BinaryOperationHints::Any(); |
| 826 Node* lhs = Parameter(Type::String(), 0); | 826 Node* lhs = Parameter(Type::String(), 0); |
| 827 Node* rhs = Parameter(Type::String(), 1); | 827 Node* rhs = Parameter(Type::String(), 1); |
| 828 Node* context = Parameter(Type::Any(), 2); | 828 Node* context = Parameter(Type::Any(), 2); |
| 829 Node* frame_state = EmptyFrameState(); | 829 Node* frame_state = EmptyFrameState(); |
| 830 Node* effect = graph()->start(); | 830 Node* effect = graph()->start(); |
| 831 Node* control = graph()->start(); | 831 Node* control = graph()->start(); |
| 832 Reduction r = | 832 Reduction r = Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, |
| 833 Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, context, | 833 context, frame_state, effect, control)); |
| 834 frame_state, effect, control)); | 834 ASSERT_TRUE(r.Changed()); |
| 835 ASSERT_TRUE(r.Changed()); | 835 EXPECT_THAT(r.replacement(), |
| 836 EXPECT_THAT(r.replacement(), | 836 IsCall(_, IsHeapConstant( |
| 837 IsCall(_, IsHeapConstant( | 837 CodeFactory::StringAdd( |
| 838 CodeFactory::StringAdd( | 838 isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED) |
| 839 isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED) | 839 .code()), |
| 840 .code()), | 840 lhs, rhs, context, frame_state, effect, control)); |
| 841 lhs, rhs, context, frame_state, effect, control)); | |
| 842 } | 841 } |
| 843 | 842 |
| 844 TEST_F(JSTypedLoweringTest, JSAddSmis) { | 843 TEST_F(JSTypedLoweringTest, JSAddSmis) { |
| 845 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, | 844 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, |
| 846 BinaryOperationHints::kSignedSmall, | 845 BinaryOperationHints::kSignedSmall, |
| 847 BinaryOperationHints::kSignedSmall); | 846 BinaryOperationHints::kSignedSmall); |
| 848 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 847 Node* lhs = Parameter(Type::Number(), 0); |
| 849 Node* lhs = Parameter(Type::Number(), 0); | 848 Node* rhs = Parameter(Type::Number(), 1); |
| 850 Node* rhs = Parameter(Type::Number(), 1); | 849 Node* context = Parameter(Type::Any(), 2); |
| 851 Node* context = Parameter(Type::Any(), 2); | 850 Node* frame_state = EmptyFrameState(); |
| 852 Node* frame_state = EmptyFrameState(); | 851 Node* effect = graph()->start(); |
| 853 Node* effect = graph()->start(); | 852 Node* control = graph()->start(); |
| 854 Node* control = graph()->start(); | 853 Reduction r = Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, |
| 855 Reduction r = | 854 context, frame_state, effect, control)); |
| 856 Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, context, | 855 ASSERT_TRUE(r.Changed()); |
| 857 frame_state, effect, control)); | 856 EXPECT_THAT(r.replacement(), |
| 858 ASSERT_TRUE(r.Changed()); | 857 IsSpeculativeNumberAdd(BinaryOperationHints::kSignedSmall, lhs, |
| 859 EXPECT_THAT(r.replacement(), | 858 rhs, effect, control)); |
| 860 IsSpeculativeNumberAdd(BinaryOperationHints::kSignedSmall, lhs, | |
| 861 rhs, effect, control)); | |
| 862 } | |
| 863 } | 859 } |
| 864 | 860 |
| 865 // ----------------------------------------------------------------------------- | 861 // ----------------------------------------------------------------------------- |
| 866 // JSSubtract | 862 // JSSubtract |
| 867 | 863 |
| 868 TEST_F(JSTypedLoweringTest, JSSubtractSmis) { | 864 TEST_F(JSTypedLoweringTest, JSSubtractSmis) { |
| 869 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, | 865 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, |
| 870 BinaryOperationHints::kSignedSmall, | 866 BinaryOperationHints::kSignedSmall, |
| 871 BinaryOperationHints::kSignedSmall); | 867 BinaryOperationHints::kSignedSmall); |
| 872 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 868 Node* lhs = Parameter(Type::Number(), 0); |
| 873 Node* lhs = Parameter(Type::Number(), 0); | 869 Node* rhs = Parameter(Type::Number(), 1); |
| 874 Node* rhs = Parameter(Type::Number(), 1); | 870 Node* context = Parameter(Type::Any(), 2); |
| 875 Node* context = Parameter(Type::Any(), 2); | 871 Node* frame_state = EmptyFrameState(); |
| 876 Node* frame_state = EmptyFrameState(); | 872 Node* effect = graph()->start(); |
| 877 Node* effect = graph()->start(); | 873 Node* control = graph()->start(); |
| 878 Node* control = graph()->start(); | 874 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hints), lhs, rhs, |
| 879 Reduction r = | 875 context, frame_state, effect, control)); |
| 880 Reduce(graph()->NewNode(javascript()->Subtract(hints), lhs, rhs, | 876 ASSERT_TRUE(r.Changed()); |
| 881 context, frame_state, effect, control)); | 877 EXPECT_THAT(r.replacement(), |
| 882 ASSERT_TRUE(r.Changed()); | 878 IsSpeculativeNumberSubtract(BinaryOperationHints::kSignedSmall, |
| 883 EXPECT_THAT(r.replacement(), | 879 lhs, rhs, effect, control)); |
| 884 IsSpeculativeNumberSubtract(BinaryOperationHints::kSignedSmall, | |
| 885 lhs, rhs, effect, control)); | |
| 886 } | |
| 887 } | 880 } |
| 888 | 881 |
| 889 // ----------------------------------------------------------------------------- | 882 // ----------------------------------------------------------------------------- |
| 890 // JSInstanceOf | 883 // JSInstanceOf |
| 891 // Test that instanceOf is reduced if and only if the right-hand side is a | 884 // Test that instanceOf is reduced if and only if the right-hand side is a |
| 892 // function constant. Functional correctness is ensured elsewhere. | 885 // function constant. Functional correctness is ensured elsewhere. |
| 893 | 886 |
| 894 | 887 |
| 895 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { | 888 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { |
| 896 Node* const context = Parameter(Type::Any()); | 889 Node* const context = Parameter(Type::Any()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, | 938 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, |
| 946 frame_state, effect, control); | 939 frame_state, effect, control); |
| 947 Reduction r = Reduce(instanceOf); | 940 Reduction r = Reduce(instanceOf); |
| 948 ASSERT_FALSE(r.Changed()); | 941 ASSERT_FALSE(r.Changed()); |
| 949 ASSERT_EQ(instanceOf, dummy->InputAt(0)); | 942 ASSERT_EQ(instanceOf, dummy->InputAt(0)); |
| 950 } | 943 } |
| 951 | 944 |
| 952 } // namespace compiler | 945 } // namespace compiler |
| 953 } // namespace internal | 946 } // namespace internal |
| 954 } // namespace v8 | 947 } // namespace v8 |
| OLD | NEW |