Index: src/arm64/full-codegen-arm64.cc |
diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc |
index 083a8350320c0d495ae696b4a4dd8ddda1f7b8a5..e841c743bf41aa571c5fc60aa7eb289c4267aef9 100644 |
--- a/src/arm64/full-codegen-arm64.cc |
+++ b/src/arm64/full-codegen-arm64.cc |
@@ -2415,23 +2415,6 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
__ Ldr(StoreDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
CallStoreIC(); |
- } else if (op == Token::INIT_CONST_LEGACY) { |
- // Const initializers need a write barrier. |
- DCHECK(!var->IsParameter()); // No const parameters. |
- if (var->IsLookupSlot()) { |
- __ Mov(x1, Operand(var->name())); |
- __ Push(x0, cp, x1); |
- __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); |
- } else { |
- DCHECK(var->IsStackLocal() || var->IsContextSlot()); |
- Label skip; |
- MemOperand location = VarOperand(var, x1); |
- __ Ldr(x10, location); |
- __ JumpIfNotRoot(x10, Heap::kTheHoleValueRootIndex, &skip); |
- EmitStoreToStackLocalOrContextSlot(var, location); |
- __ Bind(&skip); |
- } |
- |
} else if (var->mode() == LET && op != Token::INIT_LET) { |
// Non-initializing assignment to let variable needs a write barrier. |
DCHECK(!var->IsLookupSlot()); |
@@ -2447,6 +2430,20 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
__ Bind(&assign); |
EmitStoreToStackLocalOrContextSlot(var, location); |
+ } else if (var->mode() == CONST && op != Token::INIT_CONST) { |
+ // Assignment to const variable needs a write barrier. |
+ DCHECK(!var->IsLookupSlot()); |
+ DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
+ Label const_error; |
+ MemOperand location = VarOperand(var, x1); |
+ __ Ldr(x10, location); |
+ __ JumpIfNotRoot(x10, Heap::kTheHoleValueRootIndex, &const_error); |
+ __ Mov(x10, Operand(var->name())); |
+ __ Push(x10); |
+ __ CallRuntime(Runtime::kThrowReferenceError, 1); |
+ __ Bind(&const_error); |
+ __ CallRuntime(Runtime::kThrowConstAssignError, 0); |
+ |
} else if (!var->is_const_mode() || op == Token::INIT_CONST) { |
if (var->IsLookupSlot()) { |
// Assignment to var. |
@@ -2470,8 +2467,31 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
} |
EmitStoreToStackLocalOrContextSlot(var, location); |
} |
- } else if (IsSignallingAssignmentToConst(var, op, language_mode())) { |
- __ CallRuntime(Runtime::kThrowConstAssignError, 0); |
+ |
+ } else if (op == Token::INIT_CONST_LEGACY) { |
+ // Const initializers need a write barrier. |
+ DCHECK(var->mode() == CONST_LEGACY); |
+ DCHECK(!var->IsParameter()); // No const parameters. |
+ if (var->IsLookupSlot()) { |
+ __ Mov(x1, Operand(var->name())); |
+ __ Push(x0, cp, x1); |
+ __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); |
+ } else { |
+ DCHECK(var->IsStackLocal() || var->IsContextSlot()); |
+ Label skip; |
+ MemOperand location = VarOperand(var, x1); |
+ __ Ldr(x10, location); |
+ __ JumpIfNotRoot(x10, Heap::kTheHoleValueRootIndex, &skip); |
+ EmitStoreToStackLocalOrContextSlot(var, location); |
+ __ Bind(&skip); |
+ } |
+ |
+ } else { |
+ DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY); |
+ if (is_strict(language_mode())) { |
+ __ CallRuntime(Runtime::kThrowConstAssignError, 0); |
+ } |
+ // Silently ignore store in sloppy mode. |
} |
} |