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

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

Issue 10735071: Introduce Goto instructions to the flow graph. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rewrite a comment that was word salad. 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 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 1675
1676 // Instructions. 1676 // Instructions.
1677 1677
1678 // M is a single argument macro. It is applied to each concrete instruction 1678 // M is a single argument macro. It is applied to each concrete instruction
1679 // type name. The concrete instruction classes are the name with Instr 1679 // type name. The concrete instruction classes are the name with Instr
1680 // concatenated. 1680 // concatenated.
1681 #define FOR_EACH_INSTRUCTION(M) \ 1681 #define FOR_EACH_INSTRUCTION(M) \
1682 M(GraphEntry) \ 1682 M(GraphEntry) \
1683 M(JoinEntry) \ 1683 M(JoinEntry) \
1684 M(TargetEntry) \ 1684 M(TargetEntry) \
1685 M(Phi) \
1685 M(Bind) \ 1686 M(Bind) \
1686 M(Phi) \ 1687 M(Parameter) \
1688 M(ParallelMove) \
1687 M(Return) \ 1689 M(Return) \
1688 M(Throw) \ 1690 M(Throw) \
1689 M(ReThrow) \ 1691 M(ReThrow) \
1692 M(Goto) \
1690 M(Branch) \ 1693 M(Branch) \
1691 M(ParallelMove) \
1692 M(Parameter)
1693 1694
1694 1695
1695 // Forward declarations for Instruction classes. 1696 // Forward declarations for Instruction classes.
1696 class BlockEntryInstr; 1697 class BlockEntryInstr;
1697 class FlowGraphBuilder; 1698 class FlowGraphBuilder;
1698 class Environment; 1699 class Environment;
1699 1700
1700 #define FORWARD_DECLARATION(type) class type##Instr; 1701 #define FORWARD_DECLARATION(type) class type##Instr;
1701 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 1702 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
1702 #undef FORWARD_DECLARATION 1703 #undef FORWARD_DECLARATION
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 ASSERT(!IsBlockEntry()); 1755 ASSERT(!IsBlockEntry());
1755 previous_ = instr; 1756 previous_ = instr;
1756 } 1757 }
1757 1758
1758 Instruction* next() const { return next_; } 1759 Instruction* next() const { return next_; }
1759 void set_next(Instruction* instr) { 1760 void set_next(Instruction* instr) {
1760 ASSERT(!IsGraphEntry()); 1761 ASSERT(!IsGraphEntry());
1761 ASSERT(!IsReturn()); 1762 ASSERT(!IsReturn());
1762 ASSERT(!IsBranch()); 1763 ASSERT(!IsBranch());
1763 ASSERT(!IsPhi()); 1764 ASSERT(!IsPhi());
1765 ASSERT(instr == NULL || !instr->IsBlockEntry());
1764 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions 1766 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions
srdjan 2012/07/12 16:42:26 parenthesis
1765 // that do not have a successor. Currently, the graph builder will continue 1767 // that do not have a successor. Currently, the graph builder will continue
1766 // to append instruction in case of a Throw inside an expression. This 1768 // to append instruction in case of a Throw inside an expression. This
1767 // condition should be handled in the graph builder 1769 // condition should be handled in the graph builder
1768 next_ = instr; 1770 next_ = instr;
1769 } 1771 }
1770 1772
1771 // Normal instructions can have 0 (inside a block) or 1 (last instruction in 1773 // Normal instructions can have 0 (inside a block) or 1 (last instruction in
1772 // a block) successors. Branch instruction with >1 successors override this 1774 // a block) successors. Branch instruction with >1 successors override this
1773 // function. 1775 // function.
1774 virtual intptr_t SuccessorCount() const; 1776 virtual intptr_t SuccessorCount() const;
1775 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1777 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1776 1778
1779 void Goto(JoinEntryInstr* entry);
1780
1777 // Discover basic-block structure by performing a recursive depth first 1781 // Discover basic-block structure by performing a recursive depth first
1778 // traversal of the instruction graph reachable from this instruction. As 1782 // traversal of the instruction graph reachable from this instruction. As
1779 // a side effect, the block entry instructions in the graph are assigned 1783 // a side effect, the block entry instructions in the graph are assigned
1780 // numbers in both preorder and postorder. The array 'preorder' maps 1784 // numbers in both preorder and postorder. The array 'preorder' maps
1781 // preorder block numbers to the block entry instruction with that number 1785 // preorder block numbers to the block entry instruction with that number
1782 // and analogously for the array 'postorder'. The depth first spanning 1786 // and analogously for the array 'postorder'. The depth first spanning
1783 // tree is recorded in the array 'parent', which maps preorder block 1787 // tree is recorded in the array 'parent', which maps preorder block
1784 // numbers to the preorder number of the block's spanning-tree parent. 1788 // numbers to the preorder number of the block's spanning-tree parent.
1785 // The array 'assigned_vars' maps preorder block numbers to the set of 1789 // The array 'assigned_vars' maps preorder block numbers to the set of
1786 // assigned frame-allocated local variables in the block. As a side 1790 // assigned frame-allocated local variables in the block. As a side
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 ICData* ic_data_; 1849 ICData* ic_data_;
1846 Instruction* previous_; 1850 Instruction* previous_;
1847 Instruction* next_; 1851 Instruction* next_;
1848 Environment* env_; 1852 Environment* env_;
1849 DISALLOW_COPY_AND_ASSIGN(Instruction); 1853 DISALLOW_COPY_AND_ASSIGN(Instruction);
1850 }; 1854 };
1851 1855
1852 1856
1853 class InstructionWithInputs : public Instruction { 1857 class InstructionWithInputs : public Instruction {
1854 public: 1858 public:
1855 InstructionWithInputs() : locs_(NULL) { 1859 InstructionWithInputs() : locs_(NULL) { }
1856 }
1857 1860
1858 virtual LocationSummary* locs() { 1861 virtual LocationSummary* locs() {
1859 if (locs_ == NULL) { 1862 if (locs_ == NULL) {
1860 locs_ = MakeLocationSummary(); 1863 locs_ = MakeLocationSummary();
1861 } 1864 }
1862 return locs_; 1865 return locs_;
1863 } 1866 }
1864 1867
1865 virtual LocationSummary* MakeLocationSummary() const = 0; 1868 virtual LocationSummary* MakeLocationSummary() const = 0;
1866 1869
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 private: 2282 private:
2280 const intptr_t token_pos_; 2283 const intptr_t token_pos_;
2281 const intptr_t try_index_; 2284 const intptr_t try_index_;
2282 Value* exception_; 2285 Value* exception_;
2283 Value* stack_trace_; 2286 Value* stack_trace_;
2284 2287
2285 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 2288 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
2286 }; 2289 };
2287 2290
2288 2291
2292 class GotoInstr : public InstructionWithInputs {
srdjan 2012/07/12 16:42:26 Why is a goto InstructionWithInputs and not just I
Kevin Millikin (Google) 2012/07/13 15:34:59 Well, it's an instruction with inputs that happens
2293 public:
2294 explicit GotoInstr(JoinEntryInstr* entry) : successor_(entry) { }
2295
2296 DECLARE_INSTRUCTION(Goto)
2297
2298 JoinEntryInstr* successor() const { return successor_; }
2299 void set_successor(JoinEntryInstr* successor) { successor_ = successor; }
2300 virtual intptr_t SuccessorCount() const;
2301 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2302
2303 virtual LocationSummary* MakeLocationSummary() const;
2304
2305 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2306
2307 private:
2308 JoinEntryInstr* successor_;
srdjan 2012/07/12 16:42:26 DISALLOW_...
2309 };
2310
2311
2289 class BranchInstr : public InstructionWithInputs { 2312 class BranchInstr : public InstructionWithInputs {
2290 public: 2313 public:
2291 explicit BranchInstr(Value* value) 2314 explicit BranchInstr(Value* value)
2292 : InstructionWithInputs(), 2315 : InstructionWithInputs(),
2293 value_(value), 2316 value_(value),
2294 true_successor_(NULL), 2317 true_successor_(NULL),
2295 false_successor_(NULL), 2318 false_successor_(NULL),
2296 fused_with_comparison_(NULL), 2319 fused_with_comparison_(NULL),
2297 is_negated_(false) { } 2320 is_negated_(false) { }
2298 2321
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 const GrowableArray<BlockEntryInstr*>& block_order_; 2507 const GrowableArray<BlockEntryInstr*>& block_order_;
2485 2508
2486 private: 2509 private:
2487 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2510 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2488 }; 2511 };
2489 2512
2490 2513
2491 } // namespace dart 2514 } // namespace dart
2492 2515
2493 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2516 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698