Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 27307005: Change == into an instance call to allow polymorphic inlining of ==. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased, addressed comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 friend class ComparisonInstr; 1009 friend class ComparisonInstr;
1009 friend class TargetEntryInstr; 1010 friend class TargetEntryInstr;
1010 friend class JoinEntryInstr; 1011 friend class JoinEntryInstr;
1011 friend class InstanceOfInstr; 1012 friend class InstanceOfInstr;
1012 friend class PolymorphicInstanceCallInstr; 1013 friend class PolymorphicInstanceCallInstr;
1013 friend class SmiToDoubleInstr; 1014 friend class SmiToDoubleInstr;
1014 friend class DoubleToIntegerInstr; 1015 friend class DoubleToIntegerInstr;
1015 friend class BranchSimplifier; 1016 friend class BranchSimplifier;
1016 friend class BlockEntryInstr; 1017 friend class BlockEntryInstr;
1017 friend class RelationalOpInstr; 1018 friend class RelationalOpInstr;
1019 friend class EqualityCompareInstr;
1018 1020
1019 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; 1021 virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
1020 1022
1021 enum { 1023 enum {
1022 kNoPlaceId = -1 1024 kNoPlaceId = -1
1023 }; 1025 };
1024 1026
1025 intptr_t deopt_id_; 1027 intptr_t deopt_id_;
1026 intptr_t lifetime_position_; // Position used by register allocator. 1028 intptr_t lifetime_position_; // Position used by register allocator.
1027 Instruction* previous_; 1029 Instruction* previous_;
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 token_pos_(token_pos), 2728 token_pos_(token_pos),
2727 function_name_(function_name), 2729 function_name_(function_name),
2728 token_kind_(token_kind), 2730 token_kind_(token_kind),
2729 arguments_(arguments), 2731 arguments_(arguments),
2730 argument_names_(argument_names), 2732 argument_names_(argument_names),
2731 checked_argument_count_(checked_argument_count) { 2733 checked_argument_count_(checked_argument_count) {
2732 ASSERT(function_name.IsNotTemporaryScopedHandle()); 2734 ASSERT(function_name.IsNotTemporaryScopedHandle());
2733 ASSERT(!arguments->is_empty()); 2735 ASSERT(!arguments->is_empty());
2734 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); 2736 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap());
2735 ASSERT(Token::IsBinaryOperator(token_kind) || 2737 ASSERT(Token::IsBinaryOperator(token_kind) ||
2738 Token::IsEqualityOperator(token_kind) ||
2736 Token::IsRelationalOperator(token_kind) || 2739 Token::IsRelationalOperator(token_kind) ||
2737 Token::IsPrefixOperator(token_kind) || 2740 Token::IsPrefixOperator(token_kind) ||
2738 Token::IsIndexOperator(token_kind) || 2741 Token::IsIndexOperator(token_kind) ||
2739 Token::IsTypeTestOperator(token_kind) || 2742 Token::IsTypeTestOperator(token_kind) ||
2740 Token::IsTypeCastOperator(token_kind) || 2743 Token::IsTypeCastOperator(token_kind) ||
2741 token_kind == Token::kGET || 2744 token_kind == Token::kGET ||
2742 token_kind == Token::kSET || 2745 token_kind == Token::kSET ||
2743 token_kind == Token::kILLEGAL); 2746 token_kind == Token::kILLEGAL);
2744 } 2747 }
2745 2748
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2981 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); 2984 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr);
2982 }; 2985 };
2983 2986
2984 2987
2985 class EqualityCompareInstr : public ComparisonInstr { 2988 class EqualityCompareInstr : public ComparisonInstr {
2986 public: 2989 public:
2987 EqualityCompareInstr(intptr_t token_pos, 2990 EqualityCompareInstr(intptr_t token_pos,
2988 Token::Kind kind, 2991 Token::Kind kind,
2989 Value* left, 2992 Value* left,
2990 Value* right, 2993 Value* right,
2991 const Array& ic_data_array) 2994 intptr_t cid,
2992 : ComparisonInstr(token_pos, kind, left, right), 2995 intptr_t deopt_id)
2993 ic_data_(GetICData(ic_data_array)), 2996 : ComparisonInstr(token_pos, kind, left, right) {
2994 unary_ic_data_(NULL) { 2997 ASSERT(Token::IsEqualityOperator(kind));
2995 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); 2998 set_operation_cid(cid);
2996 if (HasICData()) { 2999 deopt_id_ = deopt_id; // Override generated deopt-id.
2997 unary_ic_data_ = &ICData::ZoneHandle(ic_data_->AsUnaryClassChecks());
2998 }
2999 } 3000 }
3000 3001
3001 DECLARE_INSTRUCTION(EqualityCompare) 3002 DECLARE_INSTRUCTION(EqualityCompare)
3002 virtual CompileType ComputeType() const; 3003 virtual CompileType ComputeType() const;
3003 virtual bool RecomputeType(); 3004 virtual bool RecomputeType();
3004 3005
3005 const ICData* ic_data() const { return ic_data_; }
3006 bool HasICData() const {
3007 return (ic_data() != NULL) && !ic_data()->IsNull();
3008 }
3009 void set_ic_data(const ICData* value) {
3010 ic_data_ = value;
3011 if (HasICData()) {
3012 unary_ic_data_ = &ICData::ZoneHandle(ic_data_->AsUnaryClassChecks());
3013 }
3014 }
3015
3016 bool IsInlinedNumericComparison() const {
3017 return (operation_cid() == kDoubleCid)
3018 || (operation_cid() == kMintCid)
3019 || (operation_cid() == kSmiCid);
3020 }
3021
3022 bool IsCheckedStrictEqual() const;
3023
3024 virtual void PrintOperandsTo(BufferFormatter* f) const; 3006 virtual void PrintOperandsTo(BufferFormatter* f) const;
3025 3007
3026 virtual bool CanDeoptimize() const { 3008 virtual bool CanDeoptimize() const { return false; }
3027 return !IsInlinedNumericComparison(); 3009
3010 virtual bool CanBecomeDeoptimizationTarget() const {
3011 // EqualityCompare can be merged into Branch and thus needs an environment.
3012 return true;
3028 } 3013 }
3029 3014
3030 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 3015 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
3031 BranchInstr* branch); 3016 BranchInstr* branch);
3032 3017
3033 virtual intptr_t DeoptimizationTarget() const { 3018 virtual intptr_t DeoptimizationTarget() const {
3034 return GetDeoptId(); 3019 return GetDeoptId();
3035 } 3020 }
3036 3021
3037 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3022 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3038 ASSERT((idx == 0) || (idx == 1)); 3023 ASSERT((idx == 0) || (idx == 1));
3039 if (operation_cid() == kDoubleCid) return kUnboxedDouble; 3024 if (operation_cid() == kDoubleCid) return kUnboxedDouble;
3040 if (operation_cid() == kMintCid) return kUnboxedMint; 3025 if (operation_cid() == kMintCid) return kUnboxedMint;
3041 return kTagged; 3026 return kTagged;
3042 } 3027 }
3043 3028
3044 bool IsPolymorphic() const; 3029 virtual EffectSet Effects() const { return EffectSet::None(); }
3045 3030
3046 virtual EffectSet Effects() const { 3031 virtual bool MayThrow() const { return false; }
3047 return IsInlinedNumericComparison() ? EffectSet::None() : EffectSet::All();
3048 }
3049
3050 virtual bool MayThrow() const {
3051 return !IsInlinedNumericComparison() && !IsCheckedStrictEqual();
3052 }
3053 3032
3054 private: 3033 private:
3055 const ICData* ic_data_;
3056 ICData* unary_ic_data_;
3057
3058 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); 3034 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr);
3059 }; 3035 };
3060 3036
3061 3037
3062 class RelationalOpInstr : public ComparisonInstr { 3038 class RelationalOpInstr : public ComparisonInstr {
3063 public: 3039 public:
3064 RelationalOpInstr(intptr_t token_pos, 3040 RelationalOpInstr(intptr_t token_pos,
3065 Token::Kind kind, 3041 Token::Kind kind,
3066 Value* left, 3042 Value* left,
3067 Value* right, 3043 Value* right,
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
3774 3750
3775 private: 3751 private:
3776 const StoreBarrierType emit_store_barrier_; 3752 const StoreBarrierType emit_store_barrier_;
3777 const intptr_t index_scale_; 3753 const intptr_t index_scale_;
3778 const intptr_t class_id_; 3754 const intptr_t class_id_;
3779 3755
3780 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr); 3756 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr);
3781 }; 3757 };
3782 3758
3783 3759
3784 // Note overrideable, built-in: value? false : true. 3760 // Note overrideable, built-in: value ? false : true.
3785 class BooleanNegateInstr : public TemplateDefinition<1> { 3761 class BooleanNegateInstr : public TemplateDefinition<1> {
3786 public: 3762 public:
3787 explicit BooleanNegateInstr(Value* value) { 3763 explicit BooleanNegateInstr(Value* value) {
3788 SetInputAt(0, value); 3764 SetInputAt(0, value);
3789 } 3765 }
3790 3766
3791 DECLARE_INSTRUCTION(BooleanNegate) 3767 DECLARE_INSTRUCTION(BooleanNegate)
3792 virtual CompileType ComputeType() const; 3768 virtual CompileType ComputeType() const;
3793 3769
3794 Value* value() const { return inputs_[0]; } 3770 Value* value() const { return inputs_[0]; }
(...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after
6928 ForwardInstructionIterator* current_iterator_; 6904 ForwardInstructionIterator* current_iterator_;
6929 6905
6930 private: 6906 private:
6931 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6907 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6932 }; 6908 };
6933 6909
6934 6910
6935 } // namespace dart 6911 } // namespace dart
6936 6912
6937 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6913 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698