OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-create-lowering.h" | 5 #include "src/compiler/js-create-lowering.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // JSCreateArguments | 81 // JSCreateArguments |
82 | 82 |
83 TEST_F(JSCreateLoweringTest, JSCreateArgumentsViaStub) { | 83 TEST_F(JSCreateLoweringTest, JSCreateArgumentsViaStub) { |
84 Node* const closure = Parameter(Type::Any()); | 84 Node* const closure = Parameter(Type::Any()); |
85 Node* const context = UndefinedConstant(); | 85 Node* const context = UndefinedConstant(); |
86 Node* const effect = graph()->start(); | 86 Node* const effect = graph()->start(); |
87 Node* const control = graph()->start(); | 87 Node* const control = graph()->start(); |
88 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 88 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
89 Node* const frame_state = FrameState(shared, graph()->start()); | 89 Node* const frame_state = FrameState(shared, graph()->start()); |
90 Reduction r = Reduce(graph()->NewNode( | 90 Reduction r = Reduce(graph()->NewNode( |
91 javascript()->CreateArguments(CreateArgumentsType::kMappedArguments), | 91 javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments), |
92 closure, context, frame_state, effect, control)); | 92 closure, context, frame_state, effect, control)); |
93 ASSERT_TRUE(r.Changed()); | 93 ASSERT_TRUE(r.Changed()); |
94 EXPECT_THAT( | 94 EXPECT_THAT( |
95 r.replacement(), | 95 r.replacement(), |
96 IsCall(_, | 96 IsCall(_, IsHeapConstant( |
97 IsHeapConstant( | 97 CodeFactory::FastNewStrictArguments(isolate()).code()), |
98 CodeFactory::ArgumentsAccess(isolate(), false, false).code()), | 98 closure, context, frame_state, effect, control)); |
99 closure, IsNumberConstant(0), _, effect, control)); | |
100 } | 99 } |
101 | 100 |
102 TEST_F(JSCreateLoweringTest, JSCreateArgumentsRestParameterViaStub) { | 101 TEST_F(JSCreateLoweringTest, JSCreateArgumentsRestParameterViaStub) { |
103 Node* const closure = Parameter(Type::Any()); | 102 Node* const closure = Parameter(Type::Any()); |
104 Node* const context = UndefinedConstant(); | 103 Node* const context = UndefinedConstant(); |
105 Node* const effect = graph()->start(); | 104 Node* const effect = graph()->start(); |
106 Node* const control = graph()->start(); | 105 Node* const control = graph()->start(); |
107 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 106 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
108 Node* const frame_state = FrameState(shared, graph()->start()); | 107 Node* const frame_state = FrameState(shared, graph()->start()); |
109 Reduction r = Reduce(graph()->NewNode( | 108 Reduction r = Reduce(graph()->NewNode( |
(...skipping 14 matching lines...) Expand all Loading... |
124 Node* const control = graph()->start(); | 123 Node* const control = graph()->start(); |
125 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 124 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
126 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 125 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
127 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 126 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
128 Reduction r = Reduce(graph()->NewNode( | 127 Reduction r = Reduce(graph()->NewNode( |
129 javascript()->CreateArguments(CreateArgumentsType::kMappedArguments), | 128 javascript()->CreateArguments(CreateArgumentsType::kMappedArguments), |
130 closure, context, frame_state_inner, effect, control)); | 129 closure, context, frame_state_inner, effect, control)); |
131 ASSERT_TRUE(r.Changed()); | 130 ASSERT_TRUE(r.Changed()); |
132 EXPECT_THAT(r.replacement(), | 131 EXPECT_THAT(r.replacement(), |
133 IsFinishRegion( | 132 IsFinishRegion( |
134 IsAllocate(IsNumberConstant(Heap::kSloppyArgumentsObjectSize), | 133 IsAllocate(IsNumberConstant(JSSloppyArgumentsObject::kSize), |
135 _, control), | 134 _, control), |
136 _)); | 135 _)); |
137 } | 136 } |
138 | 137 |
139 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedUnmapped) { | 138 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedUnmapped) { |
140 Node* const closure = Parameter(Type::Any()); | 139 Node* const closure = Parameter(Type::Any()); |
141 Node* const context = UndefinedConstant(); | 140 Node* const context = UndefinedConstant(); |
142 Node* const effect = graph()->start(); | 141 Node* const effect = graph()->start(); |
143 Node* const control = graph()->start(); | 142 Node* const control = graph()->start(); |
144 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 143 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
145 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 144 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
146 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 145 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
147 Reduction r = Reduce(graph()->NewNode( | 146 Reduction r = Reduce(graph()->NewNode( |
148 javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments), | 147 javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments), |
149 closure, context, frame_state_inner, effect, control)); | 148 closure, context, frame_state_inner, effect, control)); |
150 ASSERT_TRUE(r.Changed()); | 149 ASSERT_TRUE(r.Changed()); |
151 EXPECT_THAT(r.replacement(), | 150 EXPECT_THAT(r.replacement(), |
152 IsFinishRegion( | 151 IsFinishRegion( |
153 IsAllocate(IsNumberConstant(Heap::kStrictArgumentsObjectSize), | 152 IsAllocate(IsNumberConstant(JSStrictArgumentsObject::kSize), |
154 _, control), | 153 _, control), |
155 _)); | 154 _)); |
156 } | 155 } |
157 | 156 |
158 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) { | 157 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) { |
159 Node* const closure = Parameter(Type::Any()); | 158 Node* const closure = Parameter(Type::Any()); |
160 Node* const context = UndefinedConstant(); | 159 Node* const context = UndefinedConstant(); |
161 Node* const effect = graph()->start(); | 160 Node* const effect = graph()->start(); |
162 Node* const control = graph()->start(); | 161 Node* const control = graph()->start(); |
163 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 162 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 EXPECT_THAT(r.replacement(), | 227 EXPECT_THAT(r.replacement(), |
229 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 228 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
230 Context::MIN_CONTEXT_SLOTS + 1)), | 229 Context::MIN_CONTEXT_SLOTS + 1)), |
231 IsBeginRegion(_), control), | 230 IsBeginRegion(_), control), |
232 _)); | 231 _)); |
233 } | 232 } |
234 | 233 |
235 } // namespace compiler | 234 } // namespace compiler |
236 } // namespace internal | 235 } // namespace internal |
237 } // namespace v8 | 236 } // namespace v8 |
OLD | NEW |