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 { ...@@ -1047,6 +1047,8 @@ class Slot: public Expression {
virtual bool IsLeaf() { return true; } virtual bool IsLeaf() { return true; }
bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; }
// Accessors // Accessors
Variable* var() const { return var_; } Variable* var() const { return var_; }
Type type() const { return type_; } Type type() const { return type_; }
......
...@@ -433,11 +433,7 @@ void FlowGraphBuilder::VisitAssignment(Assignment* expr) { ...@@ -433,11 +433,7 @@ void FlowGraphBuilder::VisitAssignment(Assignment* expr) {
ASSERT(var == NULL || prop == NULL); ASSERT(var == NULL || prop == NULL);
if (var != NULL) { if (var != NULL) {
Visit(expr->value()); Visit(expr->value());
Slot* slot = var->slot(); if (var->IsStackAllocated()) definitions_.Add(expr);
if (slot != NULL &&
(slot->type() == Slot::LOCAL || slot->type() == Slot::PARAMETER)) {
definitions_.Add(expr);
}
} else if (prop != NULL) { } else if (prop != NULL) {
Visit(prop->obj()); Visit(prop->obj());
...@@ -499,12 +495,8 @@ void FlowGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { ...@@ -499,12 +495,8 @@ void FlowGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
void FlowGraphBuilder::VisitCountOperation(CountOperation* expr) { void FlowGraphBuilder::VisitCountOperation(CountOperation* expr) {
Visit(expr->expression()); Visit(expr->expression());
Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
if (var != NULL) { if (var != NULL && var->IsStackAllocated()) {
Slot* slot = var->slot(); definitions_.Add(expr);
if (slot != NULL &&
(slot->type() == Slot::LOCAL || slot->type() == Slot::PARAMETER)) {
definitions_.Add(expr);
}
} }
graph_.AppendInstruction(expr); graph_.AppendInstruction(expr);
} }
......
...@@ -246,11 +246,8 @@ void AstOptimizer::VisitVariableProxy(VariableProxy* node) { ...@@ -246,11 +246,8 @@ void AstOptimizer::VisitVariableProxy(VariableProxy* node) {
} }
if (FLAG_safe_int32_compiler) { if (FLAG_safe_int32_compiler) {
Slot* slot = var->slot(); if (var->IsStackAllocated() && !var->is_arguments()) {
if (slot != NULL) { node->set_side_effect_free(true);
node->set_side_effect_free(
(slot->type() == Slot::LOCAL && !slot->is_arguments()) ||
slot->type() == Slot::PARAMETER);
} }
} }
} }
......
...@@ -85,6 +85,12 @@ Slot* Variable::slot() const { ...@@ -85,6 +85,12 @@ Slot* Variable::slot() const {
} }
bool Variable::IsStackAllocated() const {
Slot* s = slot();
return s != NULL && s->IsStackAllocated();
}
Variable::Variable(Scope* scope, Variable::Variable(Scope* scope,
Handle<String> name, Handle<String> name,
Mode mode, Mode mode,
......
...@@ -146,6 +146,8 @@ class Variable: public ZoneObject { ...@@ -146,6 +146,8 @@ class Variable: public ZoneObject {
return !is_this() && name().is_identical_to(n); return !is_this() && name().is_identical_to(n);
} }
bool IsStackAllocated() const;
bool is_dynamic() const { bool is_dynamic() const {
return (mode_ == DYNAMIC || return (mode_ == DYNAMIC ||
mode_ == DYNAMIC_GLOBAL || 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