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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 EXPECT_EQ(context, NodeProperties::GetContextInput(node)); | 146 EXPECT_EQ(context, NodeProperties::GetContextInput(node)); |
147 } | 147 } |
148 | 148 |
149 TEST_F(JSContextRelaxationTest, | 149 TEST_F(JSContextRelaxationTest, |
150 RelaxJSCallFunctionDeepContextChainFullRelaxForCatch) { | 150 RelaxJSCallFunctionDeepContextChainFullRelaxForCatch) { |
151 Node* const input0 = Parameter(0); | 151 Node* const input0 = Parameter(0); |
152 Node* const input1 = Parameter(1); | 152 Node* const input1 = Parameter(1); |
153 Node* const context = Parameter(2); | 153 Node* const context = Parameter(2); |
154 Node* const outer_context = Parameter(3); | 154 Node* const outer_context = Parameter(3); |
155 const Operator* op = javascript()->CreateCatchContext(Handle<String>()); | 155 const Operator* op = javascript()->CreateCatchContext(Handle<String>()); |
156 Node* const frame_state_1 = | |
157 ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); | |
158 Node* const effect = graph()->start(); | 156 Node* const effect = graph()->start(); |
159 Node* const control = graph()->start(); | 157 Node* const control = graph()->start(); |
160 Node* nested_context = | 158 Node* nested_context = graph()->NewNode( |
161 graph()->NewNode(op, graph()->start(), graph()->start(), outer_context, | 159 op, graph()->start(), graph()->start(), outer_context, effect, control); |
162 frame_state_1, effect, control); | |
163 Node* const frame_state_2 = | 160 Node* const frame_state_2 = |
164 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 161 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
165 Node* node = | 162 Node* node = |
166 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, | 163 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, |
167 STRICT, VectorSlotPair()), | 164 STRICT, VectorSlotPair()), |
168 input0, input1, context, frame_state_2, effect, control); | 165 input0, input1, context, frame_state_2, effect, control); |
169 Reduction const r = Reduce(node); | 166 Reduction const r = Reduce(node); |
170 EXPECT_TRUE(r.Changed()); | 167 EXPECT_TRUE(r.Changed()); |
171 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); | 168 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); |
172 } | 169 } |
(...skipping 25 matching lines...) Expand all Loading... |
198 } | 195 } |
199 | 196 |
200 | 197 |
201 TEST_F(JSContextRelaxationTest, | 198 TEST_F(JSContextRelaxationTest, |
202 RelaxJSCallFunctionDeepContextChainFullRelaxForBlock) { | 199 RelaxJSCallFunctionDeepContextChainFullRelaxForBlock) { |
203 Node* const input0 = Parameter(0); | 200 Node* const input0 = Parameter(0); |
204 Node* const input1 = Parameter(1); | 201 Node* const input1 = Parameter(1); |
205 Node* const context = Parameter(2); | 202 Node* const context = Parameter(2); |
206 Node* const outer_context = Parameter(3); | 203 Node* const outer_context = Parameter(3); |
207 const Operator* op = javascript()->CreateBlockContext(); | 204 const Operator* op = javascript()->CreateBlockContext(); |
208 Node* const frame_state_1 = | |
209 ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); | |
210 Node* const effect = graph()->start(); | 205 Node* const effect = graph()->start(); |
211 Node* const control = graph()->start(); | 206 Node* const control = graph()->start(); |
212 Node* nested_context = | 207 Node* nested_context = graph()->NewNode( |
213 graph()->NewNode(op, graph()->start(), graph()->start(), outer_context, | 208 op, graph()->start(), graph()->start(), outer_context, effect, control); |
214 frame_state_1, effect, control); | |
215 Node* const frame_state_2 = | 209 Node* const frame_state_2 = |
216 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 210 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
217 Node* node = | 211 Node* node = |
218 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, | 212 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, |
219 STRICT, VectorSlotPair()), | 213 STRICT, VectorSlotPair()), |
220 input0, input1, context, frame_state_2, effect, control); | 214 input0, input1, context, frame_state_2, effect, control); |
221 Reduction const r = Reduce(node); | 215 Reduction const r = Reduce(node); |
222 EXPECT_TRUE(r.Changed()); | 216 EXPECT_TRUE(r.Changed()); |
223 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); | 217 EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node)); |
224 } | 218 } |
(...skipping 25 matching lines...) Expand all Loading... |
250 } | 244 } |
251 | 245 |
252 | 246 |
253 TEST_F(JSContextRelaxationTest, | 247 TEST_F(JSContextRelaxationTest, |
254 RelaxJSCallFunctionDeepContextChainPartialRelaxForModule) { | 248 RelaxJSCallFunctionDeepContextChainPartialRelaxForModule) { |
255 Node* const input0 = Parameter(0); | 249 Node* const input0 = Parameter(0); |
256 Node* const input1 = Parameter(1); | 250 Node* const input1 = Parameter(1); |
257 Node* const context = Parameter(2); | 251 Node* const context = Parameter(2); |
258 Node* const outer_context = Parameter(3); | 252 Node* const outer_context = Parameter(3); |
259 const Operator* op = javascript()->CreateModuleContext(); | 253 const Operator* op = javascript()->CreateModuleContext(); |
260 Node* const frame_state_1 = | |
261 ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); | |
262 Node* const effect = graph()->start(); | 254 Node* const effect = graph()->start(); |
263 Node* const control = graph()->start(); | 255 Node* const control = graph()->start(); |
264 Node* nested_context = | 256 Node* nested_context = graph()->NewNode( |
265 graph()->NewNode(op, graph()->start(), graph()->start(), outer_context, | 257 op, graph()->start(), graph()->start(), outer_context, effect, control); |
266 frame_state_1, effect, control); | |
267 Node* const frame_state_2 = | 258 Node* const frame_state_2 = |
268 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 259 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
269 Node* node = | 260 Node* node = |
270 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, | 261 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, |
271 STRICT, VectorSlotPair()), | 262 STRICT, VectorSlotPair()), |
272 input0, input1, context, frame_state_2, effect, control); | 263 input0, input1, context, frame_state_2, effect, control); |
273 Reduction const r = Reduce(node); | 264 Reduction const r = Reduce(node); |
274 EXPECT_TRUE(r.Changed()); | 265 EXPECT_TRUE(r.Changed()); |
275 EXPECT_EQ(nested_context, NodeProperties::GetContextInput(node)); | 266 EXPECT_EQ(nested_context, NodeProperties::GetContextInput(node)); |
276 } | 267 } |
277 | 268 |
278 | 269 |
279 TEST_F(JSContextRelaxationTest, | 270 TEST_F(JSContextRelaxationTest, |
280 RelaxJSCallFunctionDeepContextChainPartialNoRelax) { | 271 RelaxJSCallFunctionDeepContextChainPartialNoRelax) { |
281 Node* const input0 = Parameter(0); | 272 Node* const input0 = Parameter(0); |
282 Node* const input1 = Parameter(1); | 273 Node* const input1 = Parameter(1); |
283 Node* const context = Parameter(2); | 274 Node* const context = Parameter(2); |
284 Node* const outer_context = Parameter(3); | 275 Node* const outer_context = Parameter(3); |
285 const Operator* op = javascript()->CreateFunctionContext(); | 276 const Operator* op = javascript()->CreateFunctionContext(); |
286 Node* const frame_state_1 = | |
287 ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); | |
288 Node* const effect = graph()->start(); | 277 Node* const effect = graph()->start(); |
289 Node* const control = graph()->start(); | 278 Node* const control = graph()->start(); |
290 Node* nested_context = | 279 Node* nested_context = |
291 graph()->NewNode(op, graph()->start(), graph()->start(), outer_context, | 280 graph()->NewNode(op, graph()->start(), outer_context, effect, control); |
292 frame_state_1, effect, control); | |
293 Node* const frame_state_2 = | 281 Node* const frame_state_2 = |
294 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); | 282 ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); |
295 Node* node = | 283 Node* node = |
296 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, | 284 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, |
297 STRICT, VectorSlotPair()), | 285 STRICT, VectorSlotPair()), |
298 input0, input1, context, frame_state_2, effect, control); | 286 input0, input1, context, frame_state_2, effect, control); |
299 Reduction const r = Reduce(node); | 287 Reduction const r = Reduce(node); |
300 EXPECT_FALSE(r.Changed()); | 288 EXPECT_FALSE(r.Changed()); |
301 EXPECT_EQ(context, NodeProperties::GetContextInput(node)); | 289 EXPECT_EQ(context, NodeProperties::GetContextInput(node)); |
302 } | 290 } |
303 | 291 |
304 } // namespace compiler | 292 } // namespace compiler |
305 } // namespace internal | 293 } // namespace internal |
306 } // namespace v8 | 294 } // namespace v8 |
OLD | NEW |