Revision: 4064 Author: [email protected] Date: Tue Mar 9 01:56:19 2010 Log: Have the flow graph builder collect definitions.
Before computing reaching definitions, the set of all definitions in a function must be collected and they must be numbered. Have the flow graph builder collect definitions for stack-allocated variables into a list, and implicitly number them with their list index. Review URL: http://codereview.chromium.org/668257 http://code.google.com/p/v8/source/detail?r=4064 Modified: /branches/bleeding_edge/src/data-flow.cc /branches/bleeding_edge/src/data-flow.h ======================================= --- /branches/bleeding_edge/src/data-flow.cc Mon Mar 8 05:04:09 2010 +++ /branches/bleeding_edge/src/data-flow.cc Tue Mar 9 01:56:19 2010 @@ -431,11 +431,17 @@ // Left-hand side can be a variable or property (or reference error) but // not both. ASSERT(var == NULL || prop == NULL); - if (prop != NULL) { + if (var != NULL) { + Visit(expr->value()); + Slot* slot = var->slot(); + if (slot != NULL && + (slot->type() == Slot::LOCAL || slot->type() == Slot::PARAMETER)) { + definitions_.Add(expr); + } + + } else if (prop != NULL) { Visit(prop->obj()); if (!prop->key()->IsPropertyName()) Visit(prop->key()); - } - if (var != NULL || prop != NULL) { Visit(expr->value()); } graph_.AppendInstruction(expr); @@ -492,6 +498,14 @@ void FlowGraphBuilder::VisitCountOperation(CountOperation* expr) { Visit(expr->expression()); + Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); + if (var != NULL) { + Slot* slot = var->slot(); + if (slot != NULL && + (slot->type() == Slot::LOCAL || slot->type() == Slot::PARAMETER)) { + definitions_.Add(expr); + } + } graph_.AppendInstruction(expr); } ======================================= --- /branches/bleeding_edge/src/data-flow.h Tue Mar 9 01:51:37 2010 +++ /branches/bleeding_edge/src/data-flow.h Tue Mar 9 01:56:19 2010 @@ -385,7 +385,12 @@ // traversal orders as a byproduct. class FlowGraphBuilder: public AstVisitor { public: - FlowGraphBuilder() : global_exit_(NULL), preorder_(4), postorder_(4) {} + FlowGraphBuilder() + : global_exit_(NULL), + preorder_(4), + postorder_(4), + definitions_(4) { + } void Build(FunctionLiteral* lit); @@ -406,6 +411,11 @@ ZoneList<Node*> preorder_; ZoneList<Node*> postorder_; + // The flow graph builder collects a list of definitions (assignments and + // count operations) to stack-allocated variables to use for reaching + // definitions analysis. + ZoneList<AstNode*> definitions_; + DISALLOW_COPY_AND_ASSIGN(FlowGraphBuilder); }; -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
