| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 20 matching lines...) Expand all Loading... |
| 31 // TODO(srdjan): Add _ByteArrayBase, get:length. | 31 // TODO(srdjan): Add _ByteArrayBase, get:length. |
| 32 | 32 |
| 33 #define RECOGNIZED_LIST(V) \ | 33 #define RECOGNIZED_LIST(V) \ |
| 34 V(_ObjectArray, get:length, ObjectArrayLength) \ | 34 V(_ObjectArray, get:length, ObjectArrayLength) \ |
| 35 V(_ImmutableArray, get:length, ImmutableArrayLength) \ | 35 V(_ImmutableArray, get:length, ImmutableArrayLength) \ |
| 36 V(_GrowableObjectArray, get:length, GrowableArrayLength) \ | 36 V(_GrowableObjectArray, get:length, GrowableArrayLength) \ |
| 37 V(_GrowableObjectArray, get:capacity, GrowableArrayCapacity) \ | 37 V(_GrowableObjectArray, get:capacity, GrowableArrayCapacity) \ |
| 38 V(_StringBase, get:length, StringBaseLength) \ | 38 V(_StringBase, get:length, StringBaseLength) \ |
| 39 V(_StringBase, get:isEmpty, StringBaseIsEmpty) \ | 39 V(_StringBase, get:isEmpty, StringBaseIsEmpty) \ |
| 40 V(_IntegerImplementation, toDouble, IntegerToDouble) \ | 40 V(_IntegerImplementation, toDouble, IntegerToDouble) \ |
| 41 V(_Double, toDouble, DoubleToDouble) \ | |
| 42 V(_Double, toInt, DoubleToInteger) \ | 41 V(_Double, toInt, DoubleToInteger) \ |
| 43 V(_IntegerImplementation, toInt, IntegerToInteger) \ | |
| 44 V(::, sqrt, MathSqrt) \ | 42 V(::, sqrt, MathSqrt) \ |
| 45 | 43 |
| 46 // Class that recognizes the name and owner of a function and returns the | 44 // Class that recognizes the name and owner of a function and returns the |
| 47 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable | 45 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable |
| 48 // functions. | 46 // functions. |
| 49 class MethodRecognizer : public AllStatic { | 47 class MethodRecognizer : public AllStatic { |
| 50 public: | 48 public: |
| 51 enum Kind { | 49 enum Kind { |
| 52 kUnknown, | 50 kUnknown, |
| 53 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name) k##enum_name, | 51 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name) k##enum_name, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 M(InstantiateTypeArguments) \ | 239 M(InstantiateTypeArguments) \ |
| 242 M(ExtractConstructorTypeArguments) \ | 240 M(ExtractConstructorTypeArguments) \ |
| 243 M(ExtractConstructorInstantiator) \ | 241 M(ExtractConstructorInstantiator) \ |
| 244 M(AllocateContext) \ | 242 M(AllocateContext) \ |
| 245 M(ChainContext) \ | 243 M(ChainContext) \ |
| 246 M(CloneContext) \ | 244 M(CloneContext) \ |
| 247 M(CatchEntry) \ | 245 M(CatchEntry) \ |
| 248 M(BinarySmiOp) \ | 246 M(BinarySmiOp) \ |
| 249 M(UnarySmiOp) \ | 247 M(UnarySmiOp) \ |
| 250 M(CheckStackOverflow) \ | 248 M(CheckStackOverflow) \ |
| 251 M(DoubleToDouble) \ | |
| 252 M(SmiToDouble) \ | 249 M(SmiToDouble) \ |
| 253 M(DoubleToInteger) \ | 250 M(DoubleToInteger) \ |
| 254 M(CheckClass) \ | 251 M(CheckClass) \ |
| 255 M(CheckSmi) \ | 252 M(CheckSmi) \ |
| 256 M(Constant) \ | 253 M(Constant) \ |
| 257 M(CheckEitherNonSmi) \ | 254 M(CheckEitherNonSmi) \ |
| 258 M(BinaryDoubleOp) \ | 255 M(BinaryDoubleOp) \ |
| 259 M(MathSqrt) \ | 256 M(MathSqrt) \ |
| 260 M(UnboxDouble) \ | 257 M(UnboxDouble) \ |
| 261 M(BoxDouble) \ | 258 M(BoxDouble) \ |
| (...skipping 3478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3740 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); | 3737 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); |
| 3741 }; | 3738 }; |
| 3742 | 3739 |
| 3743 | 3740 |
| 3744 // Handles both Smi operations: BIT_OR and NEGATE. | 3741 // Handles both Smi operations: BIT_OR and NEGATE. |
| 3745 class UnarySmiOpInstr : public TemplateDefinition<1> { | 3742 class UnarySmiOpInstr : public TemplateDefinition<1> { |
| 3746 public: | 3743 public: |
| 3747 UnarySmiOpInstr(Token::Kind op_kind, | 3744 UnarySmiOpInstr(Token::Kind op_kind, |
| 3748 InstanceCallInstr* instance_call, | 3745 InstanceCallInstr* instance_call, |
| 3749 Value* value) | 3746 Value* value) |
| 3750 : op_kind_(op_kind), instance_call_(instance_call) { | 3747 : op_kind_(op_kind) { |
| 3751 ASSERT((op_kind == Token::kNEGATE) || (op_kind == Token::kBIT_NOT)); | 3748 ASSERT((op_kind == Token::kNEGATE) || (op_kind == Token::kBIT_NOT)); |
| 3752 ASSERT(value != NULL); | 3749 ASSERT(value != NULL); |
| 3753 inputs_[0] = value; | 3750 inputs_[0] = value; |
| 3754 deopt_id_ = instance_call->deopt_id(); | 3751 deopt_id_ = instance_call->deopt_id(); |
| 3755 } | 3752 } |
| 3756 | 3753 |
| 3757 Value* value() const { return inputs_[0]; } | 3754 Value* value() const { return inputs_[0]; } |
| 3758 Token::Kind op_kind() const { return op_kind_; } | 3755 Token::Kind op_kind() const { return op_kind_; } |
| 3759 | 3756 |
| 3760 InstanceCallInstr* instance_call() const { return instance_call_; } | |
| 3761 | |
| 3762 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3757 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3763 | 3758 |
| 3764 DECLARE_INSTRUCTION(UnarySmiOp) | 3759 DECLARE_INSTRUCTION(UnarySmiOp) |
| 3765 virtual RawAbstractType* CompileType() const; | 3760 virtual RawAbstractType* CompileType() const; |
| 3766 | 3761 |
| 3767 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } | 3762 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } |
| 3768 | 3763 |
| 3769 virtual bool HasSideEffect() const { return false; } | 3764 virtual bool HasSideEffect() const { return false; } |
| 3770 | 3765 |
| 3771 virtual intptr_t ResultCid() const { return kSmiCid; } | 3766 virtual intptr_t ResultCid() const { return kSmiCid; } |
| 3772 | 3767 |
| 3773 private: | 3768 private: |
| 3774 const Token::Kind op_kind_; | 3769 const Token::Kind op_kind_; |
| 3775 InstanceCallInstr* instance_call_; | |
| 3776 | 3770 |
| 3777 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); | 3771 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); |
| 3778 }; | 3772 }; |
| 3779 | 3773 |
| 3780 | 3774 |
| 3781 class CheckStackOverflowInstr : public TemplateInstruction<0> { | 3775 class CheckStackOverflowInstr : public TemplateInstruction<0> { |
| 3782 public: | 3776 public: |
| 3783 explicit CheckStackOverflowInstr(intptr_t token_pos) | 3777 explicit CheckStackOverflowInstr(intptr_t token_pos) |
| 3784 : token_pos_(token_pos) {} | 3778 : token_pos_(token_pos) {} |
| 3785 | 3779 |
| 3786 intptr_t token_pos() const { return token_pos_; } | 3780 intptr_t token_pos() const { return token_pos_; } |
| 3787 | 3781 |
| 3788 DECLARE_INSTRUCTION(CheckStackOverflow) | 3782 DECLARE_INSTRUCTION(CheckStackOverflow) |
| 3789 virtual RawAbstractType* CompileType() const; | 3783 virtual RawAbstractType* CompileType() const; |
| 3790 | 3784 |
| 3791 virtual intptr_t ArgumentCount() const { return 0; } | 3785 virtual intptr_t ArgumentCount() const { return 0; } |
| 3792 | 3786 |
| 3793 virtual bool CanDeoptimize() const { return false; } | 3787 virtual bool CanDeoptimize() const { return false; } |
| 3794 | 3788 |
| 3795 virtual bool HasSideEffect() const { return false; } | 3789 virtual bool HasSideEffect() const { return false; } |
| 3796 | 3790 |
| 3797 private: | 3791 private: |
| 3798 const intptr_t token_pos_; | 3792 const intptr_t token_pos_; |
| 3799 | 3793 |
| 3800 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); | 3794 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); |
| 3801 }; | 3795 }; |
| 3802 | 3796 |
| 3803 | 3797 |
| 3804 class DoubleToDoubleInstr : public TemplateDefinition<1> { | |
| 3805 public: | |
| 3806 DoubleToDoubleInstr(Value* value, InstanceCallInstr* instance_call) | |
| 3807 : instance_call_(instance_call) { | |
| 3808 ASSERT(value != NULL); | |
| 3809 inputs_[0] = value; | |
| 3810 } | |
| 3811 | |
| 3812 Value* value() const { return inputs_[0]; } | |
| 3813 | |
| 3814 InstanceCallInstr* instance_call() const { return instance_call_; } | |
| 3815 | |
| 3816 DECLARE_INSTRUCTION(DoubleToDouble) | |
| 3817 virtual RawAbstractType* CompileType() const; | |
| 3818 | |
| 3819 virtual bool CanDeoptimize() const { return true; } | |
| 3820 | |
| 3821 virtual bool HasSideEffect() const { return false; } | |
| 3822 | |
| 3823 virtual intptr_t ResultCid() const { return kDoubleCid; } | |
| 3824 | |
| 3825 private: | |
| 3826 InstanceCallInstr* instance_call_; | |
| 3827 | |
| 3828 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleInstr); | |
| 3829 }; | |
| 3830 | |
| 3831 | |
| 3832 class SmiToDoubleInstr : public TemplateDefinition<0> { | 3798 class SmiToDoubleInstr : public TemplateDefinition<0> { |
| 3833 public: | 3799 public: |
| 3834 explicit SmiToDoubleInstr(InstanceCallInstr* instance_call) | 3800 explicit SmiToDoubleInstr(InstanceCallInstr* instance_call) |
| 3835 : instance_call_(instance_call) { } | 3801 : instance_call_(instance_call) { } |
| 3836 | 3802 |
| 3837 InstanceCallInstr* instance_call() const { return instance_call_; } | 3803 InstanceCallInstr* instance_call() const { return instance_call_; } |
| 3838 | 3804 |
| 3839 DECLARE_INSTRUCTION(SmiToDouble) | 3805 DECLARE_INSTRUCTION(SmiToDouble) |
| 3840 virtual RawAbstractType* CompileType() const; | 3806 virtual RawAbstractType* CompileType() const; |
| 3841 | 3807 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4200 ForwardInstructionIterator* current_iterator_; | 4166 ForwardInstructionIterator* current_iterator_; |
| 4201 | 4167 |
| 4202 private: | 4168 private: |
| 4203 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4169 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4204 }; | 4170 }; |
| 4205 | 4171 |
| 4206 | 4172 |
| 4207 } // namespace dart | 4173 } // namespace dart |
| 4208 | 4174 |
| 4209 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4175 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |