Ensure environment does not contain nil values.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/436553003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22766 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b7999fd2
...@@ -177,18 +177,14 @@ AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder, ...@@ -177,18 +177,14 @@ AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder,
ASSERT_EQ(scope->num_parameters() + 1, parameters_count()); ASSERT_EQ(scope->num_parameters() + 1, parameters_count());
// Bind the receiver variable. // Bind the receiver variable.
values()->insert(values()->end(), parameters_count(),
static_cast<Node*>(NULL));
Node* receiver = builder->graph()->NewNode(common()->Parameter(0)); Node* receiver = builder->graph()->NewNode(common()->Parameter(0));
Bind(scope->receiver(), receiver); values()->push_back(receiver);
// Bind all parameter variables. The parameter indices are shifted by 1 // Bind all parameter variables. The parameter indices are shifted by 1
// (receiver is parameter index -1 but environment index 0). // (receiver is parameter index -1 but environment index 0).
for (int i = 0; i < scope->num_parameters(); ++i) { for (int i = 0; i < scope->num_parameters(); ++i) {
// Unused parameters are allocated to Variable::UNALLOCATED.
if (!scope->parameter(i)->IsParameter()) continue;
Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1)); Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1));
Bind(scope->parameter(i), parameter); values()->push_back(parameter);
} }
// Bind all local variables to undefined. // Bind all local variables to undefined.
......
...@@ -145,7 +145,6 @@ void StructuredGraphBuilder::Environment::Merge(Environment* other) { ...@@ -145,7 +145,6 @@ void StructuredGraphBuilder::Environment::Merge(Environment* other) {
// Introduce Phi nodes for values that have differing input at merge points, // Introduce Phi nodes for values that have differing input at merge points,
// potentially extending an existing Phi node if possible. // potentially extending an existing Phi node if possible.
for (int i = 0; i < static_cast<int>(values_.size()); ++i) { for (int i = 0; i < static_cast<int>(values_.size()); ++i) {
if (values_[i] == NULL) continue;
values_[i] = builder_->MergeValue(values_[i], other->values_[i], control); values_[i] = builder_->MergeValue(values_[i], other->values_[i], control);
} }
} }
...@@ -154,7 +153,6 @@ void StructuredGraphBuilder::Environment::Merge(Environment* other) { ...@@ -154,7 +153,6 @@ void StructuredGraphBuilder::Environment::Merge(Environment* other) {
void StructuredGraphBuilder::Environment::PrepareForLoop() { void StructuredGraphBuilder::Environment::PrepareForLoop() {
Node* control = GetControlDependency(); Node* control = GetControlDependency();
for (int i = 0; i < static_cast<int>(values()->size()); ++i) { for (int i = 0; i < static_cast<int>(values()->size()); ++i) {
if (values()->at(i) == NULL) continue;
Node* phi = builder_->NewPhi(1, values()->at(i), control); Node* phi = builder_->NewPhi(1, values()->at(i), control);
values()->at(i) = phi; values()->at(i) = phi;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment