Commit b94e9d88 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: Remove all non-function-name uses of CONST_LEGACY.

  port 59546149 (r35632)

  original commit message:
  Now that all 'const' declarations are of the ES2015 variety, the only
  use of CONST_LEGACY is for function name bindings in sloppy mode
  named function expressions.

  This patch aims to delete all code meant to handle other cases, which
  mostly had to do with hole initialization/hole checks. Since function
  name bindings are initialized at entry to a function, it's impossible
  to ever observe one in an uninitialized state.

  To simplify the patch further, it removes the `IMPORT` VariableMode,
  as it's not likely to be needed (IMPORT is identical to CONST for
  the purpose of VariableMode).

BUG=

Review URL: https://codereview.chromium.org/1902943003

Cr-Commit-Position: refs/heads/master@{#35641}
parent c14c1b9d
......@@ -705,7 +705,7 @@ void FullCodeGenerator::VisitVariableDeclaration(
VariableProxy* proxy = declaration->proxy();
VariableMode mode = declaration->mode();
Variable* variable = proxy->var();
bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY;
bool hole_init = mode == LET || mode == CONST;
switch (variable->location()) {
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED:
......@@ -1199,16 +1199,11 @@ void FullCodeGenerator::EmitDynamicLookupFastCase(VariableProxy* proxy,
} else if (var->mode() == DYNAMIC_LOCAL) {
Variable* local = var->local_if_not_shadowed();
__ mov(eax, ContextSlotOperandCheckExtensions(local, slow));
if (local->mode() == LET || local->mode() == CONST ||
local->mode() == CONST_LEGACY) {
if (local->mode() == LET || local->mode() == CONST) {
__ cmp(eax, isolate()->factory()->the_hole_value());
__ j(not_equal, done);
if (local->mode() == CONST_LEGACY) {
__ mov(eax, isolate()->factory()->undefined_value());
} else { // LET || CONST
__ push(Immediate(var->name()));
__ CallRuntime(Runtime::kThrowReferenceError);
}
__ push(Immediate(var->name()));
__ CallRuntime(Runtime::kThrowReferenceError);
}
__ jmp(done);
}
......@@ -1266,10 +1261,6 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy,
// binding in harmony mode.
__ push(Immediate(var->name()));
__ CallRuntime(Runtime::kThrowReferenceError);
} else {
// Uninitialized legacy const bindings are unholed.
DCHECK(var->mode() == CONST_LEGACY);
__ mov(eax, isolate()->factory()->undefined_value());
}
__ bind(&done);
context()->Plug(eax);
......@@ -2135,8 +2126,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
__ bind(&uninitialized_this);
EmitStoreToStackLocalOrContextSlot(var, location);
} else if (!var->is_const_mode() ||
(var->mode() == CONST && op == Token::INIT)) {
} else if (!var->is_const_mode() || op == Token::INIT) {
if (var->IsLookupSlot()) {
// Assignment to var.
__ Push(Immediate(var->name()));
......@@ -2158,25 +2148,6 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
EmitStoreToStackLocalOrContextSlot(var, location);
}
} else if (var->mode() == CONST_LEGACY && op == Token::INIT) {
// Const initializers need a write barrier.
DCHECK(!var->IsParameter()); // No const parameters.
if (var->IsLookupSlot()) {
__ push(eax);
__ push(esi);
__ push(Immediate(var->name()));
__ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot);
} else {
DCHECK(var->IsStackLocal() || var->IsContextSlot());
Label skip;
MemOperand location = VarOperand(var, ecx);
__ mov(edx, location);
__ cmp(edx, isolate()->factory()->the_hole_value());
__ j(not_equal, &skip, Label::kNear);
EmitStoreToStackLocalOrContextSlot(var, location);
__ bind(&skip);
}
} else {
DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
if (is_strict(language_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