| 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 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 V(_ImmutableArray, get:length, ImmutableArrayLength, 433698233) \ | 39 V(_ImmutableArray, get:length, ImmutableArrayLength, 433698233) \ |
| 40 V(_TypedList, get:length, TypedDataLength, 231908172) \ | 40 V(_TypedList, get:length, TypedDataLength, 231908172) \ |
| 41 V(_TypedList, _getInt8, ByteArrayBaseGetInt8, 380843687) \ | 41 V(_TypedList, _getInt8, ByteArrayBaseGetInt8, 380843687) \ |
| 42 V(_TypedList, _getUint8, ByteArrayBaseGetUint8, 380843687) \ | 42 V(_TypedList, _getUint8, ByteArrayBaseGetUint8, 380843687) \ |
| 43 V(_TypedList, _getInt16, ByteArrayBaseGetInt16, 380843687) \ | 43 V(_TypedList, _getInt16, ByteArrayBaseGetInt16, 380843687) \ |
| 44 V(_TypedList, _getUint16, ByteArrayBaseGetUint16, 380843687) \ | 44 V(_TypedList, _getUint16, ByteArrayBaseGetUint16, 380843687) \ |
| 45 V(_TypedList, _getInt32, ByteArrayBaseGetInt32, 380843687) \ | 45 V(_TypedList, _getInt32, ByteArrayBaseGetInt32, 380843687) \ |
| 46 V(_TypedList, _getUint32, ByteArrayBaseGetUint32, 380843687) \ | 46 V(_TypedList, _getUint32, ByteArrayBaseGetUint32, 380843687) \ |
| 47 V(_TypedList, _getFloat32, ByteArrayBaseGetFloat32, 979971573) \ | 47 V(_TypedList, _getFloat32, ByteArrayBaseGetFloat32, 979971573) \ |
| 48 V(_TypedList, _getFloat64, ByteArrayBaseGetFloat64, 979971573) \ | 48 V(_TypedList, _getFloat64, ByteArrayBaseGetFloat64, 979971573) \ |
| 49 V(_TypedList, _getFloat32x4, ByteArrayBaseGetFloat32x4, 690339584) \ |
| 49 V(_TypedList, _setInt8, ByteArrayBaseSetInt8, 287047804) \ | 50 V(_TypedList, _setInt8, ByteArrayBaseSetInt8, 287047804) \ |
| 50 V(_TypedList, _setUint8, ByteArrayBaseSetUint8, 287047804) \ | 51 V(_TypedList, _setUint8, ByteArrayBaseSetUint8, 287047804) \ |
| 51 V(_TypedList, _setInt16, ByteArrayBaseSetInt16, 287047804) \ | 52 V(_TypedList, _setInt16, ByteArrayBaseSetInt16, 287047804) \ |
| 52 V(_TypedList, _setUint16, ByteArrayBaseSetUint16, 287047804) \ | 53 V(_TypedList, _setUint16, ByteArrayBaseSetUint16, 287047804) \ |
| 53 V(_TypedList, _setInt32, ByteArrayBaseSetInt32, 287047804) \ | 54 V(_TypedList, _setInt32, ByteArrayBaseSetInt32, 287047804) \ |
| 54 V(_TypedList, _setUint32, ByteArrayBaseSetUint32, 287047804) \ | 55 V(_TypedList, _setUint32, ByteArrayBaseSetUint32, 287047804) \ |
| 55 V(_TypedList, _setFloat32, ByteArrayBaseSetFloat32, 1032541114) \ | 56 V(_TypedList, _setFloat32, ByteArrayBaseSetFloat32, 1032541114) \ |
| 56 V(_TypedList, _setFloat64, ByteArrayBaseSetFloat64, 1032541114) \ | 57 V(_TypedList, _setFloat64, ByteArrayBaseSetFloat64, 1032541114) \ |
| 58 V(_TypedList, _setFloat32x4, ByteArrayBaseSetFloat32x4, 1016704782) \ |
| 57 V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \ | 59 V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \ |
| 58 V(_GrowableObjectArray, get:_capacity, GrowableArrayCapacity, 725548050) \ | 60 V(_GrowableObjectArray, get:_capacity, GrowableArrayCapacity, 725548050) \ |
| 59 V(_StringBase, get:length, StringBaseLength, 320803993) \ | 61 V(_StringBase, get:length, StringBaseLength, 320803993) \ |
| 60 V(_StringBase, get:isEmpty, StringBaseIsEmpty, 110632481) \ | 62 V(_StringBase, get:isEmpty, StringBaseIsEmpty, 110632481) \ |
| 61 V(_StringBase, codeUnitAt, StringBaseCodeUnitAt, 984449525) \ | 63 V(_StringBase, codeUnitAt, StringBaseCodeUnitAt, 984449525) \ |
| 62 V(_StringBase, [], StringBaseCharAt, 1062366987) \ | 64 V(_StringBase, [], StringBaseCharAt, 1062366987) \ |
| 63 V(_IntegerImplementation, toDouble, IntegerToDouble, 927078825) \ | 65 V(_IntegerImplementation, toDouble, IntegerToDouble, 927078825) \ |
| 64 V(_Double, toInt, DoubleToInteger, 362666636) \ | 66 V(_Double, toInt, DoubleToInteger, 362666636) \ |
| 65 V(_Double, truncateToDouble, DoubleTruncate, 620870996) \ | 67 V(_Double, truncateToDouble, DoubleTruncate, 620870996) \ |
| 66 V(_Double, roundToDouble, DoubleRound, 620870996) \ | 68 V(_Double, roundToDouble, DoubleRound, 620870996) \ |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 M(CatchEntry) \ | 478 M(CatchEntry) \ |
| 477 M(BinarySmiOp) \ | 479 M(BinarySmiOp) \ |
| 478 M(UnarySmiOp) \ | 480 M(UnarySmiOp) \ |
| 479 M(CheckStackOverflow) \ | 481 M(CheckStackOverflow) \ |
| 480 M(SmiToDouble) \ | 482 M(SmiToDouble) \ |
| 481 M(DoubleToInteger) \ | 483 M(DoubleToInteger) \ |
| 482 M(DoubleToSmi) \ | 484 M(DoubleToSmi) \ |
| 483 M(DoubleToDouble) \ | 485 M(DoubleToDouble) \ |
| 484 M(CheckClass) \ | 486 M(CheckClass) \ |
| 485 M(CheckSmi) \ | 487 M(CheckSmi) \ |
| 488 M(CheckNonSmi) \ |
| 486 M(Constant) \ | 489 M(Constant) \ |
| 487 M(CheckEitherNonSmi) \ | 490 M(CheckEitherNonSmi) \ |
| 488 M(BinaryDoubleOp) \ | 491 M(BinaryDoubleOp) \ |
| 489 M(MathSqrt) \ | 492 M(MathSqrt) \ |
| 490 M(UnboxDouble) \ | 493 M(UnboxDouble) \ |
| 491 M(BoxDouble) \ | 494 M(BoxDouble) \ |
| 495 M(BoxFloat32x4) \ |
| 496 M(UnboxFloat32x4) \ |
| 492 M(UnboxInteger) \ | 497 M(UnboxInteger) \ |
| 493 M(BoxInteger) \ | 498 M(BoxInteger) \ |
| 494 M(BinaryMintOp) \ | 499 M(BinaryMintOp) \ |
| 495 M(ShiftMintOp) \ | 500 M(ShiftMintOp) \ |
| 496 M(UnaryMintOp) \ | 501 M(UnaryMintOp) \ |
| 497 M(CheckArrayBound) \ | 502 M(CheckArrayBound) \ |
| 498 M(Constraint) \ | 503 M(Constraint) \ |
| 499 M(StringFromCharCode) \ | 504 M(StringFromCharCode) \ |
| 500 M(InvokeMathCFunction) \ | 505 M(InvokeMathCFunction) \ |
| 501 M(GuardField) \ | 506 M(GuardField) \ |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 intptr_t GetDeoptId() const { | 738 intptr_t GetDeoptId() const { |
| 734 return deopt_id_; | 739 return deopt_id_; |
| 735 } | 740 } |
| 736 | 741 |
| 737 private: | 742 private: |
| 738 friend class Definition; // Needed for InsertBefore, InsertAfter. | 743 friend class Definition; // Needed for InsertBefore, InsertAfter. |
| 739 | 744 |
| 740 // Classes that set deopt_id_. | 745 // Classes that set deopt_id_. |
| 741 friend class UnboxIntegerInstr; | 746 friend class UnboxIntegerInstr; |
| 742 friend class UnboxDoubleInstr; | 747 friend class UnboxDoubleInstr; |
| 748 friend class UnboxFloat32x4Instr; |
| 743 friend class BinaryDoubleOpInstr; | 749 friend class BinaryDoubleOpInstr; |
| 744 friend class BinaryMintOpInstr; | 750 friend class BinaryMintOpInstr; |
| 745 friend class BinarySmiOpInstr; | 751 friend class BinarySmiOpInstr; |
| 746 friend class UnarySmiOpInstr; | 752 friend class UnarySmiOpInstr; |
| 747 friend class ShiftMintOpInstr; | 753 friend class ShiftMintOpInstr; |
| 748 friend class UnaryMintOpInstr; | 754 friend class UnaryMintOpInstr; |
| 749 friend class MathSqrtInstr; | 755 friend class MathSqrtInstr; |
| 750 friend class CheckClassInstr; | 756 friend class CheckClassInstr; |
| 751 friend class GuardFieldInstr; | 757 friend class GuardFieldInstr; |
| 752 friend class CheckSmiInstr; | 758 friend class CheckSmiInstr; |
| 759 friend class CheckNonSmiInstr; |
| 753 friend class CheckArrayBoundInstr; | 760 friend class CheckArrayBoundInstr; |
| 754 friend class CheckEitherNonSmiInstr; | 761 friend class CheckEitherNonSmiInstr; |
| 755 friend class LICM; | 762 friend class LICM; |
| 756 friend class DoubleToSmiInstr; | 763 friend class DoubleToSmiInstr; |
| 757 friend class DoubleToDoubleInstr; | 764 friend class DoubleToDoubleInstr; |
| 758 friend class InvokeMathCFunctionInstr; | 765 friend class InvokeMathCFunctionInstr; |
| 759 friend class FlowGraphOptimizer; | 766 friend class FlowGraphOptimizer; |
| 760 friend class LoadIndexedInstr; | 767 friend class LoadIndexedInstr; |
| 761 friend class StoreIndexedInstr; | 768 friend class StoreIndexedInstr; |
| 762 friend class StoreInstanceFieldInstr; | 769 friend class StoreInstanceFieldInstr; |
| (...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3670 | 3677 |
| 3671 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); | 3678 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| 3672 | 3679 |
| 3673 private: | 3680 private: |
| 3674 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); | 3681 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); |
| 3675 }; | 3682 }; |
| 3676 | 3683 |
| 3677 | 3684 |
| 3678 class BoxDoubleInstr : public TemplateDefinition<1> { | 3685 class BoxDoubleInstr : public TemplateDefinition<1> { |
| 3679 public: | 3686 public: |
| 3680 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call) | 3687 explicit BoxDoubleInstr(Value* value) { |
| 3681 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { | |
| 3682 SetInputAt(0, value); | 3688 SetInputAt(0, value); |
| 3683 } | 3689 } |
| 3684 | 3690 |
| 3685 Value* value() const { return inputs_[0]; } | 3691 Value* value() const { return inputs_[0]; } |
| 3686 | 3692 |
| 3687 intptr_t token_pos() const { return token_pos_; } | |
| 3688 | |
| 3689 virtual bool CanDeoptimize() const { return false; } | 3693 virtual bool CanDeoptimize() const { return false; } |
| 3690 | 3694 |
| 3691 virtual bool HasSideEffect() const { return false; } | 3695 virtual bool HasSideEffect() const { return false; } |
| 3692 | 3696 |
| 3693 virtual bool AffectedBySideEffect() const { return false; } | 3697 virtual bool AffectedBySideEffect() const { return false; } |
| 3694 virtual bool AttributesEqual(Instruction* other) const { return true; } | 3698 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 3695 | 3699 |
| 3696 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3700 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3697 ASSERT(idx == 0); | 3701 ASSERT(idx == 0); |
| 3698 return kUnboxedDouble; | 3702 return kUnboxedDouble; |
| 3699 } | 3703 } |
| 3700 | 3704 |
| 3701 DECLARE_INSTRUCTION(BoxDouble) | 3705 DECLARE_INSTRUCTION(BoxDouble) |
| 3702 virtual CompileType ComputeType() const; | 3706 virtual CompileType ComputeType() const; |
| 3703 | 3707 |
| 3704 private: | 3708 private: |
| 3705 const intptr_t token_pos_; | 3709 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); |
| 3710 }; |
| 3706 | 3711 |
| 3707 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); | 3712 |
| 3713 class BoxFloat32x4Instr : public TemplateDefinition<1> { |
| 3714 public: |
| 3715 explicit BoxFloat32x4Instr(Value* value) { |
| 3716 SetInputAt(0, value); |
| 3717 } |
| 3718 |
| 3719 Value* value() const { return inputs_[0]; } |
| 3720 |
| 3721 virtual bool CanDeoptimize() const { return false; } |
| 3722 |
| 3723 virtual bool HasSideEffect() const { return false; } |
| 3724 |
| 3725 virtual bool AffectedBySideEffect() const { return false; } |
| 3726 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 3727 |
| 3728 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3729 ASSERT(idx == 0); |
| 3730 return kUnboxedFloat32x4; |
| 3731 } |
| 3732 |
| 3733 DECLARE_INSTRUCTION(BoxFloat32x4) |
| 3734 virtual CompileType ComputeType() const; |
| 3735 |
| 3736 private: |
| 3737 DISALLOW_COPY_AND_ASSIGN(BoxFloat32x4Instr); |
| 3708 }; | 3738 }; |
| 3709 | 3739 |
| 3710 | 3740 |
| 3711 class BoxIntegerInstr : public TemplateDefinition<1> { | 3741 class BoxIntegerInstr : public TemplateDefinition<1> { |
| 3712 public: | 3742 public: |
| 3713 explicit BoxIntegerInstr(Value* value) { | 3743 explicit BoxIntegerInstr(Value* value) { |
| 3714 SetInputAt(0, value); | 3744 SetInputAt(0, value); |
| 3715 } | 3745 } |
| 3716 | 3746 |
| 3717 Value* value() const { return inputs_[0]; } | 3747 Value* value() const { return inputs_[0]; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3760 virtual bool AttributesEqual(Instruction* other) const { return true; } | 3790 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 3761 | 3791 |
| 3762 DECLARE_INSTRUCTION(UnboxDouble) | 3792 DECLARE_INSTRUCTION(UnboxDouble) |
| 3763 virtual CompileType ComputeType() const; | 3793 virtual CompileType ComputeType() const; |
| 3764 | 3794 |
| 3765 private: | 3795 private: |
| 3766 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); | 3796 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); |
| 3767 }; | 3797 }; |
| 3768 | 3798 |
| 3769 | 3799 |
| 3800 class UnboxFloat32x4Instr : public TemplateDefinition<1> { |
| 3801 public: |
| 3802 UnboxFloat32x4Instr(Value* value, intptr_t deopt_id) { |
| 3803 SetInputAt(0, value); |
| 3804 deopt_id_ = deopt_id; |
| 3805 } |
| 3806 |
| 3807 Value* value() const { return inputs_[0]; } |
| 3808 |
| 3809 virtual bool CanDeoptimize() const { |
| 3810 return (value()->Type()->ToCid() != kFloat32x4Cid); |
| 3811 } |
| 3812 |
| 3813 virtual bool HasSideEffect() const { return false; } |
| 3814 |
| 3815 virtual Representation representation() const { |
| 3816 return kUnboxedFloat32x4; |
| 3817 } |
| 3818 |
| 3819 virtual bool AffectedBySideEffect() const { return false; } |
| 3820 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 3821 |
| 3822 DECLARE_INSTRUCTION(UnboxFloat32x4) |
| 3823 virtual CompileType ComputeType() const; |
| 3824 |
| 3825 private: |
| 3826 DISALLOW_COPY_AND_ASSIGN(UnboxFloat32x4Instr); |
| 3827 }; |
| 3828 |
| 3829 |
| 3770 class UnboxIntegerInstr : public TemplateDefinition<1> { | 3830 class UnboxIntegerInstr : public TemplateDefinition<1> { |
| 3771 public: | 3831 public: |
| 3772 UnboxIntegerInstr(Value* value, intptr_t deopt_id) { | 3832 UnboxIntegerInstr(Value* value, intptr_t deopt_id) { |
| 3773 SetInputAt(0, value); | 3833 SetInputAt(0, value); |
| 3774 deopt_id_ = deopt_id; | 3834 deopt_id_ = deopt_id; |
| 3775 } | 3835 } |
| 3776 | 3836 |
| 3777 Value* value() const { return inputs_[0]; } | 3837 Value* value() const { return inputs_[0]; } |
| 3778 | 3838 |
| 3779 virtual bool CanDeoptimize() const { | 3839 virtual bool CanDeoptimize() const { |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4430 | 4490 |
| 4431 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); | 4491 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| 4432 | 4492 |
| 4433 Value* value() const { return inputs_[0]; } | 4493 Value* value() const { return inputs_[0]; } |
| 4434 | 4494 |
| 4435 private: | 4495 private: |
| 4436 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); | 4496 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); |
| 4437 }; | 4497 }; |
| 4438 | 4498 |
| 4439 | 4499 |
| 4500 class CheckNonSmiInstr : public TemplateInstruction<1> { |
| 4501 public: |
| 4502 CheckNonSmiInstr(Value* value, intptr_t original_deopt_id) { |
| 4503 ASSERT(original_deopt_id != Isolate::kNoDeoptId); |
| 4504 SetInputAt(0, value); |
| 4505 deopt_id_ = original_deopt_id; |
| 4506 } |
| 4507 |
| 4508 DECLARE_INSTRUCTION(CheckNonSmi) |
| 4509 |
| 4510 virtual intptr_t ArgumentCount() const { return 0; } |
| 4511 |
| 4512 virtual bool CanDeoptimize() const { return true; } |
| 4513 |
| 4514 virtual bool HasSideEffect() const { return false; } |
| 4515 |
| 4516 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 4517 |
| 4518 virtual bool AffectedBySideEffect() const { return false; } |
| 4519 |
| 4520 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer); |
| 4521 |
| 4522 Value* value() const { return inputs_[0]; } |
| 4523 |
| 4524 private: |
| 4525 DISALLOW_COPY_AND_ASSIGN(CheckNonSmiInstr); |
| 4526 }; |
| 4527 |
| 4528 |
| 4440 class CheckArrayBoundInstr : public TemplateInstruction<2> { | 4529 class CheckArrayBoundInstr : public TemplateInstruction<2> { |
| 4441 public: | 4530 public: |
| 4442 CheckArrayBoundInstr(Value* length, | 4531 CheckArrayBoundInstr(Value* length, |
| 4443 Value* index, | 4532 Value* index, |
| 4444 intptr_t array_type, | 4533 intptr_t array_type, |
| 4445 InstanceCallInstr* instance_call) | 4534 InstanceCallInstr* instance_call) |
| 4446 : array_type_(array_type) { | 4535 : array_type_(array_type) { |
| 4447 SetInputAt(0, length); | 4536 SetInputAt(0, length); |
| 4448 SetInputAt(1, index); | 4537 SetInputAt(1, index); |
| 4449 deopt_id_ = instance_call->deopt_id(); | 4538 deopt_id_ = instance_call->deopt_id(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4697 ForwardInstructionIterator* current_iterator_; | 4786 ForwardInstructionIterator* current_iterator_; |
| 4698 | 4787 |
| 4699 private: | 4788 private: |
| 4700 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4789 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4701 }; | 4790 }; |
| 4702 | 4791 |
| 4703 | 4792 |
| 4704 } // namespace dart | 4793 } // namespace dart |
| 4705 | 4794 |
| 4706 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4795 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |