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

Unified Diff: vm/intermediate_language.h

Issue 10692107: Add forward iterator to iterate instructions inside a basic block. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: vm/intermediate_language.h
===================================================================
--- vm/intermediate_language.h (revision 9430)
+++ vm/intermediate_language.h (working copy)
@@ -1777,7 +1777,11 @@
// Remove instruction from the graph and return the instruction following the
// removed instruction.
- Instruction* RemoveFromGraph();
+ enum RemoveReturnValue {
+ kReturnPrevious,
+ kReturnNext
+ };
+ Instruction* RemoveFromGraph(RemoveReturnValue ret);
// Normal instructions can have 0 (inside a block) or 1 (last instruction in
// a block) successors. Branch instruction with >1 successors override this
@@ -1942,6 +1946,33 @@
};
+class ForwardIterator : public ValueObject {
Kevin Millikin (Google) 2012/07/06 10:44:30 I think the class name is probably too generic. W
+ public:
+ explicit ForwardIterator(BlockEntryInstr* block_entry)
+ : block_entry_(block_entry), current_(block_entry) {
+ Advance();
+ }
+
+ void Advance() {
+ if (!Done()) current_ = current_->successor();
+ }
+
+ bool Done() const {
+ return current_ == block_entry_->last_instruction()->successor();
+ }
+
+ void RemoveCurrentFromGraph() {
+ current_ = current_->RemoveFromGraph(Instruction::kReturnPrevious);
+ }
+
+ Instruction* Current() const { return current_; }
+
+ private:
+ BlockEntryInstr* block_entry_;
+ Instruction* current_;
+};
+
+
class GraphEntryInstr : public BlockEntryInstr {
public:
explicit GraphEntryInstr(TargetEntryInstr* normal_entry)

Powered by Google App Engine
This is Rietveld 408576698