Revision: 4065 Author: [email protected] Date: Tue Mar 9 02:39:18 2010 Log: Add IsStackAllocated helper for variables.
Add a simple boolean helper function for Variables and Slots. Review URL: http://codereview.chromium.org/722001 http://code.google.com/p/v8/source/detail?r=4065 Modified: /branches/bleeding_edge/src/ast.h /branches/bleeding_edge/src/data-flow.cc /branches/bleeding_edge/src/rewriter.cc /branches/bleeding_edge/src/variables.cc /branches/bleeding_edge/src/variables.h ======================================= --- /branches/bleeding_edge/src/ast.h Mon Mar 8 08:01:40 2010 +++ /branches/bleeding_edge/src/ast.h Tue Mar 9 02:39:18 2010 @@ -1046,6 +1046,8 @@ virtual Slot* AsSlot() { return this; } virtual bool IsLeaf() { return true; } + + bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } // Accessors Variable* var() const { return var_; } ======================================= --- /branches/bleeding_edge/src/data-flow.cc Tue Mar 9 01:56:19 2010 +++ /branches/bleeding_edge/src/data-flow.cc Tue Mar 9 02:39:18 2010 @@ -433,11 +433,7 @@ ASSERT(var == NULL || 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); - } + if (var->IsStackAllocated()) definitions_.Add(expr); } else if (prop != NULL) { Visit(prop->obj()); @@ -499,12 +495,8 @@ 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); - } + if (var != NULL && var->IsStackAllocated()) { + definitions_.Add(expr); } graph_.AppendInstruction(expr); } ======================================= --- /branches/bleeding_edge/src/rewriter.cc Mon Mar 8 07:28:57 2010 +++ /branches/bleeding_edge/src/rewriter.cc Tue Mar 9 02:39:18 2010 @@ -246,11 +246,8 @@ } if (FLAG_safe_int32_compiler) { - Slot* slot = var->slot(); - if (slot != NULL) { - node->set_side_effect_free( - (slot->type() == Slot::LOCAL && !slot->is_arguments()) || - slot->type() == Slot::PARAMETER); + if (var->IsStackAllocated() && !var->is_arguments()) { + node->set_side_effect_free(true); } } } ======================================= --- /branches/bleeding_edge/src/variables.cc Mon Mar 8 05:01:24 2010 +++ /branches/bleeding_edge/src/variables.cc Tue Mar 9 02:39:18 2010 @@ -83,6 +83,12 @@ Slot* Variable::slot() const { return rewrite_ != NULL ? rewrite_->AsSlot() : NULL; } + + +bool Variable::IsStackAllocated() const { + Slot* s = slot(); + return s != NULL && s->IsStackAllocated(); +} Variable::Variable(Scope* scope, ======================================= --- /branches/bleeding_edge/src/variables.h Mon Mar 8 05:01:24 2010 +++ /branches/bleeding_edge/src/variables.h Tue Mar 9 02:39:18 2010 @@ -145,6 +145,8 @@ bool IsVariable(Handle<String> n) const { return !is_this() && name().is_identical_to(n); } + + bool IsStackAllocated() const; bool is_dynamic() const { return (mode_ == DYNAMIC || -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
