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
virtual bool IsLeaf() { return true; }
+ bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; }
+
// Accessors
Variable* var() const { return var_; }
Type type() const { return type_; }
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());
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);
}
}
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);
}
}
}
}
+bool Variable::IsStackAllocated() const {
+ Slot* s = slot();
+ return s != NULL && s->IsStackAllocated();
+}
+
+
Variable::Variable(Scope* scope,
Handle<String> name,
Mode mode,
return !is_this() && name().is_identical_to(n);
}
+ bool IsStackAllocated() const;
+
bool is_dynamic() const {
return (mode_ == DYNAMIC ||
mode_ == DYNAMIC_GLOBAL ||