Disable context-allocated const variables.

We intended them to be fully disabled for now, but there was a missing
check at initialization time.

R=fschneider@chromium.org
BUG=
TEST=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8139 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kmillikin@chromium.org 2011-06-01 09:12:22 +00:00
parent 56de6f750a
commit d985af520e

View File

@ -3577,6 +3577,9 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
if (expr->op() != Token::INIT_CONST) { if (expr->op() != Token::INIT_CONST) {
return Bailout("non-initializer assignment to const"); return Bailout("non-initializer assignment to const");
} }
if (!var->IsStackAllocated()) {
return Bailout("assignment to const context slot");
}
// We insert a use of the old value to detect unsupported uses of const // We insert a use of the old value to detect unsupported uses of const
// variables (e.g. initialization inside a loop). // variables (e.g. initialization inside a loop).
HValue* old_value = environment()->Lookup(var); HValue* old_value = environment()->Lookup(var);
@ -3595,7 +3598,8 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
Bind(var, value); Bind(var, value);
ast_context()->ReturnValue(value); ast_context()->ReturnValue(value);
} else if (var->IsContextSlot() && var->mode() != Variable::CONST) { } else if (var->IsContextSlot()) {
ASSERT(var->mode() != Variable::CONST);
CHECK_ALIVE(VisitForValue(expr->value())); CHECK_ALIVE(VisitForValue(expr->value()));
HValue* context = BuildContextChainWalk(var); HValue* context = BuildContextChainWalk(var);
int index = var->AsSlot()->index(); int index = var->AsSlot()->index();
@ -5381,6 +5385,7 @@ void HGraphBuilder::VisitDeclaration(Declaration* decl) {
} }
if (decl->mode() == Variable::CONST) { if (decl->mode() == Variable::CONST) {
ASSERT(var->IsStackAllocated());
environment()->Bind(var, graph()->GetConstantHole()); environment()->Bind(var, graph()->GetConstantHole());
} }
} }