| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 r.replacement(), | 73 r.replacement(), |
| 74 IsFinishRegion( | 74 IsFinishRegion( |
| 75 IsAllocate(IsNumberConstant(function->initial_map()->instance_size()), | 75 IsAllocate(IsNumberConstant(function->initial_map()->instance_size()), |
| 76 IsBeginRegion(effect), _), | 76 IsBeginRegion(effect), _), |
| 77 _)); | 77 _)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // ----------------------------------------------------------------------------- | 80 // ----------------------------------------------------------------------------- |
| 81 // JSCreateArguments | 81 // JSCreateArguments |
| 82 | 82 |
| 83 TEST_F(JSCreateLoweringTest, JSCreateArgumentsViaStub) { | |
| 84 Node* const closure = Parameter(Type::Any()); | |
| 85 Node* const context = UndefinedConstant(); | |
| 86 Node* const effect = graph()->start(); | |
| 87 Node* const control = graph()->start(); | |
| 88 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | |
| 89 Node* const frame_state = FrameState(shared, graph()->start()); | |
| 90 Reduction r = Reduce(graph()->NewNode( | |
| 91 javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments), | |
| 92 closure, context, frame_state, effect, control)); | |
| 93 ASSERT_TRUE(r.Changed()); | |
| 94 EXPECT_THAT( | |
| 95 r.replacement(), | |
| 96 IsCall(_, IsHeapConstant( | |
| 97 CodeFactory::FastNewStrictArguments(isolate()).code()), | |
| 98 closure, context, frame_state, effect, control)); | |
| 99 } | |
| 100 | |
| 101 TEST_F(JSCreateLoweringTest, JSCreateArgumentsRestParameterViaStub) { | |
| 102 Node* const closure = Parameter(Type::Any()); | |
| 103 Node* const context = UndefinedConstant(); | |
| 104 Node* const effect = graph()->start(); | |
| 105 Node* const control = graph()->start(); | |
| 106 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | |
| 107 Node* const frame_state = FrameState(shared, graph()->start()); | |
| 108 Reduction r = Reduce(graph()->NewNode( | |
| 109 javascript()->CreateArguments(CreateArgumentsType::kRestParameter), | |
| 110 closure, context, frame_state, effect, control)); | |
| 111 ASSERT_TRUE(r.Changed()); | |
| 112 EXPECT_THAT( | |
| 113 r.replacement(), | |
| 114 IsCall(_, IsHeapConstant( | |
| 115 CodeFactory::FastNewRestParameter(isolate()).code()), | |
| 116 closure, context, frame_state, effect, control)); | |
| 117 } | |
| 118 | |
| 119 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedMapped) { | 83 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedMapped) { |
| 120 Node* const closure = Parameter(Type::Any()); | 84 Node* const closure = Parameter(Type::Any()); |
| 121 Node* const context = UndefinedConstant(); | 85 Node* const context = UndefinedConstant(); |
| 122 Node* const effect = graph()->start(); | 86 Node* const effect = graph()->start(); |
| 123 Node* const control = graph()->start(); | |
| 124 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 87 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 125 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 88 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
| 126 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 89 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
| 127 Reduction r = Reduce(graph()->NewNode( | 90 Reduction r = Reduce(graph()->NewNode( |
| 128 javascript()->CreateArguments(CreateArgumentsType::kMappedArguments), | 91 javascript()->CreateArguments(CreateArgumentsType::kMappedArguments), |
| 129 closure, context, frame_state_inner, effect, control)); | 92 closure, context, frame_state_inner, effect)); |
| 130 ASSERT_TRUE(r.Changed()); | 93 ASSERT_TRUE(r.Changed()); |
| 131 EXPECT_THAT(r.replacement(), | 94 EXPECT_THAT( |
| 132 IsFinishRegion( | 95 r.replacement(), |
| 133 IsAllocate(IsNumberConstant(JSSloppyArgumentsObject::kSize), | 96 IsFinishRegion( |
| 134 _, control), | 97 IsAllocate(IsNumberConstant(JSSloppyArgumentsObject::kSize), _, _), |
| 135 _)); | 98 _)); |
| 136 } | 99 } |
| 137 | 100 |
| 138 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedUnmapped) { | 101 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedUnmapped) { |
| 139 Node* const closure = Parameter(Type::Any()); | 102 Node* const closure = Parameter(Type::Any()); |
| 140 Node* const context = UndefinedConstant(); | 103 Node* const context = UndefinedConstant(); |
| 141 Node* const effect = graph()->start(); | 104 Node* const effect = graph()->start(); |
| 142 Node* const control = graph()->start(); | |
| 143 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 105 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 144 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 106 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
| 145 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 107 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
| 146 Reduction r = Reduce(graph()->NewNode( | 108 Reduction r = Reduce(graph()->NewNode( |
| 147 javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments), | 109 javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments), |
| 148 closure, context, frame_state_inner, effect, control)); | 110 closure, context, frame_state_inner, effect)); |
| 149 ASSERT_TRUE(r.Changed()); | 111 ASSERT_TRUE(r.Changed()); |
| 150 EXPECT_THAT(r.replacement(), | 112 EXPECT_THAT( |
| 151 IsFinishRegion( | 113 r.replacement(), |
| 152 IsAllocate(IsNumberConstant(JSStrictArgumentsObject::kSize), | 114 IsFinishRegion( |
| 153 _, control), | 115 IsAllocate(IsNumberConstant(JSStrictArgumentsObject::kSize), _, _), |
| 154 _)); | 116 _)); |
| 155 } | 117 } |
| 156 | 118 |
| 157 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) { | 119 TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) { |
| 158 Node* const closure = Parameter(Type::Any()); | 120 Node* const closure = Parameter(Type::Any()); |
| 159 Node* const context = UndefinedConstant(); | 121 Node* const context = UndefinedConstant(); |
| 160 Node* const effect = graph()->start(); | 122 Node* const effect = graph()->start(); |
| 161 Node* const control = graph()->start(); | |
| 162 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 123 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| 163 Node* const frame_state_outer = FrameState(shared, graph()->start()); | 124 Node* const frame_state_outer = FrameState(shared, graph()->start()); |
| 164 Node* const frame_state_inner = FrameState(shared, frame_state_outer); | 125 Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
| 165 Reduction r = Reduce(graph()->NewNode( | 126 Reduction r = Reduce(graph()->NewNode( |
| 166 javascript()->CreateArguments(CreateArgumentsType::kRestParameter), | 127 javascript()->CreateArguments(CreateArgumentsType::kRestParameter), |
| 167 closure, context, frame_state_inner, effect, control)); | 128 closure, context, frame_state_inner, effect)); |
| 168 ASSERT_TRUE(r.Changed()); | 129 ASSERT_TRUE(r.Changed()); |
| 169 EXPECT_THAT(r.replacement(), | 130 EXPECT_THAT( |
| 170 IsFinishRegion( | 131 r.replacement(), |
| 171 IsAllocate(IsNumberConstant(JSArray::kSize), _, control), _)); | 132 IsFinishRegion(IsAllocate(IsNumberConstant(JSArray::kSize), _, _), _)); |
| 172 } | 133 } |
| 173 | 134 |
| 174 // ----------------------------------------------------------------------------- | 135 // ----------------------------------------------------------------------------- |
| 175 // JSCreateClosure | 136 // JSCreateClosure |
| 176 | 137 |
| 177 TEST_F(JSCreateLoweringTest, JSCreateClosureViaInlinedAllocation) { | 138 TEST_F(JSCreateLoweringTest, JSCreateClosureViaInlinedAllocation) { |
| 178 Node* const context = UndefinedConstant(); | 139 Node* const context = UndefinedConstant(); |
| 179 Node* const effect = graph()->start(); | 140 Node* const effect = graph()->start(); |
| 180 Node* const control = graph()->start(); | 141 Node* const control = graph()->start(); |
| 181 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); | 142 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 EXPECT_THAT(r.replacement(), | 206 EXPECT_THAT(r.replacement(), |
| 246 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 207 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
| 247 Context::MIN_CONTEXT_SLOTS + 1)), | 208 Context::MIN_CONTEXT_SLOTS + 1)), |
| 248 IsBeginRegion(_), control), | 209 IsBeginRegion(_), control), |
| 249 _)); | 210 _)); |
| 250 } | 211 } |
| 251 | 212 |
| 252 } // namespace compiler | 213 } // namespace compiler |
| 253 } // namespace internal | 214 } // namespace internal |
| 254 } // namespace v8 | 215 } // namespace v8 |
| OLD | NEW |