Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

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

Issue 2522543008: Merged: Squashed multiple commits. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/regress/regress-crbug-667689.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler/js-typed-lowering.h" 5 #include "src/compiler/js-typed-lowering.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 Node* control = graph()->start(); 824 Node* control = graph()->start();
825 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hint), lhs, rhs, 825 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hint), lhs, rhs,
826 context, frame_state, effect, control)); 826 context, frame_state, effect, control));
827 ASSERT_TRUE(r.Changed()); 827 ASSERT_TRUE(r.Changed());
828 EXPECT_THAT(r.replacement(), 828 EXPECT_THAT(r.replacement(),
829 IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall, 829 IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall,
830 lhs, rhs, effect, control)); 830 lhs, rhs, effect, control));
831 } 831 }
832 832
833 // ----------------------------------------------------------------------------- 833 // -----------------------------------------------------------------------------
834 // JSInstanceOf
835 // Test that instanceOf is reduced if and only if the right-hand side is a
836 // function constant. Functional correctness is ensured elsewhere.
837
838 TEST_F(JSTypedLoweringTest, JSInstanceOfSpecialization) {
839 Node* const context = Parameter(Type::Any());
840 Node* const frame_state = EmptyFrameState();
841 Node* const effect = graph()->start();
842 Node* const control = graph()->start();
843
844 Node* instanceOf =
845 graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Any(), 0),
846 HeapConstant(isolate()->object_function()), context,
847 frame_state, effect, control);
848 Reduction r = Reduce(instanceOf);
849 ASSERT_TRUE(r.Changed());
850 }
851
852
853 TEST_F(JSTypedLoweringTest, JSInstanceOfNoSpecialization) {
854 Node* const context = Parameter(Type::Any());
855 Node* const frame_state = EmptyFrameState();
856 Node* const effect = graph()->start();
857 Node* const control = graph()->start();
858
859 // Do not reduce if right-hand side is not a function constant.
860 Node* instanceOf = graph()->NewNode(
861 javascript()->InstanceOf(), Parameter(Type::Any(), 0),
862 Parameter(Type::Any()), context, frame_state, effect, control);
863 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
864 frame_state, effect, control);
865 Reduction r = Reduce(instanceOf);
866 ASSERT_FALSE(r.Changed());
867 ASSERT_EQ(instanceOf, dummy->InputAt(0));
868 }
869
870 // -----------------------------------------------------------------------------
871 // JSBitwiseAnd 834 // JSBitwiseAnd
872 835
873 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSignedSmallHint) { 836 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSignedSmallHint) {
874 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall; 837 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
875 Node* lhs = Parameter(Type::Number(), 2); 838 Node* lhs = Parameter(Type::Number(), 2);
876 Node* rhs = Parameter(Type::Number(), 3); 839 Node* rhs = Parameter(Type::Number(), 3);
877 Node* effect = graph()->start(); 840 Node* effect = graph()->start();
878 Node* control = graph()->start(); 841 Node* control = graph()->start();
879 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs, 842 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs,
880 rhs, UndefinedConstant(), 843 rhs, UndefinedConstant(),
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 EmptyFrameState(), effect, control)); 970 EmptyFrameState(), effect, control));
1008 ASSERT_TRUE(r.Changed()); 971 ASSERT_TRUE(r.Changed());
1009 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( 972 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor(
1010 NumberOperationHint::kNumberOrOddball, lhs, 973 NumberOperationHint::kNumberOrOddball, lhs,
1011 rhs, effect, control)); 974 rhs, effect, control));
1012 } 975 }
1013 976
1014 } // namespace compiler 977 } // namespace compiler
1015 } // namespace internal 978 } // namespace internal
1016 } // namespace v8 979 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-crbug-667689.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698