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

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

Issue 23757016: Simplify compilation of relational operators. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months 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
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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 friend class ControlInstruction; 951 friend class ControlInstruction;
952 friend class ComparisonInstr; 952 friend class ComparisonInstr;
953 friend class TargetEntryInstr; 953 friend class TargetEntryInstr;
954 friend class JoinEntryInstr; 954 friend class JoinEntryInstr;
955 friend class InstanceOfInstr; 955 friend class InstanceOfInstr;
956 friend class PolymorphicInstanceCallInstr; 956 friend class PolymorphicInstanceCallInstr;
957 friend class SmiToDoubleInstr; 957 friend class SmiToDoubleInstr;
958 friend class DoubleToIntegerInstr; 958 friend class DoubleToIntegerInstr;
959 friend class BranchSimplifier; 959 friend class BranchSimplifier;
960 friend class BlockEntryInstr; 960 friend class BlockEntryInstr;
961 friend class RelationalOpInstr;
961 962
962 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; 963 virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
963 964
964 enum { 965 enum {
965 kNoPlaceId = -1 966 kNoPlaceId = -1
966 }; 967 };
967 968
968 intptr_t deopt_id_; 969 intptr_t deopt_id_;
969 intptr_t lifetime_position_; // Position used by register allocator. 970 intptr_t lifetime_position_; // Position used by register allocator.
970 Instruction* previous_; 971 Instruction* previous_;
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 token_pos_(token_pos), 2665 token_pos_(token_pos),
2665 function_name_(function_name), 2666 function_name_(function_name),
2666 token_kind_(token_kind), 2667 token_kind_(token_kind),
2667 arguments_(arguments), 2668 arguments_(arguments),
2668 argument_names_(argument_names), 2669 argument_names_(argument_names),
2669 checked_argument_count_(checked_argument_count) { 2670 checked_argument_count_(checked_argument_count) {
2670 ASSERT(function_name.IsNotTemporaryScopedHandle()); 2671 ASSERT(function_name.IsNotTemporaryScopedHandle());
2671 ASSERT(!arguments->is_empty()); 2672 ASSERT(!arguments->is_empty());
2672 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); 2673 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap());
2673 ASSERT(Token::IsBinaryOperator(token_kind) || 2674 ASSERT(Token::IsBinaryOperator(token_kind) ||
2675 Token::IsRelationalOperator(token_kind) ||
2674 Token::IsPrefixOperator(token_kind) || 2676 Token::IsPrefixOperator(token_kind) ||
2675 Token::IsIndexOperator(token_kind) || 2677 Token::IsIndexOperator(token_kind) ||
2676 Token::IsTypeTestOperator(token_kind) || 2678 Token::IsTypeTestOperator(token_kind) ||
2677 Token::IsTypeCastOperator(token_kind) || 2679 Token::IsTypeCastOperator(token_kind) ||
2678 token_kind == Token::kGET || 2680 token_kind == Token::kGET ||
2679 token_kind == Token::kSET || 2681 token_kind == Token::kSET ||
2680 token_kind == Token::kILLEGAL); 2682 token_kind == Token::kILLEGAL);
2681 } 2683 }
2682 2684
2683 DECLARE_INSTRUCTION(InstanceCall) 2685 DECLARE_INSTRUCTION(InstanceCall)
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); 2995 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr);
2994 }; 2996 };
2995 2997
2996 2998
2997 class RelationalOpInstr : public ComparisonInstr { 2999 class RelationalOpInstr : public ComparisonInstr {
2998 public: 3000 public:
2999 RelationalOpInstr(intptr_t token_pos, 3001 RelationalOpInstr(intptr_t token_pos,
3000 Token::Kind kind, 3002 Token::Kind kind,
3001 Value* left, 3003 Value* left,
3002 Value* right, 3004 Value* right,
3003 const Array& ic_data_array) 3005 intptr_t cid,
3004 : ComparisonInstr(token_pos, kind, left, right), 3006 intptr_t deopt_id)
3005 ic_data_(GetICData(ic_data_array)) { 3007 : ComparisonInstr(token_pos, kind, left, right) {
3006 ASSERT(Token::IsRelationalOperator(kind)); 3008 ASSERT(Token::IsRelationalOperator(kind));
3009 set_operation_cid(cid);
3010 // Override generated deopt-id.
3011 deopt_id_ = deopt_id;
Kevin Millikin (Google) 2013/09/03 13:23:55 You can just set this in the member initializer li
Florian Schneider 2013/09/03 13:55:06 Unfortunately it won't work with a private field o
3007 } 3012 }
3008 3013
3009 DECLARE_INSTRUCTION(RelationalOp) 3014 DECLARE_INSTRUCTION(RelationalOp)
3010 virtual CompileType ComputeType() const; 3015 virtual CompileType ComputeType() const;
3011 virtual bool RecomputeType(); 3016 virtual bool RecomputeType();
3012 3017
3013 const ICData* ic_data() const { return ic_data_; }
3014 bool HasICData() const {
3015 return (ic_data() != NULL) && !ic_data()->IsNull();
3016 }
3017 void set_ic_data(const ICData* value) { ic_data_ = value; }
3018
3019 bool IsInlinedNumericComparison() const {
3020 return (operation_cid() == kDoubleCid)
3021 || (operation_cid() == kMintCid)
3022 || (operation_cid() == kSmiCid);
3023 }
3024
3025 virtual void PrintOperandsTo(BufferFormatter* f) const; 3018 virtual void PrintOperandsTo(BufferFormatter* f) const;
3026 3019
3027 virtual bool CanDeoptimize() const { 3020 virtual bool CanDeoptimize() const { return false; }
3028 return !IsInlinedNumericComparison(); 3021
3022 virtual bool CanBecomeDeoptimizationTarget() const {
3023 // RelationalOp can be merged into Branch and thus needs an environment.
3024 return true;
3029 } 3025 }
3030 3026
3031 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 3027 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
3032 BranchInstr* branch); 3028 BranchInstr* branch);
3033 3029
3034 3030
3035 virtual intptr_t DeoptimizationTarget() const { 3031 virtual intptr_t DeoptimizationTarget() const {
3036 return GetDeoptId(); 3032 return GetDeoptId();
3037 } 3033 }
3038 3034
3039 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3035 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3040 ASSERT((idx == 0) || (idx == 1)); 3036 ASSERT((idx == 0) || (idx == 1));
3041 if (operation_cid() == kDoubleCid) return kUnboxedDouble; 3037 if (operation_cid() == kDoubleCid) return kUnboxedDouble;
3042 if (operation_cid() == kMintCid) return kUnboxedMint; 3038 if (operation_cid() == kMintCid) return kUnboxedMint;
3043 return kTagged; 3039 return kTagged;
3044 } 3040 }
3045 3041
3046 virtual EffectSet Effects() const { 3042 virtual EffectSet Effects() const {
3047 return IsInlinedNumericComparison() ? EffectSet::None() : EffectSet::All(); 3043 return EffectSet::None();
3048 } 3044 }
3049 3045
3050 virtual bool MayThrow() const { return !IsInlinedNumericComparison(); } 3046 virtual bool MayThrow() const { return false; }
3051 3047
3052 private: 3048 private:
3053 const ICData* ic_data_;
3054
3055 DISALLOW_COPY_AND_ASSIGN(RelationalOpInstr); 3049 DISALLOW_COPY_AND_ASSIGN(RelationalOpInstr);
3056 }; 3050 };
3057 3051
3058 3052
3059 // TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for 3053 // TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for
3060 // materialization of true and false constants. 3054 // materialization of true and false constants.
3061 class IfThenElseInstr : public TemplateDefinition<2> { 3055 class IfThenElseInstr : public TemplateDefinition<2> {
3062 public: 3056 public:
3063 IfThenElseInstr(Token::Kind kind, 3057 IfThenElseInstr(Token::Kind kind,
3064 Value* left, 3058 Value* left,
(...skipping 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after
6791 ForwardInstructionIterator* current_iterator_; 6785 ForwardInstructionIterator* current_iterator_;
6792 6786
6793 private: 6787 private:
6794 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6788 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6795 }; 6789 };
6796 6790
6797 6791
6798 } // namespace dart 6792 } // namespace dart
6799 6793
6800 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6794 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698