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

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
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language_arm.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 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 deopt_id_ = deopt_id; // Override generated deopt-id.
3007 } 3011 }
3008 3012
3009 DECLARE_INSTRUCTION(RelationalOp) 3013 DECLARE_INSTRUCTION(RelationalOp)
3010 virtual CompileType ComputeType() const; 3014 virtual CompileType ComputeType() const;
3011 virtual bool RecomputeType(); 3015 virtual bool RecomputeType();
3012 3016
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; 3017 virtual void PrintOperandsTo(BufferFormatter* f) const;
3026 3018
3027 virtual bool CanDeoptimize() const { 3019 virtual bool CanDeoptimize() const { return false; }
3028 return !IsInlinedNumericComparison(); 3020
3021 virtual bool CanBecomeDeoptimizationTarget() const {
3022 // RelationalOp can be merged into Branch and thus needs an environment.
3023 return true;
3029 } 3024 }
3030 3025
3031 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 3026 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
3032 BranchInstr* branch); 3027 BranchInstr* branch);
3033 3028
3034 3029
3035 virtual intptr_t DeoptimizationTarget() const { 3030 virtual intptr_t DeoptimizationTarget() const {
3036 return GetDeoptId(); 3031 return GetDeoptId();
3037 } 3032 }
3038 3033
3039 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 3034 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3040 ASSERT((idx == 0) || (idx == 1)); 3035 ASSERT((idx == 0) || (idx == 1));
3041 if (operation_cid() == kDoubleCid) return kUnboxedDouble; 3036 if (operation_cid() == kDoubleCid) return kUnboxedDouble;
3042 if (operation_cid() == kMintCid) return kUnboxedMint; 3037 if (operation_cid() == kMintCid) return kUnboxedMint;
3043 return kTagged; 3038 return kTagged;
3044 } 3039 }
3045 3040
3046 virtual EffectSet Effects() const { 3041 virtual EffectSet Effects() const {
3047 return IsInlinedNumericComparison() ? EffectSet::None() : EffectSet::All(); 3042 return EffectSet::None();
3048 } 3043 }
3049 3044
3050 virtual bool MayThrow() const { return !IsInlinedNumericComparison(); } 3045 virtual bool MayThrow() const { return false; }
3051 3046
3052 private: 3047 private:
3053 const ICData* ic_data_;
3054
3055 DISALLOW_COPY_AND_ASSIGN(RelationalOpInstr); 3048 DISALLOW_COPY_AND_ASSIGN(RelationalOpInstr);
3056 }; 3049 };
3057 3050
3058 3051
3059 // TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for 3052 // TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for
3060 // materialization of true and false constants. 3053 // materialization of true and false constants.
3061 class IfThenElseInstr : public TemplateDefinition<2> { 3054 class IfThenElseInstr : public TemplateDefinition<2> {
3062 public: 3055 public:
3063 IfThenElseInstr(Token::Kind kind, 3056 IfThenElseInstr(Token::Kind kind,
3064 Value* left, 3057 Value* left,
(...skipping 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after
6791 ForwardInstructionIterator* current_iterator_; 6784 ForwardInstructionIterator* current_iterator_;
6792 6785
6793 private: 6786 private:
6794 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6787 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6795 }; 6788 };
6796 6789
6797 6790
6798 } // namespace dart 6791 } // namespace dart
6799 6792
6800 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6793 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698