| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-context-relaxation.h" | 5 #include "src/compiler/js-context-relaxation.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "test/unittests/compiler/graph-unittest.h" | 7 #include "test/unittests/compiler/graph-unittest.h" |
| 8 #include "test/unittests/compiler/node-test-utils.h" | 8 #include "test/unittests/compiler/node-test-utils.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); | 194 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 | 197 |
| 198 TEST_F(JSContextRelaxationTest, | 198 TEST_F(JSContextRelaxationTest, |
| 199 RelaxJSCallFunctionDeepContextChainFullRelaxForBlock) { | 199 RelaxJSCallFunctionDeepContextChainFullRelaxForBlock) { |
| 200 Node* const input0 = Parameter(0); | 200 Node* const input0 = Parameter(0); |
| 201 Node* const input1 = Parameter(1); | 201 Node* const input1 = Parameter(1); |
| 202 Node* const context = Parameter(2); | 202 Node* const context = Parameter(2); |
| 203 Node* const outer_context = Parameter(3); | 203 Node* const outer_context = Parameter(3); |
| 204 const Operator* op = javascript()->CreateBlockContext(); | 204 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::null(); |
| 205 const Operator* op = javascript()->CreateBlockContext(scope_info); |
| 205 Node* const effect = graph()->start(); | 206 Node* const effect = graph()->start(); |
| 206 Node* const control = graph()->start(); | 207 Node* const control = graph()->start(); |
| 207 Node* nested_context = graph()->NewNode( | 208 Node* nested_context = |
| 208 op, graph()->start(), graph()->start(), outer_context, effect, control); | 209 graph()->NewNode(op, graph()->start(), outer_context, effect, control); |
| 209 Node* const frame_state_2 = | 210 Node* const frame_state_2 = |
| 210 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 211 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
| 211 Node* node = | 212 Node* node = |
| 212 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, | 213 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, |
| 213 STRICT, VectorSlotPair()), | 214 STRICT, VectorSlotPair()), |
| 214 input0, input1, context, frame_state_2, effect, control); | 215 input0, input1, context, frame_state_2, effect, control); |
| 215 Reduction const r = Reduce(node); | 216 Reduction const r = Reduce(node); |
| 216 EXPECT_TRUE(r.Changed()); | 217 EXPECT_TRUE(r.Changed()); |
| 217 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); | 218 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 | 221 |
| 221 TEST_F(JSContextRelaxationTest, | 222 TEST_F(JSContextRelaxationTest, |
| 222 RelaxJSCallFunctionDeepContextChainPartialRelaxForScript) { | 223 RelaxJSCallFunctionDeepContextChainPartialRelaxForScript) { |
| 223 Node* const input0 = Parameter(0); | 224 Node* const input0 = Parameter(0); |
| 224 Node* const input1 = Parameter(1); | 225 Node* const input1 = Parameter(1); |
| 225 Node* const context = Parameter(2); | 226 Node* const context = Parameter(2); |
| 226 Node* const outer_context = Parameter(3); | 227 Node* const outer_context = Parameter(3); |
| 227 const Operator* op = javascript()->CreateScriptContext(); | 228 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::null(); |
| 229 const Operator* op = javascript()->CreateScriptContext(scope_info); |
| 228 Node* const frame_state_1 = | 230 Node* const frame_state_1 = |
| 229 ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 231 ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
| 230 Node* const effect = graph()->start(); | 232 Node* const effect = graph()->start(); |
| 231 Node* const control = graph()->start(); | 233 Node* const control = graph()->start(); |
| 232 Node* nested_context = | 234 Node* nested_context = graph()->NewNode(op, graph()->start(), outer_context, |
| 233 graph()->NewNode(op, graph()->start(), graph()->start(), outer_context, | 235 frame_state_1, effect, control); |
| 234 frame_state_1, effect, control); | |
| 235 Node* const frame_state_2 = | 236 Node* const frame_state_2 = |
| 236 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 237 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
| 237 Node* node = | 238 Node* node = |
| 238 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, | 239 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, |
| 239 STRICT, VectorSlotPair()), | 240 STRICT, VectorSlotPair()), |
| 240 input0, input1, context, frame_state_2, effect, control); | 241 input0, input1, context, frame_state_2, effect, control); |
| 241 Reduction const r = Reduce(node); | 242 Reduction const r = Reduce(node); |
| 242 EXPECT_TRUE(r.Changed()); | 243 EXPECT_TRUE(r.Changed()); |
| 243 EXPECT_EQ(nested_context, NodeProperties::GetContextInput(node)); | 244 EXPECT_EQ(nested_context, NodeProperties::GetContextInput(node)); |
| 244 } | 245 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 STRICT, VectorSlotPair()), | 286 STRICT, VectorSlotPair()), |
| 286 input0, input1, context, frame_state_2, effect, control); | 287 input0, input1, context, frame_state_2, effect, control); |
| 287 Reduction const r = Reduce(node); | 288 Reduction const r = Reduce(node); |
| 288 EXPECT_FALSE(r.Changed()); | 289 EXPECT_FALSE(r.Changed()); |
| 289 EXPECT_EQ(context, NodeProperties::GetContextInput(node)); | 290 EXPECT_EQ(context, NodeProperties::GetContextInput(node)); |
| 290 } | 291 } |
| 291 | 292 |
| 292 } // namespace compiler | 293 } // namespace compiler |
| 293 } // namespace internal | 294 } // namespace internal |
| 294 } // namespace v8 | 295 } // namespace v8 |
| OLD | NEW |