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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 M(UnboxFloat32x4) \ | 662 M(UnboxFloat32x4) \ |
663 M(BoxInt32x4) \ | 663 M(BoxInt32x4) \ |
664 M(UnboxInt32x4) \ | 664 M(UnboxInt32x4) \ |
665 M(UnboxInteger) \ | 665 M(UnboxInteger) \ |
666 M(BoxInteger) \ | 666 M(BoxInteger) \ |
667 M(BinaryMintOp) \ | 667 M(BinaryMintOp) \ |
668 M(ShiftMintOp) \ | 668 M(ShiftMintOp) \ |
669 M(UnaryMintOp) \ | 669 M(UnaryMintOp) \ |
670 M(CheckArrayBound) \ | 670 M(CheckArrayBound) \ |
671 M(Constraint) \ | 671 M(Constraint) \ |
672 M(StringFromCharCode) \ | 672 M(StringCharCode) \ |
673 M(StringInterpolate) \ | 673 M(StringInterpolate) \ |
674 M(InvokeMathCFunction) \ | 674 M(InvokeMathCFunction) \ |
675 M(MergedMath) \ | 675 M(MergedMath) \ |
676 M(GuardField) \ | 676 M(GuardField) \ |
677 M(IfThenElse) \ | 677 M(IfThenElse) \ |
678 M(BinaryFloat32x4Op) \ | 678 M(BinaryFloat32x4Op) \ |
679 M(Simd32x4Shuffle) \ | 679 M(Simd32x4Shuffle) \ |
680 M(Simd32x4ShuffleMix) \ | 680 M(Simd32x4ShuffleMix) \ |
681 M(Simd32x4GetSignMask) \ | 681 M(Simd32x4GetSignMask) \ |
682 M(Float32x4Constructor) \ | 682 M(Float32x4Constructor) \ |
(...skipping 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3657 virtual bool MayThrow() const { return false; } | 3657 virtual bool MayThrow() const { return false; } |
3658 | 3658 |
3659 private: | 3659 private: |
3660 const intptr_t index_scale_; | 3660 const intptr_t index_scale_; |
3661 const intptr_t class_id_; | 3661 const intptr_t class_id_; |
3662 | 3662 |
3663 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); | 3663 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); |
3664 }; | 3664 }; |
3665 | 3665 |
3666 | 3666 |
3667 class StringFromCharCodeInstr : public TemplateDefinition<1> { | 3667 // Either converts a char-code to a string or a string to a charcode (-1 if |
3668 // string is not of length one). | |
3669 class StringCharCodeInstr : public TemplateDefinition<1> { | |
Florian Schneider
2013/12/20 09:29:12
Why packing two different instructions into one? I
srdjan
2013/12/20 19:48:03
Split it up in two instructions.
| |
3668 public: | 3670 public: |
3669 StringFromCharCodeInstr(Value* char_code, intptr_t cid) : cid_(cid) { | 3671 enum Kind { |
3670 ASSERT(char_code != NULL); | 3672 kFromCharCode, |
3671 ASSERT(char_code->definition()->IsLoadIndexed() && | 3673 kToCharCode, |
3672 (char_code->definition()->AsLoadIndexed()->class_id() == | 3674 }; |
3673 kOneByteStringCid)); | 3675 StringCharCodeInstr(Value* val, |
3674 SetInputAt(0, char_code); | 3676 intptr_t cid, |
3677 StringCharCodeInstr::Kind kind) | |
3678 : cid_(cid), kind_(kind) { | |
3679 ASSERT(val != NULL); | |
3680 if (kind == kFromCharCode) { | |
3681 ASSERT(val->definition()->IsLoadIndexed() && | |
3682 (val->definition()->AsLoadIndexed()->class_id() == | |
3683 kOneByteStringCid)); | |
3684 } else { | |
3685 ASSERT(kind == kToCharCode); | |
3686 } | |
3687 SetInputAt(0, val); | |
3675 } | 3688 } |
3676 | 3689 |
3677 DECLARE_INSTRUCTION(StringFromCharCode) | 3690 DECLARE_INSTRUCTION(StringCharCode) |
3678 virtual CompileType ComputeType() const; | 3691 virtual CompileType ComputeType() const; |
3679 | 3692 |
3680 Value* char_code() const { return inputs_[0]; } | 3693 Value* char_code() const { |
3694 ASSERT(kind_ == kFromCharCode); | |
3695 return inputs_[0]; | |
3696 } | |
3697 Value* str() const { | |
3698 ASSERT(kind_ == kToCharCode); | |
3699 return inputs_[0]; | |
3700 } | |
3701 StringCharCodeInstr::Kind kind() const { return kind_; } | |
3681 | 3702 |
3682 virtual bool CanDeoptimize() const { return false; } | 3703 virtual bool CanDeoptimize() const { return false; } |
3683 | 3704 |
3684 virtual bool AllowsCSE() const { return true; } | 3705 virtual bool AllowsCSE() const { return true; } |
3685 virtual EffectSet Effects() const { return EffectSet::None(); } | 3706 virtual EffectSet Effects() const { return EffectSet::None(); } |
3686 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 3707 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
3687 virtual bool AttributesEqual(Instruction* other) const { | 3708 virtual bool AttributesEqual(Instruction* other) const { |
3688 return other->AsStringFromCharCode()->cid_ == cid_; | 3709 return (other->AsStringCharCode()->cid_ == cid_) && |
3710 (other->AsStringCharCode()->kind_ == kind_); | |
3689 } | 3711 } |
3690 | 3712 |
3691 virtual bool MayThrow() const { return false; } | 3713 virtual bool MayThrow() const { return false; } |
3692 | 3714 |
3715 virtual void PrintTo(BufferFormatter* f) const; | |
3716 | |
3693 private: | 3717 private: |
3694 const intptr_t cid_; | 3718 const intptr_t cid_; |
3719 const Kind kind_; | |
3695 | 3720 |
3696 DISALLOW_COPY_AND_ASSIGN(StringFromCharCodeInstr); | 3721 DISALLOW_COPY_AND_ASSIGN(StringCharCodeInstr); |
3697 }; | 3722 }; |
3698 | 3723 |
3699 | 3724 |
3700 class StringInterpolateInstr : public TemplateDefinition<1> { | 3725 class StringInterpolateInstr : public TemplateDefinition<1> { |
3701 public: | 3726 public: |
3702 StringInterpolateInstr(Value* value, intptr_t token_pos) | 3727 StringInterpolateInstr(Value* value, intptr_t token_pos) |
3703 : token_pos_(token_pos), function_(Function::Handle()) { | 3728 : token_pos_(token_pos), function_(Function::Handle()) { |
3704 SetInputAt(0, value); | 3729 SetInputAt(0, value); |
3705 } | 3730 } |
3706 | 3731 |
(...skipping 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7054 ForwardInstructionIterator* current_iterator_; | 7079 ForwardInstructionIterator* current_iterator_; |
7055 | 7080 |
7056 private: | 7081 private: |
7057 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 7082 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
7058 }; | 7083 }; |
7059 | 7084 |
7060 | 7085 |
7061 } // namespace dart | 7086 } // namespace dart |
7062 | 7087 |
7063 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7088 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |