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

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

Issue 10826230: Added def-use chain to the intermediate language. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed comments for def-use chain. Created 8 years, 4 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 | « no previous file | runtime/vm/intermediate_language.cc » ('j') | runtime/vm/intermediate_language.cc » ('J')
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 virtual ComparisonComp* AsComparison() { return NULL; } 175 virtual ComparisonComp* AsComparison() { return NULL; }
176 176
177 // Create a location summary for this computation. 177 // Create a location summary for this computation.
178 // TODO(fschneider): Temporarily returns NULL for instructions 178 // TODO(fschneider): Temporarily returns NULL for instructions
179 // that are not yet converted to the location based code generation. 179 // that are not yet converted to the location based code generation.
180 virtual LocationSummary* MakeLocationSummary() const = 0; 180 virtual LocationSummary* MakeLocationSummary() const = 0;
181 181
182 // TODO(fschneider): Make EmitNativeCode and locs const. 182 // TODO(fschneider): Make EmitNativeCode and locs const.
183 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; 183 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0;
184 184
185 virtual void RemoveInputUses() = 0;
186
185 static LocationSummary* MakeCallSummary(); 187 static LocationSummary* MakeCallSummary();
186 188
187 // Declare an enum value used to define kind-test predicates. 189 // Declare an enum value used to define kind-test predicates.
188 enum ComputationKind { 190 enum ComputationKind {
189 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName, 191 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName,
190 192
191 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND) 193 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND)
192 194
193 #undef DECLARE_COMPUTATION_KIND 195 #undef DECLARE_COMPUTATION_KIND
194 }; 196 };
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return sentinel; 263 return sentinel;
262 } 264 }
263 }; 265 };
264 266
265 267
266 template<intptr_t N> 268 template<intptr_t N>
267 class TemplateComputation : public Computation { 269 class TemplateComputation : public Computation {
268 public: 270 public:
269 virtual intptr_t InputCount() const { return N; } 271 virtual intptr_t InputCount() const { return N; }
270 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } 272 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; }
271 virtual void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } 273 virtual void SetInputAt(intptr_t i, Value* value) {
274 ASSERT(value != NULL);
275 inputs_[i] = value;
276 }
277 virtual void RemoveInputUses() {
278 for (intptr_t i = 0; i < N; ++i) {
279 ASSERT(inputs_[i] != NULL);
280 inputs_[i]->RemoveFromUseList();
281 }
282 }
272 283
273 protected: 284 protected:
274 EmbeddedArray<Value*, N> inputs_; 285 EmbeddedArray<Value*, N> inputs_;
275 }; 286 };
276 287
277 288
278 class Value : public TemplateComputation<0> { 289 class Value : public TemplateComputation<0> {
279 public: 290 public:
280 Value() { } 291 Value() { }
281 292
282 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const; 293 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const;
283 294
295 virtual void RemoveFromUseList() = 0;
296
284 private: 297 private:
285 DISALLOW_COPY_AND_ASSIGN(Value); 298 DISALLOW_COPY_AND_ASSIGN(Value);
286 }; 299 };
287 300
288 301
289 // Functions defined in all concrete computation classes. 302 // Functions defined in all concrete computation classes.
290 #define DECLARE_COMPUTATION(ShortName) \ 303 #define DECLARE_COMPUTATION(ShortName) \
291 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ 304 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \
292 virtual ComputationKind computation_kind() const { \ 305 virtual ComputationKind computation_kind() const { \
293 return Computation::k##ShortName; \ 306 return Computation::k##ShortName; \
(...skipping 20 matching lines...) Expand all
314 virtual RawAbstractType* CompileType() const; \ 327 virtual RawAbstractType* CompileType() const; \
315 virtual LocationSummary* MakeLocationSummary() const; \ 328 virtual LocationSummary* MakeLocationSummary() const; \
316 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 329 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
317 330
318 331
319 class Definition; 332 class Definition;
320 class PhiInstr; 333 class PhiInstr;
321 334
322 class UseVal : public Value { 335 class UseVal : public Value {
323 public: 336 public:
324 explicit UseVal(Definition* definition) : definition_(definition) {} 337 explicit UseVal(Definition* definition);
325 338
326 DECLARE_VALUE(Use) 339 DECLARE_VALUE(Use)
327 340
328 inline Definition* definition() const; 341 inline Definition* definition() const;
329 void set_definition(Definition* definition) { 342 void SetDefinition(Definition* definition);
330 definition_ = definition;
331 }
332 343
333 virtual bool CanDeoptimize() const { return false; } 344 virtual bool CanDeoptimize() const { return false; }
334 345
346 UseVal* next_use() const { return next_use_; }
347 UseVal* previous_use() const { return previous_use_; }
348 virtual void RemoveFromUseList();
349 virtual void RemoveInputUses() { RemoveFromUseList(); }
350
335 private: 351 private:
352 void AddToUseList();
336 Definition* definition_; 353 Definition* definition_;
354 UseVal* next_use_;
355 UseVal* previous_use_;
337 356
338 DISALLOW_COPY_AND_ASSIGN(UseVal); 357 DISALLOW_COPY_AND_ASSIGN(UseVal);
339 }; 358 };
340 359
341 360
342 class ConstantVal: public Value { 361 class ConstantVal: public Value {
343 public: 362 public:
344 explicit ConstantVal(const Object& value) 363 explicit ConstantVal(const Object& value)
345 : value_(value) { 364 : value_(value) {
346 ASSERT(value.IsZoneHandle()); 365 ASSERT(value.IsZoneHandle());
347 ASSERT(value.IsSmi() || value.IsOld()); 366 ASSERT(value.IsSmi() || value.IsOld());
348 } 367 }
349 368
350 DECLARE_VALUE(Constant) 369 DECLARE_VALUE(Constant)
351 370
352 const Object& value() const { return value_; } 371 const Object& value() const { return value_; }
353 372
354 virtual bool CanDeoptimize() const { return false; } 373 virtual bool CanDeoptimize() const { return false; }
355 374
375 virtual void RemoveFromUseList() { }
376
356 private: 377 private:
357 const Object& value_; 378 const Object& value_;
358 379
359 DISALLOW_COPY_AND_ASSIGN(ConstantVal); 380 DISALLOW_COPY_AND_ASSIGN(ConstantVal);
360 }; 381 };
361 382
362 #undef DECLARE_VALUE 383 #undef DECLARE_VALUE
363 384
364 385
365 class AssertAssignableComp : public TemplateComputation<3> { 386 class AssertAssignableComp : public TemplateComputation<3> {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 }; 797 };
777 798
778 799
779 class StoreLocalComp : public TemplateComputation<1> { 800 class StoreLocalComp : public TemplateComputation<1> {
780 public: 801 public:
781 StoreLocalComp(const LocalVariable& local, 802 StoreLocalComp(const LocalVariable& local,
782 Value* value, 803 Value* value,
783 intptr_t context_level) 804 intptr_t context_level)
784 : local_(local), 805 : local_(local),
785 context_level_(context_level) { 806 context_level_(context_level) {
807 ASSERT(value != NULL);
786 inputs_[0] = value; 808 inputs_[0] = value;
787 } 809 }
788 810
789 DECLARE_COMPUTATION(StoreLocal) 811 DECLARE_COMPUTATION(StoreLocal)
790 812
791 const LocalVariable& local() const { return local_; } 813 const LocalVariable& local() const { return local_; }
792 Value* value() const { return inputs_[0]; } 814 Value* value() const { return inputs_[0]; }
793 intptr_t context_level() const { return context_level_; } 815 intptr_t context_level() const { return context_level_; }
794 816
795 virtual void RecordAssignedVars(BitVector* assigned_vars, 817 virtual void RecordAssignedVars(BitVector* assigned_vars,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 class StoreIndexedComp : public TemplateComputation<3> { 1021 class StoreIndexedComp : public TemplateComputation<3> {
1000 public: 1022 public:
1001 StoreIndexedComp(intptr_t token_pos, 1023 StoreIndexedComp(intptr_t token_pos,
1002 intptr_t try_index, 1024 intptr_t try_index,
1003 Value* array, 1025 Value* array,
1004 Value* index, 1026 Value* index,
1005 Value* value) 1027 Value* value)
1006 : token_pos_(token_pos), 1028 : token_pos_(token_pos),
1007 try_index_(try_index), 1029 try_index_(try_index),
1008 receiver_type_(kIllegalCid) { 1030 receiver_type_(kIllegalCid) {
1031 ASSERT(array != NULL);
1032 ASSERT(index != NULL);
1033 ASSERT(value != NULL);
1009 inputs_[0] = array; 1034 inputs_[0] = array;
1010 inputs_[1] = index; 1035 inputs_[1] = index;
1011 inputs_[2] = value; 1036 inputs_[2] = value;
1012 } 1037 }
1013 1038
1014 DECLARE_COMPUTATION(StoreIndexed) 1039 DECLARE_COMPUTATION(StoreIndexed)
1015 1040
1016 intptr_t token_pos() const { return token_pos_; } 1041 intptr_t token_pos() const { return token_pos_; }
1017 intptr_t try_index() const { return try_index_; } 1042 intptr_t try_index() const { return try_index_; }
1018 Value* array() const { return inputs_[0]; } 1043 Value* array() const { return inputs_[0]; }
(...skipping 16 matching lines...) Expand all
1035 intptr_t receiver_type_; 1060 intptr_t receiver_type_;
1036 1061
1037 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); 1062 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp);
1038 }; 1063 };
1039 1064
1040 1065
1041 // Note overrideable, built-in: value? false : true. 1066 // Note overrideable, built-in: value? false : true.
1042 class BooleanNegateComp : public TemplateComputation<1> { 1067 class BooleanNegateComp : public TemplateComputation<1> {
1043 public: 1068 public:
1044 explicit BooleanNegateComp(Value* value) { 1069 explicit BooleanNegateComp(Value* value) {
1070 ASSERT(value != NULL);
1045 inputs_[0] = value; 1071 inputs_[0] = value;
1046 } 1072 }
1047 1073
1048 DECLARE_COMPUTATION(BooleanNegate) 1074 DECLARE_COMPUTATION(BooleanNegate)
1049 1075
1050 Value* value() const { return inputs_[0]; } 1076 Value* value() const { return inputs_[0]; }
1051 1077
1052 virtual bool CanDeoptimize() const { return false; } 1078 virtual bool CanDeoptimize() const { return false; }
1053 1079
1054 private: 1080 private:
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 1307
1282 1308
1283 class StoreVMFieldComp : public TemplateComputation<2> { 1309 class StoreVMFieldComp : public TemplateComputation<2> {
1284 public: 1310 public:
1285 StoreVMFieldComp(Value* dest, 1311 StoreVMFieldComp(Value* dest,
1286 intptr_t offset_in_bytes, 1312 intptr_t offset_in_bytes,
1287 Value* value, 1313 Value* value,
1288 const AbstractType& type) 1314 const AbstractType& type)
1289 : offset_in_bytes_(offset_in_bytes), type_(type) { 1315 : offset_in_bytes_(offset_in_bytes), type_(type) {
1290 ASSERT(value != NULL); 1316 ASSERT(value != NULL);
1317 ASSERT(dest != NULL);
1291 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. 1318 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance.
1292 inputs_[0] = value; 1319 inputs_[0] = value;
1293 inputs_[1] = dest; 1320 inputs_[1] = dest;
1294 } 1321 }
1295 1322
1296 DECLARE_COMPUTATION(StoreVMField) 1323 DECLARE_COMPUTATION(StoreVMField)
1297 1324
1298 Value* value() const { return inputs_[0]; } 1325 Value* value() const { return inputs_[0]; }
1299 Value* dest() const { return inputs_[1]; } 1326 Value* dest() const { return inputs_[1]; }
1300 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 1327 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 ASSERT(instr == NULL || !instr->IsBlockEntry()); 1811 ASSERT(instr == NULL || !instr->IsBlockEntry());
1785 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions 1812 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions
1786 // that do not have a successor. Currently, the graph builder will continue 1813 // that do not have a successor. Currently, the graph builder will continue
1787 // to append instruction in case of a Throw inside an expression. This 1814 // to append instruction in case of a Throw inside an expression. This
1788 // condition should be handled in the graph builder 1815 // condition should be handled in the graph builder
1789 next_ = instr; 1816 next_ = instr;
1790 } 1817 }
1791 1818
1792 // Removed this instruction from the graph. 1819 // Removed this instruction from the graph.
1793 Instruction* RemoveFromGraph(bool return_previous = true); 1820 Instruction* RemoveFromGraph(bool return_previous = true);
1821 // Remove uses in this instruction from the def-use chains.
zerny-google 2012/08/10 12:20:18 I'll change this comment.
1822 virtual void RemoveInputUses() = 0;
1794 1823
1795 // Normal instructions can have 0 (inside a block) or 1 (last instruction in 1824 // Normal instructions can have 0 (inside a block) or 1 (last instruction in
1796 // a block) successors. Branch instruction with >1 successors override this 1825 // a block) successors. Branch instruction with >1 successors override this
1797 // function. 1826 // function.
1798 virtual intptr_t SuccessorCount() const; 1827 virtual intptr_t SuccessorCount() const;
1799 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1828 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1800 1829
1801 void Goto(JoinEntryInstr* entry); 1830 void Goto(JoinEntryInstr* entry);
1802 1831
1803 // Discover basic-block structure by performing a recursive depth first 1832 // Discover basic-block structure by performing a recursive depth first
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 }; 1899 };
1871 1900
1872 1901
1873 template<intptr_t N> 1902 template<intptr_t N>
1874 class TemplateInstruction: public Instruction { 1903 class TemplateInstruction: public Instruction {
1875 public: 1904 public:
1876 TemplateInstruction<N>() : locs_(NULL) { } 1905 TemplateInstruction<N>() : locs_(NULL) { }
1877 1906
1878 virtual intptr_t InputCount() const { return N; } 1907 virtual intptr_t InputCount() const { return N; }
1879 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } 1908 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; }
1880 virtual void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } 1909 virtual void SetInputAt(intptr_t i, Value* value) {
1910 ASSERT(value != NULL);
1911 inputs_[i] = value;
1912 }
1881 1913
1882 virtual LocationSummary* locs() { 1914 virtual LocationSummary* locs() {
1883 if (locs_ == NULL) { 1915 if (locs_ == NULL) {
1884 locs_ = MakeLocationSummary(); 1916 locs_ = MakeLocationSummary();
1885 } 1917 }
1886 return locs_; 1918 return locs_;
1887 } 1919 }
1888 1920
1889 virtual LocationSummary* MakeLocationSummary() const = 0; 1921 virtual LocationSummary* MakeLocationSummary() const = 0;
1890 1922
1923 virtual void RemoveInputUses() {
1924 for (intptr_t i = 0; i < N; ++i) {
1925 ASSERT(inputs_[i] != NULL);
1926 inputs_[i]->RemoveFromUseList();
1927 }
1928 }
1929
1891 protected: 1930 protected:
1892 EmbeddedArray<Value*, N> inputs_; 1931 EmbeddedArray<Value*, N> inputs_;
1893 1932
1894 private: 1933 private:
1895 LocationSummary* locs_; 1934 LocationSummary* locs_;
1896 }; 1935 };
1897 1936
1898 1937
1899 class MoveOperands : public ZoneAllocated { 1938 class MoveOperands : public ZoneAllocated {
1900 public: 1939 public:
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 virtual Value* InputAt(intptr_t i) const { 2097 virtual Value* InputAt(intptr_t i) const {
2059 UNREACHABLE(); 2098 UNREACHABLE();
2060 return NULL; 2099 return NULL;
2061 } 2100 }
2062 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } 2101 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
2063 2102
2064 virtual intptr_t ArgumentCount() const { return 0; } 2103 virtual intptr_t ArgumentCount() const { return 0; }
2065 2104
2066 virtual bool CanDeoptimize() const { return false; } 2105 virtual bool CanDeoptimize() const { return false; }
2067 2106
2107 virtual void RemoveInputUses() { }
2108
2068 protected: 2109 protected:
2069 BlockEntryInstr() 2110 BlockEntryInstr()
2070 : preorder_number_(-1), 2111 : preorder_number_(-1),
2071 postorder_number_(-1), 2112 postorder_number_(-1),
2072 block_id_(-1), 2113 block_id_(-1),
2073 dominator_(NULL), 2114 dominator_(NULL),
2074 dominated_blocks_(1), 2115 dominated_blocks_(1),
2075 last_instruction_(NULL), 2116 last_instruction_(NULL),
2076 parallel_move_(NULL) { } 2117 parallel_move_(NULL) { }
2077 2118
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); 2322 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
2282 }; 2323 };
2283 2324
2284 2325
2285 // Abstract super-class of all instructions that define a value (Bind, Phi). 2326 // Abstract super-class of all instructions that define a value (Bind, Phi).
2286 class Definition : public Instruction { 2327 class Definition : public Instruction {
2287 public: 2328 public:
2288 Definition() 2329 Definition()
2289 : temp_index_(-1), 2330 : temp_index_(-1),
2290 ssa_temp_index_(-1), 2331 ssa_temp_index_(-1),
2291 propagated_type_(AbstractType::Handle()) { } 2332 propagated_type_(AbstractType::Handle()),
2333 use_list_(NULL) { }
2292 2334
2293 virtual bool IsDefinition() const { return true; } 2335 virtual bool IsDefinition() const { return true; }
2294 virtual Definition* AsDefinition() { return this; } 2336 virtual Definition* AsDefinition() { return this; }
2295 2337
2296 intptr_t temp_index() const { return temp_index_; } 2338 intptr_t temp_index() const { return temp_index_; }
2297 void set_temp_index(intptr_t index) { temp_index_ = index; } 2339 void set_temp_index(intptr_t index) { temp_index_ = index; }
2298 2340
2299 intptr_t ssa_temp_index() const { return ssa_temp_index_; } 2341 intptr_t ssa_temp_index() const { return ssa_temp_index_; }
2300 void set_ssa_temp_index(intptr_t index) { 2342 void set_ssa_temp_index(intptr_t index) {
2301 ASSERT(index >= 0); 2343 ASSERT(index >= 0);
(...skipping 17 matching lines...) Expand all
2319 if (propagated_type.IsNull()) { 2361 if (propagated_type.IsNull()) {
2320 // Not a typed definition, e.g. access to a VM field. 2362 // Not a typed definition, e.g. access to a VM field.
2321 return false; 2363 return false;
2322 } 2364 }
2323 const bool changed = 2365 const bool changed =
2324 propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_); 2366 propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_);
2325 propagated_type_ = propagated_type.raw(); 2367 propagated_type_ = propagated_type.raw();
2326 return changed; 2368 return changed;
2327 } 2369 }
2328 2370
2371 UseVal* use_list() { return use_list_; }
2372 void set_use_list(UseVal* head) {
2373 ASSERT(head == NULL || head->previous_use() == NULL);
2374 use_list_ = head;
2375 }
2376
2329 private: 2377 private:
2330 intptr_t temp_index_; 2378 intptr_t temp_index_;
2331 intptr_t ssa_temp_index_; 2379 intptr_t ssa_temp_index_;
2332 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; 2380 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_;
2333 // For now: 2381 // For now:
2334 AbstractType& propagated_type_; 2382 AbstractType& propagated_type_;
2383 UseVal* use_list_;
2335 2384
2336 DISALLOW_COPY_AND_ASSIGN(Definition); 2385 DISALLOW_COPY_AND_ASSIGN(Definition);
2337 }; 2386 };
2338 2387
2339 2388
2340 Definition* UseVal::definition() const { 2389 Definition* UseVal::definition() const {
2341 // Check that the definition is either a Phi or a linked in the the IR. 2390 // Check that the definition is either a Phi or a linked in the the IR.
2342 ASSERT(definition_ != NULL); 2391 ASSERT(definition_ != NULL);
2343 return definition_; 2392 return definition_;
2344 } 2393 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 2425
2377 virtual void RecordAssignedVars(BitVector* assigned_vars, 2426 virtual void RecordAssignedVars(BitVector* assigned_vars,
2378 intptr_t fixed_parameter_count); 2427 intptr_t fixed_parameter_count);
2379 2428
2380 virtual LocationSummary* locs() { 2429 virtual LocationSummary* locs() {
2381 return computation()->locs(); 2430 return computation()->locs();
2382 } 2431 }
2383 2432
2384 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2433 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2385 2434
2435 virtual void RemoveInputUses() { computation()->RemoveInputUses(); }
2436
2386 private: 2437 private:
2387 Computation* computation_; 2438 Computation* computation_;
2388 const bool is_used_; 2439 const bool is_used_;
2389 2440
2390 DISALLOW_COPY_AND_ASSIGN(BindInstr); 2441 DISALLOW_COPY_AND_ASSIGN(BindInstr);
2391 }; 2442 };
2392 2443
2393 2444
2394 class PhiInstr : public Definition { 2445 class PhiInstr : public Definition {
2395 public: 2446 public:
2396 explicit PhiInstr(intptr_t num_inputs) 2447 explicit PhiInstr(intptr_t num_inputs)
2397 : inputs_(num_inputs), is_alive_(false) { 2448 : inputs_(num_inputs), is_alive_(false) {
2398 for (intptr_t i = 0; i < num_inputs; ++i) { 2449 for (intptr_t i = 0; i < num_inputs; ++i) {
2399 inputs_.Add(NULL); 2450 inputs_.Add(NULL);
2400 } 2451 }
2401 } 2452 }
2402 2453
2403 virtual RawAbstractType* CompileType() const; 2454 virtual RawAbstractType* CompileType() const;
2404 2455
2405 virtual intptr_t ArgumentCount() const { return 0; } 2456 virtual intptr_t ArgumentCount() const { return 0; }
2406 2457
2407 intptr_t InputCount() const { return inputs_.length(); } 2458 intptr_t InputCount() const { return inputs_.length(); }
2408 2459
2409 Value* InputAt(intptr_t i) const { return inputs_[i]; } 2460 Value* InputAt(intptr_t i) const { return inputs_[i]; }
2410 2461
2411 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } 2462 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; }
2412 2463
2413 virtual bool CanDeoptimize() const { return false; } 2464 virtual bool CanDeoptimize() const { return false; }
2414 2465
2466 virtual void RemoveInputUses() {
2467 for (intptr_t i = 0; i < inputs_.length(); ++i) {
2468 ASSERT(inputs_[i] != NULL);
2469 inputs_[i]->RemoveFromUseList();
2470 }
2471 }
2472
2415 // TODO(regis): This helper will be removed once we support type sets. 2473 // TODO(regis): This helper will be removed once we support type sets.
2416 RawAbstractType* LeastSpecificInputType() const; 2474 RawAbstractType* LeastSpecificInputType() const;
2417 2475
2418 // Phi is alive if it reaches a non-environment use. 2476 // Phi is alive if it reaches a non-environment use.
2419 bool is_alive() const { return is_alive_; } 2477 bool is_alive() const { return is_alive_; }
2420 void mark_alive() { is_alive_ = true; } 2478 void mark_alive() { is_alive_ = true; }
2421 2479
2422 DECLARE_INSTRUCTION(Phi) 2480 DECLARE_INSTRUCTION(Phi)
2423 2481
2424 private: 2482 private:
(...skipping 17 matching lines...) Expand all
2442 2500
2443 virtual intptr_t ArgumentCount() const { return 0; } 2501 virtual intptr_t ArgumentCount() const { return 0; }
2444 2502
2445 intptr_t InputCount() const { return 0; } 2503 intptr_t InputCount() const { return 0; }
2446 Value* InputAt(intptr_t i) const { 2504 Value* InputAt(intptr_t i) const {
2447 UNREACHABLE(); 2505 UNREACHABLE();
2448 return NULL; 2506 return NULL;
2449 } 2507 }
2450 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } 2508 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
2451 2509
2510 virtual bool CanDeoptimize() const { return false; }
2452 2511
2453 virtual bool CanDeoptimize() const { return false; } 2512 virtual void RemoveInputUses() { }
2454 2513
2455 private: 2514 private:
2456 const intptr_t index_; 2515 const intptr_t index_;
2457 2516
2458 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); 2517 DISALLOW_COPY_AND_ASSIGN(ParameterInstr);
2459 }; 2518 };
2460 2519
2461 2520
2462 class PushArgumentInstr : public TemplateInstruction<1> { 2521 class PushArgumentInstr : public TemplateInstruction<1> {
2463 public: 2522 public:
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 const GrowableArray<BlockEntryInstr*>& block_order_; 2855 const GrowableArray<BlockEntryInstr*>& block_order_;
2797 2856
2798 private: 2857 private:
2799 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2858 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2800 }; 2859 };
2801 2860
2802 2861
2803 } // namespace dart 2862 } // namespace dart
2804 2863
2805 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2864 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | runtime/vm/intermediate_language.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698