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

Unified Diff: vm/intermediate_language.cc

Issue 10665022: Make IL instructions a doubly-linked list within basic blocks. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/intermediate_language.cc
===================================================================
--- vm/intermediate_language.cc (revision 9281)
+++ vm/intermediate_language.cc (working copy)
@@ -66,7 +66,7 @@
#define DEFINE_ACCEPT(ShortName) \
Instruction* ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \
visitor->Visit##ShortName(this); \
- return StraightLineSuccessor(); \
+ return successor(); \
}
FOR_EACH_INSTRUCTION(DEFINE_ACCEPT)
@@ -459,15 +459,15 @@
// 5. Iterate straight-line successors until a branch instruction or
// another basic block entry instruction, and visit that instruction.
- ASSERT(StraightLineSuccessor() != NULL);
- Instruction* next = StraightLineSuccessor();
+ ASSERT(successor() != NULL);
+ Instruction* next = successor();
if (next->IsBlockEntry()) {
set_last_instruction(this);
} else {
while ((next != NULL) && !next->IsBlockEntry() && !next->IsBranch()) {
if (vars != NULL) next->RecordAssignedVars(vars);
set_last_instruction(next);
- next = next->StraightLineSuccessor();
+ next = next->successor();
}
}
if (next != NULL) {
@@ -521,17 +521,54 @@
intptr_t Instruction::SuccessorCount() const {
ASSERT(!IsBranch());
ASSERT(!IsGraphEntry());
- ASSERT(StraightLineSuccessor() == NULL ||
- StraightLineSuccessor()->IsBlockEntry());
- return StraightLineSuccessor() != NULL ? 1 : 0;
+ ASSERT(successor() == NULL ||
+ successor()->IsBlockEntry());
+ return successor() != NULL ? 1 : 0;
}
BlockEntryInstr* Instruction::SuccessorAt(intptr_t index) const {
- return StraightLineSuccessor()->AsBlockEntry();
+ return successor()->AsBlockEntry();
}
+void Instruction::RemoveFromGraph() {
+ ASSERT(!IsBlockEntry());
+ ASSERT(previous() != NULL);
+ Instruction* next = successor();
+ previous()->set_successor(next);
+ if (next != NULL) {
+ if (!next->IsBlockEntry()) {
+ next->set_previous(previous());
+ } else {
+ // Removing the last instruction of a block.
+ ASSERT(!IsBranch());
+ ASSERT(!IsThrow());
+ ASSERT(!IsReturn());
+ ASSERT(!IsReThrow());
+ // Update last_instruction of the current basic block.
+ Instruction* current = this;
+ while (!current->IsBlockEntry()) {
+ current = current->previous();
+ }
+ ASSERT(current->AsBlockEntry()->last_instruction() == this);
+ current->AsBlockEntry()->set_last_instruction(previous());
+ }
+ }
+ // Reset successor and previous instruction to indicate
+ // that the instruction is removed from the graph.
+ set_successor(NULL);
+ set_previous(NULL);
+}
+
+
+bool Instruction::is_linked() const {
+ ASSERT(!IsBlockEntry() || ((successor() != NULL) && (previous() == NULL)));
+ ASSERT(IsBlockEntry() || previous() != NULL);
+ return (previous() != NULL) || (successor() != NULL);
+}
+
+
intptr_t GraphEntryInstr::SuccessorCount() const {
return 1 + catch_entries_.length();
}
« no previous file with comments | « vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698