Add IsStackAllocated helper for variables.

Add a simple boolean helper function for Variables and Slots.

Review URL: http://codereview.chromium.org/722001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4065 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3c0a0ba1
......@@ -1047,6 +1047,8 @@ class Slot: public Expression {
virtual bool IsLeaf() { return true; }
bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; }
// Accessors
Variable* var() const { return var_; }
Type type() const { return type_; }
......
......@@ -433,11 +433,7 @@ void FlowGraphBuilder::VisitAssignment(Assignment* expr) {
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,13 +495,9 @@ void FlowGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
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)) {
if (var != NULL && var->IsStackAllocated()) {
definitions_.Add(expr);
}
}
graph_.AppendInstruction(expr);
}
......
......@@ -246,11 +246,8 @@ void AstOptimizer::VisitVariableProxy(VariableProxy* node) {
}
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);
}
}
}
......
......@@ -85,6 +85,12 @@ Slot* Variable::slot() const {
}
bool Variable::IsStackAllocated() const {
Slot* s = slot();
return s != NULL && s->IsStackAllocated();
}
Variable::Variable(Scope* scope,
Handle<String> name,
Mode mode,
......
......@@ -146,6 +146,8 @@ class Variable: public ZoneObject {
return !is_this() && name().is_identical_to(n);
}
bool IsStackAllocated() const;
bool is_dynamic() const {
return (mode_ == DYNAMIC ||
mode_ == DYNAMIC_GLOBAL ||
......
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