Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 619ed89a942807cd3d55f7c5bb450452ea5e2392..91f57f75b0d15bb94e3ad34cb7db901c43c43509 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -1967,11 +1967,15 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable, |
| // Break here because the value should not be stored unconditionally. |
| break; |
| } else if (mode == CONST_LEGACY && op != Token::INIT) { |
| - DCHECK(!is_strict(language_mode())); |
| - // Ensure accumulator is in the correct state. |
| - builder()->LoadAccumulatorWithRegister(value_temp); |
| - // Break here, non-initializing assignments to legacy constants are |
| - // ignored. |
| + if (is_strict(language_mode())) { |
| + builder()->CallRuntime(Runtime::kThrowConstAssignError, Register(), |
| + 0); |
| + } else { |
| + // Ensure accumulator is in the correct state. |
| + builder()->LoadAccumulatorWithRegister(value_temp); |
| + } |
| + // Non-initializing assignments to legacy constants are ignored |
| + // in sloppy mode. Break here to avoid storing into variable. |
| break; |
| } else { |
| BuildHoleCheckForVariableAssignment(variable, op); |
| @@ -2034,11 +2038,15 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable, |
| // The above code performs the store conditionally. |
| break; |
| } else if (mode == CONST_LEGACY && op != Token::INIT) { |
| - DCHECK(!is_strict(language_mode())); |
| - // Ensure accumulator is in the correct state. |
| - builder()->LoadAccumulatorWithRegister(value_temp); |
| - // Break here, non-initializing assignments to legacy constants are |
| - // ignored. |
| + if (is_strict(language_mode())) { |
| + builder()->CallRuntime(Runtime::kThrowConstAssignError, Register(), |
| + 0); |
| + } else { |
| + // Ensure accumulator is in the correct state. |
| + builder()->LoadAccumulatorWithRegister(value_temp); |
| + } |
| + // Non-initializing assignments to legacy constants are ignored |
| + // in sloppy mode. Break hear to avoid storing into variable. |
|
rmcilroy
2016/04/05 08:44:21
/s/hear/here
mythria
2016/04/11 10:10:05
Done.
|
| break; |
| } else { |
| BuildHoleCheckForVariableAssignment(variable, op); |
| @@ -2066,8 +2074,12 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable, |
| .StoreAccumulatorInRegister(name) |
| .CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, value, 3); |
| } else if (mode == CONST_LEGACY && op != Token::INIT) { |
| - // Non-intializing assignments to legacy constants are ignored. |
| - DCHECK(!is_strict(language_mode())); |
| + // Non-intializing assignments to legacy constants are ignored in sloppy |
| + // mode and throws TypeError in strict mode. |
| + if (is_strict(language_mode())) { |
|
Michael Starzinger
2016/04/04 12:02:24
nit: The Runtime_StoreLookupSlot_[Strict|Sloppy] m
mythria
2016/04/11 10:10:05
Done.
|
| + builder()->CallRuntime(Runtime::kThrowConstAssignError, Register(), |
| + 0); |
| + } |
| } else { |
| builder()->StoreLookupSlot(variable->name(), language_mode()); |
| } |