| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 ASSERT(phi->is_alive()); | 621 ASSERT(phi->is_alive()); |
| 622 // For phis conversions have to be inserted in the predecessor. | 622 // For phis conversions have to be inserted in the predecessor. |
| 623 insert_before = | 623 insert_before = |
| 624 phi->block()->PredecessorAt(use->use_index())->last_instruction(); | 624 phi->block()->PredecessorAt(use->use_index())->last_instruction(); |
| 625 deopt_target = NULL; | 625 deopt_target = NULL; |
| 626 } else { | 626 } else { |
| 627 deopt_target = insert_before = use->instruction(); | 627 deopt_target = insert_before = use->instruction(); |
| 628 } | 628 } |
| 629 | 629 |
| 630 Definition* converted = NULL; | 630 Definition* converted = NULL; |
| 631 if ((from == kTagged) && (to == kUnboxedMint)) { | 631 if (IsUnboxedInteger(from) && IsUnboxedInteger(to)) { |
| 632 ASSERT((deopt_target != NULL) || | |
| 633 (use->Type()->ToCid() == kUnboxedMint)); | |
| 634 const intptr_t deopt_id = (deopt_target != NULL) ? | |
| 635 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | |
| 636 converted = new(I) UnboxIntegerInstr(use->CopyWithType(), deopt_id); | |
| 637 } else if ((from == kUnboxedMint) && (to == kTagged)) { | |
| 638 converted = new(I) BoxIntegerInstr(use->CopyWithType()); | |
| 639 } else if ((from == kUnboxedUint32) && (to == kTagged)) { | |
| 640 converted = new(I) BoxUint32Instr(use->CopyWithType()); | |
| 641 } else if (IsUnboxedInteger(from) && IsUnboxedInteger(to)) { | |
| 642 const intptr_t deopt_id = (to == kUnboxedInt32) && (deopt_target != NULL) ? | 632 const intptr_t deopt_id = (to == kUnboxedInt32) && (deopt_target != NULL) ? |
| 643 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | 633 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; |
| 644 converted = new(I) UnboxedIntConverterInstr(from, | 634 converted = new(I) UnboxedIntConverterInstr(from, |
| 645 to, | 635 to, |
| 646 use->CopyWithType(), | 636 use->CopyWithType(), |
| 647 deopt_id); | 637 deopt_id); |
| 648 } else if ((from == kUnboxedInt32) && (to == kUnboxedDouble)) { | 638 } else if ((from == kUnboxedInt32) && (to == kUnboxedDouble)) { |
| 649 converted = new Int32ToDoubleInstr(use->CopyWithType()); | 639 converted = new Int32ToDoubleInstr(use->CopyWithType()); |
| 650 } else if ((from == kTagged) && (to == kUnboxedInt32)) { | 640 } else if ((from == kUnboxedMint) && |
| 641 (to == kUnboxedDouble) && |
| 642 CanConvertUnboxedMintToDouble()) { |
| 651 const intptr_t deopt_id = (deopt_target != NULL) ? | 643 const intptr_t deopt_id = (deopt_target != NULL) ? |
| 652 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | 644 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; |
| 653 converted = new UnboxInt32Instr(use->CopyWithType(), deopt_id); | 645 ASSERT(CanUnboxDouble()); |
| 654 } else if ((from == kUnboxedInt32) && (to == kTagged)) { | 646 converted = new MintToDoubleInstr(use->CopyWithType(), deopt_id); |
| 655 converted = new BoxInt32Instr(use->CopyWithType()); | 647 } else if ((from == kTagged) && Boxing::Supports(to)) { |
| 656 } else if ((from == kTagged) && (to == kUnboxedUint32)) { | |
| 657 const intptr_t deopt_id = (deopt_target != NULL) ? | 648 const intptr_t deopt_id = (deopt_target != NULL) ? |
| 658 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | 649 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; |
| 659 converted = new UnboxUint32Instr(use->CopyWithType(), deopt_id); | 650 converted = UnboxInstr::Create(to, use->CopyWithType(), deopt_id); |
| 660 } else if (from == kUnboxedMint && to == kUnboxedDouble) { | 651 } else if ((to == kTagged) && Boxing::Supports(from)) { |
| 661 ASSERT(CanUnboxDouble()); | 652 converted = BoxInstr::Create(from, use->CopyWithType()); |
| 662 const intptr_t deopt_id = (deopt_target != NULL) ? | |
| 663 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | |
| 664 if (CanConvertUnboxedMintToDouble()) { | |
| 665 // Fast path. | |
| 666 converted = new MintToDoubleInstr(use->CopyWithType(), deopt_id); | |
| 667 } else { | |
| 668 // Slow path. | |
| 669 BoxIntegerInstr* boxed = new(I) BoxIntegerInstr(use->CopyWithType()); | |
| 670 use->BindTo(boxed); | |
| 671 InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue); | |
| 672 converted = new(I) UnboxDoubleInstr(new(I) Value(boxed), deopt_id); | |
| 673 } | |
| 674 } else if ((from == kUnboxedDouble) && (to == kTagged)) { | |
| 675 ASSERT(CanUnboxDouble()); | |
| 676 converted = new(I) BoxDoubleInstr(use->CopyWithType()); | |
| 677 } else if ((from == kTagged) && (to == kUnboxedDouble)) { | |
| 678 ASSERT(CanUnboxDouble()); | |
| 679 ASSERT((deopt_target != NULL) || | |
| 680 (use->Type()->ToCid() == kDoubleCid)); | |
| 681 const intptr_t deopt_id = (deopt_target != NULL) ? | |
| 682 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | |
| 683 ConstantInstr* constant = use->definition()->AsConstant(); | |
| 684 if ((constant != NULL) && constant->value().IsSmi()) { | |
| 685 const double dbl_val = Smi::Cast(constant->value()).AsDoubleValue(); | |
| 686 const Double& dbl_obj = | |
| 687 Double::ZoneHandle(I, Double::NewCanonical(dbl_val)); | |
| 688 ConstantInstr* double_const = flow_graph()->GetConstant(dbl_obj); | |
| 689 converted = new(I) UnboxDoubleInstr(new(I) Value(double_const), deopt_id); | |
| 690 } else { | |
| 691 converted = new(I) UnboxDoubleInstr(use->CopyWithType(), deopt_id); | |
| 692 } | |
| 693 } else if ((from == kTagged) && (to == kUnboxedFloat32x4)) { | |
| 694 ASSERT((deopt_target != NULL) || | |
| 695 (use->Type()->ToCid() == kFloat32x4Cid)); | |
| 696 const intptr_t deopt_id = (deopt_target != NULL) ? | |
| 697 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | |
| 698 converted = new(I) UnboxFloat32x4Instr( | |
| 699 use->CopyWithType(), deopt_id); | |
| 700 } else if ((from == kUnboxedFloat32x4) && (to == kTagged)) { | |
| 701 converted = new(I) BoxFloat32x4Instr(use->CopyWithType()); | |
| 702 } else if ((from == kTagged) && (to == kUnboxedInt32x4)) { | |
| 703 ASSERT((deopt_target != NULL) || (use->Type()->ToCid() == kInt32x4Cid)); | |
| 704 const intptr_t deopt_id = (deopt_target != NULL) ? | |
| 705 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | |
| 706 converted = new(I) UnboxInt32x4Instr(use->CopyWithType(), deopt_id); | |
| 707 } else if ((from == kUnboxedInt32x4) && (to == kTagged)) { | |
| 708 converted = new(I) BoxInt32x4Instr(use->CopyWithType()); | |
| 709 } else if ((from == kTagged) && (to == kUnboxedFloat64x2)) { | |
| 710 ASSERT((deopt_target != NULL) || (use->Type()->ToCid() == kFloat64x2Cid)); | |
| 711 const intptr_t deopt_id = (deopt_target != NULL) ? | |
| 712 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | |
| 713 converted = new(I) UnboxFloat64x2Instr(use->CopyWithType(), deopt_id); | |
| 714 } else if ((from == kUnboxedFloat64x2) && (to == kTagged)) { | |
| 715 converted = new(I) BoxFloat64x2Instr(use->CopyWithType()); | |
| 716 } else { | 653 } else { |
| 717 // We have failed to find a suitable conversion instruction. | 654 // We have failed to find a suitable conversion instruction. |
| 718 // Insert two "dummy" conversion instructions with the correct | 655 // Insert two "dummy" conversion instructions with the correct |
| 719 // "from" and "to" representation. The inserted instructions will | 656 // "from" and "to" representation. The inserted instructions will |
| 720 // trigger a deoptimization if executed. See #12417 for a discussion. | 657 // trigger a deoptimization if executed. See #12417 for a discussion. |
| 721 const intptr_t deopt_id = (deopt_target != NULL) ? | 658 const intptr_t deopt_id = (deopt_target != NULL) ? |
| 722 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | 659 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; |
| 723 ASSERT(from != kTagged); | 660 ASSERT(Boxing::Supports(from)); |
| 724 ASSERT(to != kTagged); | 661 ASSERT(Boxing::Supports(to)); |
| 725 Definition* boxed = NULL; | 662 Definition* boxed = BoxInstr::Create(from, use->CopyWithType()); |
| 726 if (from == kUnboxedDouble) { | |
| 727 boxed = new(I) BoxDoubleInstr(use->CopyWithType()); | |
| 728 } else if (from == kUnboxedInt32x4) { | |
| 729 boxed = new(I) BoxInt32x4Instr(use->CopyWithType()); | |
| 730 } else if (from == kUnboxedFloat32x4) { | |
| 731 boxed = new(I) BoxFloat32x4Instr(use->CopyWithType()); | |
| 732 } else if (from == kUnboxedMint) { | |
| 733 boxed = new(I) BoxIntegerInstr(use->CopyWithType()); | |
| 734 } else if (from == kUnboxedFloat64x2) { | |
| 735 boxed = new(I) BoxFloat64x2Instr(use->CopyWithType()); | |
| 736 } else if (from == kUnboxedInt32) { | |
| 737 boxed = new(I) BoxInt32Instr(use->CopyWithType()); | |
| 738 } else if (from == kUnboxedUint32) { | |
| 739 boxed = new(I) BoxUint32Instr(use->CopyWithType()); | |
| 740 } else { | |
| 741 UNIMPLEMENTED(); | |
| 742 } | |
| 743 use->BindTo(boxed); | 663 use->BindTo(boxed); |
| 744 InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue); | 664 InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue); |
| 745 Value* to_value = new(I) Value(boxed); | 665 converted = UnboxInstr::Create(to, new(I) Value(boxed), deopt_id); |
| 746 if (to == kUnboxedDouble) { | |
| 747 converted = new(I) UnboxDoubleInstr(to_value, deopt_id); | |
| 748 } else if (to == kUnboxedInt32x4) { | |
| 749 converted = new(I) UnboxInt32x4Instr(to_value, deopt_id); | |
| 750 } else if (to == kUnboxedFloat32x4) { | |
| 751 converted = new(I) UnboxFloat32x4Instr(to_value, deopt_id); | |
| 752 } else if (to == kUnboxedMint) { | |
| 753 converted = new(I) UnboxIntegerInstr(to_value, deopt_id); | |
| 754 } else if (to == kUnboxedFloat64x2) { | |
| 755 converted = new(I) UnboxFloat64x2Instr(to_value, deopt_id); | |
| 756 } else if (to == kUnboxedInt32) { | |
| 757 boxed = new(I) UnboxInt32Instr(use->CopyWithType(), deopt_id); | |
| 758 } else if (to == kUnboxedUint32) { | |
| 759 boxed = new(I) UnboxUint32Instr(use->CopyWithType(), deopt_id); | |
| 760 } else { | |
| 761 UNIMPLEMENTED(); | |
| 762 } | |
| 763 } | 666 } |
| 764 ASSERT(converted != NULL); | 667 ASSERT(converted != NULL); |
| 765 InsertBefore(insert_before, converted, use->instruction()->env(), | 668 InsertBefore(insert_before, converted, use->instruction()->env(), |
| 766 FlowGraph::kValue); | 669 FlowGraph::kValue); |
| 767 if (is_environment_use) { | 670 if (is_environment_use) { |
| 768 use->BindToEnvironment(converted); | 671 use->BindToEnvironment(converted); |
| 769 } else { | 672 } else { |
| 770 use->BindTo(converted); | 673 use->BindTo(converted); |
| 771 } | 674 } |
| 772 | 675 |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 if (array_cid == kTypedDataFloat32ArrayCid) { | 1290 if (array_cid == kTypedDataFloat32ArrayCid) { |
| 1388 stored_value = | 1291 stored_value = |
| 1389 new(I) DoubleToFloatInstr( | 1292 new(I) DoubleToFloatInstr( |
| 1390 new(I) Value(stored_value), call->deopt_id()); | 1293 new(I) Value(stored_value), call->deopt_id()); |
| 1391 cursor = flow_graph()->AppendTo(cursor, | 1294 cursor = flow_graph()->AppendTo(cursor, |
| 1392 stored_value, | 1295 stored_value, |
| 1393 NULL, | 1296 NULL, |
| 1394 FlowGraph::kValue); | 1297 FlowGraph::kValue); |
| 1395 } else if (array_cid == kTypedDataInt32ArrayCid) { | 1298 } else if (array_cid == kTypedDataInt32ArrayCid) { |
| 1396 stored_value = new(I) UnboxInt32Instr( | 1299 stored_value = new(I) UnboxInt32Instr( |
| 1300 UnboxInt32Instr::kTruncate, |
| 1397 new(I) Value(stored_value), | 1301 new(I) Value(stored_value), |
| 1398 call->deopt_id()); | 1302 call->deopt_id()); |
| 1399 stored_value->AsUnboxIntN()->mark_truncating(); | |
| 1400 cursor = flow_graph()->AppendTo(cursor, | 1303 cursor = flow_graph()->AppendTo(cursor, |
| 1401 stored_value, | 1304 stored_value, |
| 1402 call->env(), | 1305 call->env(), |
| 1403 FlowGraph::kValue); | 1306 FlowGraph::kValue); |
| 1404 } else if (array_cid == kTypedDataUint32ArrayCid) { | 1307 } else if (array_cid == kTypedDataUint32ArrayCid) { |
| 1405 stored_value = new(I) UnboxUint32Instr( | 1308 stored_value = new(I) UnboxUint32Instr( |
| 1406 new(I) Value(stored_value), | 1309 new(I) Value(stored_value), |
| 1407 call->deopt_id()); | 1310 call->deopt_id()); |
| 1408 ASSERT(stored_value->AsUnboxIntN()->is_truncating()); | 1311 ASSERT(stored_value->AsUnboxInteger()->is_truncating()); |
| 1409 cursor = flow_graph()->AppendTo(cursor, | 1312 cursor = flow_graph()->AppendTo(cursor, |
| 1410 stored_value, | 1313 stored_value, |
| 1411 call->env(), | 1314 call->env(), |
| 1412 FlowGraph::kValue); | 1315 FlowGraph::kValue); |
| 1413 } | 1316 } |
| 1414 | 1317 |
| 1415 const intptr_t index_scale = Instance::ElementSizeFor(array_cid); | 1318 const intptr_t index_scale = Instance::ElementSizeFor(array_cid); |
| 1416 *last = new(I) StoreIndexedInstr(new(I) Value(array), | 1319 *last = new(I) StoreIndexedInstr(new(I) Value(array), |
| 1417 new(I) Value(index), | 1320 new(I) Value(index), |
| 1418 new(I) Value(stored_value), | 1321 new(I) Value(stored_value), |
| (...skipping 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3875 | 3778 |
| 3876 if (view_cid == kTypedDataFloat32ArrayCid) { | 3779 if (view_cid == kTypedDataFloat32ArrayCid) { |
| 3877 stored_value = new(I) DoubleToFloatInstr( | 3780 stored_value = new(I) DoubleToFloatInstr( |
| 3878 new(I) Value(stored_value), call->deopt_id()); | 3781 new(I) Value(stored_value), call->deopt_id()); |
| 3879 cursor = flow_graph()->AppendTo(cursor, | 3782 cursor = flow_graph()->AppendTo(cursor, |
| 3880 stored_value, | 3783 stored_value, |
| 3881 NULL, | 3784 NULL, |
| 3882 FlowGraph::kValue); | 3785 FlowGraph::kValue); |
| 3883 } else if (view_cid == kTypedDataInt32ArrayCid) { | 3786 } else if (view_cid == kTypedDataInt32ArrayCid) { |
| 3884 stored_value = new(I) UnboxInt32Instr( | 3787 stored_value = new(I) UnboxInt32Instr( |
| 3788 UnboxInt32Instr::kTruncate, |
| 3885 new(I) Value(stored_value), | 3789 new(I) Value(stored_value), |
| 3886 call->deopt_id()); | 3790 call->deopt_id()); |
| 3887 stored_value->AsUnboxIntN()->mark_truncating(); | |
| 3888 cursor = flow_graph()->AppendTo(cursor, | 3791 cursor = flow_graph()->AppendTo(cursor, |
| 3889 stored_value, | 3792 stored_value, |
| 3890 call->env(), | 3793 call->env(), |
| 3891 FlowGraph::kValue); | 3794 FlowGraph::kValue); |
| 3892 } else if (view_cid == kTypedDataUint32ArrayCid) { | 3795 } else if (view_cid == kTypedDataUint32ArrayCid) { |
| 3893 stored_value = new(I) UnboxUint32Instr( | 3796 stored_value = new(I) UnboxUint32Instr( |
| 3894 new(I) Value(stored_value), | 3797 new(I) Value(stored_value), |
| 3895 call->deopt_id()); | 3798 call->deopt_id()); |
| 3896 ASSERT(stored_value->AsUnboxIntN()->is_truncating()); | 3799 ASSERT(stored_value->AsUnboxInteger()->is_truncating()); |
| 3897 cursor = flow_graph()->AppendTo(cursor, | 3800 cursor = flow_graph()->AppendTo(cursor, |
| 3898 stored_value, | 3801 stored_value, |
| 3899 call->env(), | 3802 call->env(), |
| 3900 FlowGraph::kValue); | 3803 FlowGraph::kValue); |
| 3901 } | 3804 } |
| 3902 | 3805 |
| 3903 StoreBarrierType needs_store_barrier = kNoStoreBarrier; | 3806 StoreBarrierType needs_store_barrier = kNoStoreBarrier; |
| 3904 *last = new(I) StoreIndexedInstr(new(I) Value(array), | 3807 *last = new(I) StoreIndexedInstr(new(I) Value(array), |
| 3905 new(I) Value(index), | 3808 new(I) Value(index), |
| 3906 new(I) Value(stored_value), | 3809 new(I) Value(stored_value), |
| (...skipping 4486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8393 void ConstantPropagator::VisitBinaryMintOp(BinaryMintOpInstr* instr) { | 8296 void ConstantPropagator::VisitBinaryMintOp(BinaryMintOpInstr* instr) { |
| 8394 VisitBinaryIntegerOp(instr); | 8297 VisitBinaryIntegerOp(instr); |
| 8395 } | 8298 } |
| 8396 | 8299 |
| 8397 | 8300 |
| 8398 void ConstantPropagator::VisitShiftMintOp(ShiftMintOpInstr* instr) { | 8301 void ConstantPropagator::VisitShiftMintOp(ShiftMintOpInstr* instr) { |
| 8399 VisitBinaryIntegerOp(instr); | 8302 VisitBinaryIntegerOp(instr); |
| 8400 } | 8303 } |
| 8401 | 8304 |
| 8402 | 8305 |
| 8403 void ConstantPropagator::VisitBoxInteger(BoxIntegerInstr* instr) { | 8306 void ConstantPropagator::VisitBoxInt64(BoxInt64Instr* instr) { |
| 8404 // TODO(kmillikin): Handle box operation. | 8307 // TODO(kmillikin): Handle box operation. |
| 8405 SetValue(instr, non_constant_); | 8308 SetValue(instr, non_constant_); |
| 8406 } | 8309 } |
| 8407 | 8310 |
| 8408 | 8311 |
| 8409 void ConstantPropagator::VisitUnboxInteger(UnboxIntegerInstr* instr) { | 8312 void ConstantPropagator::VisitUnboxInt64(UnboxInt64Instr* instr) { |
| 8410 // TODO(kmillikin): Handle unbox operation. | 8313 // TODO(kmillikin): Handle unbox operation. |
| 8411 SetValue(instr, non_constant_); | 8314 SetValue(instr, non_constant_); |
| 8412 } | 8315 } |
| 8413 | 8316 |
| 8414 | 8317 |
| 8415 void ConstantPropagator::VisitUnaryMintOp(UnaryMintOpInstr* instr) { | 8318 void ConstantPropagator::VisitUnaryMintOp(UnaryMintOpInstr* instr) { |
| 8416 // TODO(kmillikin): Handle unary operations. | 8319 // TODO(kmillikin): Handle unary operations. |
| 8417 SetValue(instr, non_constant_); | 8320 SetValue(instr, non_constant_); |
| 8418 } | 8321 } |
| 8419 | 8322 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8782 const Object& right = instr->right()->definition()->constant_value(); | 8685 const Object& right = instr->right()->definition()->constant_value(); |
| 8783 if (IsNonConstant(left) || IsNonConstant(right)) { | 8686 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 8784 SetValue(instr, non_constant_); | 8687 SetValue(instr, non_constant_); |
| 8785 } else if (IsConstant(left) && IsConstant(right)) { | 8688 } else if (IsConstant(left) && IsConstant(right)) { |
| 8786 // TODO(srdjan): Handle min and max. | 8689 // TODO(srdjan): Handle min and max. |
| 8787 SetValue(instr, non_constant_); | 8690 SetValue(instr, non_constant_); |
| 8788 } | 8691 } |
| 8789 } | 8692 } |
| 8790 | 8693 |
| 8791 | 8694 |
| 8792 void ConstantPropagator::VisitUnboxDouble(UnboxDoubleInstr* instr) { | 8695 void ConstantPropagator::VisitUnbox(UnboxInstr* instr) { |
| 8793 const Object& value = instr->value()->definition()->constant_value(); | 8696 const Object& value = instr->value()->definition()->constant_value(); |
| 8794 if (IsNonConstant(value)) { | 8697 if (IsNonConstant(value)) { |
| 8795 SetValue(instr, non_constant_); | 8698 SetValue(instr, non_constant_); |
| 8796 } else if (IsConstant(value)) { | |
| 8797 // TODO(kmillikin): Handle conversion. | |
| 8798 SetValue(instr, non_constant_); | |
| 8799 } | |
| 8800 } | |
| 8801 | |
| 8802 | |
| 8803 void ConstantPropagator::VisitBoxDouble(BoxDoubleInstr* instr) { | |
| 8804 const Object& value = instr->value()->definition()->constant_value(); | |
| 8805 if (IsNonConstant(value)) { | |
| 8806 SetValue(instr, non_constant_); | |
| 8807 } else if (IsConstant(value)) { | |
| 8808 // TODO(kmillikin): Handle conversion. | |
| 8809 SetValue(instr, non_constant_); | |
| 8810 } | |
| 8811 } | |
| 8812 | |
| 8813 | |
| 8814 void ConstantPropagator::VisitUnboxFloat32x4(UnboxFloat32x4Instr* instr) { | |
| 8815 const Object& value = instr->value()->definition()->constant_value(); | |
| 8816 if (IsNonConstant(value)) { | |
| 8817 SetValue(instr, non_constant_); | |
| 8818 } else if (IsConstant(value)) { | |
| 8819 // TODO(kmillikin): Handle conversion. | |
| 8820 SetValue(instr, non_constant_); | |
| 8821 } | |
| 8822 } | |
| 8823 | |
| 8824 | |
| 8825 void ConstantPropagator::VisitBoxFloat32x4(BoxFloat32x4Instr* instr) { | |
| 8826 const Object& value = instr->value()->definition()->constant_value(); | |
| 8827 if (IsNonConstant(value)) { | |
| 8828 SetValue(instr, non_constant_); | |
| 8829 } else if (IsConstant(value)) { | |
| 8830 // TODO(kmillikin): Handle conversion. | |
| 8831 SetValue(instr, non_constant_); | |
| 8832 } | |
| 8833 } | |
| 8834 | |
| 8835 | |
| 8836 void ConstantPropagator::VisitUnboxFloat64x2(UnboxFloat64x2Instr* instr) { | |
| 8837 const Object& value = instr->value()->definition()->constant_value(); | |
| 8838 if (IsNonConstant(value)) { | |
| 8839 SetValue(instr, non_constant_); | |
| 8840 } else if (IsConstant(value)) { | |
| 8841 // TODO(kmillikin): Handle conversion. | |
| 8842 SetValue(instr, non_constant_); | |
| 8843 } | |
| 8844 } | |
| 8845 | |
| 8846 | |
| 8847 void ConstantPropagator::VisitBoxFloat64x2(BoxFloat64x2Instr* instr) { | |
| 8848 const Object& value = instr->value()->definition()->constant_value(); | |
| 8849 if (IsNonConstant(value)) { | |
| 8850 SetValue(instr, non_constant_); | |
| 8851 } else if (IsConstant(value)) { | |
| 8852 // TODO(kmillikin): Handle conversion. | |
| 8853 SetValue(instr, non_constant_); | |
| 8854 } | |
| 8855 } | |
| 8856 | |
| 8857 | |
| 8858 void ConstantPropagator::VisitUnboxInt32x4(UnboxInt32x4Instr* instr) { | |
| 8859 const Object& value = instr->value()->definition()->constant_value(); | |
| 8860 if (IsNonConstant(value)) { | |
| 8861 SetValue(instr, non_constant_); | |
| 8862 } else if (IsConstant(value)) { | 8699 } else if (IsConstant(value)) { |
| 8863 // TODO(kmillikin): Handle conversion. | 8700 // TODO(kmillikin): Handle conversion. |
| 8864 SetValue(instr, non_constant_); | 8701 SetValue(instr, non_constant_); |
| 8865 } | 8702 } |
| 8866 } | 8703 } |
| 8867 | 8704 |
| 8868 | 8705 |
| 8869 void ConstantPropagator::VisitBoxInt32x4(BoxInt32x4Instr* instr) { | 8706 void ConstantPropagator::VisitBox(BoxInstr* instr) { |
| 8870 const Object& value = instr->value()->definition()->constant_value(); | 8707 const Object& value = instr->value()->definition()->constant_value(); |
| 8871 if (IsNonConstant(value)) { | 8708 if (IsNonConstant(value)) { |
| 8872 SetValue(instr, non_constant_); | 8709 SetValue(instr, non_constant_); |
| 8873 } else if (IsConstant(value)) { | 8710 } else if (IsConstant(value)) { |
| 8874 // TODO(kmillikin): Handle conversion. | 8711 // TODO(kmillikin): Handle conversion. |
| 8875 SetValue(instr, non_constant_); | 8712 SetValue(instr, non_constant_); |
| 8876 } | 8713 } |
| 8877 } | 8714 } |
| 8878 | 8715 |
| 8879 | 8716 |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9886 } | 9723 } |
| 9887 | 9724 |
| 9888 // Process materializations and unbox their arguments: materializations | 9725 // Process materializations and unbox their arguments: materializations |
| 9889 // are part of the environment and can materialize boxes for double/mint/simd | 9726 // are part of the environment and can materialize boxes for double/mint/simd |
| 9890 // values when needed. | 9727 // values when needed. |
| 9891 // TODO(vegorov): handle all box types here. | 9728 // TODO(vegorov): handle all box types here. |
| 9892 for (intptr_t i = 0; i < materializations_.length(); i++) { | 9729 for (intptr_t i = 0; i < materializations_.length(); i++) { |
| 9893 MaterializeObjectInstr* mat = materializations_[i]; | 9730 MaterializeObjectInstr* mat = materializations_[i]; |
| 9894 for (intptr_t j = 0; j < mat->InputCount(); j++) { | 9731 for (intptr_t j = 0; j < mat->InputCount(); j++) { |
| 9895 Definition* defn = mat->InputAt(j)->definition(); | 9732 Definition* defn = mat->InputAt(j)->definition(); |
| 9896 if (defn->IsBoxDouble() || | 9733 if (defn->IsBox()) { |
| 9897 defn->IsBoxFloat32x4() || | |
| 9898 defn->IsBoxInt32x4()) { | |
| 9899 mat->InputAt(j)->BindTo(defn->InputAt(0)->definition()); | 9734 mat->InputAt(j)->BindTo(defn->InputAt(0)->definition()); |
| 9900 } | 9735 } |
| 9901 } | 9736 } |
| 9902 } | 9737 } |
| 9903 } | 9738 } |
| 9904 | 9739 |
| 9905 | 9740 |
| 9906 // Remove materializations from the graph. Register allocator will treat them | 9741 // Remove materializations from the graph. Register allocator will treat them |
| 9907 // as part of the environment not as a real instruction. | 9742 // as part of the environment not as a real instruction. |
| 9908 void AllocationSinking::DetachMaterializations() { | 9743 void AllocationSinking::DetachMaterializations() { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10122 | 9957 |
| 10123 // Insert materializations at environment uses. | 9958 // Insert materializations at environment uses. |
| 10124 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 9959 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 10125 CreateMaterializationAt( | 9960 CreateMaterializationAt( |
| 10126 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 9961 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 10127 } | 9962 } |
| 10128 } | 9963 } |
| 10129 | 9964 |
| 10130 | 9965 |
| 10131 } // namespace dart | 9966 } // namespace dart |
| OLD | NEW |