| 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 receiver, vector, context, EmptyFrameState(), | 922 receiver, vector, context, EmptyFrameState(), |
| 923 EmptyFrameState(), effect, control)); | 923 EmptyFrameState(), effect, control)); |
| 924 ASSERT_TRUE(r.Changed()); | 924 ASSERT_TRUE(r.Changed()); |
| 925 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), | 925 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), |
| 926 receiver, effect, control)); | 926 receiver, effect, control)); |
| 927 } | 927 } |
| 928 } | 928 } |
| 929 | 929 |
| 930 | 930 |
| 931 // ----------------------------------------------------------------------------- | 931 // ----------------------------------------------------------------------------- |
| 932 // JSLoadDynamicGlobal | |
| 933 | |
| 934 | |
| 935 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { | |
| 936 Node* const context = Parameter(Type::Any()); | |
| 937 Node* const vector = UndefinedConstant(); | |
| 938 Node* const frame_state = EmptyFrameState(); | |
| 939 Node* const effect = graph()->start(); | |
| 940 Node* const control = graph()->start(); | |
| 941 Handle<String> name = factory()->object_string(); | |
| 942 VectorSlotPair feedback; | |
| 943 for (int i = 0; i < DynamicGlobalAccess::kMaxCheckDepth; ++i) { | |
| 944 uint32_t bitset = 1 << i; // Only single check. | |
| 945 Reduction r = Reduce(graph()->NewNode( | |
| 946 javascript()->LoadDynamicGlobal(name, bitset, feedback, | |
| 947 NOT_INSIDE_TYPEOF), | |
| 948 vector, context, context, frame_state, frame_state, effect, control)); | |
| 949 ASSERT_TRUE(r.Changed()); | |
| 950 EXPECT_THAT( | |
| 951 r.replacement(), | |
| 952 IsPhi(kMachAnyTagged, _, _, | |
| 953 IsMerge( | |
| 954 IsIfTrue(IsBranch( | |
| 955 IsReferenceEqual( | |
| 956 Type::Tagged(), | |
| 957 IsLoadContext( | |
| 958 ContextAccess(i, Context::EXTENSION_INDEX, false), | |
| 959 context), | |
| 960 IsNumberConstant(BitEq(0.0))), | |
| 961 control)), | |
| 962 _))); | |
| 963 } | |
| 964 } | |
| 965 | |
| 966 | |
| 967 // ----------------------------------------------------------------------------- | |
| 968 // JSLoadDynamicContext | |
| 969 | |
| 970 | |
| 971 TEST_F(JSTypedLoweringTest, JSLoadDynamicContext) { | |
| 972 Node* const context = Parameter(Type::Any()); | |
| 973 Node* const frame_state = EmptyFrameState(); | |
| 974 Node* const effect = graph()->start(); | |
| 975 Node* const control = graph()->start(); | |
| 976 Handle<String> name = factory()->object_string(); | |
| 977 for (int i = 0; i < DynamicContextAccess::kMaxCheckDepth; ++i) { | |
| 978 uint32_t bitset = 1 << i; // Only single check. | |
| 979 Reduction r = Reduce( | |
| 980 graph()->NewNode(javascript()->LoadDynamicContext(name, bitset, 23, 42), | |
| 981 context, context, frame_state, effect, control)); | |
| 982 ASSERT_TRUE(r.Changed()); | |
| 983 EXPECT_THAT( | |
| 984 r.replacement(), | |
| 985 IsPhi(kMachAnyTagged, | |
| 986 IsLoadContext(ContextAccess(23, 42, false), context), _, | |
| 987 IsMerge( | |
| 988 IsIfTrue(IsBranch( | |
| 989 IsReferenceEqual( | |
| 990 Type::Tagged(), | |
| 991 IsLoadContext( | |
| 992 ContextAccess(i, Context::EXTENSION_INDEX, false), | |
| 993 context), | |
| 994 IsNumberConstant(BitEq(0.0))), | |
| 995 control)), | |
| 996 _))); | |
| 997 } | |
| 998 } | |
| 999 | |
| 1000 | |
| 1001 // ----------------------------------------------------------------------------- | |
| 1002 // JSAdd | 932 // JSAdd |
| 1003 | 933 |
| 1004 | 934 |
| 1005 TEST_F(JSTypedLoweringTest, JSAddWithString) { | 935 TEST_F(JSTypedLoweringTest, JSAddWithString) { |
| 1006 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 936 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 1007 Node* lhs = Parameter(Type::String(), 0); | 937 Node* lhs = Parameter(Type::String(), 0); |
| 1008 Node* rhs = Parameter(Type::String(), 1); | 938 Node* rhs = Parameter(Type::String(), 1); |
| 1009 Node* context = Parameter(Type::Any(), 2); | 939 Node* context = Parameter(Type::Any(), 2); |
| 1010 Node* frame_state0 = EmptyFrameState(); | 940 Node* frame_state0 = EmptyFrameState(); |
| 1011 Node* frame_state1 = EmptyFrameState(); | 941 Node* frame_state1 = EmptyFrameState(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 EXPECT_THAT(r.replacement(), | 1144 EXPECT_THAT(r.replacement(), |
| 1215 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 1145 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
| 1216 Context::MIN_CONTEXT_SLOTS)), | 1146 Context::MIN_CONTEXT_SLOTS)), |
| 1217 IsBeginRegion(effect), control), | 1147 IsBeginRegion(effect), control), |
| 1218 _)); | 1148 _)); |
| 1219 } | 1149 } |
| 1220 | 1150 |
| 1221 } // namespace compiler | 1151 } // namespace compiler |
| 1222 } // namespace internal | 1152 } // namespace internal |
| 1223 } // namespace v8 | 1153 } // namespace v8 |
| OLD | NEW |