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/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
11 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
12 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
13 #include "src/compiler/operator-properties.h" | 13 #include "src/compiler/operator-properties.h" |
14 #include "src/isolate-inl.h" | 14 #include "src/isolate-inl.h" |
| 15 #include "src/type-feedback-vector.h" |
15 #include "test/unittests/compiler/compiler-test-utils.h" | 16 #include "test/unittests/compiler/compiler-test-utils.h" |
16 #include "test/unittests/compiler/graph-unittest.h" | 17 #include "test/unittests/compiler/graph-unittest.h" |
17 #include "test/unittests/compiler/node-test-utils.h" | 18 #include "test/unittests/compiler/node-test-utils.h" |
18 #include "testing/gmock-support.h" | 19 #include "testing/gmock-support.h" |
19 | 20 |
20 using testing::_; | 21 using testing::_; |
21 using testing::BitEq; | 22 using testing::BitEq; |
22 using testing::IsNaN; | 23 using testing::IsNaN; |
23 | 24 |
24 namespace v8 { | 25 namespace v8 { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 137 } |
137 | 138 |
138 // ----------------------------------------------------------------------------- | 139 // ----------------------------------------------------------------------------- |
139 // JSCreateClosure | 140 // JSCreateClosure |
140 | 141 |
141 TEST_F(JSCreateLoweringTest, JSCreateClosureViaInlinedAllocation) { | 142 TEST_F(JSCreateLoweringTest, JSCreateClosureViaInlinedAllocation) { |
142 Node* const context = UndefinedConstant(); | 143 Node* const context = UndefinedConstant(); |
143 Node* const effect = graph()->start(); | 144 Node* const effect = graph()->start(); |
144 Node* const control = graph()->start(); | 145 Node* const control = graph()->start(); |
145 Handle<SharedFunctionInfo> shared(isolate()->number_function()->shared()); | 146 Handle<SharedFunctionInfo> shared(isolate()->number_function()->shared()); |
146 Reduction r = | 147 |
147 Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED), | 148 // Create a mock feedback vector. It just has to be an array with an array |
148 context, effect, control)); | 149 // in slot 0. |
| 150 Handle<FixedArray> array = isolate()->factory()->NewFixedArray( |
| 151 TypeFeedbackVector::kReservedIndexCount + 1); |
| 152 array->set_map_no_write_barrier( |
| 153 isolate()->heap()->type_feedback_vector_map()); |
| 154 Handle<TypeFeedbackVector> vector = Handle<TypeFeedbackVector>::cast(array); |
| 155 FeedbackVectorSlot slot(0); |
| 156 vector->Set(slot, *vector); |
| 157 VectorSlotPair pair(vector, slot); |
| 158 |
| 159 Reduction r = Reduce( |
| 160 graph()->NewNode(javascript()->CreateClosure(shared, pair, NOT_TENURED), |
| 161 context, effect, control)); |
149 ASSERT_TRUE(r.Changed()); | 162 ASSERT_TRUE(r.Changed()); |
150 EXPECT_THAT(r.replacement(), | 163 EXPECT_THAT(r.replacement(), |
151 IsFinishRegion(IsAllocate(IsNumberConstant(JSFunction::kSize), | 164 IsFinishRegion(IsAllocate(IsNumberConstant(JSFunction::kSize), |
152 IsBeginRegion(_), control), | 165 IsBeginRegion(_), control), |
153 _)); | 166 _)); |
154 } | 167 } |
155 | 168 |
156 // ----------------------------------------------------------------------------- | 169 // ----------------------------------------------------------------------------- |
157 // JSCreateFunctionContext | 170 // JSCreateFunctionContext |
158 | 171 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 EXPECT_THAT(r.replacement(), | 224 EXPECT_THAT(r.replacement(), |
212 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 225 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
213 Context::MIN_CONTEXT_SLOTS + 1)), | 226 Context::MIN_CONTEXT_SLOTS + 1)), |
214 IsBeginRegion(_), control), | 227 IsBeginRegion(_), control), |
215 _)); | 228 _)); |
216 } | 229 } |
217 | 230 |
218 } // namespace compiler | 231 } // namespace compiler |
219 } // namespace internal | 232 } // namespace internal |
220 } // namespace v8 | 233 } // namespace v8 |
OLD | NEW |