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

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: use_ssa flag off by default 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
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 1716 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* StraightLineSuccessor() const { return successor_; }
srdjan 2012/06/25 15:57:16 Since it is a very simple setter now, maybe rename
Florian Schneider 2012/07/02 09:20:42 Done.
1764 virtual void SetSuccessor(Instruction* instr) = 0; 1764 void SetSuccessor(Instruction* instr);
1765
1766 Instruction* Previous() const { return previous_; }
srdjan 2012/06/25 15:57:16 s/Previous/previous/
Florian Schneider 2012/07/02 09:20:42 Done.
1767 void SetPrevious(Instruction* instr);
1768
1769 // Remove instruction from the graph.
1770 void RemoveFromGraph();
1765 1771
1766 // Normal instructions can have 0 (inside a block) or 1 (last instruction in 1772 // Normal instructions can have 0 (inside a block) or 1 (last instruction in
1767 // a block) successors. Branch instruction with >1 successors override this 1773 // a block) successors. Branch instruction with >1 successors override this
1768 // function. 1774 // function.
1769 virtual intptr_t SuccessorCount() const; 1775 virtual intptr_t SuccessorCount() const;
1770 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1776 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1771 1777
1772 virtual void replace_computation(Computation* value) { 1778 virtual void replace_computation(Computation* value) {
1773 UNREACHABLE(); 1779 UNREACHABLE();
1774 } 1780 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 return NULL; 1831 return NULL;
1826 } 1832 }
1827 1833
1828 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1834 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1829 UNIMPLEMENTED(); 1835 UNIMPLEMENTED();
1830 } 1836 }
1831 1837
1832 private: 1838 private:
1833 intptr_t cid_; 1839 intptr_t cid_;
1834 ICData* ic_data_; 1840 ICData* ic_data_;
1841 Instruction* successor_;
1842 Instruction* previous_;
1835 DISALLOW_COPY_AND_ASSIGN(Instruction); 1843 DISALLOW_COPY_AND_ASSIGN(Instruction);
1836 }; 1844 };
1837 1845
1838 1846
1839 class InstructionWithInputs : public Instruction { 1847 class InstructionWithInputs : public Instruction {
1840 public: 1848 public:
1841 InstructionWithInputs() : locs_(NULL) { 1849 InstructionWithInputs() : locs_(NULL) {
1842 } 1850 }
1843 1851
1844 virtual LocationSummary* locs() { 1852 virtual LocationSummary* locs() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 1941
1934 DECLARE_INSTRUCTION(GraphEntry) 1942 DECLARE_INSTRUCTION(GraphEntry)
1935 1943
1936 virtual intptr_t PredecessorCount() const { return 0; } 1944 virtual intptr_t PredecessorCount() const { return 0; }
1937 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1945 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1938 UNREACHABLE(); 1946 UNREACHABLE();
1939 return NULL; 1947 return NULL;
1940 } 1948 }
1941 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 1949 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
1942 1950
1943 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1944 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
1945
1946 virtual intptr_t SuccessorCount() const; 1951 virtual intptr_t SuccessorCount() const;
1947 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1952 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1948 1953
1949 virtual void DiscoverBlocks( 1954 virtual void DiscoverBlocks(
1950 BlockEntryInstr* current_block, 1955 BlockEntryInstr* current_block,
1951 GrowableArray<BlockEntryInstr*>* preorder, 1956 GrowableArray<BlockEntryInstr*>* preorder,
1952 GrowableArray<BlockEntryInstr*>* postorder, 1957 GrowableArray<BlockEntryInstr*>* postorder,
1953 GrowableArray<intptr_t>* parent, 1958 GrowableArray<intptr_t>* parent,
1954 GrowableArray<BitVector*>* assigned_vars, 1959 GrowableArray<BitVector*>* assigned_vars,
1955 intptr_t variable_count); 1960 intptr_t variable_count);
(...skipping 12 matching lines...) Expand all
1968 1973
1969 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 1974 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
1970 }; 1975 };
1971 1976
1972 1977
1973 class JoinEntryInstr : public BlockEntryInstr { 1978 class JoinEntryInstr : public BlockEntryInstr {
1974 public: 1979 public:
1975 JoinEntryInstr() 1980 JoinEntryInstr()
1976 : BlockEntryInstr(), 1981 : BlockEntryInstr(),
1977 predecessors_(2), // Two is the assumed to be the common case. 1982 predecessors_(2), // Two is the assumed to be the common case.
1978 successor_(NULL),
1979 phis_(NULL), 1983 phis_(NULL),
1980 phi_count_(0) { } 1984 phi_count_(0) { }
1981 1985
1982 DECLARE_INSTRUCTION(JoinEntry) 1986 DECLARE_INSTRUCTION(JoinEntry)
1983 1987
1984 virtual intptr_t PredecessorCount() const { return predecessors_.length(); } 1988 virtual intptr_t PredecessorCount() const { return predecessors_.length(); }
1985 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1989 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1986 return predecessors_[index]; 1990 return predecessors_[index];
1987 } 1991 }
1988 virtual void AddPredecessor(BlockEntryInstr* predecessor) { 1992 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
1989 predecessors_.Add(predecessor); 1993 predecessors_.Add(predecessor);
1990 } 1994 }
1991 1995
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_; } 1996 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; }
2000 1997
2001 virtual void PrepareEntry(FlowGraphCompiler* compiler); 1998 virtual void PrepareEntry(FlowGraphCompiler* compiler);
2002 1999
2003 void InsertPhi(intptr_t var_index, intptr_t var_count); 2000 void InsertPhi(intptr_t var_index, intptr_t var_count);
2004 2001
2005 intptr_t phi_count() const { return phi_count_; } 2002 intptr_t phi_count() const { return phi_count_; }
2006 2003
2007 private: 2004 private:
2008 ZoneGrowableArray<BlockEntryInstr*> predecessors_; 2005 ZoneGrowableArray<BlockEntryInstr*> predecessors_;
2009 Instruction* successor_;
2010 ZoneGrowableArray<PhiInstr*>* phis_; 2006 ZoneGrowableArray<PhiInstr*>* phis_;
2011 intptr_t phi_count_; 2007 intptr_t phi_count_;
2012 2008
2013 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); 2009 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr);
2014 }; 2010 };
2015 2011
2016 2012
2017 class TargetEntryInstr : public BlockEntryInstr { 2013 class TargetEntryInstr : public BlockEntryInstr {
2018 public: 2014 public:
2019 TargetEntryInstr() 2015 TargetEntryInstr()
2020 : BlockEntryInstr(), 2016 : BlockEntryInstr(),
2021 predecessor_(NULL), 2017 predecessor_(NULL),
2022 successor_(NULL),
2023 try_index_(CatchClauseNode::kInvalidTryIndex) { } 2018 try_index_(CatchClauseNode::kInvalidTryIndex) { }
2024 2019
2025 // Used for exception catch entries. 2020 // Used for exception catch entries.
2026 explicit TargetEntryInstr(intptr_t try_index) 2021 explicit TargetEntryInstr(intptr_t try_index)
2027 : BlockEntryInstr(), 2022 : BlockEntryInstr(),
2028 predecessor_(NULL), 2023 predecessor_(NULL),
2029 successor_(NULL),
2030 try_index_(try_index) { } 2024 try_index_(try_index) { }
2031 2025
2032 DECLARE_INSTRUCTION(TargetEntry) 2026 DECLARE_INSTRUCTION(TargetEntry)
2033 2027
2034 virtual intptr_t PredecessorCount() const { 2028 virtual intptr_t PredecessorCount() const {
2035 return (predecessor_ == NULL) ? 0 : 1; 2029 return (predecessor_ == NULL) ? 0 : 1;
2036 } 2030 }
2037 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 2031 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
2038 ASSERT((index == 0) && (predecessor_ != NULL)); 2032 ASSERT((index == 0) && (predecessor_ != NULL));
2039 return predecessor_; 2033 return predecessor_;
2040 } 2034 }
2041 virtual void AddPredecessor(BlockEntryInstr* predecessor) { 2035 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
2042 ASSERT(predecessor_ == NULL); 2036 ASSERT(predecessor_ == NULL);
2043 predecessor_ = predecessor; 2037 predecessor_ = predecessor;
2044 } 2038 }
2045 2039
2046 virtual Instruction* StraightLineSuccessor() const {
2047 return successor_;
2048 }
2049 virtual void SetSuccessor(Instruction* instr) {
2050 successor_ = instr;
2051 }
2052
2053 bool HasTryIndex() const { 2040 bool HasTryIndex() const {
2054 return try_index_ != CatchClauseNode::kInvalidTryIndex; 2041 return try_index_ != CatchClauseNode::kInvalidTryIndex;
2055 } 2042 }
2056 2043
2057 intptr_t try_index() const { 2044 intptr_t try_index() const {
2058 ASSERT(HasTryIndex()); 2045 ASSERT(HasTryIndex());
2059 return try_index_; 2046 return try_index_;
2060 } 2047 }
2061 2048
2062 virtual void PrepareEntry(FlowGraphCompiler* compiler); 2049 virtual void PrepareEntry(FlowGraphCompiler* compiler);
2063 2050
2064 private: 2051 private:
2065 BlockEntryInstr* predecessor_; 2052 BlockEntryInstr* predecessor_;
2066 Instruction* successor_;
2067 const intptr_t try_index_; 2053 const intptr_t try_index_;
2068 2054
2069 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); 2055 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
2070 }; 2056 };
2071 2057
2072 2058
2073 class DoInstr : public Instruction { 2059 class DoInstr : public Instruction {
2074 public: 2060 public:
2075 explicit DoInstr(Computation* computation) 2061 explicit DoInstr(Computation* computation)
2076 : computation_(computation), successor_(NULL) { 2062 : computation_(computation) {
2077 ASSERT(computation != NULL); 2063 ASSERT(computation != NULL);
2078 computation->set_instr(this); 2064 computation->set_instr(this);
2079 } 2065 }
2080 2066
2081 DECLARE_INSTRUCTION(Do) 2067 DECLARE_INSTRUCTION(Do)
2082 2068
2083 Computation* computation() const { return computation_; } 2069 Computation* computation() const { return computation_; }
2084 virtual void replace_computation(Computation* value) { computation_ = value; } 2070 virtual void replace_computation(Computation* value) { computation_ = value; }
2085 2071
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); 2072 virtual void RecordAssignedVars(BitVector* assigned_vars);
2095 2073
2096 virtual LocationSummary* locs() { 2074 virtual LocationSummary* locs() {
2097 return computation()->locs(); 2075 return computation()->locs();
2098 } 2076 }
2099 2077
2100 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 2078 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
2101 computation()->EmitNativeCode(compiler); 2079 computation()->EmitNativeCode(compiler);
2102 } 2080 }
2103 2081
2104 private: 2082 private:
2105 Computation* computation_; 2083 Computation* computation_;
2106 Instruction* successor_;
2107 2084
2108 DISALLOW_COPY_AND_ASSIGN(DoInstr); 2085 DISALLOW_COPY_AND_ASSIGN(DoInstr);
2109 }; 2086 };
2110 2087
2111 2088
2112 // Abstract super-class of all instructions that define a value (Bind, Phi). 2089 // Abstract super-class of all instructions that define a value (Bind, Phi).
2113 class Definition : public Instruction { 2090 class Definition : public Instruction {
2114 public: 2091 public:
2115 Definition() : temp_index_(-1), ssa_temp_index_(-1) { } 2092 Definition() : temp_index_(-1), ssa_temp_index_(-1) { }
2116 2093
(...skipping 10 matching lines...) Expand all
2127 intptr_t temp_index_; 2104 intptr_t temp_index_;
2128 intptr_t ssa_temp_index_; 2105 intptr_t ssa_temp_index_;
2129 2106
2130 DISALLOW_COPY_AND_ASSIGN(Definition); 2107 DISALLOW_COPY_AND_ASSIGN(Definition);
2131 }; 2108 };
2132 2109
2133 2110
2134 class BindInstr : public Definition { 2111 class BindInstr : public Definition {
2135 public: 2112 public:
2136 explicit BindInstr(Computation* computation) 2113 explicit BindInstr(Computation* computation)
2137 : computation_(computation), successor_(NULL) { 2114 : computation_(computation) {
2138 ASSERT(computation != NULL); 2115 ASSERT(computation != NULL);
2139 computation->set_instr(this); 2116 computation->set_instr(this);
2140 } 2117 }
2141 2118
2142 DECLARE_INSTRUCTION(Bind) 2119 DECLARE_INSTRUCTION(Bind)
2143 2120
2144 Computation* computation() const { return computation_; } 2121 Computation* computation() const { return computation_; }
2145 virtual void replace_computation(Computation* value) { computation_ = value; } 2122 virtual void replace_computation(Computation* value) { computation_ = value; }
2146 2123
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. 2124 // Static type of the underlying computation.
2156 virtual RawAbstractType* StaticType() const { 2125 virtual RawAbstractType* StaticType() const {
2157 return computation()->StaticType(); 2126 return computation()->StaticType();
2158 } 2127 }
2159 2128
2160 virtual void RecordAssignedVars(BitVector* assigned_vars); 2129 virtual void RecordAssignedVars(BitVector* assigned_vars);
2161 2130
2162 virtual LocationSummary* locs() { 2131 virtual LocationSummary* locs() {
2163 return computation()->locs(); 2132 return computation()->locs();
2164 } 2133 }
2165 2134
2166 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2135 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2167 2136
2168 private: 2137 private:
2169 Computation* computation_; 2138 Computation* computation_;
2170 Instruction* successor_;
2171 2139
2172 DISALLOW_COPY_AND_ASSIGN(BindInstr); 2140 DISALLOW_COPY_AND_ASSIGN(BindInstr);
2173 }; 2141 };
2174 2142
2175 2143
2176 class PhiInstr: public Definition { 2144 class PhiInstr: public Definition {
2177 public: 2145 public:
2178 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { 2146 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) {
2179 for (intptr_t i = 0; i < num_inputs; ++i) { 2147 for (intptr_t i = 0; i < num_inputs; ++i) {
2180 inputs_.Add(NULL); 2148 inputs_.Add(NULL);
2181 } 2149 }
2182 } 2150 }
2183 2151
2184 DECLARE_INSTRUCTION(Phi) 2152 DECLARE_INSTRUCTION(Phi)
2185 2153
2186 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2187 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
2188
2189 private: 2154 private:
2190 GrowableArray<Value*> inputs_; 2155 GrowableArray<Value*> inputs_;
2191 2156
2192 DISALLOW_COPY_AND_ASSIGN(PhiInstr); 2157 DISALLOW_COPY_AND_ASSIGN(PhiInstr);
2193 }; 2158 };
2194 2159
2195 2160
2196 class ReturnInstr : public InstructionWithInputs { 2161 class ReturnInstr : public InstructionWithInputs {
2197 public: 2162 public:
2198 ReturnInstr(intptr_t token_pos, Value* value) 2163 ReturnInstr(intptr_t token_pos, Value* value)
2199 : InstructionWithInputs(), token_pos_(token_pos), value_(value) { 2164 : InstructionWithInputs(), token_pos_(token_pos), value_(value) {
2200 ASSERT(value_ != NULL); 2165 ASSERT(value_ != NULL);
2201 } 2166 }
2202 2167
2203 DECLARE_INSTRUCTION(Return) 2168 DECLARE_INSTRUCTION(Return)
2204 2169
2205 Value* value() const { return value_; } 2170 Value* value() const { return value_; }
2206 intptr_t token_pos() const { return token_pos_; } 2171 intptr_t token_pos() const { return token_pos_; }
2207 2172
2208 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2209 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
2210
2211 virtual LocationSummary* MakeLocationSummary() const; 2173 virtual LocationSummary* MakeLocationSummary() const;
2212 2174
2213 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2175 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2214 2176
2215 private: 2177 private:
2216 const intptr_t token_pos_; 2178 const intptr_t token_pos_;
2217 Value* value_; 2179 Value* value_;
2218 2180
2219 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 2181 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
2220 }; 2182 };
2221 2183
2222 2184
2223 class ThrowInstr : public InstructionWithInputs { 2185 class ThrowInstr : public InstructionWithInputs {
2224 public: 2186 public:
2225 ThrowInstr(intptr_t token_pos, 2187 ThrowInstr(intptr_t token_pos,
2226 intptr_t try_index, 2188 intptr_t try_index,
2227 Value* exception) 2189 Value* exception)
2228 : InstructionWithInputs(), 2190 : InstructionWithInputs(),
2229 token_pos_(token_pos), 2191 token_pos_(token_pos),
2230 try_index_(try_index), 2192 try_index_(try_index),
2231 exception_(exception), 2193 exception_(exception) {
2232 successor_(NULL) {
2233 ASSERT(exception_ != NULL); 2194 ASSERT(exception_ != NULL);
2234 } 2195 }
2235 2196
2236 DECLARE_INSTRUCTION(Throw) 2197 DECLARE_INSTRUCTION(Throw)
2237 2198
2238 intptr_t token_pos() const { return token_pos_; } 2199 intptr_t token_pos() const { return token_pos_; }
2239 intptr_t try_index() const { return try_index_; } 2200 intptr_t try_index() const { return try_index_; }
2240 Value* exception() const { return exception_; } 2201 Value* exception() const { return exception_; }
2241 2202
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; 2203 virtual LocationSummary* MakeLocationSummary() const;
2250 2204
2251 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2205 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2252 2206
2253 private: 2207 private:
2254 const intptr_t token_pos_; 2208 const intptr_t token_pos_;
2255 const intptr_t try_index_; 2209 const intptr_t try_index_;
2256 Value* exception_; 2210 Value* exception_;
2257 Instruction* successor_;
2258 2211
2259 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 2212 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
2260 }; 2213 };
2261 2214
2262 2215
2263 class ReThrowInstr : public InstructionWithInputs { 2216 class ReThrowInstr : public InstructionWithInputs {
2264 public: 2217 public:
2265 ReThrowInstr(intptr_t token_pos, 2218 ReThrowInstr(intptr_t token_pos,
2266 intptr_t try_index, 2219 intptr_t try_index,
2267 Value* exception, 2220 Value* exception,
2268 Value* stack_trace) 2221 Value* stack_trace)
2269 : InstructionWithInputs(), 2222 : InstructionWithInputs(),
2270 token_pos_(token_pos), 2223 token_pos_(token_pos),
2271 try_index_(try_index), 2224 try_index_(try_index),
2272 exception_(exception), 2225 exception_(exception),
2273 stack_trace_(stack_trace), 2226 stack_trace_(stack_trace) {
2274 successor_(NULL) {
2275 ASSERT(exception_ != NULL); 2227 ASSERT(exception_ != NULL);
2276 ASSERT(stack_trace_ != NULL); 2228 ASSERT(stack_trace_ != NULL);
2277 } 2229 }
2278 2230
2279 DECLARE_INSTRUCTION(ReThrow) 2231 DECLARE_INSTRUCTION(ReThrow)
2280 2232
2281 intptr_t token_pos() const { return token_pos_; } 2233 intptr_t token_pos() const { return token_pos_; }
2282 intptr_t try_index() const { return try_index_; } 2234 intptr_t try_index() const { return try_index_; }
2283 Value* exception() const { return exception_; } 2235 Value* exception() const { return exception_; }
2284 Value* stack_trace() const { return stack_trace_; } 2236 Value* stack_trace() const { return stack_trace_; }
2285 2237
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; 2238 virtual LocationSummary* MakeLocationSummary() const;
2296 2239
2297 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2240 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2298 2241
2299 private: 2242 private:
2300 const intptr_t token_pos_; 2243 const intptr_t token_pos_;
2301 const intptr_t try_index_; 2244 const intptr_t try_index_;
2302 Value* exception_; 2245 Value* exception_;
2303 Value* stack_trace_; 2246 Value* stack_trace_;
2304 Instruction* successor_;
2305 2247
2306 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 2248 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
2307 }; 2249 };
2308 2250
2309 2251
2310 class BranchInstr : public InstructionWithInputs { 2252 class BranchInstr : public InstructionWithInputs {
2311 public: 2253 public:
2312 explicit BranchInstr(Value* value) 2254 explicit BranchInstr(Value* value)
2313 : InstructionWithInputs(), 2255 : InstructionWithInputs(),
2314 value_(value), 2256 value_(value),
2315 true_successor_(NULL), 2257 true_successor_(NULL),
2316 false_successor_(NULL), 2258 false_successor_(NULL),
2317 is_fused_with_comparison_(false), 2259 is_fused_with_comparison_(false),
2318 is_negated_(false) { } 2260 is_negated_(false) { }
2319 2261
2320 DECLARE_INSTRUCTION(Branch) 2262 DECLARE_INSTRUCTION(Branch)
2321 2263
2322 Value* value() const { return value_; } 2264 Value* value() const { return value_; }
2323 TargetEntryInstr* true_successor() const { return true_successor_; } 2265 TargetEntryInstr* true_successor() const { return true_successor_; }
2324 TargetEntryInstr* false_successor() const { return false_successor_; } 2266 TargetEntryInstr* false_successor() const { return false_successor_; }
2325 2267
2326 TargetEntryInstr** true_successor_address() { return &true_successor_; } 2268 TargetEntryInstr** true_successor_address() { return &true_successor_; }
2327 TargetEntryInstr** false_successor_address() { return &false_successor_; } 2269 TargetEntryInstr** false_successor_address() { return &false_successor_; }
2328 2270
2329 virtual Instruction* StraightLineSuccessor() const { return NULL; }
2330 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
2331
2332 virtual intptr_t SuccessorCount() const; 2271 virtual intptr_t SuccessorCount() const;
2333 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 2272 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2334 2273
2335 virtual void DiscoverBlocks( 2274 virtual void DiscoverBlocks(
2336 BlockEntryInstr* current_block, 2275 BlockEntryInstr* current_block,
2337 GrowableArray<BlockEntryInstr*>* preorder, 2276 GrowableArray<BlockEntryInstr*>* preorder,
2338 GrowableArray<BlockEntryInstr*>* postorder, 2277 GrowableArray<BlockEntryInstr*>* postorder,
2339 GrowableArray<intptr_t>* parent, 2278 GrowableArray<intptr_t>* parent,
2340 GrowableArray<BitVector*>* assigned_vars, 2279 GrowableArray<BitVector*>* assigned_vars,
2341 intptr_t variable_count); 2280 intptr_t variable_count);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 const GrowableArray<BlockEntryInstr*>& block_order_; 2369 const GrowableArray<BlockEntryInstr*>& block_order_;
2431 2370
2432 private: 2371 private:
2433 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2372 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2434 }; 2373 };
2435 2374
2436 2375
2437 } // namespace dart 2376 } // namespace dart
2438 2377
2439 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2378 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698