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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 EXPECT_THAT( | 867 EXPECT_THAT( |
868 r.replacement(), | 868 r.replacement(), |
869 IsStoreElement( | 869 IsStoreElement( |
870 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), | 870 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), |
871 key, value, effect, control)); | 871 key, value, effect, control)); |
872 } | 872 } |
873 } | 873 } |
874 } | 874 } |
875 | 875 |
876 | 876 |
877 TEST_F(JSTypedLoweringTest, JSLoadNamedGlobalConstants) { | 877 // ----------------------------------------------------------------------------- |
| 878 // JSLoadGlobal |
| 879 |
| 880 |
| 881 TEST_F(JSTypedLoweringTest, JSLoadGlobalConstants) { |
878 Handle<String> names[] = { | 882 Handle<String> names[] = { |
879 Handle<String>(isolate()->heap()->undefined_string(), isolate()), | 883 Handle<String>(isolate()->heap()->undefined_string(), isolate()), |
880 Handle<String>(isolate()->heap()->infinity_string(), isolate()), | 884 Handle<String>(isolate()->heap()->infinity_string(), isolate()), |
881 Handle<String>(isolate()->heap()->nan_string(), isolate()) // -- | 885 Handle<String>(isolate()->heap()->nan_string(), isolate()) // -- |
882 }; | 886 }; |
883 Matcher<Node*> matches[] = { | 887 Matcher<Node*> matches[] = { |
884 IsHeapConstant(Unique<HeapObject>::CreateImmovable( | 888 IsHeapConstant(Unique<HeapObject>::CreateImmovable( |
885 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()))), | 889 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()))), |
886 IsNumberConstant(std::numeric_limits<double>::infinity()), | 890 IsNumberConstant(std::numeric_limits<double>::infinity()), |
887 IsNumberConstant(IsNaN()) // -- | 891 IsNumberConstant(IsNaN()) // -- |
(...skipping 12 matching lines...) Expand all Loading... |
900 javascript()->LoadGlobal(name, feedback), global, vector, context, | 904 javascript()->LoadGlobal(name, feedback), global, vector, context, |
901 EmptyFrameState(), EmptyFrameState(), effect, control)); | 905 EmptyFrameState(), EmptyFrameState(), effect, control)); |
902 | 906 |
903 ASSERT_TRUE(r.Changed()); | 907 ASSERT_TRUE(r.Changed()); |
904 EXPECT_THAT(r.replacement(), matches[i]); | 908 EXPECT_THAT(r.replacement(), matches[i]); |
905 } | 909 } |
906 } | 910 } |
907 | 911 |
908 | 912 |
909 // ----------------------------------------------------------------------------- | 913 // ----------------------------------------------------------------------------- |
| 914 // JSLoadNamed |
| 915 |
| 916 |
| 917 TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) { |
| 918 VectorSlotPair feedback; |
| 919 Unique<Name> name = Unique<Name>::CreateImmovable(factory()->length_string()); |
| 920 Node* const receiver = Parameter(Type::String(), 0); |
| 921 Node* const vector = Parameter(Type::Internal(), 1); |
| 922 Node* const context = UndefinedConstant(); |
| 923 Node* const effect = graph()->start(); |
| 924 Node* const control = graph()->start(); |
| 925 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 926 Reduction const r = Reduce( |
| 927 graph()->NewNode(javascript()->LoadNamed(name, feedback, language_mode), |
| 928 receiver, vector, context, EmptyFrameState(), |
| 929 EmptyFrameState(), effect, control)); |
| 930 ASSERT_TRUE(r.Changed()); |
| 931 EXPECT_THAT(r.replacement(), |
| 932 IsLoadField(AccessBuilder::ForStringLength(zone()), receiver, |
| 933 effect, control)); |
| 934 } |
| 935 } |
| 936 |
| 937 |
| 938 // ----------------------------------------------------------------------------- |
910 // JSLoadDynamicGlobal | 939 // JSLoadDynamicGlobal |
911 | 940 |
912 | 941 |
913 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { | 942 TEST_F(JSTypedLoweringTest, JSLoadDynamicGlobal) { |
914 Node* const context = Parameter(Type::Any()); | 943 Node* const context = Parameter(Type::Any()); |
915 Node* const vector = UndefinedConstant(); | 944 Node* const vector = UndefinedConstant(); |
916 Node* const frame_state = EmptyFrameState(); | 945 Node* const frame_state = EmptyFrameState(); |
917 Node* const effect = graph()->start(); | 946 Node* const effect = graph()->start(); |
918 Node* const control = graph()->start(); | 947 Node* const control = graph()->start(); |
919 Handle<String> name = factory()->object_string(); | 948 Handle<String> name = factory()->object_string(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 EXPECT_THAT(r.replacement(), | 1125 EXPECT_THAT(r.replacement(), |
1097 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( | 1126 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( |
1098 Context::MIN_CONTEXT_SLOTS)), | 1127 Context::MIN_CONTEXT_SLOTS)), |
1099 effect, control), | 1128 effect, control), |
1100 _)); | 1129 _)); |
1101 } | 1130 } |
1102 | 1131 |
1103 } // namespace compiler | 1132 } // namespace compiler |
1104 } // namespace internal | 1133 } // namespace internal |
1105 } // namespace v8 | 1134 } // namespace v8 |
OLD | NEW |