| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_THAT(r.replacement(), IsFalseConstant()); | 184 EXPECT_THAT(r.replacement(), IsFalseConstant()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 | 187 |
| 188 TEST_F(JSTypedLoweringTest, JSUnaryNotWithString) { | 188 TEST_F(JSTypedLoweringTest, JSUnaryNotWithString) { |
| 189 Node* input = Parameter(Type::String(), 0); | 189 Node* input = Parameter(Type::String(), 0); |
| 190 Node* context = Parameter(Type::Any(), 1); | 190 Node* context = Parameter(Type::Any(), 1); |
| 191 Reduction r = Reduce(graph()->NewNode(javascript()->UnaryNot(), input, | 191 Reduction r = Reduce(graph()->NewNode(javascript()->UnaryNot(), input, |
| 192 context, graph()->start())); | 192 context, graph()->start())); |
| 193 ASSERT_TRUE(r.Changed()); | 193 ASSERT_TRUE(r.Changed()); |
| 194 EXPECT_THAT( | 194 EXPECT_THAT(r.replacement(), |
| 195 r.replacement(), | 195 IsNumberEqual(IsLoadField(AccessBuilder::ForStringLength(), input, |
| 196 IsNumberEqual(IsLoadField(AccessBuilder::ForStringLength(zone()), input, | 196 graph()->start(), graph()->start()), |
| 197 graph()->start(), graph()->start()), | 197 IsNumberConstant(0.0))); |
| 198 IsNumberConstant(0.0))); | |
| 199 } | 198 } |
| 200 | 199 |
| 201 | 200 |
| 202 TEST_F(JSTypedLoweringTest, JSUnaryNotWithAny) { | 201 TEST_F(JSTypedLoweringTest, JSUnaryNotWithAny) { |
| 203 Node* input = Parameter(Type::Any(), 0); | 202 Node* input = Parameter(Type::Any(), 0); |
| 204 Node* context = Parameter(Type::Any(), 1); | 203 Node* context = Parameter(Type::Any(), 1); |
| 205 Reduction r = Reduce(graph()->NewNode(javascript()->UnaryNot(), input, | 204 Reduction r = Reduce(graph()->NewNode(javascript()->UnaryNot(), input, |
| 206 context, graph()->start())); | 205 context, graph()->start())); |
| 207 ASSERT_FALSE(r.Changed()); | 206 ASSERT_FALSE(r.Changed()); |
| 208 } | 207 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 382 |
| 384 TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { | 383 TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { |
| 385 Node* input = Parameter(Type::String(), 0); | 384 Node* input = Parameter(Type::String(), 0); |
| 386 Node* context = Parameter(Type::Any(), 1); | 385 Node* context = Parameter(Type::Any(), 1); |
| 387 Reduction r = Reduce(graph()->NewNode(javascript()->ToBoolean(), input, | 386 Reduction r = Reduce(graph()->NewNode(javascript()->ToBoolean(), input, |
| 388 context, graph()->start())); | 387 context, graph()->start())); |
| 389 ASSERT_TRUE(r.Changed()); | 388 ASSERT_TRUE(r.Changed()); |
| 390 EXPECT_THAT( | 389 EXPECT_THAT( |
| 391 r.replacement(), | 390 r.replacement(), |
| 392 IsNumberLessThan(IsNumberConstant(0.0), | 391 IsNumberLessThan(IsNumberConstant(0.0), |
| 393 IsLoadField(AccessBuilder::ForStringLength(zone()), | 392 IsLoadField(AccessBuilder::ForStringLength(), input, |
| 394 input, graph()->start(), graph()->start()))); | 393 graph()->start(), graph()->start()))); |
| 395 } | 394 } |
| 396 | 395 |
| 397 | 396 |
| 398 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { | 397 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { |
| 399 Node* input = Parameter(Type::Any(), 0); | 398 Node* input = Parameter(Type::Any(), 0); |
| 400 Node* context = Parameter(Type::Any(), 1); | 399 Node* context = Parameter(Type::Any(), 1); |
| 401 Reduction r = Reduce(graph()->NewNode(javascript()->ToBoolean(), input, | 400 Reduction r = Reduce(graph()->NewNode(javascript()->ToBoolean(), input, |
| 402 context, graph()->start())); | 401 context, graph()->start())); |
| 403 ASSERT_FALSE(r.Changed()); | 402 ASSERT_FALSE(r.Changed()); |
| 404 } | 403 } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 Node* const vector = Parameter(Type::Internal(), 1); | 873 Node* const vector = Parameter(Type::Internal(), 1); |
| 875 Node* const context = UndefinedConstant(); | 874 Node* const context = UndefinedConstant(); |
| 876 Node* const effect = graph()->start(); | 875 Node* const effect = graph()->start(); |
| 877 Node* const control = graph()->start(); | 876 Node* const control = graph()->start(); |
| 878 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 877 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 879 Reduction const r = Reduce( | 878 Reduction const r = Reduce( |
| 880 graph()->NewNode(javascript()->LoadNamed(language_mode, name, feedback), | 879 graph()->NewNode(javascript()->LoadNamed(language_mode, name, feedback), |
| 881 receiver, vector, context, EmptyFrameState(), | 880 receiver, vector, context, EmptyFrameState(), |
| 882 EmptyFrameState(), effect, control)); | 881 EmptyFrameState(), effect, control)); |
| 883 ASSERT_TRUE(r.Changed()); | 882 ASSERT_TRUE(r.Changed()); |
| 884 EXPECT_THAT(r.replacement(), | 883 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), |
| 885 IsLoadField(AccessBuilder::ForStringLength(zone()), receiver, | 884 receiver, effect, control)); |
| 886 effect, control)); | |
| 887 } | 885 } |
| 888 } | 886 } |
| 889 | 887 |
| 890 | 888 |
| 891 // ----------------------------------------------------------------------------- | 889 // ----------------------------------------------------------------------------- |
| 892 // JSLoadDynamicGlobal | 890 // JSLoadDynamicGlobal |
| 893 | 891 |
| 894 | 892 |
| 895 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { | 893 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { |
| 896 Node* const context = Parameter(Type::Any()); | 894 Node* const context = Parameter(Type::Any()); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 EXPECT_THAT(r.replacement(), | 1106 EXPECT_THAT(r.replacement(), |
| 1109 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 1107 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
| 1110 Context::MIN_CONTEXT_SLOTS)), | 1108 Context::MIN_CONTEXT_SLOTS)), |
| 1111 IsBeginRegion(effect), control), | 1109 IsBeginRegion(effect), control), |
| 1112 _)); | 1110 _)); |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 } // namespace compiler | 1113 } // namespace compiler |
| 1116 } // namespace internal | 1114 } // namespace internal |
| 1117 } // namespace v8 | 1115 } // namespace v8 |
| OLD | NEW |