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

Side by Side Diff: vm/intermediate_language.h

Issue 10446116: Add flow graph printing into a .cfg file with flag --print-flow-graph-file. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 #undef FORWARD_DECLARATION 1340 #undef FORWARD_DECLARATION
1341 1341
1342 1342
1343 // Functions required in all concrete instruction classes. 1343 // Functions required in all concrete instruction classes.
1344 #define DECLARE_INSTRUCTION(type) \ 1344 #define DECLARE_INSTRUCTION(type) \
1345 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ 1345 virtual Instruction* Accept(FlowGraphVisitor* visitor); \
1346 virtual bool Is##type() const { return true; } \ 1346 virtual bool Is##type() const { return true; } \
1347 virtual type##Instr* As##type() { return this; } \ 1347 virtual type##Instr* As##type() { return this; } \
1348 virtual intptr_t InputCount() const; \ 1348 virtual intptr_t InputCount() const; \
1349 virtual const char* DebugName() const { return #type; } \ 1349 virtual const char* DebugName() const { return #type; } \
1350 virtual void PrintTo(BufferFormatter* f) const; 1350 virtual void PrintTo(BufferFormatter* f) const; \
1351 virtual void PrintToVisualizer(BufferFormatter* f) const;
1351 1352
1352 1353
1353 class Instruction : public ZoneAllocated { 1354 class Instruction : public ZoneAllocated {
1354 public: 1355 public:
1355 Instruction() : cid_(-1), ic_data_(NULL) { 1356 Instruction() : cid_(-1), ic_data_(NULL) {
1356 Isolate* isolate = Isolate::Current(); 1357 Isolate* isolate = Isolate::Current();
1357 cid_ = Computation::GetNextCid(isolate); 1358 cid_ = Computation::GetNextCid(isolate);
1358 ic_data_ = Computation::GetICDataForCid(cid_, isolate); 1359 ic_data_ = Computation::GetICDataForCid(cid_, isolate);
1359 } 1360 }
1360 1361
(...skipping 13 matching lines...) Expand all
1374 } 1375 }
1375 1376
1376 virtual intptr_t InputCount() const = 0; 1377 virtual intptr_t InputCount() const = 0;
1377 1378
1378 // Visiting support. 1379 // Visiting support.
1379 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0; 1380 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0;
1380 1381
1381 virtual Instruction* StraightLineSuccessor() const = 0; 1382 virtual Instruction* StraightLineSuccessor() const = 0;
1382 virtual void SetSuccessor(Instruction* instr) = 0; 1383 virtual void SetSuccessor(Instruction* instr) = 0;
1383 1384
1385 // Normal instructions can have 0 (inside a block) or 1 (last instruction in
1386 // a block) successors. Branch instruction with >1 successors override this
1387 // function.
1388 virtual intptr_t SuccessorCount() const;
1389 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1390
1384 virtual void replace_computation(Computation* value) { 1391 virtual void replace_computation(Computation* value) {
1385 UNREACHABLE(); 1392 UNREACHABLE();
1386 } 1393 }
1387 // Discover basic-block structure by performing a recursive depth first 1394 // Discover basic-block structure by performing a recursive depth first
1388 // traversal of the instruction graph reachable from this instruction. As 1395 // traversal of the instruction graph reachable from this instruction. As
1389 // a side effect, the block entry instructions in the graph are assigned 1396 // a side effect, the block entry instructions in the graph are assigned
1390 // numbers in both preorder and postorder. The array 'preorder' maps 1397 // numbers in both preorder and postorder. The array 'preorder' maps
1391 // preorder block numbers to the block entry instruction with that number 1398 // preorder block numbers to the block entry instruction with that number
1392 // and analogously for the array 'postorder'. The depth first spanning 1399 // and analogously for the array 'postorder'. The depth first spanning
1393 // tree is recorded in the array 'parent', which maps preorder block 1400 // tree is recorded in the array 'parent', which maps preorder block
(...skipping 13 matching lines...) Expand all
1407 // Never called for instructions except block entries and branches. 1414 // Never called for instructions except block entries and branches.
1408 UNREACHABLE(); 1415 UNREACHABLE();
1409 } 1416 }
1410 1417
1411 // Mutate assigned_vars to add the local variable index for all 1418 // Mutate assigned_vars to add the local variable index for all
1412 // frame-allocated locals assigned to by the instruction. 1419 // frame-allocated locals assigned to by the instruction.
1413 virtual void RecordAssignedVars(BitVector* assigned_vars); 1420 virtual void RecordAssignedVars(BitVector* assigned_vars);
1414 1421
1415 // Printing support. 1422 // Printing support.
1416 virtual void PrintTo(BufferFormatter* f) const = 0; 1423 virtual void PrintTo(BufferFormatter* f) const = 0;
1424 virtual void PrintToVisualizer(BufferFormatter* f) const = 0;
1417 1425
1418 #define INSTRUCTION_TYPE_CHECK(type) \ 1426 #define INSTRUCTION_TYPE_CHECK(type) \
1419 virtual bool Is##type() const { return false; } \ 1427 virtual bool Is##type() const { return false; } \
1420 virtual type##Instr* As##type() { return NULL; } 1428 virtual type##Instr* As##type() { return NULL; }
1421 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) 1429 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
1422 #undef INSTRUCTION_TYPE_CHECK 1430 #undef INSTRUCTION_TYPE_CHECK
1423 1431
1424 // Static type of the instruction. 1432 // Static type of the instruction.
1425 virtual RawAbstractType* StaticType() const { 1433 virtual RawAbstractType* StaticType() const {
1426 UNREACHABLE(); 1434 UNREACHABLE();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 virtual intptr_t PredecessorCount() const { return 0; } 1520 virtual intptr_t PredecessorCount() const { return 0; }
1513 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1521 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1514 UNREACHABLE(); 1522 UNREACHABLE();
1515 return NULL; 1523 return NULL;
1516 } 1524 }
1517 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 1525 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
1518 1526
1519 virtual Instruction* StraightLineSuccessor() const { return NULL; } 1527 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1520 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } 1528 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
1521 1529
1530 virtual intptr_t SuccessorCount() const;
1531 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1532
1522 virtual void DiscoverBlocks( 1533 virtual void DiscoverBlocks(
1523 BlockEntryInstr* current_block, 1534 BlockEntryInstr* current_block,
1524 GrowableArray<BlockEntryInstr*>* preorder, 1535 GrowableArray<BlockEntryInstr*>* preorder,
1525 GrowableArray<BlockEntryInstr*>* postorder, 1536 GrowableArray<BlockEntryInstr*>* postorder,
1526 GrowableArray<intptr_t>* parent, 1537 GrowableArray<intptr_t>* parent,
1527 GrowableArray<BitVector*>* assigned_vars, 1538 GrowableArray<BitVector*>* assigned_vars,
1528 intptr_t variable_count); 1539 intptr_t variable_count);
1529 1540
1530 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } 1541 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); }
1531 1542
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 Value* value() const { return value_; } 1838 Value* value() const { return value_; }
1828 TargetEntryInstr* true_successor() const { return true_successor_; } 1839 TargetEntryInstr* true_successor() const { return true_successor_; }
1829 TargetEntryInstr* false_successor() const { return false_successor_; } 1840 TargetEntryInstr* false_successor() const { return false_successor_; }
1830 1841
1831 TargetEntryInstr** true_successor_address() { return &true_successor_; } 1842 TargetEntryInstr** true_successor_address() { return &true_successor_; }
1832 TargetEntryInstr** false_successor_address() { return &false_successor_; } 1843 TargetEntryInstr** false_successor_address() { return &false_successor_; }
1833 1844
1834 virtual Instruction* StraightLineSuccessor() const { return NULL; } 1845 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1835 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } 1846 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
1836 1847
1848 virtual intptr_t SuccessorCount() const;
1849 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1850
1837 virtual void DiscoverBlocks( 1851 virtual void DiscoverBlocks(
1838 BlockEntryInstr* current_block, 1852 BlockEntryInstr* current_block,
1839 GrowableArray<BlockEntryInstr*>* preorder, 1853 GrowableArray<BlockEntryInstr*>* preorder,
1840 GrowableArray<BlockEntryInstr*>* postorder, 1854 GrowableArray<BlockEntryInstr*>* postorder,
1841 GrowableArray<intptr_t>* parent, 1855 GrowableArray<intptr_t>* parent,
1842 GrowableArray<BitVector*>* assigned_vars, 1856 GrowableArray<BitVector*>* assigned_vars,
1843 intptr_t variable_count); 1857 intptr_t variable_count);
1844 1858
1845 private: 1859 private:
1846 Value* value_; 1860 Value* value_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 const GrowableArray<BlockEntryInstr*>& block_order_; 1904 const GrowableArray<BlockEntryInstr*>& block_order_;
1891 1905
1892 private: 1906 private:
1893 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 1907 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
1894 }; 1908 };
1895 1909
1896 1910
1897 } // namespace dart 1911 } // namespace dart
1898 1912
1899 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 1913 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« vm/flow_graph_builder.cc ('K') | « vm/il_printer.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698