Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1845223006: [Interpreter] Handles legacy constants in strict mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed nits. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | test/mjsunit/regress/regress-599068-func-bindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 619ed89a942807cd3d55f7c5bb450452ea5e2392..38167f43f6e1dfed79db3c27bbc1ae2065cd154a 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 here to avoid storing into variable.
break;
} else {
BuildHoleCheckForVariableAssignment(variable, op);
@@ -2065,9 +2073,6 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable,
.LoadLiteral(variable->name())
.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()));
} else {
builder()->StoreLookupSlot(variable->name(), language_mode());
}
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | test/mjsunit/regress/regress-599068-func-bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698