Chromium Code Reviews| Index: src/compiler/ast-graph-builder.cc |
| diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
| index 7d752a81eb7162069ba5cd4be29315853e3e1ea6..19bb873946fa96a67df61225566d6f30bed7c9f7 100644 |
| --- a/src/compiler/ast-graph-builder.cc |
| +++ b/src/compiler/ast-graph-builder.cc |
| @@ -535,7 +535,7 @@ bool AstGraphBuilder::CreateGraph(bool stack_check) { |
| // TODO(mstarzinger): For now we cannot assume that the {this} parameter is |
| // not {the_hole}, because for derived classes {this} has a TDZ and the |
| // JSConstructStubForDerived magically passes {the_hole} as a receiver. |
| - if (scope->has_this_declaration() && scope->receiver()->is_const_mode()) { |
| + if (scope->has_this_declaration() && scope->receiver()->mode() == CONST) { |
| env.RawParameterBind(0, jsgraph()->TheHoleConstant()); |
| } |
| @@ -3439,15 +3439,7 @@ Node* AstGraphBuilder::BuildVariableAssignment( |
| case VariableLocation::PARAMETER: |
| case VariableLocation::LOCAL: |
| // Local var, const, or let variable. |
| - if (mode == CONST_LEGACY && op != Token::INIT) { |
| - // Non-initializing assignment to legacy const is |
| - // - exception in strict mode. |
| - // - ignored in sloppy mode. |
| - if (is_strict(language_mode())) { |
| - return BuildThrowConstAssignError(bailout_id); |
| - } |
| - return value; |
| - } else if (mode == LET && op == Token::INIT) { |
| + if (mode == LET && op == Token::INIT) { |
| // No initialization check needed because scoping guarantees it. Note |
| // that we still perform a lookup to keep the variable live, because |
| // baseline code might contain debug code that inspects the variable. |
| @@ -3472,7 +3464,10 @@ Node* AstGraphBuilder::BuildVariableAssignment( |
| } |
| } |
| if (mode == CONST) { |
| - return BuildThrowConstAssignError(bailout_id); |
| + if (variable->throw_on_const_assignment(language_mode())) { |
|
Toon Verwaest
2016/08/18 07:05:26
What about returning a ShouldThrow flag from throw
adamk
2016/08/18 18:40:18
I'm worried that still runs afoul of making each c
|
| + return BuildThrowConstAssignError(bailout_id); |
| + } |
| + return value; |
| } |
| } |
| environment()->Bind(variable, value); |
| @@ -3480,15 +3475,7 @@ Node* AstGraphBuilder::BuildVariableAssignment( |
| case VariableLocation::CONTEXT: { |
| // Context variable (potentially up the context chain). |
| int depth = current_scope()->ContextChainLength(variable->scope()); |
| - if (mode == CONST_LEGACY && op != Token::INIT) { |
| - // Non-initializing assignment to legacy const is |
| - // - exception in strict mode. |
| - // - ignored in sloppy mode. |
| - if (is_strict(language_mode())) { |
| - return BuildThrowConstAssignError(bailout_id); |
| - } |
| - return value; |
| - } else if (mode == CONST && op == Token::INIT) { |
| + 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 |
| // to trigger bind operations outside the TDZ, via {super} calls. |
| @@ -3507,8 +3494,11 @@ Node* AstGraphBuilder::BuildVariableAssignment( |
| value = BuildHoleCheckThenThrow(current, variable, value, bailout_id); |
| } |
| if (mode == CONST) { |
| - // Assignment to const is exception in all modes. |
| - return BuildThrowConstAssignError(bailout_id); |
| + if (variable->throw_on_const_assignment(language_mode())) { |
| + return BuildThrowConstAssignError(bailout_id); |
| + } else { |
| + return value; |
| + } |
| } |
| } |
| const Operator* op = javascript()->StoreContext(depth, variable->index()); |