Commit 1722786c authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: Remove CONST_LEGACY VariableMode.

  port 7516fe1e (r39052)

  original commit message:
  The only remaining use of this VariableMode is for the names of sloppy
  named function expressions. This patch instead uses CONST for such
  bindings (just as we do in strict mode) and instead marks those
  Variables specially. During code generation a new helper method,
  Variable::throw_on_const_assignment(), is called to decide whether
  to throw or silently ignore the assignment.

BUG=

Review-Url: https://codereview.chromium.org/2299103002
Cr-Commit-Position: refs/heads/master@{#39059}
parent 081d4870
......@@ -2067,10 +2067,10 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
__ CallRuntime(Runtime::kThrowReferenceError);
__ bind(&assign);
}
if (var->mode() == CONST) {
__ CallRuntime(Runtime::kThrowConstAssignError);
} else {
if (var->mode() != CONST) {
EmitStoreToStackLocalOrContextSlot(var, location);
} else if (var->throw_on_const_assignment(language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError);
}
} else if (var->is_this() && var->mode() == CONST && op == Token::INIT) {
// Initializing assignment to const {this} needs a write barrier.
......@@ -2085,7 +2085,8 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
__ bind(&uninitialized_this);
EmitStoreToStackLocalOrContextSlot(var, location);
} else if (!var->is_const_mode() || op == Token::INIT) {
} else {
DCHECK(var->mode() != CONST || op == Token::INIT);
if (var->IsLookupSlot()) {
// Assignment to var.
__ Push(Immediate(var->name()));
......@@ -2106,13 +2107,6 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
}
EmitStoreToStackLocalOrContextSlot(var, location);
}
} else {
DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
if (is_strict(language_mode())) {
__ CallRuntime(Runtime::kThrowConstAssignError);
}
// Silently ignore store in sloppy mode.
}
}
......
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