| 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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 if (TryWireInStateEffect(node, effect, control)) { | 283 if (TryWireInStateEffect(node, effect, control)) { |
| 284 return; | 284 return; |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Remove the end markers of 'atomic' allocation region because the | 287 // Remove the end markers of 'atomic' allocation region because the |
| 288 // region should be wired-in now. | 288 // region should be wired-in now. |
| 289 if (node->opcode() == IrOpcode::kFinishRegion || | 289 if (node->opcode() == IrOpcode::kFinishRegion || |
| 290 node->opcode() == IrOpcode::kBeginRegion) { | 290 node->opcode() == IrOpcode::kBeginRegion) { |
| 291 // Update the value uses to the value input of the finish node and | 291 // Update the value uses to the value input of the finish node and |
| 292 // the effect uses to the effect input. | 292 // the effect uses to the effect input. |
| 293 return RemoveRegionNode(node); | 293 |
| 294 // TODO(jarin) Enable this once we make sure everything with side effects |
| 295 // is marked as effectful. |
| 296 if (false) { |
| 297 return RemoveRegionNode(node); |
| 298 } |
| 294 } | 299 } |
| 295 | 300 |
| 296 if (node->opcode() == IrOpcode::kIfSuccess) { | 301 if (node->opcode() == IrOpcode::kIfSuccess) { |
| 297 // We always schedule IfSuccess with its call, so skip it here. | 302 // We always schedule IfSuccess with its call, so skip it here. |
| 298 DCHECK_EQ(IrOpcode::kCall, node->InputAt(0)->opcode()); | 303 DCHECK_EQ(IrOpcode::kCall, node->InputAt(0)->opcode()); |
| 299 // The IfSuccess node should not belong to an exceptional call node | 304 // The IfSuccess node should not belong to an exceptional call node |
| 300 // because such IfSuccess nodes should only start a basic block (and | 305 // because such IfSuccess nodes should only start a basic block (and |
| 301 // basic block start nodes are not handled in the ProcessNode method). | 306 // basic block start nodes are not handled in the ProcessNode method). |
| 302 DCHECK(!NodeProperties::IsExceptionalCall(node->InputAt(0))); | 307 DCHECK(!NodeProperties::IsExceptionalCall(node->InputAt(0))); |
| 303 return; | 308 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 334 // Schedule the call's IfSuccess node (if there is no exception use). | 339 // Schedule the call's IfSuccess node (if there is no exception use). |
| 335 TryScheduleCallIfSuccess(node, control); | 340 TryScheduleCallIfSuccess(node, control); |
| 336 } | 341 } |
| 337 } | 342 } |
| 338 } | 343 } |
| 339 | 344 |
| 340 bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect, | 345 bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect, |
| 341 Node** control) { | 346 Node** control) { |
| 342 ValueEffectControl state(nullptr, nullptr, nullptr); | 347 ValueEffectControl state(nullptr, nullptr, nullptr); |
| 343 switch (node->opcode()) { | 348 switch (node->opcode()) { |
| 344 case IrOpcode::kChangeBitToTagged: | |
| 345 state = LowerChangeBitToTagged(node, *effect, *control); | |
| 346 break; | |
| 347 case IrOpcode::kChangeInt31ToTaggedSigned: | |
| 348 state = LowerChangeInt31ToTaggedSigned(node, *effect, *control); | |
| 349 break; | |
| 350 case IrOpcode::kChangeInt32ToTagged: | 349 case IrOpcode::kChangeInt32ToTagged: |
| 351 state = LowerChangeInt32ToTagged(node, *effect, *control); | 350 state = LowerChangeInt32ToTagged(node, *effect, *control); |
| 352 break; | 351 break; |
| 353 case IrOpcode::kChangeUint32ToTagged: | 352 case IrOpcode::kChangeUint32ToTagged: |
| 354 state = LowerChangeUint32ToTagged(node, *effect, *control); | 353 state = LowerChangeUint32ToTagged(node, *effect, *control); |
| 355 break; | 354 break; |
| 356 case IrOpcode::kChangeFloat64ToTagged: | 355 case IrOpcode::kChangeFloat64ToTagged: |
| 357 state = LowerChangeFloat64ToTagged(node, *effect, *control); | 356 state = LowerChangeFloat64ToTagged(node, *effect, *control); |
| 358 break; | 357 break; |
| 359 case IrOpcode::kChangeTaggedSignedToInt32: | |
| 360 state = LowerChangeTaggedSignedToInt32(node, *effect, *control); | |
| 361 break; | |
| 362 case IrOpcode::kChangeTaggedToBit: | |
| 363 state = LowerChangeTaggedToBit(node, *effect, *control); | |
| 364 break; | |
| 365 case IrOpcode::kChangeTaggedToInt32: | 358 case IrOpcode::kChangeTaggedToInt32: |
| 366 state = LowerChangeTaggedToInt32(node, *effect, *control); | 359 state = LowerChangeTaggedToInt32(node, *effect, *control); |
| 367 break; | 360 break; |
| 368 case IrOpcode::kChangeTaggedToUint32: | 361 case IrOpcode::kChangeTaggedToUint32: |
| 369 state = LowerChangeTaggedToUint32(node, *effect, *control); | 362 state = LowerChangeTaggedToUint32(node, *effect, *control); |
| 370 break; | 363 break; |
| 371 case IrOpcode::kChangeTaggedToFloat64: | 364 case IrOpcode::kChangeTaggedToFloat64: |
| 372 state = LowerChangeTaggedToFloat64(node, *effect, *control); | 365 state = LowerChangeTaggedToFloat64(node, *effect, *control); |
| 373 break; | 366 break; |
| 374 case IrOpcode::kTruncateTaggedToWord32: | 367 case IrOpcode::kTruncateTaggedToWord32: |
| 375 state = LowerTruncateTaggedToWord32(node, *effect, *control); | 368 state = LowerTruncateTaggedToWord32(node, *effect, *control); |
| 376 break; | 369 break; |
| 377 case IrOpcode::kObjectIsCallable: | 370 case IrOpcode::kObjectIsCallable: |
| 378 state = LowerObjectIsCallable(node, *effect, *control); | 371 state = LowerObjectIsCallable(node, *effect, *control); |
| 379 break; | 372 break; |
| 380 case IrOpcode::kObjectIsNumber: | 373 case IrOpcode::kObjectIsNumber: |
| 381 state = LowerObjectIsNumber(node, *effect, *control); | 374 state = LowerObjectIsNumber(node, *effect, *control); |
| 382 break; | 375 break; |
| 383 case IrOpcode::kObjectIsReceiver: | 376 case IrOpcode::kObjectIsReceiver: |
| 384 state = LowerObjectIsReceiver(node, *effect, *control); | 377 state = LowerObjectIsReceiver(node, *effect, *control); |
| 385 break; | 378 break; |
| 386 case IrOpcode::kObjectIsSmi: | |
| 387 state = LowerObjectIsSmi(node, *effect, *control); | |
| 388 break; | |
| 389 case IrOpcode::kObjectIsString: | 379 case IrOpcode::kObjectIsString: |
| 390 state = LowerObjectIsString(node, *effect, *control); | 380 state = LowerObjectIsString(node, *effect, *control); |
| 391 break; | 381 break; |
| 392 case IrOpcode::kObjectIsUndetectable: | 382 case IrOpcode::kObjectIsUndetectable: |
| 393 state = LowerObjectIsUndetectable(node, *effect, *control); | 383 state = LowerObjectIsUndetectable(node, *effect, *control); |
| 394 break; | 384 break; |
| 395 default: | 385 default: |
| 396 return false; | 386 return false; |
| 397 } | 387 } |
| 398 NodeProperties::ReplaceUses(node, state.value); | 388 NodeProperties::ReplaceUses(node, state.value); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 454 |
| 465 control = graph()->NewNode(common()->Merge(2), if_smi, box.control); | 455 control = graph()->NewNode(common()->Merge(2), if_smi, box.control); |
| 466 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), | 456 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 467 vsmi, box.value, control); | 457 vsmi, box.value, control); |
| 468 effect = | 458 effect = |
| 469 graph()->NewNode(common()->EffectPhi(2), effect, box.effect, control); | 459 graph()->NewNode(common()->EffectPhi(2), effect, box.effect, control); |
| 470 return ValueEffectControl(value, effect, control); | 460 return ValueEffectControl(value, effect, control); |
| 471 } | 461 } |
| 472 | 462 |
| 473 EffectControlLinearizer::ValueEffectControl | 463 EffectControlLinearizer::ValueEffectControl |
| 474 EffectControlLinearizer::LowerChangeBitToTagged(Node* node, Node* effect, | |
| 475 Node* control) { | |
| 476 Node* value = node->InputAt(0); | |
| 477 | |
| 478 Node* branch = graph()->NewNode(common()->Branch(), value, control); | |
| 479 | |
| 480 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | |
| 481 Node* vtrue = jsgraph()->TrueConstant(); | |
| 482 | |
| 483 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | |
| 484 Node* vfalse = jsgraph()->FalseConstant(); | |
| 485 | |
| 486 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | |
| 487 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), | |
| 488 vtrue, vfalse, control); | |
| 489 | |
| 490 return ValueEffectControl(value, effect, control); | |
| 491 } | |
| 492 | |
| 493 EffectControlLinearizer::ValueEffectControl | |
| 494 EffectControlLinearizer::LowerChangeInt31ToTaggedSigned(Node* node, | |
| 495 Node* effect, | |
| 496 Node* control) { | |
| 497 Node* value = node->InputAt(0); | |
| 498 value = ChangeInt32ToSmi(value); | |
| 499 return ValueEffectControl(value, effect, control); | |
| 500 } | |
| 501 | |
| 502 EffectControlLinearizer::ValueEffectControl | |
| 503 EffectControlLinearizer::LowerChangeInt32ToTagged(Node* node, Node* effect, | 464 EffectControlLinearizer::LowerChangeInt32ToTagged(Node* node, Node* effect, |
| 504 Node* control) { | 465 Node* control) { |
| 505 Node* value = node->InputAt(0); | 466 Node* value = node->InputAt(0); |
| 506 | 467 |
| 507 if (machine()->Is64()) { | 468 if (machine()->Is64()) { |
| 508 return ValueEffectControl(ChangeInt32ToSmi(value), effect, control); | 469 return ValueEffectControl(ChangeInt32ToSmi(value), effect, control); |
| 509 } | 470 } |
| 510 | 471 |
| 511 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), value, value); | 472 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), value, value); |
| 512 | 473 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 Node* merge = graph()->NewNode(common()->Merge(2), if_true, alloc.control); | 511 Node* merge = graph()->NewNode(common()->Merge(2), if_true, alloc.control); |
| 551 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), | 512 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 552 vtrue, alloc.value, merge); | 513 vtrue, alloc.value, merge); |
| 553 Node* ephi = | 514 Node* ephi = |
| 554 graph()->NewNode(common()->EffectPhi(2), effect, alloc.effect, merge); | 515 graph()->NewNode(common()->EffectPhi(2), effect, alloc.effect, merge); |
| 555 | 516 |
| 556 return ValueEffectControl(phi, ephi, merge); | 517 return ValueEffectControl(phi, ephi, merge); |
| 557 } | 518 } |
| 558 | 519 |
| 559 EffectControlLinearizer::ValueEffectControl | 520 EffectControlLinearizer::ValueEffectControl |
| 560 EffectControlLinearizer::LowerChangeTaggedSignedToInt32(Node* node, | |
| 561 Node* effect, | |
| 562 Node* control) { | |
| 563 Node* value = node->InputAt(0); | |
| 564 value = ChangeSmiToInt32(value); | |
| 565 return ValueEffectControl(value, effect, control); | |
| 566 } | |
| 567 | |
| 568 EffectControlLinearizer::ValueEffectControl | |
| 569 EffectControlLinearizer::LowerChangeTaggedToBit(Node* node, Node* effect, | |
| 570 Node* control) { | |
| 571 Node* value = node->InputAt(0); | |
| 572 value = graph()->NewNode(machine()->WordEqual(), value, | |
| 573 jsgraph()->TrueConstant()); | |
| 574 return ValueEffectControl(value, effect, control); | |
| 575 } | |
| 576 | |
| 577 EffectControlLinearizer::ValueEffectControl | |
| 578 EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node, Node* effect, | 521 EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node, Node* effect, |
| 579 Node* control) { | 522 Node* control) { |
| 580 Node* value = node->InputAt(0); | 523 Node* value = node->InputAt(0); |
| 581 | 524 |
| 582 Node* check = ObjectIsSmi(value); | 525 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 583 Node* branch = | 526 Node* branch = |
| 584 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 527 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 585 | 528 |
| 586 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 529 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 587 Node* etrue = effect; | 530 Node* etrue = effect; |
| 588 Node* vtrue = ChangeSmiToInt32(value); | 531 Node* vtrue = |
| 532 graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
| 589 | 533 |
| 590 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 534 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 591 Node* efalse = effect; | 535 Node* efalse = effect; |
| 592 Node* vfalse; | 536 Node* vfalse; |
| 593 { | 537 { |
| 594 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); | 538 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
| 595 vfalse = efalse = graph()->NewNode( | 539 vfalse = efalse = graph()->NewNode( |
| 596 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, | 540 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, |
| 597 efalse, if_false); | 541 efalse, if_false); |
| 598 vfalse = graph()->NewNode(machine()->ChangeFloat64ToInt32(), vfalse); | 542 vfalse = graph()->NewNode(machine()->ChangeFloat64ToInt32(), vfalse); |
| 599 } | 543 } |
| 600 | 544 |
| 601 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 545 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 602 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 546 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 603 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | 547 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
| 604 vtrue, vfalse, control); | 548 vtrue, vfalse, control); |
| 605 | 549 |
| 606 return ValueEffectControl(value, effect, control); | 550 return ValueEffectControl(value, effect, control); |
| 607 } | 551 } |
| 608 | 552 |
| 609 EffectControlLinearizer::ValueEffectControl | 553 EffectControlLinearizer::ValueEffectControl |
| 610 EffectControlLinearizer::LowerChangeTaggedToUint32(Node* node, Node* effect, | 554 EffectControlLinearizer::LowerChangeTaggedToUint32(Node* node, Node* effect, |
| 611 Node* control) { | 555 Node* control) { |
| 612 Node* value = node->InputAt(0); | 556 Node* value = node->InputAt(0); |
| 613 | 557 |
| 614 Node* check = ObjectIsSmi(value); | 558 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 615 Node* branch = | 559 Node* branch = |
| 616 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 560 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 617 | 561 |
| 618 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 562 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 619 Node* etrue = effect; | 563 Node* etrue = effect; |
| 620 Node* vtrue = ChangeSmiToInt32(value); | 564 Node* vtrue = |
| 565 graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
| 621 | 566 |
| 622 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 567 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 623 Node* efalse = effect; | 568 Node* efalse = effect; |
| 624 Node* vfalse; | 569 Node* vfalse; |
| 625 { | 570 { |
| 626 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); | 571 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
| 627 vfalse = efalse = graph()->NewNode( | 572 vfalse = efalse = graph()->NewNode( |
| 628 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, | 573 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, |
| 629 efalse, if_false); | 574 efalse, if_false); |
| 630 vfalse = graph()->NewNode(machine()->ChangeFloat64ToUint32(), vfalse); | 575 vfalse = graph()->NewNode(machine()->ChangeFloat64ToUint32(), vfalse); |
| 631 } | 576 } |
| 632 | 577 |
| 633 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 578 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 634 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 579 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 635 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | 580 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
| 636 vtrue, vfalse, control); | 581 vtrue, vfalse, control); |
| 637 | 582 |
| 638 return ValueEffectControl(value, effect, control); | 583 return ValueEffectControl(value, effect, control); |
| 639 } | 584 } |
| 640 | 585 |
| 641 EffectControlLinearizer::ValueEffectControl | 586 EffectControlLinearizer::ValueEffectControl |
| 642 EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect, | 587 EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect, |
| 643 Node* control) { | 588 Node* control) { |
| 644 Node* value = node->InputAt(0); | 589 Node* value = node->InputAt(0); |
| 645 | 590 |
| 646 Node* check = ObjectIsSmi(value); | 591 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 647 Node* branch = | 592 Node* branch = |
| 648 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 593 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 649 | 594 |
| 650 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 595 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 651 Node* etrue = effect; | 596 Node* etrue = effect; |
| 652 Node* vtrue; | 597 Node* vtrue; |
| 653 { | 598 { |
| 654 vtrue = ChangeSmiToInt32(value); | 599 vtrue = graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
| 655 vtrue = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue); | 600 vtrue = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue); |
| 656 } | 601 } |
| 657 | 602 |
| 658 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 603 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 659 Node* efalse = effect; | 604 Node* efalse = effect; |
| 660 Node* vfalse; | 605 Node* vfalse; |
| 661 { | 606 { |
| 662 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); | 607 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
| 663 vfalse = efalse = graph()->NewNode( | 608 vfalse = efalse = graph()->NewNode( |
| 664 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, | 609 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, |
| 665 efalse, if_false); | 610 efalse, if_false); |
| 666 } | 611 } |
| 667 | 612 |
| 668 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 613 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 669 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 614 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 670 value = graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), | 615 value = graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), |
| 671 vtrue, vfalse, control); | 616 vtrue, vfalse, control); |
| 672 | 617 |
| 673 return ValueEffectControl(value, effect, control); | 618 return ValueEffectControl(value, effect, control); |
| 674 } | 619 } |
| 675 | 620 |
| 676 EffectControlLinearizer::ValueEffectControl | 621 EffectControlLinearizer::ValueEffectControl |
| 677 EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node, Node* effect, | 622 EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node, Node* effect, |
| 678 Node* control) { | 623 Node* control) { |
| 679 Node* value = node->InputAt(0); | 624 Node* value = node->InputAt(0); |
| 680 | 625 |
| 681 Node* check = ObjectIsSmi(value); | 626 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 682 Node* branch = | 627 Node* branch = |
| 683 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 628 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 684 | 629 |
| 685 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 630 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 686 Node* etrue = effect; | 631 Node* etrue = effect; |
| 687 Node* vtrue = ChangeSmiToInt32(value); | 632 Node* vtrue = |
| 633 graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
| 688 | 634 |
| 689 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 635 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 690 Node* efalse = effect; | 636 Node* efalse = effect; |
| 691 Node* vfalse; | 637 Node* vfalse; |
| 692 { | 638 { |
| 693 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); | 639 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
| 694 vfalse = efalse = graph()->NewNode( | 640 vfalse = efalse = graph()->NewNode( |
| 695 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, | 641 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, |
| 696 efalse, if_false); | 642 efalse, if_false); |
| 697 vfalse = graph()->NewNode(machine()->TruncateFloat64ToWord32(), vfalse); | 643 vfalse = graph()->NewNode(machine()->TruncateFloat64ToWord32(), vfalse); |
| 698 } | 644 } |
| 699 | 645 |
| 700 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 646 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 701 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 647 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 702 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | 648 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
| 703 vtrue, vfalse, control); | 649 vtrue, vfalse, control); |
| 704 | 650 |
| 705 return ValueEffectControl(value, effect, control); | 651 return ValueEffectControl(value, effect, control); |
| 706 } | 652 } |
| 707 | 653 |
| 708 EffectControlLinearizer::ValueEffectControl | 654 EffectControlLinearizer::ValueEffectControl |
| 709 EffectControlLinearizer::LowerObjectIsCallable(Node* node, Node* effect, | 655 EffectControlLinearizer::LowerObjectIsCallable(Node* node, Node* effect, |
| 710 Node* control) { | 656 Node* control) { |
| 711 Node* value = node->InputAt(0); | 657 Node* value = node->InputAt(0); |
| 712 | 658 |
| 713 Node* check = ObjectIsSmi(value); | 659 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 714 Node* branch = | 660 Node* branch = |
| 715 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 661 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
| 716 | 662 |
| 717 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 663 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 718 Node* etrue = effect; | 664 Node* etrue = effect; |
| 719 Node* vtrue = jsgraph()->Int32Constant(0); | 665 Node* vtrue = jsgraph()->Int32Constant(0); |
| 720 | 666 |
| 721 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 667 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 722 Node* efalse = effect; | 668 Node* efalse = effect; |
| 723 Node* vfalse; | 669 Node* vfalse; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 743 vfalse, control); | 689 vfalse, control); |
| 744 | 690 |
| 745 return ValueEffectControl(value, effect, control); | 691 return ValueEffectControl(value, effect, control); |
| 746 } | 692 } |
| 747 | 693 |
| 748 EffectControlLinearizer::ValueEffectControl | 694 EffectControlLinearizer::ValueEffectControl |
| 749 EffectControlLinearizer::LowerObjectIsNumber(Node* node, Node* effect, | 695 EffectControlLinearizer::LowerObjectIsNumber(Node* node, Node* effect, |
| 750 Node* control) { | 696 Node* control) { |
| 751 Node* value = node->InputAt(0); | 697 Node* value = node->InputAt(0); |
| 752 | 698 |
| 753 Node* check = ObjectIsSmi(value); | 699 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 754 Node* branch = graph()->NewNode(common()->Branch(), check, control); | 700 Node* branch = graph()->NewNode(common()->Branch(), check, control); |
| 755 | 701 |
| 756 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 702 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 757 Node* etrue = effect; | 703 Node* etrue = effect; |
| 758 Node* vtrue = jsgraph()->Int32Constant(1); | 704 Node* vtrue = jsgraph()->Int32Constant(1); |
| 759 | 705 |
| 760 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 706 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 761 Node* efalse = effect; | 707 Node* efalse = effect; |
| 762 Node* vfalse; | 708 Node* vfalse; |
| 763 { | 709 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 774 vfalse, control); | 720 vfalse, control); |
| 775 | 721 |
| 776 return ValueEffectControl(value, effect, control); | 722 return ValueEffectControl(value, effect, control); |
| 777 } | 723 } |
| 778 | 724 |
| 779 EffectControlLinearizer::ValueEffectControl | 725 EffectControlLinearizer::ValueEffectControl |
| 780 EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect, | 726 EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect, |
| 781 Node* control) { | 727 Node* control) { |
| 782 Node* value = node->InputAt(0); | 728 Node* value = node->InputAt(0); |
| 783 | 729 |
| 784 Node* check = ObjectIsSmi(value); | 730 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 785 Node* branch = | 731 Node* branch = |
| 786 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 732 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
| 787 | 733 |
| 788 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 734 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 789 Node* etrue = effect; | 735 Node* etrue = effect; |
| 790 Node* vtrue = jsgraph()->Int32Constant(0); | 736 Node* vtrue = jsgraph()->Int32Constant(0); |
| 791 | 737 |
| 792 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 738 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 793 Node* efalse = effect; | 739 Node* efalse = effect; |
| 794 Node* vfalse; | 740 Node* vfalse; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 807 | 753 |
| 808 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 754 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 809 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 755 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 810 value = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2), vtrue, | 756 value = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2), vtrue, |
| 811 vfalse, control); | 757 vfalse, control); |
| 812 | 758 |
| 813 return ValueEffectControl(value, effect, control); | 759 return ValueEffectControl(value, effect, control); |
| 814 } | 760 } |
| 815 | 761 |
| 816 EffectControlLinearizer::ValueEffectControl | 762 EffectControlLinearizer::ValueEffectControl |
| 817 EffectControlLinearizer::LowerObjectIsSmi(Node* node, Node* effect, | |
| 818 Node* control) { | |
| 819 Node* value = node->InputAt(0); | |
| 820 value = ObjectIsSmi(value); | |
| 821 return ValueEffectControl(value, effect, control); | |
| 822 } | |
| 823 | |
| 824 EffectControlLinearizer::ValueEffectControl | |
| 825 EffectControlLinearizer::LowerObjectIsString(Node* node, Node* effect, | 763 EffectControlLinearizer::LowerObjectIsString(Node* node, Node* effect, |
| 826 Node* control) { | 764 Node* control) { |
| 827 Node* value = node->InputAt(0); | 765 Node* value = node->InputAt(0); |
| 828 | 766 |
| 829 Node* check = ObjectIsSmi(value); | 767 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 830 Node* branch = | 768 Node* branch = |
| 831 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 769 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
| 832 | 770 |
| 833 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 771 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 834 Node* etrue = effect; | 772 Node* etrue = effect; |
| 835 Node* vtrue = jsgraph()->Int32Constant(0); | 773 Node* vtrue = jsgraph()->Int32Constant(0); |
| 836 | 774 |
| 837 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 775 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 838 Node* efalse = effect; | 776 Node* efalse = effect; |
| 839 Node* vfalse; | 777 Node* vfalse; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 854 vfalse, control); | 792 vfalse, control); |
| 855 | 793 |
| 856 return ValueEffectControl(value, effect, control); | 794 return ValueEffectControl(value, effect, control); |
| 857 } | 795 } |
| 858 | 796 |
| 859 EffectControlLinearizer::ValueEffectControl | 797 EffectControlLinearizer::ValueEffectControl |
| 860 EffectControlLinearizer::LowerObjectIsUndetectable(Node* node, Node* effect, | 798 EffectControlLinearizer::LowerObjectIsUndetectable(Node* node, Node* effect, |
| 861 Node* control) { | 799 Node* control) { |
| 862 Node* value = node->InputAt(0); | 800 Node* value = node->InputAt(0); |
| 863 | 801 |
| 864 Node* check = ObjectIsSmi(value); | 802 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
| 865 Node* branch = | 803 Node* branch = |
| 866 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 804 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
| 867 | 805 |
| 868 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 806 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 869 Node* etrue = effect; | 807 Node* etrue = effect; |
| 870 Node* vtrue = jsgraph()->Int32Constant(0); | 808 Node* vtrue = jsgraph()->Int32Constant(0); |
| 871 | 809 |
| 872 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 810 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 873 Node* efalse = effect; | 811 Node* efalse = effect; |
| 874 Node* vfalse; | 812 Node* vfalse; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 893 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 831 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 894 value = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2), vtrue, | 832 value = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2), vtrue, |
| 895 vfalse, control); | 833 vfalse, control); |
| 896 | 834 |
| 897 return ValueEffectControl(value, effect, control); | 835 return ValueEffectControl(value, effect, control); |
| 898 } | 836 } |
| 899 | 837 |
| 900 EffectControlLinearizer::ValueEffectControl | 838 EffectControlLinearizer::ValueEffectControl |
| 901 EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect, | 839 EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect, |
| 902 Node* control) { | 840 Node* control) { |
| 841 effect = graph()->NewNode(common()->BeginRegion(), effect); |
| 903 Node* result = effect = graph()->NewNode( | 842 Node* result = effect = graph()->NewNode( |
| 904 simplified()->Allocate(NOT_TENURED), | 843 simplified()->Allocate(NOT_TENURED), |
| 905 jsgraph()->Int32Constant(HeapNumber::kSize), effect, control); | 844 jsgraph()->Int32Constant(HeapNumber::kSize), effect, control); |
| 906 effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()), | 845 effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()), |
| 907 result, jsgraph()->HeapNumberMapConstant(), effect, | 846 result, jsgraph()->HeapNumberMapConstant(), effect, |
| 908 control); | 847 control); |
| 909 effect = graph()->NewNode( | 848 effect = graph()->NewNode( |
| 910 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), result, | 849 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), result, |
| 911 value, effect, control); | 850 value, effect, control); |
| 851 result = effect = graph()->NewNode(common()->FinishRegion(), result, effect); |
| 912 return ValueEffectControl(result, effect, control); | 852 return ValueEffectControl(result, effect, control); |
| 913 } | 853 } |
| 914 | 854 |
| 915 Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) { | 855 Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) { |
| 916 if (machine()->Is64()) { | 856 if (machine()->Is64()) { |
| 917 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value); | 857 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value); |
| 918 } | 858 } |
| 919 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); | 859 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); |
| 920 } | 860 } |
| 921 | 861 |
| 922 Node* EffectControlLinearizer::ChangeUint32ToSmi(Node* value) { | 862 Node* EffectControlLinearizer::ChangeUint32ToSmi(Node* value) { |
| 923 if (machine()->Is64()) { | 863 if (machine()->Is64()) { |
| 924 value = graph()->NewNode(machine()->ChangeUint32ToUint64(), value); | 864 value = graph()->NewNode(machine()->ChangeUint32ToUint64(), value); |
| 925 } | 865 } |
| 926 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); | 866 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); |
| 927 } | 867 } |
| 928 | 868 |
| 929 Node* EffectControlLinearizer::ChangeInt32ToFloat64(Node* value) { | 869 Node* EffectControlLinearizer::ChangeInt32ToFloat64(Node* value) { |
| 930 return graph()->NewNode(machine()->ChangeInt32ToFloat64(), value); | 870 return graph()->NewNode(machine()->ChangeInt32ToFloat64(), value); |
| 931 } | 871 } |
| 932 | 872 |
| 933 Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) { | 873 Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) { |
| 934 return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value); | 874 return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value); |
| 935 } | 875 } |
| 936 | 876 |
| 937 Node* EffectControlLinearizer::ChangeSmiToInt32(Node* value) { | |
| 938 value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant()); | |
| 939 if (machine()->Is64()) { | |
| 940 value = graph()->NewNode(machine()->TruncateInt64ToInt32(), value); | |
| 941 } | |
| 942 return value; | |
| 943 } | |
| 944 | |
| 945 Node* EffectControlLinearizer::ObjectIsSmi(Node* value) { | |
| 946 return graph()->NewNode( | |
| 947 machine()->WordEqual(), | |
| 948 graph()->NewNode(machine()->WordAnd(), value, | |
| 949 jsgraph()->IntPtrConstant(kSmiTagMask)), | |
| 950 jsgraph()->IntPtrConstant(kSmiTag)); | |
| 951 } | |
| 952 | |
| 953 Node* EffectControlLinearizer::SmiMaxValueConstant() { | 877 Node* EffectControlLinearizer::SmiMaxValueConstant() { |
| 954 return jsgraph()->Int32Constant(Smi::kMaxValue); | 878 return jsgraph()->Int32Constant(Smi::kMaxValue); |
| 955 } | 879 } |
| 956 | 880 |
| 957 Node* EffectControlLinearizer::SmiShiftBitsConstant() { | 881 Node* EffectControlLinearizer::SmiShiftBitsConstant() { |
| 958 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize); | 882 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize); |
| 959 } | 883 } |
| 960 | 884 |
| 961 } // namespace compiler | 885 } // namespace compiler |
| 962 } // namespace internal | 886 } // namespace internal |
| 963 } // namespace v8 | 887 } // namespace v8 |
| OLD | NEW |