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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 2237933002: [turbofan] Re-separate logic for LET and CONST in BuildVariableAssignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index d72313e23baf3460a3dae9599d2a71195a74fd74..55457bec9cb99fd469da74ec708379214ddb74e7 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -3453,6 +3453,15 @@ Node* AstGraphBuilder::BuildVariableAssignment(
// baseline code might contain debug code that inspects the variable.
Node* current = environment()->Lookup(variable);
CHECK_NOT_NULL(current);
+ } else if (mode == LET && op != Token::INIT &&
+ variable->binding_needs_init()) {
+ // Perform an initialization check for let declared variables.
+ Node* current = environment()->Lookup(variable);
+ if (current->op() == the_hole->op()) {
+ return BuildThrowReferenceError(variable, bailout_id);
+ } else if (current->opcode() == IrOpcode::kPhi) {
+ BuildHoleCheckThenThrow(current, variable, value, bailout_id);
+ }
} else if (mode == CONST && op == Token::INIT) {
// Perform an initialization check for const {this} variables.
// Note that the {this} variable is the only const variable being able
@@ -3461,19 +3470,17 @@ Node* AstGraphBuilder::BuildVariableAssignment(
if (current->op() != the_hole->op() && variable->is_this()) {
value = BuildHoleCheckElseThrow(current, variable, value, bailout_id);
}
- } else if (IsLexicalVariableMode(mode) && op != Token::INIT) {
- // Perform an initialization check for lexically declared variables.
- Node* current = environment()->Lookup(variable);
+ } else if (mode == CONST && op != Token::INIT) {
if (variable->binding_needs_init()) {
+ Node* current = environment()->Lookup(variable);
if (current->op() == the_hole->op()) {
return BuildThrowReferenceError(variable, bailout_id);
} else if (current->opcode() == IrOpcode::kPhi) {
BuildHoleCheckThenThrow(current, variable, value, bailout_id);
}
}
- if (mode == CONST) {
- return BuildThrowConstAssignError(bailout_id);
- }
+ // Assignment to const is exception in all modes.
+ return BuildThrowConstAssignError(bailout_id);
}
environment()->Bind(variable, value);
return value;
@@ -3488,6 +3495,13 @@ Node* AstGraphBuilder::BuildVariableAssignment(
return BuildThrowConstAssignError(bailout_id);
}
return value;
+ } else if (mode == LET && op != Token::INIT &&
+ variable->binding_needs_init()) {
+ // Perform an initialization check for let declared variables.
+ const Operator* op =
+ javascript()->LoadContext(depth, variable->index(), false);
+ Node* current = NewNode(op, current_context());
+ value = BuildHoleCheckThenThrow(current, variable, value, bailout_id);
} else if (mode == CONST && op == Token::INIT) {
// Perform an initialization check for const {this} variables.
// Note that the {this} variable is the only const variable being able
@@ -3498,18 +3512,15 @@ Node* AstGraphBuilder::BuildVariableAssignment(
Node* current = NewNode(op, current_context());
value = BuildHoleCheckElseThrow(current, variable, value, bailout_id);
}
- } else if (IsLexicalVariableMode(mode) && op != Token::INIT) {
- // Perform an initialization check for lexically declared variables.
+ } else if (mode == CONST && op != Token::INIT) {
if (variable->binding_needs_init()) {
const Operator* op =
javascript()->LoadContext(depth, variable->index(), false);
Node* current = NewNode(op, current_context());
- value = BuildHoleCheckThenThrow(current, variable, value, bailout_id);
- }
- if (mode == CONST) {
- // Assignment to const is exception in all modes.
- return BuildThrowConstAssignError(bailout_id);
+ BuildHoleCheckThenThrow(current, variable, value, bailout_id);
}
+ // Assignment to const is exception in all modes.
+ return BuildThrowConstAssignError(bailout_id);
}
const Operator* op = javascript()->StoreContext(depth, variable->index());
return NewNode(op, current_context(), value);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698