Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 void set_ic_data(ICData* value) { ic_data_ = value; } | 131 void set_ic_data(ICData* value) { ic_data_ = value; } |
| 132 bool HasICData() const { | 132 bool HasICData() const { |
| 133 return (ic_data() != NULL) && !ic_data()->IsNull(); | 133 return (ic_data() != NULL) && !ic_data()->IsNull(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Visiting support. | 136 // Visiting support. |
| 137 virtual void Accept(FlowGraphVisitor* visitor) = 0; | 137 virtual void Accept(FlowGraphVisitor* visitor) = 0; |
| 138 | 138 |
| 139 virtual intptr_t InputCount() const = 0; | 139 virtual intptr_t InputCount() const = 0; |
| 140 virtual Value* InputAt(intptr_t i) const = 0; | 140 virtual Value* InputAt(intptr_t i) const = 0; |
| 141 virtual void SetInputAt(intptr_t i, Value* value) = 0; | |
| 141 | 142 |
| 142 // Static type of the computation. | 143 // Static type of the computation. |
| 143 virtual RawAbstractType* StaticType() const = 0; | 144 virtual RawAbstractType* StaticType() const = 0; |
| 144 | 145 |
| 145 // Mutate assigned_vars to add the local variable index for all | 146 // Mutate assigned_vars to add the local variable index for all |
| 146 // frame-allocated locals assigned to by the computation. | 147 // frame-allocated locals assigned to by the computation. |
| 147 virtual void RecordAssignedVars(BitVector* assigned_vars); | 148 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 148 | 149 |
| 149 virtual const char* DebugName() const = 0; | 150 virtual const char* DebugName() const = 0; |
| 150 | 151 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 return sentinel; | 278 return sentinel; |
| 278 } | 279 } |
| 279 }; | 280 }; |
| 280 | 281 |
| 281 | 282 |
| 282 template<intptr_t N> | 283 template<intptr_t N> |
| 283 class TemplateComputation : public Computation { | 284 class TemplateComputation : public Computation { |
| 284 public: | 285 public: |
| 285 virtual intptr_t InputCount() const { return N; } | 286 virtual intptr_t InputCount() const { return N; } |
| 286 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } | 287 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } |
| 288 virtual void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } | |
| 287 | 289 |
| 288 protected: | 290 protected: |
| 289 EmbeddedArray<Value*, N> inputs_; | 291 EmbeddedArray<Value*, N> inputs_; |
| 290 }; | 292 }; |
| 291 | 293 |
| 292 | 294 |
| 293 class Value : public TemplateComputation<0> { | 295 class Value : public TemplateComputation<0> { |
| 294 public: | 296 public: |
| 295 Value() { } | 297 Value() { } |
| 296 | 298 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 | 473 |
| 472 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 474 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
| 473 intptr_t token_index() const { return ast_node_.token_index(); } | 475 intptr_t token_index() const { return ast_node_.token_index(); } |
| 474 intptr_t try_index() const { return try_index_; } | 476 intptr_t try_index() const { return try_index_; } |
| 475 | 477 |
| 476 intptr_t ArgumentCount() const { return arguments_->length(); } | 478 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 477 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 479 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 478 | 480 |
| 479 virtual intptr_t InputCount() const; | 481 virtual intptr_t InputCount() const; |
| 480 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | 482 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 483 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 484 (*arguments_)[i] = value; | |
| 485 } | |
| 481 | 486 |
| 482 virtual void PrintOperandsTo(BufferFormatter* f) const; | 487 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 483 | 488 |
| 484 private: | 489 private: |
| 485 const ClosureCallNode& ast_node_; | 490 const ClosureCallNode& ast_node_; |
| 486 const intptr_t try_index_; | 491 const intptr_t try_index_; |
| 487 ZoneGrowableArray<Value*>* arguments_; | 492 ZoneGrowableArray<Value*>* arguments_; |
| 488 | 493 |
| 489 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); | 494 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
| 490 }; | 495 }; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 521 intptr_t try_index() const { return try_index_; } | 526 intptr_t try_index() const { return try_index_; } |
| 522 const String& function_name() const { return function_name_; } | 527 const String& function_name() const { return function_name_; } |
| 523 Token::Kind token_kind() const { return token_kind_; } | 528 Token::Kind token_kind() const { return token_kind_; } |
| 524 intptr_t ArgumentCount() const { return arguments_->length(); } | 529 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 525 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 530 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 526 const Array& argument_names() const { return argument_names_; } | 531 const Array& argument_names() const { return argument_names_; } |
| 527 intptr_t checked_argument_count() const { return checked_argument_count_; } | 532 intptr_t checked_argument_count() const { return checked_argument_count_; } |
| 528 | 533 |
| 529 virtual intptr_t InputCount() const; | 534 virtual intptr_t InputCount() const; |
| 530 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | 535 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 536 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 537 (*arguments_)[i] = value; | |
| 538 } | |
| 531 | 539 |
| 532 virtual void PrintOperandsTo(BufferFormatter* f) const; | 540 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 533 | 541 |
| 534 bool VerifyComputation(); | 542 bool VerifyComputation(); |
| 535 | 543 |
| 536 private: | 544 private: |
| 537 const intptr_t token_index_; | 545 const intptr_t token_index_; |
| 538 const intptr_t try_index_; | 546 const intptr_t try_index_; |
| 539 const String& function_name_; | 547 const String& function_name_; |
| 540 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. | 548 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 558 } | 566 } |
| 559 | 567 |
| 560 InstanceCallComp* instance_call() const { return instance_call_; } | 568 InstanceCallComp* instance_call() const { return instance_call_; } |
| 561 const ZoneGrowableArray<intptr_t>& class_ids() const { return class_ids_; } | 569 const ZoneGrowableArray<intptr_t>& class_ids() const { return class_ids_; } |
| 562 const ZoneGrowableArray<Function*>& targets() const { return targets_; } | 570 const ZoneGrowableArray<Function*>& targets() const { return targets_; } |
| 563 | 571 |
| 564 virtual intptr_t InputCount() const { return instance_call()->InputCount(); } | 572 virtual intptr_t InputCount() const { return instance_call()->InputCount(); } |
| 565 virtual Value* InputAt(intptr_t i) const { | 573 virtual Value* InputAt(intptr_t i) const { |
| 566 return instance_call()->ArgumentAt(i); | 574 return instance_call()->ArgumentAt(i); |
| 567 } | 575 } |
| 576 virtual void SetInputAt(intptr_t index, Value* value) { | |
| 577 instance_call()->SetInputAt(index, value); | |
| 578 } | |
| 568 | 579 |
| 569 virtual void PrintOperandsTo(BufferFormatter* f) const { | 580 virtual void PrintOperandsTo(BufferFormatter* f) const { |
| 570 instance_call()->PrintOperandsTo(f); | 581 instance_call()->PrintOperandsTo(f); |
| 571 } | 582 } |
| 572 | 583 |
| 573 DECLARE_COMPUTATION(PolymorphicInstanceCall) | 584 DECLARE_COMPUTATION(PolymorphicInstanceCall) |
| 574 | 585 |
| 575 private: | 586 private: |
| 576 InstanceCallComp* instance_call_; | 587 InstanceCallComp* instance_call_; |
| 577 const ZoneGrowableArray<intptr_t>& class_ids_; | 588 const ZoneGrowableArray<intptr_t>& class_ids_; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 intptr_t try_index() const { return try_index_; } | 758 intptr_t try_index() const { return try_index_; } |
| 748 | 759 |
| 749 intptr_t ArgumentCount() const { return arguments_->length(); } | 760 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 750 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 761 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 751 | 762 |
| 752 MethodRecognizer::Kind recognized() const { return recognized_; } | 763 MethodRecognizer::Kind recognized() const { return recognized_; } |
| 753 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } | 764 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } |
| 754 | 765 |
| 755 virtual intptr_t InputCount() const; | 766 virtual intptr_t InputCount() const; |
| 756 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | 767 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 768 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 769 (*arguments_)[i] = value; | |
| 770 } | |
| 757 | 771 |
| 758 virtual void PrintOperandsTo(BufferFormatter* f) const; | 772 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 759 | 773 |
| 760 private: | 774 private: |
| 761 const intptr_t token_index_; | 775 const intptr_t token_index_; |
| 762 const intptr_t try_index_; | 776 const intptr_t try_index_; |
| 763 const Function& function_; | 777 const Function& function_; |
| 764 const Array& argument_names_; | 778 const Array& argument_names_; |
| 765 ZoneGrowableArray<Value*>* arguments_; | 779 ZoneGrowableArray<Value*>* arguments_; |
| 766 MethodRecognizer::Kind recognized_; | 780 MethodRecognizer::Kind recognized_; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1178 | 1192 |
| 1179 DECLARE_COMPUTATION(AllocateObject) | 1193 DECLARE_COMPUTATION(AllocateObject) |
| 1180 | 1194 |
| 1181 const Function& constructor() const { return ast_node_.constructor(); } | 1195 const Function& constructor() const { return ast_node_.constructor(); } |
| 1182 intptr_t token_index() const { return ast_node_.token_index(); } | 1196 intptr_t token_index() const { return ast_node_.token_index(); } |
| 1183 intptr_t try_index() const { return try_index_; } | 1197 intptr_t try_index() const { return try_index_; } |
| 1184 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } | 1198 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| 1185 | 1199 |
| 1186 virtual intptr_t InputCount() const; | 1200 virtual intptr_t InputCount() const; |
| 1187 virtual Value* InputAt(intptr_t i) const { return arguments()[i]; } | 1201 virtual Value* InputAt(intptr_t i) const { return arguments()[i]; } |
| 1202 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 1203 (*arguments_)[i] = value; | |
| 1204 } | |
| 1188 | 1205 |
| 1189 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1206 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1190 | 1207 |
| 1191 private: | 1208 private: |
| 1192 const ConstructorCallNode& ast_node_; | 1209 const ConstructorCallNode& ast_node_; |
| 1193 const intptr_t try_index_; | 1210 const intptr_t try_index_; |
| 1194 ZoneGrowableArray<Value*>* const arguments_; | 1211 ZoneGrowableArray<Value*>* const arguments_; |
| 1195 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); | 1212 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); |
| 1196 }; | 1213 }; |
| 1197 | 1214 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1208 | 1225 |
| 1209 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) | 1226 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) |
| 1210 | 1227 |
| 1211 const Function& constructor() const { return ast_node_.constructor(); } | 1228 const Function& constructor() const { return ast_node_.constructor(); } |
| 1212 intptr_t token_index() const { return ast_node_.token_index(); } | 1229 intptr_t token_index() const { return ast_node_.token_index(); } |
| 1213 intptr_t try_index() const { return try_index_; } | 1230 intptr_t try_index() const { return try_index_; } |
| 1214 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } | 1231 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| 1215 | 1232 |
| 1216 virtual intptr_t InputCount() const; | 1233 virtual intptr_t InputCount() const; |
| 1217 virtual Value* InputAt(intptr_t i) const { return arguments()[i]; } | 1234 virtual Value* InputAt(intptr_t i) const { return arguments()[i]; } |
| 1235 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 1236 (*arguments_)[i] = value; | |
| 1237 } | |
| 1218 | 1238 |
| 1219 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1239 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1220 | 1240 |
| 1221 private: | 1241 private: |
| 1222 const ConstructorCallNode& ast_node_; | 1242 const ConstructorCallNode& ast_node_; |
| 1223 const intptr_t try_index_; | 1243 const intptr_t try_index_; |
| 1224 ZoneGrowableArray<Value*>* const arguments_; | 1244 ZoneGrowableArray<Value*>* const arguments_; |
| 1225 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); | 1245 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); |
| 1226 }; | 1246 }; |
| 1227 | 1247 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1247 DECLARE_COMPUTATION(CreateArray) | 1267 DECLARE_COMPUTATION(CreateArray) |
| 1248 | 1268 |
| 1249 intptr_t token_index() const { return token_index_; } | 1269 intptr_t token_index() const { return token_index_; } |
| 1250 intptr_t try_index() const { return try_index_; } | 1270 intptr_t try_index() const { return try_index_; } |
| 1251 intptr_t ElementCount() const { return elements_->length(); } | 1271 intptr_t ElementCount() const { return elements_->length(); } |
| 1252 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } | 1272 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } |
| 1253 Value* element_type() const { return inputs_[0]; } | 1273 Value* element_type() const { return inputs_[0]; } |
| 1254 | 1274 |
| 1255 virtual intptr_t InputCount() const; | 1275 virtual intptr_t InputCount() const; |
| 1256 virtual Value* InputAt(intptr_t i) const; | 1276 virtual Value* InputAt(intptr_t i) const; |
| 1277 virtual void SetInputAt(intptr_t i, Value* value); | |
| 1257 | 1278 |
| 1258 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1279 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1259 | 1280 |
| 1260 private: | 1281 private: |
| 1261 const intptr_t token_index_; | 1282 const intptr_t token_index_; |
| 1262 const intptr_t try_index_; | 1283 const intptr_t try_index_; |
| 1263 ZoneGrowableArray<Value*>* const elements_; | 1284 ZoneGrowableArray<Value*>* const elements_; |
| 1264 | 1285 |
| 1265 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); | 1286 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); |
| 1266 }; | 1287 }; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 ASSERT(value != NULL); | 1659 ASSERT(value != NULL); |
| 1639 inputs_[0] = value; | 1660 inputs_[0] = value; |
| 1640 } | 1661 } |
| 1641 | 1662 |
| 1642 Value* value() const { return inputs_[0]; } | 1663 Value* value() const { return inputs_[0]; } |
| 1643 | 1664 |
| 1644 InstanceCallComp* instance_call() const { return instance_call_; } | 1665 InstanceCallComp* instance_call() const { return instance_call_; } |
| 1645 | 1666 |
| 1646 DECLARE_COMPUTATION(NumberNegate) | 1667 DECLARE_COMPUTATION(NumberNegate) |
| 1647 | 1668 |
| 1669 void InsertPhi(intptr_t variable_index) { } | |
|
srdjan
2012/06/18 18:04:38
Remove?
Florian Schneider
2012/06/19 11:26:40
Oops. Accidental edit.
| |
| 1670 | |
| 1648 private: | 1671 private: |
| 1649 InstanceCallComp* instance_call_; | 1672 InstanceCallComp* instance_call_; |
| 1650 | 1673 |
| 1651 DISALLOW_COPY_AND_ASSIGN(NumberNegateComp); | 1674 DISALLOW_COPY_AND_ASSIGN(NumberNegateComp); |
| 1652 }; | 1675 }; |
| 1653 | 1676 |
| 1654 | 1677 |
| 1655 class CheckStackOverflowComp : public TemplateComputation<0> { | 1678 class CheckStackOverflowComp : public TemplateComputation<0> { |
| 1656 public: | 1679 public: |
| 1657 CheckStackOverflowComp(intptr_t token_index, intptr_t try_index) | 1680 CheckStackOverflowComp(intptr_t token_index, intptr_t try_index) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1748 #undef FORWARD_DECLARATION | 1771 #undef FORWARD_DECLARATION |
| 1749 | 1772 |
| 1750 | 1773 |
| 1751 // Functions required in all concrete instruction classes. | 1774 // Functions required in all concrete instruction classes. |
| 1752 #define DECLARE_INSTRUCTION(type) \ | 1775 #define DECLARE_INSTRUCTION(type) \ |
| 1753 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ | 1776 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ |
| 1754 virtual bool Is##type() const { return true; } \ | 1777 virtual bool Is##type() const { return true; } \ |
| 1755 virtual type##Instr* As##type() { return this; } \ | 1778 virtual type##Instr* As##type() { return this; } \ |
| 1756 virtual intptr_t InputCount() const; \ | 1779 virtual intptr_t InputCount() const; \ |
| 1757 virtual Value* InputAt(intptr_t i) const; \ | 1780 virtual Value* InputAt(intptr_t i) const; \ |
| 1781 virtual void SetInputAt(intptr_t i, Value* value); \ | |
| 1758 virtual const char* DebugName() const { return #type; } \ | 1782 virtual const char* DebugName() const { return #type; } \ |
| 1759 virtual void PrintTo(BufferFormatter* f) const; \ | 1783 virtual void PrintTo(BufferFormatter* f) const; \ |
| 1760 virtual void PrintToVisualizer(BufferFormatter* f) const; | 1784 virtual void PrintToVisualizer(BufferFormatter* f) const; |
| 1761 | 1785 |
| 1762 | 1786 |
| 1763 class Instruction : public ZoneAllocated { | 1787 class Instruction : public ZoneAllocated { |
| 1764 public: | 1788 public: |
| 1765 Instruction() : cid_(-1), ic_data_(NULL) { | 1789 Instruction() : cid_(-1), ic_data_(NULL) { |
| 1766 Isolate* isolate = Isolate::Current(); | 1790 Isolate* isolate = Isolate::Current(); |
| 1767 cid_ = Computation::GetNextCid(isolate); | 1791 cid_ = Computation::GetNextCid(isolate); |
| 1768 ic_data_ = Computation::GetICDataForCid(cid_, isolate); | 1792 ic_data_ = Computation::GetICDataForCid(cid_, isolate); |
| 1769 } | 1793 } |
| 1770 | 1794 |
| 1771 // Unique computation/instruction id, used for deoptimization, e.g. for | 1795 // Unique computation/instruction id, used for deoptimization, e.g. for |
| 1772 // ReturnInstr, ThrowInstr and ReThrowInstr. | 1796 // ReturnInstr, ThrowInstr and ReThrowInstr. |
| 1773 intptr_t cid() const { return cid_; } | 1797 intptr_t cid() const { return cid_; } |
| 1774 | 1798 |
| 1775 const ICData* ic_data() const { return ic_data_; } | 1799 const ICData* ic_data() const { return ic_data_; } |
| 1776 | 1800 |
| 1777 virtual bool IsBlockEntry() const { return false; } | 1801 virtual bool IsBlockEntry() const { return false; } |
| 1778 BlockEntryInstr* AsBlockEntry() { | 1802 BlockEntryInstr* AsBlockEntry() { |
| 1779 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; | 1803 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; |
| 1780 } | 1804 } |
| 1781 virtual bool IsDefinition() const { return false; } | 1805 virtual bool IsDefinition() const { return false; } |
| 1782 virtual Definition* AsDefinition() { return NULL; } | 1806 virtual Definition* AsDefinition() { return NULL; } |
| 1783 | 1807 |
| 1784 virtual intptr_t InputCount() const = 0; | 1808 virtual intptr_t InputCount() const = 0; |
| 1785 virtual Value* InputAt(intptr_t i) const = 0; | 1809 virtual Value* InputAt(intptr_t i) const = 0; |
| 1810 virtual void SetInputAt(intptr_t i, Value* value) = 0; | |
| 1786 | 1811 |
| 1787 // Visiting support. | 1812 // Visiting support. |
| 1788 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0; | 1813 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0; |
| 1789 | 1814 |
| 1790 virtual Instruction* StraightLineSuccessor() const = 0; | 1815 virtual Instruction* StraightLineSuccessor() const = 0; |
| 1791 virtual void SetSuccessor(Instruction* instr) = 0; | 1816 virtual void SetSuccessor(Instruction* instr) = 0; |
| 1792 | 1817 |
| 1793 // Normal instructions can have 0 (inside a block) or 1 (last instruction in | 1818 // Normal instructions can have 0 (inside a block) or 1 (last instruction in |
| 1794 // a block) successors. Branch instruction with >1 successors override this | 1819 // a block) successors. Branch instruction with >1 successors override this |
| 1795 // function. | 1820 // function. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1946 GrowableArray<BlockEntryInstr*> dominated_blocks_; | 1971 GrowableArray<BlockEntryInstr*> dominated_blocks_; |
| 1947 Instruction* last_instruction_; | 1972 Instruction* last_instruction_; |
| 1948 | 1973 |
| 1949 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); | 1974 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); |
| 1950 }; | 1975 }; |
| 1951 | 1976 |
| 1952 | 1977 |
| 1953 class GraphEntryInstr : public BlockEntryInstr { | 1978 class GraphEntryInstr : public BlockEntryInstr { |
| 1954 public: | 1979 public: |
| 1955 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) | 1980 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) |
| 1956 : BlockEntryInstr(), normal_entry_(normal_entry), catch_entries_() { } | 1981 : BlockEntryInstr(), |
| 1982 normal_entry_(normal_entry), | |
| 1983 catch_entries_(), | |
| 1984 start_env_(NULL) { } | |
| 1957 | 1985 |
| 1958 DECLARE_INSTRUCTION(GraphEntry) | 1986 DECLARE_INSTRUCTION(GraphEntry) |
| 1959 | 1987 |
| 1960 virtual intptr_t PredecessorCount() const { return 0; } | 1988 virtual intptr_t PredecessorCount() const { return 0; } |
| 1961 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 1989 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 1962 UNREACHABLE(); | 1990 UNREACHABLE(); |
| 1963 return NULL; | 1991 return NULL; |
| 1964 } | 1992 } |
| 1965 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } | 1993 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
| 1966 | 1994 |
| 1967 virtual Instruction* StraightLineSuccessor() const { return NULL; } | 1995 virtual Instruction* StraightLineSuccessor() const { return NULL; } |
| 1968 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 1996 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1969 | 1997 |
| 1970 virtual intptr_t SuccessorCount() const; | 1998 virtual intptr_t SuccessorCount() const; |
| 1971 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 1999 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 1972 | 2000 |
| 1973 virtual void DiscoverBlocks( | 2001 virtual void DiscoverBlocks( |
| 1974 BlockEntryInstr* current_block, | 2002 BlockEntryInstr* current_block, |
| 1975 GrowableArray<BlockEntryInstr*>* preorder, | 2003 GrowableArray<BlockEntryInstr*>* preorder, |
| 1976 GrowableArray<BlockEntryInstr*>* postorder, | 2004 GrowableArray<BlockEntryInstr*>* postorder, |
| 1977 GrowableArray<intptr_t>* parent, | 2005 GrowableArray<intptr_t>* parent, |
| 1978 GrowableArray<BitVector*>* assigned_vars, | 2006 GrowableArray<BitVector*>* assigned_vars, |
| 1979 intptr_t variable_count); | 2007 intptr_t variable_count); |
| 1980 | 2008 |
| 1981 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } | 2009 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } |
| 1982 | 2010 |
| 1983 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 2011 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 1984 | 2012 |
| 2013 ZoneGrowableArray<Value*>* start_env() const { return start_env_; } | |
| 2014 void set_start_env(ZoneGrowableArray<Value*>* env) { start_env_ = env; } | |
| 2015 | |
| 1985 private: | 2016 private: |
| 1986 TargetEntryInstr* normal_entry_; | 2017 TargetEntryInstr* normal_entry_; |
| 1987 GrowableArray<TargetEntryInstr*> catch_entries_; | 2018 GrowableArray<TargetEntryInstr*> catch_entries_; |
| 2019 ZoneGrowableArray<Value*>* start_env_; | |
| 1988 | 2020 |
| 1989 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); | 2021 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); |
| 1990 }; | 2022 }; |
| 1991 | 2023 |
| 1992 | 2024 |
| 1993 class JoinEntryInstr : public BlockEntryInstr { | 2025 class JoinEntryInstr : public BlockEntryInstr { |
| 1994 public: | 2026 public: |
| 1995 JoinEntryInstr() | 2027 JoinEntryInstr() |
| 1996 : BlockEntryInstr(), | 2028 : BlockEntryInstr(), |
| 1997 predecessors_(2), // Two is the assumed to be the common case. | 2029 predecessors_(2), // Two is the assumed to be the common case. |
| 1998 successor_(NULL), | 2030 successor_(NULL), |
| 1999 phis_(NULL), | 2031 phis_(NULL), |
| 2000 phi_count_(0) { } | 2032 phi_count_(0) { } |
| 2001 | 2033 |
| 2002 DECLARE_INSTRUCTION(JoinEntry) | 2034 DECLARE_INSTRUCTION(JoinEntry) |
| 2003 | 2035 |
| 2004 virtual intptr_t PredecessorCount() const { return predecessors_.length(); } | 2036 virtual intptr_t PredecessorCount() const { return predecessors_.length(); } |
| 2005 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 2037 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 2006 return predecessors_[index]; | 2038 return predecessors_[index]; |
| 2007 } | 2039 } |
| 2008 virtual void AddPredecessor(BlockEntryInstr* predecessor) { | 2040 virtual void AddPredecessor(BlockEntryInstr* predecessor) { |
| 2009 predecessors_.Add(predecessor); | 2041 predecessors_.Add(predecessor); |
| 2010 } | 2042 } |
| 2011 | 2043 |
| 2012 virtual Instruction* StraightLineSuccessor() const { | 2044 virtual Instruction* StraightLineSuccessor() const { |
| 2013 return successor_; | 2045 return successor_; |
| 2014 } | 2046 } |
| 2015 virtual void SetSuccessor(Instruction* instr) { | 2047 virtual void SetSuccessor(Instruction* instr) { |
| 2016 ASSERT(successor_ == NULL); | |
| 2017 successor_ = instr; | 2048 successor_ = instr; |
| 2018 } | 2049 } |
| 2019 | 2050 |
| 2020 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } | 2051 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } |
| 2021 | 2052 |
| 2022 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 2053 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 2023 | 2054 |
| 2024 void InsertPhi(intptr_t var_index, intptr_t var_count); | 2055 void InsertPhi(intptr_t var_index, intptr_t var_count); |
| 2025 | 2056 |
| 2026 intptr_t phi_count() const { return phi_count_; } | 2057 intptr_t phi_count() const { return phi_count_; } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2061 } | 2092 } |
| 2062 virtual void AddPredecessor(BlockEntryInstr* predecessor) { | 2093 virtual void AddPredecessor(BlockEntryInstr* predecessor) { |
| 2063 ASSERT(predecessor_ == NULL); | 2094 ASSERT(predecessor_ == NULL); |
| 2064 predecessor_ = predecessor; | 2095 predecessor_ = predecessor; |
| 2065 } | 2096 } |
| 2066 | 2097 |
| 2067 virtual Instruction* StraightLineSuccessor() const { | 2098 virtual Instruction* StraightLineSuccessor() const { |
| 2068 return successor_; | 2099 return successor_; |
| 2069 } | 2100 } |
| 2070 virtual void SetSuccessor(Instruction* instr) { | 2101 virtual void SetSuccessor(Instruction* instr) { |
| 2071 ASSERT(successor_ == NULL); | |
| 2072 successor_ = instr; | 2102 successor_ = instr; |
| 2073 } | 2103 } |
| 2074 | 2104 |
| 2075 bool HasTryIndex() const { | 2105 bool HasTryIndex() const { |
| 2076 return try_index_ != CatchClauseNode::kInvalidTryIndex; | 2106 return try_index_ != CatchClauseNode::kInvalidTryIndex; |
| 2077 } | 2107 } |
| 2078 | 2108 |
| 2079 intptr_t try_index() const { | 2109 intptr_t try_index() const { |
| 2080 ASSERT(HasTryIndex()); | 2110 ASSERT(HasTryIndex()); |
| 2081 return try_index_; | 2111 return try_index_; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2103 DECLARE_INSTRUCTION(Do) | 2133 DECLARE_INSTRUCTION(Do) |
| 2104 | 2134 |
| 2105 Computation* computation() const { return computation_; } | 2135 Computation* computation() const { return computation_; } |
| 2106 virtual void replace_computation(Computation* value) { computation_ = value; } | 2136 virtual void replace_computation(Computation* value) { computation_ = value; } |
| 2107 | 2137 |
| 2108 virtual Instruction* StraightLineSuccessor() const { | 2138 virtual Instruction* StraightLineSuccessor() const { |
| 2109 return successor_; | 2139 return successor_; |
| 2110 } | 2140 } |
| 2111 | 2141 |
| 2112 virtual void SetSuccessor(Instruction* instr) { | 2142 virtual void SetSuccessor(Instruction* instr) { |
| 2113 ASSERT(successor_ == NULL); | |
| 2114 successor_ = instr; | 2143 successor_ = instr; |
| 2115 } | 2144 } |
| 2116 | 2145 |
| 2117 virtual void RecordAssignedVars(BitVector* assigned_vars); | 2146 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 2118 | 2147 |
| 2119 virtual LocationSummary* locs() { | 2148 virtual LocationSummary* locs() { |
| 2120 return computation()->locs(); | 2149 return computation()->locs(); |
| 2121 } | 2150 } |
| 2122 | 2151 |
| 2123 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 2152 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2124 computation()->EmitNativeCode(compiler); | 2153 computation()->EmitNativeCode(compiler); |
| 2125 } | 2154 } |
| 2126 | 2155 |
| 2127 private: | 2156 private: |
| 2128 Computation* computation_; | 2157 Computation* computation_; |
| 2129 Instruction* successor_; | 2158 Instruction* successor_; |
| 2130 | 2159 |
| 2131 DISALLOW_COPY_AND_ASSIGN(DoInstr); | 2160 DISALLOW_COPY_AND_ASSIGN(DoInstr); |
| 2132 }; | 2161 }; |
| 2133 | 2162 |
| 2134 | 2163 |
| 2135 // Abstract super-class of all instructions that define a value (Bind, Phi). | 2164 // Abstract super-class of all instructions that define a value (Bind, Phi). |
| 2136 class Definition : public Instruction { | 2165 class Definition : public Instruction { |
| 2137 public: | 2166 public: |
| 2138 Definition() : temp_index_(-1) { } | 2167 Definition() : temp_index_(-1), ssa_temp_index_(-1) { } |
| 2139 | 2168 |
| 2140 virtual bool IsDefinition() const { return true; } | 2169 virtual bool IsDefinition() const { return true; } |
| 2141 virtual Definition* AsDefinition() { return this; } | 2170 virtual Definition* AsDefinition() { return this; } |
| 2142 | 2171 |
| 2143 intptr_t temp_index() const { return temp_index_; } | 2172 intptr_t temp_index() const { return temp_index_; } |
| 2144 void set_temp_index(intptr_t index) { temp_index_ = index; } | 2173 void set_temp_index(intptr_t index) { temp_index_ = index; } |
| 2145 | 2174 |
| 2175 intptr_t ssa_temp_index() const { return ssa_temp_index_; } | |
| 2176 void set_ssa_temp_index(intptr_t index) { ssa_temp_index_ = index; } | |
| 2177 | |
| 2146 private: | 2178 private: |
| 2147 intptr_t temp_index_; | 2179 intptr_t temp_index_; |
| 2180 intptr_t ssa_temp_index_; | |
| 2148 | 2181 |
| 2149 DISALLOW_COPY_AND_ASSIGN(Definition); | 2182 DISALLOW_COPY_AND_ASSIGN(Definition); |
| 2150 }; | 2183 }; |
| 2151 | 2184 |
| 2152 | 2185 |
| 2153 class BindInstr : public Definition { | 2186 class BindInstr : public Definition { |
| 2154 public: | 2187 public: |
| 2155 explicit BindInstr(Computation* computation) | 2188 explicit BindInstr(Computation* computation) |
| 2156 : computation_(computation), successor_(NULL) { | 2189 : computation_(computation), successor_(NULL) { |
| 2157 ASSERT(computation != NULL); | 2190 ASSERT(computation != NULL); |
| 2158 computation->set_instr(this); | 2191 computation->set_instr(this); |
| 2159 } | 2192 } |
| 2160 | 2193 |
| 2161 DECLARE_INSTRUCTION(Bind) | 2194 DECLARE_INSTRUCTION(Bind) |
| 2162 | 2195 |
| 2163 Computation* computation() const { return computation_; } | 2196 Computation* computation() const { return computation_; } |
| 2164 virtual void replace_computation(Computation* value) { computation_ = value; } | 2197 virtual void replace_computation(Computation* value) { computation_ = value; } |
| 2165 | 2198 |
| 2166 virtual Instruction* StraightLineSuccessor() const { | 2199 virtual Instruction* StraightLineSuccessor() const { |
| 2167 return successor_; | 2200 return successor_; |
| 2168 } | 2201 } |
| 2169 | 2202 |
| 2170 virtual void SetSuccessor(Instruction* instr) { | 2203 virtual void SetSuccessor(Instruction* instr) { |
| 2171 ASSERT(successor_ == NULL); | |
| 2172 successor_ = instr; | 2204 successor_ = instr; |
| 2173 } | 2205 } |
| 2174 | 2206 |
| 2175 // Static type of the underlying computation. | 2207 // Static type of the underlying computation. |
| 2176 virtual RawAbstractType* StaticType() const { | 2208 virtual RawAbstractType* StaticType() const { |
| 2177 return computation()->StaticType(); | 2209 return computation()->StaticType(); |
| 2178 } | 2210 } |
| 2179 | 2211 |
| 2180 virtual void RecordAssignedVars(BitVector* assigned_vars); | 2212 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 2181 | 2213 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2196 class PhiInstr: public Definition { | 2228 class PhiInstr: public Definition { |
| 2197 public: | 2229 public: |
| 2198 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { | 2230 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { |
| 2199 for (intptr_t i = 0; i < num_inputs; ++i) { | 2231 for (intptr_t i = 0; i < num_inputs; ++i) { |
| 2200 inputs_.Add(NULL); | 2232 inputs_.Add(NULL); |
| 2201 } | 2233 } |
| 2202 } | 2234 } |
| 2203 | 2235 |
| 2204 DECLARE_INSTRUCTION(Phi) | 2236 DECLARE_INSTRUCTION(Phi) |
| 2205 | 2237 |
| 2206 void SetInputAt(intptr_t i, Value* value) { | |
| 2207 inputs_[i] = value; | |
| 2208 } | |
| 2209 | |
| 2210 virtual Instruction* StraightLineSuccessor() const { return NULL; } | 2238 virtual Instruction* StraightLineSuccessor() const { return NULL; } |
| 2211 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 2239 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 2212 | 2240 |
| 2213 private: | 2241 private: |
| 2214 GrowableArray<Value*> inputs_; | 2242 GrowableArray<Value*> inputs_; |
| 2215 | 2243 |
| 2216 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 2244 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
| 2217 }; | 2245 }; |
| 2218 | 2246 |
| 2219 | 2247 |
| 2220 | |
| 2221 | |
| 2222 class ReturnInstr : public InstructionWithInputs { | 2248 class ReturnInstr : public InstructionWithInputs { |
| 2223 public: | 2249 public: |
| 2224 ReturnInstr(intptr_t token_index, Value* value) | 2250 ReturnInstr(intptr_t token_index, Value* value) |
| 2225 : InstructionWithInputs(), token_index_(token_index), value_(value) { | 2251 : InstructionWithInputs(), token_index_(token_index), value_(value) { |
| 2226 ASSERT(value_ != NULL); | 2252 ASSERT(value_ != NULL); |
| 2227 } | 2253 } |
| 2228 | 2254 |
| 2229 DECLARE_INSTRUCTION(Return) | 2255 DECLARE_INSTRUCTION(Return) |
| 2230 | 2256 |
| 2231 Value* value() const { return value_; } | 2257 Value* value() const { return value_; } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2420 const GrowableArray<BlockEntryInstr*>& block_order_; | 2446 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2421 | 2447 |
| 2422 private: | 2448 private: |
| 2423 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2449 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2424 }; | 2450 }; |
| 2425 | 2451 |
| 2426 | 2452 |
| 2427 } // namespace dart | 2453 } // namespace dart |
| 2428 | 2454 |
| 2429 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2455 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |