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/bit-vector.h" | 5 #include "src/bit-vector.h" |
6 #include "src/compiler/escape-analysis.h" | 6 #include "src/compiler/escape-analysis.h" |
7 #include "src/compiler/escape-analysis-reducer.h" | 7 #include "src/compiler/escape-analysis-reducer.h" |
8 #include "src/compiler/graph-visualizer.h" | 8 #include "src/compiler/graph-visualizer.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 ExpectVirtual(allocation); | 294 ExpectVirtual(allocation); |
295 ExpectReplacement(load1, object1); | 295 ExpectReplacement(load1, object1); |
296 ExpectReplacement(load2, object1); | 296 ExpectReplacement(load2, object1); |
297 | 297 |
298 Transformation(); | 298 Transformation(); |
299 | 299 |
300 ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 0)); | 300 ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 0)); |
301 } | 301 } |
302 | 302 |
| 303 |
| 304 TEST_F(EscapeAnalysisTest, DeoptReplacement) { |
| 305 Node* object1 = Constant(1); |
| 306 BeginRegion(); |
| 307 Node* allocation = Allocate(Constant(kPointerSize)); |
| 308 Store(AccessAtIndex(0), allocation, object1); |
| 309 Node* finish = FinishRegion(allocation); |
| 310 Node* effect1 = Store(AccessAtIndex(0), allocation, object1, finish); |
| 311 Branch(); |
| 312 Node* ifFalse = IfFalse(); |
| 313 Node* state_values1 = graph()->NewNode(common()->StateValues(1), finish); |
| 314 Node* state_values2 = graph()->NewNode(common()->StateValues(0)); |
| 315 Node* state_values3 = graph()->NewNode(common()->StateValues(0)); |
| 316 Node* frame_state = graph()->NewNode( |
| 317 common()->FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(), |
| 318 nullptr), |
| 319 state_values1, state_values2, state_values3, UndefinedConstant(), |
| 320 graph()->start(), graph()->start()); |
| 321 Node* deopt = graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 322 frame_state, effect1, ifFalse); |
| 323 Node* ifTrue = IfTrue(); |
| 324 Node* load = Load(AccessAtIndex(0), finish, effect1, ifTrue); |
| 325 Node* result = Return(load, effect1, ifTrue); |
| 326 EndGraph(); |
| 327 graph()->end()->AppendInput(zone(), deopt); |
| 328 Analysis(); |
| 329 |
| 330 ExpectVirtual(allocation); |
| 331 ExpectReplacement(load, object1); |
| 332 |
| 333 Transformation(); |
| 334 |
| 335 ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 0)); |
| 336 Node* object_state = NodeProperties::GetValueInput(state_values1, 0); |
| 337 ASSERT_EQ(object_state->opcode(), IrOpcode::kObjectState); |
| 338 ASSERT_EQ(1, object_state->op()->ValueInputCount()); |
| 339 ASSERT_EQ(object1, NodeProperties::GetValueInput(object_state, 0)); |
| 340 } |
| 341 |
| 342 |
| 343 TEST_F(EscapeAnalysisTest, DeoptReplacementIdentity) { |
| 344 Node* object1 = Constant(1); |
| 345 BeginRegion(); |
| 346 Node* allocation = Allocate(Constant(kPointerSize * 2)); |
| 347 Store(AccessAtIndex(0), allocation, object1); |
| 348 Store(AccessAtIndex(kPointerSize), allocation, allocation); |
| 349 Node* finish = FinishRegion(allocation); |
| 350 Node* effect1 = Store(AccessAtIndex(0), allocation, object1, finish); |
| 351 Branch(); |
| 352 Node* ifFalse = IfFalse(); |
| 353 Node* state_values1 = graph()->NewNode(common()->StateValues(1), finish); |
| 354 Node* state_values2 = graph()->NewNode(common()->StateValues(1), finish); |
| 355 Node* state_values3 = graph()->NewNode(common()->StateValues(0)); |
| 356 Node* frame_state = graph()->NewNode( |
| 357 common()->FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(), |
| 358 nullptr), |
| 359 state_values1, state_values2, state_values3, UndefinedConstant(), |
| 360 graph()->start(), graph()->start()); |
| 361 Node* deopt = graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 362 frame_state, effect1, ifFalse); |
| 363 Node* ifTrue = IfTrue(); |
| 364 Node* load = Load(AccessAtIndex(0), finish, effect1, ifTrue); |
| 365 Node* result = Return(load, effect1, ifTrue); |
| 366 EndGraph(); |
| 367 graph()->end()->AppendInput(zone(), deopt); |
| 368 Analysis(); |
| 369 |
| 370 ExpectVirtual(allocation); |
| 371 ExpectReplacement(load, object1); |
| 372 |
| 373 Transformation(); |
| 374 |
| 375 ASSERT_EQ(object1, NodeProperties::GetValueInput(result, 0)); |
| 376 |
| 377 Node* object_state = NodeProperties::GetValueInput(state_values1, 0); |
| 378 ASSERT_EQ(object_state->opcode(), IrOpcode::kObjectState); |
| 379 ASSERT_EQ(2, object_state->op()->ValueInputCount()); |
| 380 ASSERT_EQ(object1, NodeProperties::GetValueInput(object_state, 0)); |
| 381 ASSERT_EQ(object_state, NodeProperties::GetValueInput(object_state, 1)); |
| 382 |
| 383 Node* object_state2 = NodeProperties::GetValueInput(state_values1, 0); |
| 384 ASSERT_EQ(object_state, object_state2); |
| 385 } |
| 386 |
303 } // namespace compiler | 387 } // namespace compiler |
304 } // namespace internal | 388 } // namespace internal |
305 } // namespace v8 | 389 } // namespace v8 |
OLD | NEW |