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

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

Issue 17101028: Refactor load forwarding pass to use a Place abstraction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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.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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 FOR_EACH_INSTRUCTION(DECLARE_TAG) 633 FOR_EACH_INSTRUCTION(DECLARE_TAG)
634 }; 634 };
635 #undef DECLARE_TAG 635 #undef DECLARE_TAG
636 636
637 Instruction() 637 Instruction()
638 : deopt_id_(Isolate::Current()->GetNextDeoptId()), 638 : deopt_id_(Isolate::Current()->GetNextDeoptId()),
639 lifetime_position_(-1), 639 lifetime_position_(-1),
640 previous_(NULL), 640 previous_(NULL),
641 next_(NULL), 641 next_(NULL),
642 env_(NULL), 642 env_(NULL),
643 expr_id_(kNoExprId) { } 643 place_id_(kNoPlaceId) { }
644 644
645 virtual Tag tag() const = 0; 645 virtual Tag tag() const = 0;
646 646
647 intptr_t deopt_id() const { 647 intptr_t deopt_id() const {
648 ASSERT(CanDeoptimize() || CanBecomeDeoptimizationTarget()); 648 ASSERT(CanDeoptimize() || CanBecomeDeoptimizationTarget());
649 return deopt_id_; 649 return deopt_id_;
650 } 650 }
651 651
652 ICData* GetICData(const Array& ic_data_array) const; 652 ICData* GetICData(const Array& ic_data_array) const;
653 653
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 // a block) successors. Branch instruction with >1 successors override this 724 // a block) successors. Branch instruction with >1 successors override this
725 // function. 725 // function.
726 virtual intptr_t SuccessorCount() const; 726 virtual intptr_t SuccessorCount() const;
727 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 727 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
728 728
729 void Goto(JoinEntryInstr* entry); 729 void Goto(JoinEntryInstr* entry);
730 730
731 virtual const char* DebugName() const = 0; 731 virtual const char* DebugName() const = 0;
732 732
733 // Printing support. 733 // Printing support.
734 const char* ToCString() const;
734 virtual void PrintTo(BufferFormatter* f) const; 735 virtual void PrintTo(BufferFormatter* f) const;
735 virtual void PrintOperandsTo(BufferFormatter* f) const; 736 virtual void PrintOperandsTo(BufferFormatter* f) const;
736 737
737 #define INSTRUCTION_TYPE_CHECK(type) \ 738 #define INSTRUCTION_TYPE_CHECK(type) \
738 bool Is##type() { return (As##type() != NULL); } \ 739 bool Is##type() { return (As##type() != NULL); } \
739 virtual type##Instr* As##type() { return NULL; } 740 virtual type##Instr* As##type() { return NULL; }
740 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) 741 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
741 #undef INSTRUCTION_TYPE_CHECK 742 #undef INSTRUCTION_TYPE_CHECK
742 743
743 // Returns structure describing location constraints required 744 // Returns structure describing location constraints required
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 817
817 // Returns set of effects that affect this instruction. 818 // Returns set of effects that affect this instruction.
818 virtual EffectSet Dependencies() const { 819 virtual EffectSet Dependencies() const {
819 UNREACHABLE(); 820 UNREACHABLE();
820 return EffectSet::All(); 821 return EffectSet::All();
821 } 822 }
822 823
823 // Get the block entry for this instruction. 824 // Get the block entry for this instruction.
824 virtual BlockEntryInstr* GetBlock() const; 825 virtual BlockEntryInstr* GetBlock() const;
825 826
826 // Id for load instructions used during load forwarding pass and later in 827 // Place identifiers used by the load optimization pass.
827 // LICM. 828 intptr_t place_id() const { return place_id_; }
828 intptr_t expr_id() const { return expr_id_; } 829 void set_place_id(intptr_t place_id) { place_id_ = place_id; }
829 void set_expr_id(intptr_t expr_id) { expr_id_ = expr_id; } 830 bool HasPlaceId() const { return place_id_ != kNoPlaceId; }
830 bool HasExprId() const { return expr_id_ != kNoExprId; }
831 831
832 // Returns a hash code for use with hash maps. 832 // Returns a hash code for use with hash maps.
833 virtual intptr_t Hashcode() const; 833 virtual intptr_t Hashcode() const;
834 834
835 // Compares two instructions. Returns true, iff: 835 // Compares two instructions. Returns true, iff:
836 // 1. They have the same tag. 836 // 1. They have the same tag.
837 // 2. All input operands are Equals. 837 // 2. All input operands are Equals.
838 // 3. They satisfy AttributesEqual. 838 // 3. They satisfy AttributesEqual.
839 bool Equals(Instruction* other) const; 839 bool Equals(Instruction* other) const;
840 840
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 friend class InstanceOfInstr; 920 friend class InstanceOfInstr;
921 friend class PolymorphicInstanceCallInstr; 921 friend class PolymorphicInstanceCallInstr;
922 friend class SmiToDoubleInstr; 922 friend class SmiToDoubleInstr;
923 friend class DoubleToIntegerInstr; 923 friend class DoubleToIntegerInstr;
924 friend class BranchSimplifier; 924 friend class BranchSimplifier;
925 friend class BlockEntryInstr; 925 friend class BlockEntryInstr;
926 926
927 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; 927 virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
928 928
929 enum { 929 enum {
930 kNoExprId = -1 930 kNoPlaceId = -1
931 }; 931 };
932 932
933 intptr_t deopt_id_; 933 intptr_t deopt_id_;
934 intptr_t lifetime_position_; // Position used by register allocator. 934 intptr_t lifetime_position_; // Position used by register allocator.
935 Instruction* previous_; 935 Instruction* previous_;
936 Instruction* next_; 936 Instruction* next_;
937 Environment* env_; 937 Environment* env_;
938 intptr_t expr_id_; 938 intptr_t place_id_;
939 939
940 DISALLOW_COPY_AND_ASSIGN(Instruction); 940 DISALLOW_COPY_AND_ASSIGN(Instruction);
941 }; 941 };
942 942
943 943
944 template<intptr_t N> 944 template<intptr_t N>
945 class TemplateInstruction: public Instruction { 945 class TemplateInstruction: public Instruction {
946 public: 946 public:
947 TemplateInstruction<N>() : locs_(NULL) { } 947 TemplateInstruction<N>() : locs_(NULL) { }
948 948
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 1372
1373 // Returns -1 if pred is not in the list. 1373 // Returns -1 if pred is not in the list.
1374 intptr_t IndexOfPredecessor(BlockEntryInstr* pred) const; 1374 intptr_t IndexOfPredecessor(BlockEntryInstr* pred) const;
1375 1375
1376 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } 1376 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; }
1377 1377
1378 void InsertPhi(intptr_t var_index, intptr_t var_count); 1378 void InsertPhi(intptr_t var_index, intptr_t var_count);
1379 void RemoveDeadPhis(Definition* replacement); 1379 void RemoveDeadPhis(Definition* replacement);
1380 1380
1381 void InsertPhi(PhiInstr* phi); 1381 void InsertPhi(PhiInstr* phi);
1382 void RemovePhi(PhiInstr* phi);
1382 1383
1383 virtual void PrintTo(BufferFormatter* f) const; 1384 virtual void PrintTo(BufferFormatter* f) const;
1384 1385
1385 virtual EffectSet Effects() const { return EffectSet::None(); } 1386 virtual EffectSet Effects() const { return EffectSet::None(); }
1386 virtual EffectSet Dependencies() const { return EffectSet::None(); } 1387 virtual EffectSet Dependencies() const { return EffectSet::None(); }
1387 1388
1388 private: 1389 private:
1389 // Classes that have access to predecessors_ when inlining. 1390 // Classes that have access to predecessors_ when inlining.
1390 friend class BlockEntryInstr; 1391 friend class BlockEntryInstr;
1391 friend class InlineExitCollector; 1392 friend class InlineExitCollector;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 1695
1695 Value* InputAt(intptr_t i) const { return inputs_[i]; } 1696 Value* InputAt(intptr_t i) const { return inputs_[i]; }
1696 1697
1697 virtual bool CanDeoptimize() const { return false; } 1698 virtual bool CanDeoptimize() const { return false; }
1698 1699
1699 virtual EffectSet Effects() const { return EffectSet::None(); } 1700 virtual EffectSet Effects() const { return EffectSet::None(); }
1700 1701
1701 // Phi is alive if it reaches a non-environment use. 1702 // Phi is alive if it reaches a non-environment use.
1702 bool is_alive() const { return is_alive_; } 1703 bool is_alive() const { return is_alive_; }
1703 void mark_alive() { is_alive_ = true; } 1704 void mark_alive() { is_alive_ = true; }
1705 void mark_dead() { is_alive_ = false; }
1704 1706
1705 virtual Representation RequiredInputRepresentation(intptr_t i) const { 1707 virtual Representation RequiredInputRepresentation(intptr_t i) const {
1706 return representation_; 1708 return representation_;
1707 } 1709 }
1708 1710
1709 virtual Representation representation() const { 1711 virtual Representation representation() const {
1710 return representation_; 1712 return representation_;
1711 } 1713 }
1712 1714
1713 virtual void set_representation(Representation r) { 1715 virtual void set_representation(Representation r) {
(...skipping 4775 matching lines...) Expand 10 before | Expand all | Expand 10 after
6489 ForwardInstructionIterator* current_iterator_; 6491 ForwardInstructionIterator* current_iterator_;
6490 6492
6491 private: 6493 private:
6492 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6494 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6493 }; 6495 };
6494 6496
6495 6497
6496 } // namespace dart 6498 } // namespace dart
6497 6499
6498 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6500 #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