| 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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 934 |
| 935 TEST_F(JSTypedLoweringTest, JSCreateArgumentsViaStub) { | 935 TEST_F(JSTypedLoweringTest, JSCreateArgumentsViaStub) { |
| 936 Node* const closure = Parameter(Type::Any()); | 936 Node* const closure = Parameter(Type::Any()); |
| 937 Node* const context = UndefinedConstant(); | 937 Node* const context = UndefinedConstant(); |
| 938 Node* const effect = graph()->start(); | 938 Node* const effect = graph()->start(); |
| 939 Node* const control = graph()->start(); | 939 Node* const control = graph()->start(); |
| 940 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 940 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 941 Node* const frame_state = FrameState(shared, graph()->start()); | 941 Node* const frame_state = FrameState(shared, graph()->start()); |
| 942 Reduction r = Reduce( | 942 Reduction r = Reduce( |
| 943 graph()->NewNode(javascript()->CreateArguments( | 943 graph()->NewNode(javascript()->CreateArguments( |
| 944 CreateArgumentsParameters::kMappedArguments, 0), | 944 CreateArgumentsType::kMappedArguments), |
| 945 closure, context, frame_state, effect, control)); | 945 closure, context, frame_state, effect, control)); |
| 946 ASSERT_TRUE(r.Changed()); | 946 ASSERT_TRUE(r.Changed()); |
| 947 EXPECT_THAT(r.replacement(), | 947 EXPECT_THAT(r.replacement(), |
| 948 IsCall(_, IsHeapConstant(CodeFactory::ArgumentsAccess( | 948 IsCall(_, IsHeapConstant(CodeFactory::ArgumentsAccess( |
| 949 isolate(), false, false) | 949 isolate(), false, false) |
| 950 .code()), | 950 .code()), |
| 951 closure, IsNumberConstant(0), _, effect, control)); | 951 closure, IsNumberConstant(0), _, effect, control)); |
| 952 } | 952 } |
| 953 | 953 |
| 954 | 954 |
| 955 TEST_F(JSTypedLoweringTest, JSCreateArgumentsRestArrayViaStub) { | 955 TEST_F(JSTypedLoweringTest, JSCreateArgumentsRestParameterViaStub) { |
| 956 Node* const closure = Parameter(Type::Any()); | 956 Node* const closure = Parameter(Type::Any()); |
| 957 Node* const context = UndefinedConstant(); | 957 Node* const context = UndefinedConstant(); |
| 958 Node* const effect = graph()->start(); | 958 Node* const effect = graph()->start(); |
| 959 Node* const control = graph()->start(); | 959 Node* const control = graph()->start(); |
| 960 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 960 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 961 Node* const frame_state = FrameState(shared, graph()->start()); | 961 Node* const frame_state = FrameState(shared, graph()->start()); |
| 962 Reduction r = Reduce(graph()->NewNode( | 962 Reduction r = Reduce(graph()->NewNode( |
| 963 javascript()->CreateArguments(CreateArgumentsParameters::kRestArray, 0), | 963 javascript()->CreateArguments(CreateArgumentsType::kRestParameter), |
| 964 closure, context, frame_state, effect, control)); | 964 closure, context, frame_state, effect, control)); |
| 965 ASSERT_TRUE(r.Changed()); | 965 ASSERT_TRUE(r.Changed()); |
| 966 EXPECT_THAT( | 966 EXPECT_THAT( |
| 967 r.replacement(), | 967 r.replacement(), |
| 968 IsCall(_, | 968 IsCall(_, IsHeapConstant( |
| 969 IsHeapConstant(CodeFactory::RestArgumentsAccess(isolate()).code()), | 969 CodeFactory::FastNewRestParameter(isolate()).code()), |
| 970 IsNumberConstant(0), _, IsNumberConstant(0), _, effect, control)); | 970 closure, context, frame_state, effect, control)); |
| 971 } | 971 } |
| 972 | 972 |
| 973 | 973 |
| 974 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedMapped) { | 974 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedMapped) { |
| 975 Node* const closure = Parameter(Type::Any()); | 975 Node* const closure = Parameter(Type::Any()); |
| 976 Node* const context = UndefinedConstant(); | 976 Node* const context = UndefinedConstant(); |
| 977 Node* const effect = graph()->start(); | 977 Node* const effect = graph()->start(); |
| 978 Node* const control = graph()->start(); | 978 Node* const control = graph()->start(); |
| 979 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 979 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 980 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 980 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
| 981 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 981 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
| 982 Reduction r = Reduce( | 982 Reduction r = Reduce( |
| 983 graph()->NewNode(javascript()->CreateArguments( | 983 graph()->NewNode(javascript()->CreateArguments( |
| 984 CreateArgumentsParameters::kMappedArguments, 0), | 984 CreateArgumentsType::kMappedArguments), |
| 985 closure, context, frame_state_inner, effect, control)); | 985 closure, context, frame_state_inner, effect, control)); |
| 986 ASSERT_TRUE(r.Changed()); | 986 ASSERT_TRUE(r.Changed()); |
| 987 EXPECT_THAT(r.replacement(), | 987 EXPECT_THAT(r.replacement(), |
| 988 IsFinishRegion( | 988 IsFinishRegion( |
| 989 IsAllocate(IsNumberConstant(Heap::kSloppyArgumentsObjectSize), | 989 IsAllocate(IsNumberConstant(Heap::kSloppyArgumentsObjectSize), |
| 990 _, control), | 990 _, control), |
| 991 _)); | 991 _)); |
| 992 } | 992 } |
| 993 | 993 |
| 994 | 994 |
| 995 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedUnmapped) { | 995 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedUnmapped) { |
| 996 Node* const closure = Parameter(Type::Any()); | 996 Node* const closure = Parameter(Type::Any()); |
| 997 Node* const context = UndefinedConstant(); | 997 Node* const context = UndefinedConstant(); |
| 998 Node* const effect = graph()->start(); | 998 Node* const effect = graph()->start(); |
| 999 Node* const control = graph()->start(); | 999 Node* const control = graph()->start(); |
| 1000 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 1000 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 1001 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 1001 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
| 1002 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 1002 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
| 1003 Reduction r = Reduce( | 1003 Reduction r = Reduce( |
| 1004 graph()->NewNode(javascript()->CreateArguments( | 1004 graph()->NewNode(javascript()->CreateArguments( |
| 1005 CreateArgumentsParameters::kUnmappedArguments, 0), | 1005 CreateArgumentsType::kUnmappedArguments), |
| 1006 closure, context, frame_state_inner, effect, control)); | 1006 closure, context, frame_state_inner, effect, control)); |
| 1007 ASSERT_TRUE(r.Changed()); | 1007 ASSERT_TRUE(r.Changed()); |
| 1008 EXPECT_THAT(r.replacement(), | 1008 EXPECT_THAT(r.replacement(), |
| 1009 IsFinishRegion( | 1009 IsFinishRegion( |
| 1010 IsAllocate(IsNumberConstant(Heap::kStrictArgumentsObjectSize), | 1010 IsAllocate(IsNumberConstant(Heap::kStrictArgumentsObjectSize), |
| 1011 _, control), | 1011 _, control), |
| 1012 _)); | 1012 _)); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 | 1015 |
| 1016 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedRestArray) { | 1016 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedRestArray) { |
| 1017 Node* const closure = Parameter(Type::Any()); | 1017 Node* const closure = Parameter(Type::Any()); |
| 1018 Node* const context = UndefinedConstant(); | 1018 Node* const context = UndefinedConstant(); |
| 1019 Node* const effect = graph()->start(); | 1019 Node* const effect = graph()->start(); |
| 1020 Node* const control = graph()->start(); | 1020 Node* const control = graph()->start(); |
| 1021 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 1021 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 1022 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 1022 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
| 1023 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 1023 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
| 1024 Reduction r = Reduce(graph()->NewNode( | 1024 Reduction r = Reduce(graph()->NewNode( |
| 1025 javascript()->CreateArguments(CreateArgumentsParameters::kRestArray, 0), | 1025 javascript()->CreateArguments(CreateArgumentsType::kRestParameter), |
| 1026 closure, context, frame_state_inner, effect, control)); | 1026 closure, context, frame_state_inner, effect, control)); |
| 1027 ASSERT_TRUE(r.Changed()); | 1027 ASSERT_TRUE(r.Changed()); |
| 1028 EXPECT_THAT(r.replacement(), | 1028 EXPECT_THAT(r.replacement(), |
| 1029 IsFinishRegion( | 1029 IsFinishRegion( |
| 1030 IsAllocate(IsNumberConstant(JSArray::kSize), _, control), _)); | 1030 IsAllocate(IsNumberConstant(JSArray::kSize), _, control), _)); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 | 1033 |
| 1034 // ----------------------------------------------------------------------------- | 1034 // ----------------------------------------------------------------------------- |
| 1035 // JSCreateFunctionContext | 1035 // JSCreateFunctionContext |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, | 1156 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, |
| 1157 frame_state, effect, control); | 1157 frame_state, effect, control); |
| 1158 Reduction r = Reduce(instanceOf); | 1158 Reduction r = Reduce(instanceOf); |
| 1159 ASSERT_FALSE(r.Changed()); | 1159 ASSERT_FALSE(r.Changed()); |
| 1160 ASSERT_EQ(instanceOf, dummy->InputAt(0)); | 1160 ASSERT_EQ(instanceOf, dummy->InputAt(0)); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 } // namespace compiler | 1163 } // namespace compiler |
| 1164 } // namespace internal | 1164 } // namespace internal |
| 1165 } // namespace v8 | 1165 } // namespace v8 |
| OLD | NEW |