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