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

Unified Diff: vm/intermediate_language.cc

Issue 10539108: First step to SSA construction: Phi insertion. (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
Index: vm/intermediate_language.cc
===================================================================
--- vm/intermediate_language.cc (revision 8546)
+++ vm/intermediate_language.cc (working copy)
@@ -91,46 +91,113 @@
}
+Value* BranchInstr::InputAt(intptr_t i) const {
srdjan 2012/06/12 17:34:37 An alternative would be ASSERT(i == 0); return val
+ if (i == 0) return value();
+ UNREACHABLE();
+ return NULL;
+}
+
+
intptr_t ReThrowInstr::InputCount() const {
return 2;
}
+Value* ReThrowInstr::InputAt(intptr_t i) const {
+ if (i == 0) return exception();
+ if (i == 1) return stack_trace();
+ UNREACHABLE();
+ return NULL;
+}
+
+
intptr_t ThrowInstr::InputCount() const {
return 1;
}
+Value* ThrowInstr::InputAt(intptr_t i) const {
+ if (i == 0) return exception();
+ UNREACHABLE();
+ return NULL;
+}
+
+
intptr_t ReturnInstr::InputCount() const {
return 1;
}
+Value* ReturnInstr::InputAt(intptr_t i) const {
+ if (i == 0) return value();
+ UNREACHABLE();
+ return NULL;
+}
+
+
intptr_t BindInstr::InputCount() const {
return computation()->InputCount();
}
+Value* BindInstr::InputAt(intptr_t i) const {
+ return computation()->InputAt(i);
+}
+
+
+intptr_t PhiInstr::InputCount() const {
+ return inputs_.length();
+}
+
+
+Value* PhiInstr::InputAt(intptr_t i) const {
+ return inputs_[i];
+}
+
+
intptr_t DoInstr::InputCount() const {
return computation()->InputCount();
}
+Value* DoInstr::InputAt(intptr_t i) const {
+ return computation()->InputAt(i);
+}
+
+
intptr_t GraphEntryInstr::InputCount() const {
return 0;
}
+Value* GraphEntryInstr::InputAt(intptr_t i) const {
+ UNREACHABLE();
+ return NULL;
+}
+
+
intptr_t TargetEntryInstr::InputCount() const {
return 0;
}
+Value* TargetEntryInstr::InputAt(intptr_t i) const {
+ UNREACHABLE();
+ return NULL;
+}
+
+
intptr_t JoinEntryInstr::InputCount() const {
return 0;
}
+Value* JoinEntryInstr::InputAt(intptr_t i) const {
+ UNREACHABLE();
+ return NULL;
+}
+
+
// ==== Recording assigned variables.
void Computation::RecordAssignedVars(BitVector* assigned_vars) {
// Nothing to do for the base class.
@@ -139,7 +206,7 @@
void StoreLocalComp::RecordAssignedVars(BitVector* assigned_vars) {
if (!local().is_captured()) {
- assigned_vars->Add(local().BitIndexIn(assigned_vars));
+ assigned_vars->Add(local().BitIndexIn(assigned_vars->length()));
}
}
@@ -283,6 +350,23 @@
}
+void JoinEntryInstr::InsertPhi(intptr_t var_index, intptr_t var_count) {
+ // Lazily initialize the array of phis.
+ // Currently, phis are stored in a sparse array that holds the phi
+ // for variable with index i at position i.
+ // TODO(fschneider): Store phis in a more compact way.
+ if (phis_ == NULL) {
+ phis_ = new ZoneGrowableArray<PhiInstr*>(var_count);
+ for (intptr_t i = 0; i < var_count; i++) {
+ phis_->Add(NULL);
+ }
+ }
+ ASSERT((*phis_)[var_index] == NULL);
+ (*phis_)[var_index] = new PhiInstr(PredecessorCount());
+ phi_count_++;
+}
+
+
intptr_t Instruction::SuccessorCount() const {
ASSERT(!IsBranch());
ASSERT(!IsGraphEntry());
« vm/intermediate_language.h ('K') | « vm/intermediate_language.h ('k') | vm/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698