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: vm/intermediate_language.h

Issue 10796108: Add a backward instruction iterator and use it in the liveness analysis. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: 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 | « vm/flow_graph_allocator.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »
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 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 Instruction* last_instruction_; 1943 Instruction* last_instruction_;
1944 1944
1945 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); 1945 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr);
1946 }; 1946 };
1947 1947
1948 1948
1949 class ForwardInstructionIterator : public ValueObject { 1949 class ForwardInstructionIterator : public ValueObject {
1950 public: 1950 public:
1951 explicit ForwardInstructionIterator(BlockEntryInstr* block_entry) 1951 explicit ForwardInstructionIterator(BlockEntryInstr* block_entry)
1952 : block_entry_(block_entry), current_(block_entry) { 1952 : block_entry_(block_entry), current_(block_entry) {
1953 ASSERT(block_entry_->last_instruction()->next() == NULL);
1953 Advance(); 1954 Advance();
1954 } 1955 }
1955 1956
1956 void Advance() { 1957 void Advance() {
1957 ASSERT(!Done()); 1958 ASSERT(!Done());
1958 current_ = current_->next(); 1959 current_ = current_->next();
1959 } 1960 }
1960 1961
1961 bool Done() const { 1962 bool Done() const { return current_ == NULL; }
1962 return current_ == block_entry_->last_instruction()->next();
1963 }
1964 1963
1965 // Removes 'current_' from graph and sets 'current_' to previous instruction. 1964 // Removes 'current_' from graph and sets 'current_' to previous instruction.
1966 void RemoveCurrentFromGraph(); 1965 void RemoveCurrentFromGraph();
1967 1966
1968 Instruction* Current() const { return current_; } 1967 Instruction* Current() const { return current_; }
1969 1968
1970 private: 1969 private:
1971 BlockEntryInstr* block_entry_; 1970 BlockEntryInstr* block_entry_;
1972 Instruction* current_; 1971 Instruction* current_;
1973 }; 1972 };
1974 1973
1975 1974
1975 class BackwardInstructionIterator : public ValueObject {
1976 public:
1977 explicit BackwardInstructionIterator(BlockEntryInstr* block_entry)
1978 : block_entry_(block_entry), current_(block_entry->last_instruction()) {
1979 ASSERT(block_entry_->previous() == NULL);
1980 }
1981
1982 void Advance() {
1983 ASSERT(!Done());
1984 current_ = current_->previous();
1985 }
1986
1987 bool Done() const { return current_ == block_entry_; }
1988
1989 Instruction* Current() const { return current_; }
1990
1991 private:
1992 BlockEntryInstr* block_entry_;
1993 Instruction* current_;
1994 };
1995
1996
1976 class GraphEntryInstr : public BlockEntryInstr { 1997 class GraphEntryInstr : public BlockEntryInstr {
1977 public: 1998 public:
1978 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) 1999 explicit GraphEntryInstr(TargetEntryInstr* normal_entry)
1979 : BlockEntryInstr(), 2000 : BlockEntryInstr(),
1980 normal_entry_(normal_entry), 2001 normal_entry_(normal_entry),
1981 catch_entries_(), 2002 catch_entries_(),
1982 start_env_(NULL) { } 2003 start_env_(NULL) { }
1983 2004
1984 DECLARE_INSTRUCTION(GraphEntry) 2005 DECLARE_INSTRUCTION(GraphEntry)
1985 2006
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 const GrowableArray<BlockEntryInstr*>& block_order_; 2560 const GrowableArray<BlockEntryInstr*>& block_order_;
2540 2561
2541 private: 2562 private:
2542 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2563 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2543 }; 2564 };
2544 2565
2545 2566
2546 } // namespace dart 2567 } // namespace dart
2547 2568
2548 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2569 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « vm/flow_graph_allocator.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698