| 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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 Node* frame_state0 = EmptyFrameState(); | 851 Node* frame_state0 = EmptyFrameState(); |
| 852 Node* frame_state1 = EmptyFrameState(); | 852 Node* frame_state1 = EmptyFrameState(); |
| 853 Node* effect = graph()->start(); | 853 Node* effect = graph()->start(); |
| 854 Node* control = graph()->start(); | 854 Node* control = graph()->start(); |
| 855 Reduction r = | 855 Reduction r = |
| 856 Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, context, | 856 Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, context, |
| 857 frame_state0, frame_state1, effect, control)); | 857 frame_state0, frame_state1, effect, control)); |
| 858 ASSERT_TRUE(r.Changed()); | 858 ASSERT_TRUE(r.Changed()); |
| 859 EXPECT_THAT(r.replacement(), | 859 EXPECT_THAT(r.replacement(), |
| 860 IsSpeculativeNumberAdd(BinaryOperationHints::kSignedSmall, lhs, | 860 IsSpeculativeNumberAdd(BinaryOperationHints::kSignedSmall, lhs, |
| 861 rhs, frame_state1, effect, control)); | 861 rhs, effect, control)); |
| 862 } | 862 } |
| 863 } | 863 } |
| 864 | 864 |
| 865 // ----------------------------------------------------------------------------- | 865 // ----------------------------------------------------------------------------- |
| 866 // JSSubtract | 866 // JSSubtract |
| 867 | 867 |
| 868 TEST_F(JSTypedLoweringTest, JSSubtractSmis) { | 868 TEST_F(JSTypedLoweringTest, JSSubtractSmis) { |
| 869 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, | 869 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, |
| 870 BinaryOperationHints::kSignedSmall, | 870 BinaryOperationHints::kSignedSmall, |
| 871 BinaryOperationHints::kSignedSmall); | 871 BinaryOperationHints::kSignedSmall); |
| 872 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 872 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 873 Node* lhs = Parameter(Type::Number(), 0); | 873 Node* lhs = Parameter(Type::Number(), 0); |
| 874 Node* rhs = Parameter(Type::Number(), 1); | 874 Node* rhs = Parameter(Type::Number(), 1); |
| 875 Node* context = Parameter(Type::Any(), 2); | 875 Node* context = Parameter(Type::Any(), 2); |
| 876 Node* frame_state0 = EmptyFrameState(); | 876 Node* frame_state0 = EmptyFrameState(); |
| 877 Node* frame_state1 = EmptyFrameState(); | 877 Node* frame_state1 = EmptyFrameState(); |
| 878 Node* effect = graph()->start(); | 878 Node* effect = graph()->start(); |
| 879 Node* control = graph()->start(); | 879 Node* control = graph()->start(); |
| 880 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hints), lhs, | 880 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hints), lhs, |
| 881 rhs, context, frame_state0, | 881 rhs, context, frame_state0, |
| 882 frame_state1, effect, control)); | 882 frame_state1, effect, control)); |
| 883 ASSERT_TRUE(r.Changed()); | 883 ASSERT_TRUE(r.Changed()); |
| 884 EXPECT_THAT(r.replacement(), IsSpeculativeNumberSubtract( | 884 EXPECT_THAT(r.replacement(), |
| 885 BinaryOperationHints::kSignedSmall, lhs, | 885 IsSpeculativeNumberSubtract(BinaryOperationHints::kSignedSmall, |
| 886 rhs, frame_state1, effect, control)); | 886 lhs, rhs, effect, control)); |
| 887 } | 887 } |
| 888 } | 888 } |
| 889 | 889 |
| 890 // ----------------------------------------------------------------------------- | 890 // ----------------------------------------------------------------------------- |
| 891 // JSInstanceOf | 891 // JSInstanceOf |
| 892 // Test that instanceOf is reduced if and only if the right-hand side is a | 892 // Test that instanceOf is reduced if and only if the right-hand side is a |
| 893 // function constant. Functional correctness is ensured elsewhere. | 893 // function constant. Functional correctness is ensured elsewhere. |
| 894 | 894 |
| 895 | 895 |
| 896 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { | 896 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecializationWithoutSmiCheck) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, | 946 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, |
| 947 frame_state, effect, control); | 947 frame_state, effect, control); |
| 948 Reduction r = Reduce(instanceOf); | 948 Reduction r = Reduce(instanceOf); |
| 949 ASSERT_FALSE(r.Changed()); | 949 ASSERT_FALSE(r.Changed()); |
| 950 ASSERT_EQ(instanceOf, dummy->InputAt(0)); | 950 ASSERT_EQ(instanceOf, dummy->InputAt(0)); |
| 951 } | 951 } |
| 952 | 952 |
| 953 } // namespace compiler | 953 } // namespace compiler |
| 954 } // namespace internal | 954 } // namespace internal |
| 955 } // namespace v8 | 955 } // namespace v8 |
| OLD | NEW |