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); |