| 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 21 matching lines...) Expand all Loading... |
| 32 class LocalVariable; | 32 class LocalVariable; |
| 33 class ParsedFunction; | 33 class ParsedFunction; |
| 34 class Range; | 34 class Range; |
| 35 | 35 |
| 36 | 36 |
| 37 // TODO(srdjan): Unify with INTRINSIC_LIST. | 37 // TODO(srdjan): Unify with INTRINSIC_LIST. |
| 38 // (class-name, function-name, recognized enum, fingerprint). | 38 // (class-name, function-name, recognized enum, fingerprint). |
| 39 // See intrinsifier for fingerprint computation. | 39 // See intrinsifier for fingerprint computation. |
| 40 #define RECOGNIZED_LIST(V) \ | 40 #define RECOGNIZED_LIST(V) \ |
| 41 V(::, identical, ObjectIdentical, 496869842) \ | 41 V(::, identical, ObjectIdentical, 496869842) \ |
| 42 V(Object, ==, ObjectEquals, 180968008) \ |
| 42 V(Object, Object., ObjectConstructor, 1058585294) \ | 43 V(Object, Object., ObjectConstructor, 1058585294) \ |
| 43 V(Object, get:_cid, ObjectCid, 1498721510) \ | 44 V(Object, get:_cid, ObjectCid, 1498721510) \ |
| 44 V(_List, get:length, ObjectArrayLength, 215153395) \ | 45 V(_List, get:length, ObjectArrayLength, 215153395) \ |
| 45 V(_ImmutableList, get:length, ImmutableArrayLength, 578733070) \ | 46 V(_ImmutableList, get:length, ImmutableArrayLength, 578733070) \ |
| 46 V(_TypedList, get:length, TypedDataLength, 26616328) \ | 47 V(_TypedList, get:length, TypedDataLength, 26616328) \ |
| 47 V(_TypedList, _getInt8, ByteArrayBaseGetInt8, 272598802) \ | 48 V(_TypedList, _getInt8, ByteArrayBaseGetInt8, 272598802) \ |
| 48 V(_TypedList, _getUint8, ByteArrayBaseGetUint8, 831354841) \ | 49 V(_TypedList, _getUint8, ByteArrayBaseGetUint8, 831354841) \ |
| 49 V(_TypedList, _getInt16, ByteArrayBaseGetInt16, 1832126257) \ | 50 V(_TypedList, _getInt16, ByteArrayBaseGetInt16, 1832126257) \ |
| 50 V(_TypedList, _getUint16, ByteArrayBaseGetUint16, 1762714698) \ | 51 V(_TypedList, _getUint16, ByteArrayBaseGetUint16, 1762714698) \ |
| 51 V(_TypedList, _getInt32, ByteArrayBaseGetInt32, 48785449) \ | 52 V(_TypedList, _getInt32, ByteArrayBaseGetInt32, 48785449) \ |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 friend class ComparisonInstr; | 1006 friend class ComparisonInstr; |
| 1006 friend class TargetEntryInstr; | 1007 friend class TargetEntryInstr; |
| 1007 friend class JoinEntryInstr; | 1008 friend class JoinEntryInstr; |
| 1008 friend class InstanceOfInstr; | 1009 friend class InstanceOfInstr; |
| 1009 friend class PolymorphicInstanceCallInstr; | 1010 friend class PolymorphicInstanceCallInstr; |
| 1010 friend class SmiToDoubleInstr; | 1011 friend class SmiToDoubleInstr; |
| 1011 friend class DoubleToIntegerInstr; | 1012 friend class DoubleToIntegerInstr; |
| 1012 friend class BranchSimplifier; | 1013 friend class BranchSimplifier; |
| 1013 friend class BlockEntryInstr; | 1014 friend class BlockEntryInstr; |
| 1014 friend class RelationalOpInstr; | 1015 friend class RelationalOpInstr; |
| 1016 friend class EqualityCompareInstr; |
| 1015 | 1017 |
| 1016 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; | 1018 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; |
| 1017 | 1019 |
| 1018 enum { | 1020 enum { |
| 1019 kNoPlaceId = -1 | 1021 kNoPlaceId = -1 |
| 1020 }; | 1022 }; |
| 1021 | 1023 |
| 1022 intptr_t deopt_id_; | 1024 intptr_t deopt_id_; |
| 1023 intptr_t lifetime_position_; // Position used by register allocator. | 1025 intptr_t lifetime_position_; // Position used by register allocator. |
| 1024 Instruction* previous_; | 1026 Instruction* previous_; |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2723 token_pos_(token_pos), | 2725 token_pos_(token_pos), |
| 2724 function_name_(function_name), | 2726 function_name_(function_name), |
| 2725 token_kind_(token_kind), | 2727 token_kind_(token_kind), |
| 2726 arguments_(arguments), | 2728 arguments_(arguments), |
| 2727 argument_names_(argument_names), | 2729 argument_names_(argument_names), |
| 2728 checked_argument_count_(checked_argument_count) { | 2730 checked_argument_count_(checked_argument_count) { |
| 2729 ASSERT(function_name.IsNotTemporaryScopedHandle()); | 2731 ASSERT(function_name.IsNotTemporaryScopedHandle()); |
| 2730 ASSERT(!arguments->is_empty()); | 2732 ASSERT(!arguments->is_empty()); |
| 2731 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); | 2733 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); |
| 2732 ASSERT(Token::IsBinaryOperator(token_kind) || | 2734 ASSERT(Token::IsBinaryOperator(token_kind) || |
| 2735 Token::IsEqualityOperator(token_kind) || |
| 2733 Token::IsRelationalOperator(token_kind) || | 2736 Token::IsRelationalOperator(token_kind) || |
| 2734 Token::IsPrefixOperator(token_kind) || | 2737 Token::IsPrefixOperator(token_kind) || |
| 2735 Token::IsIndexOperator(token_kind) || | 2738 Token::IsIndexOperator(token_kind) || |
| 2736 Token::IsTypeTestOperator(token_kind) || | 2739 Token::IsTypeTestOperator(token_kind) || |
| 2737 Token::IsTypeCastOperator(token_kind) || | 2740 Token::IsTypeCastOperator(token_kind) || |
| 2738 token_kind == Token::kGET || | 2741 token_kind == Token::kGET || |
| 2739 token_kind == Token::kSET || | 2742 token_kind == Token::kSET || |
| 2740 token_kind == Token::kILLEGAL); | 2743 token_kind == Token::kILLEGAL); |
| 2741 } | 2744 } |
| 2742 | 2745 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2978 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); | 2981 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); |
| 2979 }; | 2982 }; |
| 2980 | 2983 |
| 2981 | 2984 |
| 2982 class EqualityCompareInstr : public ComparisonInstr { | 2985 class EqualityCompareInstr : public ComparisonInstr { |
| 2983 public: | 2986 public: |
| 2984 EqualityCompareInstr(intptr_t token_pos, | 2987 EqualityCompareInstr(intptr_t token_pos, |
| 2985 Token::Kind kind, | 2988 Token::Kind kind, |
| 2986 Value* left, | 2989 Value* left, |
| 2987 Value* right, | 2990 Value* right, |
| 2988 const Array& ic_data_array) | 2991 intptr_t cid, |
| 2989 : ComparisonInstr(token_pos, kind, left, right), | 2992 intptr_t deopt_id) |
| 2990 ic_data_(GetICData(ic_data_array)), | 2993 : ComparisonInstr(token_pos, kind, left, right) { |
| 2991 unary_ic_data_(NULL) { | 2994 ASSERT(Token::IsEqualityOperator(kind)); |
| 2992 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); | 2995 set_operation_cid(cid); |
| 2993 if (HasICData()) { | 2996 deopt_id_ = deopt_id; // Override generated deopt-id. |
| 2994 unary_ic_data_ = &ICData::ZoneHandle(ic_data_->AsUnaryClassChecks()); | |
| 2995 } | |
| 2996 } | 2997 } |
| 2997 | 2998 |
| 2998 DECLARE_INSTRUCTION(EqualityCompare) | 2999 DECLARE_INSTRUCTION(EqualityCompare) |
| 2999 virtual CompileType ComputeType() const; | 3000 virtual CompileType ComputeType() const; |
| 3000 virtual bool RecomputeType(); | 3001 virtual bool RecomputeType(); |
| 3001 | 3002 |
| 3002 const ICData* ic_data() const { return ic_data_; } | |
| 3003 bool HasICData() const { | |
| 3004 return (ic_data() != NULL) && !ic_data()->IsNull(); | |
| 3005 } | |
| 3006 void set_ic_data(const ICData* value) { | |
| 3007 ic_data_ = value; | |
| 3008 if (HasICData()) { | |
| 3009 unary_ic_data_ = &ICData::ZoneHandle(ic_data_->AsUnaryClassChecks()); | |
| 3010 } | |
| 3011 } | |
| 3012 | |
| 3013 bool IsInlinedNumericComparison() const { | |
| 3014 return (operation_cid() == kDoubleCid) | |
| 3015 || (operation_cid() == kMintCid) | |
| 3016 || (operation_cid() == kSmiCid); | |
| 3017 } | |
| 3018 | |
| 3019 bool IsCheckedStrictEqual() const; | |
| 3020 | |
| 3021 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3003 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3022 | 3004 |
| 3023 virtual bool CanDeoptimize() const { | 3005 virtual bool CanDeoptimize() const { return false; } |
| 3024 return !IsInlinedNumericComparison(); | 3006 |
| 3007 virtual bool CanBecomeDeoptimizationTarget() const { |
| 3008 // EqualityCompare can be merged into Branch and thus needs an environment. |
| 3009 return true; |
| 3025 } | 3010 } |
| 3026 | 3011 |
| 3027 virtual void EmitBranchCode(FlowGraphCompiler* compiler, | 3012 virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
| 3028 BranchInstr* branch); | 3013 BranchInstr* branch); |
| 3029 | 3014 |
| 3030 virtual intptr_t DeoptimizationTarget() const { | 3015 virtual intptr_t DeoptimizationTarget() const { |
| 3031 return GetDeoptId(); | 3016 return GetDeoptId(); |
| 3032 } | 3017 } |
| 3033 | 3018 |
| 3034 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3019 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3035 ASSERT((idx == 0) || (idx == 1)); | 3020 ASSERT((idx == 0) || (idx == 1)); |
| 3036 if (operation_cid() == kDoubleCid) return kUnboxedDouble; | 3021 if (operation_cid() == kDoubleCid) return kUnboxedDouble; |
| 3037 if (operation_cid() == kMintCid) return kUnboxedMint; | 3022 if (operation_cid() == kMintCid) return kUnboxedMint; |
| 3038 return kTagged; | 3023 return kTagged; |
| 3039 } | 3024 } |
| 3040 | 3025 |
| 3041 bool IsPolymorphic() const; | 3026 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 3042 | 3027 |
| 3043 virtual EffectSet Effects() const { | 3028 virtual bool MayThrow() const { return false; } |
| 3044 return IsInlinedNumericComparison() ? EffectSet::None() : EffectSet::All(); | |
| 3045 } | |
| 3046 | |
| 3047 virtual bool MayThrow() const { | |
| 3048 return !IsInlinedNumericComparison() && !IsCheckedStrictEqual(); | |
| 3049 } | |
| 3050 | 3029 |
| 3051 private: | 3030 private: |
| 3052 const ICData* ic_data_; | |
| 3053 ICData* unary_ic_data_; | |
| 3054 | |
| 3055 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); | 3031 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); |
| 3056 }; | 3032 }; |
| 3057 | 3033 |
| 3058 | 3034 |
| 3059 class RelationalOpInstr : public ComparisonInstr { | 3035 class RelationalOpInstr : public ComparisonInstr { |
| 3060 public: | 3036 public: |
| 3061 RelationalOpInstr(intptr_t token_pos, | 3037 RelationalOpInstr(intptr_t token_pos, |
| 3062 Token::Kind kind, | 3038 Token::Kind kind, |
| 3063 Value* left, | 3039 Value* left, |
| 3064 Value* right, | 3040 Value* right, |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3771 | 3747 |
| 3772 private: | 3748 private: |
| 3773 const StoreBarrierType emit_store_barrier_; | 3749 const StoreBarrierType emit_store_barrier_; |
| 3774 const intptr_t index_scale_; | 3750 const intptr_t index_scale_; |
| 3775 const intptr_t class_id_; | 3751 const intptr_t class_id_; |
| 3776 | 3752 |
| 3777 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr); | 3753 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr); |
| 3778 }; | 3754 }; |
| 3779 | 3755 |
| 3780 | 3756 |
| 3781 // Note overrideable, built-in: value? false : true. | 3757 // Note overrideable, built-in: value ? false : true. |
| 3782 class BooleanNegateInstr : public TemplateDefinition<1> { | 3758 class BooleanNegateInstr : public TemplateDefinition<1> { |
| 3783 public: | 3759 public: |
| 3784 explicit BooleanNegateInstr(Value* value) { | 3760 explicit BooleanNegateInstr(Value* value) { |
| 3785 SetInputAt(0, value); | 3761 SetInputAt(0, value); |
| 3786 } | 3762 } |
| 3787 | 3763 |
| 3788 DECLARE_INSTRUCTION(BooleanNegate) | 3764 DECLARE_INSTRUCTION(BooleanNegate) |
| 3789 virtual CompileType ComputeType() const; | 3765 virtual CompileType ComputeType() const; |
| 3790 | 3766 |
| 3791 Value* value() const { return inputs_[0]; } | 3767 Value* value() const { return inputs_[0]; } |
| (...skipping 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6901 ForwardInstructionIterator* current_iterator_; | 6877 ForwardInstructionIterator* current_iterator_; |
| 6902 | 6878 |
| 6903 private: | 6879 private: |
| 6904 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 6880 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 6905 }; | 6881 }; |
| 6906 | 6882 |
| 6907 | 6883 |
| 6908 } // namespace dart | 6884 } // namespace dart |
| 6909 | 6885 |
| 6910 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 6886 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |