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