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

Side by Side Diff: vm/intermediate_language.h

Issue 10665022: Make IL instructions a doubly-linked list within basic blocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « vm/il_printer.cc ('k') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 class Definition; 321 class Definition;
322 class BindInstr; 322 class BindInstr;
323 class PhiInstr; 323 class PhiInstr;
324 324
325 class UseVal : public Value { 325 class UseVal : public Value {
326 public: 326 public:
327 explicit UseVal(Definition* definition) : definition_(definition) {} 327 explicit UseVal(Definition* definition) : definition_(definition) {}
328 328
329 DECLARE_VALUE(Use) 329 DECLARE_VALUE(Use)
330 330
331 Definition* definition() const { return definition_; } 331 inline Definition* definition() const;
332 void set_definition(Definition* definition) { 332 void set_definition(Definition* definition) {
333 definition_ = definition; 333 definition_ = definition;
334 } 334 }
335 335
336 private: 336 private:
337 Definition* definition_; 337 Definition* definition_;
338 338
339 DISALLOW_COPY_AND_ASSIGN(UseVal); 339 DISALLOW_COPY_AND_ASSIGN(UseVal);
340 }; 340 };
341 341
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 virtual intptr_t InputCount() const; \ 1727 virtual intptr_t InputCount() const; \
1728 virtual Value* InputAt(intptr_t i) const; \ 1728 virtual Value* InputAt(intptr_t i) const; \
1729 virtual void SetInputAt(intptr_t i, Value* value); \ 1729 virtual void SetInputAt(intptr_t i, Value* value); \
1730 virtual const char* DebugName() const { return #type; } \ 1730 virtual const char* DebugName() const { return #type; } \
1731 virtual void PrintTo(BufferFormatter* f) const; \ 1731 virtual void PrintTo(BufferFormatter* f) const; \
1732 virtual void PrintToVisualizer(BufferFormatter* f) const; 1732 virtual void PrintToVisualizer(BufferFormatter* f) const;
1733 1733
1734 1734
1735 class Instruction : public ZoneAllocated { 1735 class Instruction : public ZoneAllocated {
1736 public: 1736 public:
1737 Instruction() : cid_(-1), ic_data_(NULL) { 1737 Instruction() : cid_(-1), ic_data_(NULL), successor_(NULL), previous_(NULL) {
1738 Isolate* isolate = Isolate::Current(); 1738 Isolate* isolate = Isolate::Current();
1739 cid_ = Computation::GetNextCid(isolate); 1739 cid_ = Computation::GetNextCid(isolate);
1740 ic_data_ = Computation::GetICDataForCid(cid_, isolate); 1740 ic_data_ = Computation::GetICDataForCid(cid_, isolate);
1741 } 1741 }
1742 1742
1743 // Unique computation/instruction id, used for deoptimization, e.g. for 1743 // Unique computation/instruction id, used for deoptimization, e.g. for
1744 // ReturnInstr, ThrowInstr and ReThrowInstr. 1744 // ReturnInstr, ThrowInstr and ReThrowInstr.
1745 intptr_t cid() const { return cid_; } 1745 intptr_t cid() const { return cid_; }
1746 1746
1747 const ICData* ic_data() const { return ic_data_; } 1747 const ICData* ic_data() const { return ic_data_; }
1748 1748
1749 virtual bool IsBlockEntry() const { return false; } 1749 virtual bool IsBlockEntry() const { return false; }
1750 BlockEntryInstr* AsBlockEntry() { 1750 BlockEntryInstr* AsBlockEntry() {
1751 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; 1751 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL;
1752 } 1752 }
1753 virtual bool IsDefinition() const { return false; } 1753 virtual bool IsDefinition() const { return false; }
1754 virtual Definition* AsDefinition() { return NULL; } 1754 virtual Definition* AsDefinition() { return NULL; }
1755 1755
1756 virtual intptr_t InputCount() const = 0; 1756 virtual intptr_t InputCount() const = 0;
1757 virtual Value* InputAt(intptr_t i) const = 0; 1757 virtual Value* InputAt(intptr_t i) const = 0;
1758 virtual void SetInputAt(intptr_t i, Value* value) = 0; 1758 virtual void SetInputAt(intptr_t i, Value* value) = 0;
1759 1759
1760 // Visiting support. 1760 // Visiting support.
1761 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0; 1761 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0;
1762 1762
1763 virtual Instruction* StraightLineSuccessor() const = 0; 1763 Instruction* successor() const { return successor_; }
1764 virtual void SetSuccessor(Instruction* instr) = 0; 1764 void set_successor(Instruction* instr) {
1765 ASSERT(!IsGraphEntry());
1766 ASSERT(!IsReturn());
1767 ASSERT(!IsBranch());
1768 ASSERT(!IsPhi());
1769 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions
1770 // that do not have a successor. Currently, the graph builder will continue
1771 // to append instruction in case of a Throw inside an expression. This
1772 // condition should be handled in the graph builder
1773 successor_ = instr;
1774 }
1775
1776 Instruction* previous() const { return previous_; }
1777 void set_previous(Instruction* instr) {
1778 ASSERT(!IsBlockEntry());
1779 previous_ = instr;
1780 }
1781
1782 bool is_linked() const;
1783
1784 // Remove instruction from the graph.
1785 void RemoveFromGraph();
1765 1786
1766 // Normal instructions can have 0 (inside a block) or 1 (last instruction in 1787 // Normal instructions can have 0 (inside a block) or 1 (last instruction in
1767 // a block) successors. Branch instruction with >1 successors override this 1788 // a block) successors. Branch instruction with >1 successors override this
1768 // function. 1789 // function.
1769 virtual intptr_t SuccessorCount() const; 1790 virtual intptr_t SuccessorCount() const;
1770 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1791 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1771 1792
1772 virtual void replace_computation(Computation* value) { 1793 virtual void replace_computation(Computation* value) {
1773 UNREACHABLE(); 1794 UNREACHABLE();
1774 } 1795 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 return NULL; 1846 return NULL;
1826 } 1847 }
1827 1848
1828 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1849 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1829 UNIMPLEMENTED(); 1850 UNIMPLEMENTED();
1830 } 1851 }
1831 1852
1832 private: 1853 private:
1833 intptr_t cid_; 1854 intptr_t cid_;
1834 ICData* ic_data_; 1855 ICData* ic_data_;
1856 Instruction* successor_;
1857 Instruction* previous_;
1835 DISALLOW_COPY_AND_ASSIGN(Instruction); 1858 DISALLOW_COPY_AND_ASSIGN(Instruction);
1836 }; 1859 };
1837 1860
1838 1861
1839 class InstructionWithInputs : public Instruction { 1862 class InstructionWithInputs : public Instruction {
1840 public: 1863 public:
1841 InstructionWithInputs() : locs_(NULL) { 1864 InstructionWithInputs() : locs_(NULL) {
1842 } 1865 }
1843 1866
1844 virtual LocationSummary* locs() { 1867 virtual LocationSummary* locs() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 1956
1934 DECLARE_INSTRUCTION(GraphEntry) 1957 DECLARE_INSTRUCTION(GraphEntry)
1935 1958
1936 virtual intptr_t PredecessorCount() const { return 0; } 1959 virtual intptr_t PredecessorCount() const { return 0; }
1937 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1960 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1938 UNREACHABLE(); 1961 UNREACHABLE();
1939 return NULL; 1962 return NULL;
1940 } 1963 }
1941 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 1964 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
1942 1965
1943 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1944 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
1945
1946 virtual intptr_t SuccessorCount() const; 1966 virtual intptr_t SuccessorCount() const;
1947 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1967 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1948 1968
1949 virtual void DiscoverBlocks( 1969 virtual void DiscoverBlocks(
1950 BlockEntryInstr* current_block, 1970 BlockEntryInstr* current_block,
1951 GrowableArray<BlockEntryInstr*>* preorder, 1971 GrowableArray<BlockEntryInstr*>* preorder,
1952 GrowableArray<BlockEntryInstr*>* postorder, 1972 GrowableArray<BlockEntryInstr*>* postorder,
1953 GrowableArray<intptr_t>* parent, 1973 GrowableArray<intptr_t>* parent,
1954 GrowableArray<BitVector*>* assigned_vars, 1974 GrowableArray<BitVector*>* assigned_vars,
1955 intptr_t variable_count); 1975 intptr_t variable_count);
(...skipping 12 matching lines...) Expand all
1968 1988
1969 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 1989 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
1970 }; 1990 };
1971 1991
1972 1992
1973 class JoinEntryInstr : public BlockEntryInstr { 1993 class JoinEntryInstr : public BlockEntryInstr {
1974 public: 1994 public:
1975 JoinEntryInstr() 1995 JoinEntryInstr()
1976 : BlockEntryInstr(), 1996 : BlockEntryInstr(),
1977 predecessors_(2), // Two is the assumed to be the common case. 1997 predecessors_(2), // Two is the assumed to be the common case.
1978 successor_(NULL),
1979 phis_(NULL), 1998 phis_(NULL),
1980 phi_count_(0) { } 1999 phi_count_(0) { }
1981 2000
1982 DECLARE_INSTRUCTION(JoinEntry) 2001 DECLARE_INSTRUCTION(JoinEntry)
1983 2002
1984 virtual intptr_t PredecessorCount() const { return predecessors_.length(); } 2003 virtual intptr_t PredecessorCount() const { return predecessors_.length(); }
1985 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 2004 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1986 return predecessors_[index]; 2005 return predecessors_[index];
1987 } 2006 }
1988 virtual void AddPredecessor(BlockEntryInstr* predecessor) { 2007 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
1989 predecessors_.Add(predecessor); 2008 predecessors_.Add(predecessor);
1990 } 2009 }
1991 2010
1992 virtual Instruction* StraightLineSuccessor() const {
1993 return successor_;
1994 }
1995 virtual void SetSuccessor(Instruction* instr) {
1996 successor_ = instr;
1997 }
1998
1999 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } 2011 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; }
2000 2012
2001 virtual void PrepareEntry(FlowGraphCompiler* compiler); 2013 virtual void PrepareEntry(FlowGraphCompiler* compiler);
2002 2014
2003 void InsertPhi(intptr_t var_index, intptr_t var_count); 2015 void InsertPhi(intptr_t var_index, intptr_t var_count);
2004 2016
2005 intptr_t phi_count() const { return phi_count_; } 2017 intptr_t phi_count() const { return phi_count_; }
2006 2018
2007 private: 2019 private:
2008 ZoneGrowableArray<BlockEntryInstr*> predecessors_; 2020 ZoneGrowableArray<BlockEntryInstr*> predecessors_;
2009 Instruction* successor_;
2010 ZoneGrowableArray<PhiInstr*>* phis_; 2021 ZoneGrowableArray<PhiInstr*>* phis_;
2011 intptr_t phi_count_; 2022 intptr_t phi_count_;
2012 2023
2013 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); 2024 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr);
2014 }; 2025 };
2015 2026
2016 2027
2017 class TargetEntryInstr : public BlockEntryInstr { 2028 class TargetEntryInstr : public BlockEntryInstr {
2018 public: 2029 public:
2019 TargetEntryInstr() 2030 TargetEntryInstr()
2020 : BlockEntryInstr(), 2031 : BlockEntryInstr(),
2021 predecessor_(NULL), 2032 predecessor_(NULL),
2022 successor_(NULL),
2023 try_index_(CatchClauseNode::kInvalidTryIndex) { } 2033 try_index_(CatchClauseNode::kInvalidTryIndex) { }
2024 2034
2025 // Used for exception catch entries. 2035 // Used for exception catch entries.
2026 explicit TargetEntryInstr(intptr_t try_index) 2036 explicit TargetEntryInstr(intptr_t try_index)
2027 : BlockEntryInstr(), 2037 : BlockEntryInstr(),
2028 predecessor_(NULL), 2038 predecessor_(NULL),
2029 successor_(NULL),
2030 try_index_(try_index) { } 2039 try_index_(try_index) { }
2031 2040
2032 DECLARE_INSTRUCTION(TargetEntry) 2041 DECLARE_INSTRUCTION(TargetEntry)
2033 2042
2034 virtual intptr_t PredecessorCount() const { 2043 virtual intptr_t PredecessorCount() const {
2035 return (predecessor_ == NULL) ? 0 : 1; 2044 return (predecessor_ == NULL) ? 0 : 1;
2036 } 2045 }
2037 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 2046 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
2038 ASSERT((index == 0) && (predecessor_ != NULL)); 2047 ASSERT((index == 0) && (predecessor_ != NULL));
2039 return predecessor_; 2048 return predecessor_;
2040 } 2049 }
2041 virtual void AddPredecessor(BlockEntryInstr* predecessor) { 2050 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
2042 ASSERT(predecessor_ == NULL); 2051 ASSERT(predecessor_ == NULL);
2043 predecessor_ = predecessor; 2052 predecessor_ = predecessor;
2044 } 2053 }
2045 2054
2046 virtual Instruction* StraightLineSuccessor() const {
2047 return successor_;
2048 }
2049 virtual void SetSuccessor(Instruction* instr) {
2050 successor_ = instr;
2051 }
2052
2053 bool HasTryIndex() const { 2055 bool HasTryIndex() const {
2054 return try_index_ != CatchClauseNode::kInvalidTryIndex; 2056 return try_index_ != CatchClauseNode::kInvalidTryIndex;
2055 } 2057 }
2056 2058
2057 intptr_t try_index() const { 2059 intptr_t try_index() const {
2058 ASSERT(HasTryIndex()); 2060 ASSERT(HasTryIndex());
2059 return try_index_; 2061 return try_index_;
2060 } 2062 }
2061 2063
2062 virtual void PrepareEntry(FlowGraphCompiler* compiler); 2064 virtual void PrepareEntry(FlowGraphCompiler* compiler);
2063 2065
2064 private: 2066 private:
2065 BlockEntryInstr* predecessor_; 2067 BlockEntryInstr* predecessor_;
2066 Instruction* successor_;
2067 const intptr_t try_index_; 2068 const intptr_t try_index_;
2068 2069
2069 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); 2070 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
2070 }; 2071 };
2071 2072
2072 2073
2073 class DoInstr : public Instruction { 2074 class DoInstr : public Instruction {
2074 public: 2075 public:
2075 explicit DoInstr(Computation* computation) 2076 explicit DoInstr(Computation* computation)
2076 : computation_(computation), successor_(NULL) { 2077 : computation_(computation) {
2077 ASSERT(computation != NULL); 2078 ASSERT(computation != NULL);
2078 computation->set_instr(this); 2079 computation->set_instr(this);
2079 } 2080 }
2080 2081
2081 DECLARE_INSTRUCTION(Do) 2082 DECLARE_INSTRUCTION(Do)
2082 2083
2083 Computation* computation() const { return computation_; } 2084 Computation* computation() const { return computation_; }
2084 virtual void replace_computation(Computation* value) { computation_ = value; } 2085 virtual void replace_computation(Computation* value) { computation_ = value; }
2085 2086
2086 virtual Instruction* StraightLineSuccessor() const {
2087 return successor_;
2088 }
2089
2090 virtual void SetSuccessor(Instruction* instr) {
2091 successor_ = instr;
2092 }
2093
2094 virtual void RecordAssignedVars(BitVector* assigned_vars); 2087 virtual void RecordAssignedVars(BitVector* assigned_vars);
2095 2088
2096 virtual LocationSummary* locs() { 2089 virtual LocationSummary* locs() {
2097 return computation()->locs(); 2090 return computation()->locs();
2098 } 2091 }
2099 2092
2100 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2093 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2101 computation()->EmitNativeCode(compiler); 2094 computation()->EmitNativeCode(compiler);
2102 } 2095 }
2103 2096
2104 private: 2097 private:
2105 Computation* computation_; 2098 Computation* computation_;
2106 Instruction* successor_;
2107 2099
2108 DISALLOW_COPY_AND_ASSIGN(DoInstr); 2100 DISALLOW_COPY_AND_ASSIGN(DoInstr);
2109 }; 2101 };
2110 2102
2111 2103
2112 // Abstract super-class of all instructions that define a value (Bind, Phi). 2104 // Abstract super-class of all instructions that define a value (Bind, Phi).
2113 class Definition : public Instruction { 2105 class Definition : public Instruction {
2114 public: 2106 public:
2115 Definition() : temp_index_(-1), ssa_temp_index_(-1) { } 2107 Definition() : temp_index_(-1), ssa_temp_index_(-1) { }
2116 2108
2117 virtual bool IsDefinition() const { return true; } 2109 virtual bool IsDefinition() const { return true; }
2118 virtual Definition* AsDefinition() { return this; } 2110 virtual Definition* AsDefinition() { return this; }
2119 2111
2120 intptr_t temp_index() const { return temp_index_; } 2112 intptr_t temp_index() const { return temp_index_; }
2121 void set_temp_index(intptr_t index) { temp_index_ = index; } 2113 void set_temp_index(intptr_t index) { temp_index_ = index; }
2122 2114
2123 intptr_t ssa_temp_index() const { return ssa_temp_index_; } 2115 intptr_t ssa_temp_index() const { return ssa_temp_index_; }
2124 void set_ssa_temp_index(intptr_t index) { ssa_temp_index_ = index; } 2116 void set_ssa_temp_index(intptr_t index) { ssa_temp_index_ = index; }
2125 2117
2126 private: 2118 private:
2127 intptr_t temp_index_; 2119 intptr_t temp_index_;
2128 intptr_t ssa_temp_index_; 2120 intptr_t ssa_temp_index_;
2129 2121
2130 DISALLOW_COPY_AND_ASSIGN(Definition); 2122 DISALLOW_COPY_AND_ASSIGN(Definition);
2131 }; 2123 };
2132 2124
2133 2125
2126 Definition* UseVal::definition() const {
2127 // Check that the definition is either a Phi or a linked in the the IR.
2128 ASSERT(definition_ != NULL);
2129 ASSERT(!definition_->IsPhi() || definition_->is_linked());
2130 return definition_;
2131 }
2132
2133
2134 class BindInstr : public Definition { 2134 class BindInstr : public Definition {
2135 public: 2135 public:
2136 explicit BindInstr(Computation* computation) 2136 explicit BindInstr(Computation* computation)
2137 : computation_(computation), successor_(NULL) { 2137 : computation_(computation) {
2138 ASSERT(computation != NULL); 2138 ASSERT(computation != NULL);
2139 computation->set_instr(this); 2139 computation->set_instr(this);
2140 } 2140 }
2141 2141
2142 DECLARE_INSTRUCTION(Bind) 2142 DECLARE_INSTRUCTION(Bind)
2143 2143
2144 Computation* computation() const { return computation_; } 2144 Computation* computation() const { return computation_; }
2145 virtual void replace_computation(Computation* value) { computation_ = value; } 2145 virtual void replace_computation(Computation* value) { computation_ = value; }
2146 2146
2147 virtual Instruction* StraightLineSuccessor() const {
2148 return successor_;
2149 }
2150
2151 virtual void SetSuccessor(Instruction* instr) {
2152 successor_ = instr;
2153 }
2154
2155 // Static type of the underlying computation. 2147 // Static type of the underlying computation.
2156 virtual RawAbstractType* StaticType() const { 2148 virtual RawAbstractType* StaticType() const {
2157 return computation()->StaticType(); 2149 return computation()->StaticType();
2158 } 2150 }
2159 2151
2160 virtual void RecordAssignedVars(BitVector* assigned_vars); 2152 virtual void RecordAssignedVars(BitVector* assigned_vars);
2161 2153
2162 virtual LocationSummary* locs() { 2154 virtual LocationSummary* locs() {
2163 return computation()->locs(); 2155 return computation()->locs();
2164 } 2156 }
2165 2157
2166 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2158 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2167 2159
2168 private: 2160 private:
2169 Computation* computation_; 2161 Computation* computation_;
2170 Instruction* successor_;
2171 2162
2172 DISALLOW_COPY_AND_ASSIGN(BindInstr); 2163 DISALLOW_COPY_AND_ASSIGN(BindInstr);
2173 }; 2164 };
2174 2165
2175 2166
2176 class PhiInstr: public Definition { 2167 class PhiInstr: public Definition {
2177 public: 2168 public:
2178 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { 2169 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) {
2179 for (intptr_t i = 0; i < num_inputs; ++i) { 2170 for (intptr_t i = 0; i < num_inputs; ++i) {
2180 inputs_.Add(NULL); 2171 inputs_.Add(NULL);
2181 } 2172 }
2182 } 2173 }
2183 2174
2184 DECLARE_INSTRUCTION(Phi) 2175 DECLARE_INSTRUCTION(Phi)
2185 2176
2186 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2187 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
2188
2189 private: 2177 private:
2190 GrowableArray<Value*> inputs_; 2178 GrowableArray<Value*> inputs_;
2191 2179
2192 DISALLOW_COPY_AND_ASSIGN(PhiInstr); 2180 DISALLOW_COPY_AND_ASSIGN(PhiInstr);
2193 }; 2181 };
2194 2182
2195 2183
2196 class ReturnInstr : public InstructionWithInputs { 2184 class ReturnInstr : public InstructionWithInputs {
2197 public: 2185 public:
2198 ReturnInstr(intptr_t token_pos, Value* value) 2186 ReturnInstr(intptr_t token_pos, Value* value)
2199 : InstructionWithInputs(), token_pos_(token_pos), value_(value) { 2187 : InstructionWithInputs(), token_pos_(token_pos), value_(value) {
2200 ASSERT(value_ != NULL); 2188 ASSERT(value_ != NULL);
2201 } 2189 }
2202 2190
2203 DECLARE_INSTRUCTION(Return) 2191 DECLARE_INSTRUCTION(Return)
2204 2192
2205 Value* value() const { return value_; } 2193 Value* value() const { return value_; }
2206 intptr_t token_pos() const { return token_pos_; } 2194 intptr_t token_pos() const { return token_pos_; }
2207 2195
2208 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2209 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
2210
2211 virtual LocationSummary* MakeLocationSummary() const; 2196 virtual LocationSummary* MakeLocationSummary() const;
2212 2197
2213 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2198 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2214 2199
2215 private: 2200 private:
2216 const intptr_t token_pos_; 2201 const intptr_t token_pos_;
2217 Value* value_; 2202 Value* value_;
2218 2203
2219 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 2204 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
2220 }; 2205 };
2221 2206
2222 2207
2223 class ThrowInstr : public InstructionWithInputs { 2208 class ThrowInstr : public InstructionWithInputs {
2224 public: 2209 public:
2225 ThrowInstr(intptr_t token_pos, 2210 ThrowInstr(intptr_t token_pos,
2226 intptr_t try_index, 2211 intptr_t try_index,
2227 Value* exception) 2212 Value* exception)
2228 : InstructionWithInputs(), 2213 : InstructionWithInputs(),
2229 token_pos_(token_pos), 2214 token_pos_(token_pos),
2230 try_index_(try_index), 2215 try_index_(try_index),
2231 exception_(exception), 2216 exception_(exception) {
2232 successor_(NULL) {
2233 ASSERT(exception_ != NULL); 2217 ASSERT(exception_ != NULL);
2234 } 2218 }
2235 2219
2236 DECLARE_INSTRUCTION(Throw) 2220 DECLARE_INSTRUCTION(Throw)
2237 2221
2238 intptr_t token_pos() const { return token_pos_; } 2222 intptr_t token_pos() const { return token_pos_; }
2239 intptr_t try_index() const { return try_index_; } 2223 intptr_t try_index() const { return try_index_; }
2240 Value* exception() const { return exception_; } 2224 Value* exception() const { return exception_; }
2241 2225
2242 // Parser can generate a throw within an expression tree. We never
2243 // add successor instructions to the graph.
2244 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2245 virtual void SetSuccessor(Instruction* instr) {
2246 ASSERT(successor_ == NULL);
2247 }
2248
2249 virtual LocationSummary* MakeLocationSummary() const; 2226 virtual LocationSummary* MakeLocationSummary() const;
2250 2227
2251 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2228 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2252 2229
2253 private: 2230 private:
2254 const intptr_t token_pos_; 2231 const intptr_t token_pos_;
2255 const intptr_t try_index_; 2232 const intptr_t try_index_;
2256 Value* exception_; 2233 Value* exception_;
2257 Instruction* successor_;
2258 2234
2259 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 2235 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
2260 }; 2236 };
2261 2237
2262 2238
2263 class ReThrowInstr : public InstructionWithInputs { 2239 class ReThrowInstr : public InstructionWithInputs {
2264 public: 2240 public:
2265 ReThrowInstr(intptr_t token_pos, 2241 ReThrowInstr(intptr_t token_pos,
2266 intptr_t try_index, 2242 intptr_t try_index,
2267 Value* exception, 2243 Value* exception,
2268 Value* stack_trace) 2244 Value* stack_trace)
2269 : InstructionWithInputs(), 2245 : InstructionWithInputs(),
2270 token_pos_(token_pos), 2246 token_pos_(token_pos),
2271 try_index_(try_index), 2247 try_index_(try_index),
2272 exception_(exception), 2248 exception_(exception),
2273 stack_trace_(stack_trace), 2249 stack_trace_(stack_trace) {
2274 successor_(NULL) {
2275 ASSERT(exception_ != NULL); 2250 ASSERT(exception_ != NULL);
2276 ASSERT(stack_trace_ != NULL); 2251 ASSERT(stack_trace_ != NULL);
2277 } 2252 }
2278 2253
2279 DECLARE_INSTRUCTION(ReThrow) 2254 DECLARE_INSTRUCTION(ReThrow)
2280 2255
2281 intptr_t token_pos() const { return token_pos_; } 2256 intptr_t token_pos() const { return token_pos_; }
2282 intptr_t try_index() const { return try_index_; } 2257 intptr_t try_index() const { return try_index_; }
2283 Value* exception() const { return exception_; } 2258 Value* exception() const { return exception_; }
2284 Value* stack_trace() const { return stack_trace_; } 2259 Value* stack_trace() const { return stack_trace_; }
2285 2260
2286 // Parser can generate a rethrow within an expression tree. We
2287 // never add successor instructions to the graph.
2288 virtual Instruction* StraightLineSuccessor() const {
2289 return NULL;
2290 }
2291 virtual void SetSuccessor(Instruction* instr) {
2292 ASSERT(successor_ == NULL);
2293 }
2294
2295 virtual LocationSummary* MakeLocationSummary() const; 2261 virtual LocationSummary* MakeLocationSummary() const;
2296 2262
2297 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2263 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2298 2264
2299 private: 2265 private:
2300 const intptr_t token_pos_; 2266 const intptr_t token_pos_;
2301 const intptr_t try_index_; 2267 const intptr_t try_index_;
2302 Value* exception_; 2268 Value* exception_;
2303 Value* stack_trace_; 2269 Value* stack_trace_;
2304 Instruction* successor_;
2305 2270
2306 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 2271 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
2307 }; 2272 };
2308 2273
2309 2274
2310 class BranchInstr : public InstructionWithInputs { 2275 class BranchInstr : public InstructionWithInputs {
2311 public: 2276 public:
2312 explicit BranchInstr(Value* value) 2277 explicit BranchInstr(Value* value)
2313 : InstructionWithInputs(), 2278 : InstructionWithInputs(),
2314 value_(value), 2279 value_(value),
2315 true_successor_(NULL), 2280 true_successor_(NULL),
2316 false_successor_(NULL), 2281 false_successor_(NULL),
2317 is_fused_with_comparison_(false), 2282 is_fused_with_comparison_(false),
2318 is_negated_(false) { } 2283 is_negated_(false) { }
2319 2284
2320 DECLARE_INSTRUCTION(Branch) 2285 DECLARE_INSTRUCTION(Branch)
2321 2286
2322 Value* value() const { return value_; } 2287 Value* value() const { return value_; }
2323 TargetEntryInstr* true_successor() const { return true_successor_; } 2288 TargetEntryInstr* true_successor() const { return true_successor_; }
2324 TargetEntryInstr* false_successor() const { return false_successor_; } 2289 TargetEntryInstr* false_successor() const { return false_successor_; }
2325 2290
2326 TargetEntryInstr** true_successor_address() { return &true_successor_; } 2291 TargetEntryInstr** true_successor_address() { return &true_successor_; }
2327 TargetEntryInstr** false_successor_address() { return &false_successor_; } 2292 TargetEntryInstr** false_successor_address() { return &false_successor_; }
2328 2293
2329 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2330 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
2331
2332 virtual intptr_t SuccessorCount() const; 2294 virtual intptr_t SuccessorCount() const;
2333 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 2295 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2334 2296
2335 virtual void DiscoverBlocks( 2297 virtual void DiscoverBlocks(
2336 BlockEntryInstr* current_block, 2298 BlockEntryInstr* current_block,
2337 GrowableArray<BlockEntryInstr*>* preorder, 2299 GrowableArray<BlockEntryInstr*>* preorder,
2338 GrowableArray<BlockEntryInstr*>* postorder, 2300 GrowableArray<BlockEntryInstr*>* postorder,
2339 GrowableArray<intptr_t>* parent, 2301 GrowableArray<intptr_t>* parent,
2340 GrowableArray<BitVector*>* assigned_vars, 2302 GrowableArray<BitVector*>* assigned_vars,
2341 intptr_t variable_count); 2303 intptr_t variable_count);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 const GrowableArray<BlockEntryInstr*>& block_order_; 2392 const GrowableArray<BlockEntryInstr*>& block_order_;
2431 2393
2432 private: 2394 private:
2433 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2395 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2434 }; 2396 };
2435 2397
2436 2398
2437 } // namespace dart 2399 } // namespace dart
2438 2400
2439 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2401 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « vm/il_printer.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698