| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
| (...skipping 3487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3498 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) { | 3498 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) { |
| 3499 // Non-initializing assignment to legacy const is | 3499 // Non-initializing assignment to legacy const is |
| 3500 // - exception in strict mode. | 3500 // - exception in strict mode. |
| 3501 // - ignored in sloppy mode. | 3501 // - ignored in sloppy mode. |
| 3502 if (is_strict(language_mode())) { | 3502 if (is_strict(language_mode())) { |
| 3503 return BuildThrowConstAssignError(bailout_id); | 3503 return BuildThrowConstAssignError(bailout_id); |
| 3504 } | 3504 } |
| 3505 return value; | 3505 return value; |
| 3506 } else if (mode == LET && op != Token::INIT_LET) { | 3506 } else if (mode == LET && op != Token::INIT_LET) { |
| 3507 // Perform an initialization check for let declared variables. | 3507 // Perform an initialization check for let declared variables. |
| 3508 // Also note that the dynamic hole-check is only done to ensure that | |
| 3509 // this does not break in the presence of do-expressions within the | |
| 3510 // temporal dead zone of a let declared variable. | |
| 3511 Node* current = environment()->Lookup(variable); | 3508 Node* current = environment()->Lookup(variable); |
| 3512 if (current->op() == the_hole->op()) { | 3509 if (current->op() == the_hole->op()) { |
| 3513 value = BuildThrowReferenceError(variable, bailout_id); | 3510 value = BuildThrowReferenceError(variable, bailout_id); |
| 3514 } else if (value->opcode() == IrOpcode::kPhi) { | 3511 } else if (current->opcode() == IrOpcode::kPhi) { |
| 3515 value = BuildHoleCheckThenThrow(current, variable, value, bailout_id); | 3512 value = BuildHoleCheckThenThrow(current, variable, value, bailout_id); |
| 3516 } | 3513 } |
| 3517 } else if (mode == CONST && op == Token::INIT_CONST) { | 3514 } else if (mode == CONST && op == Token::INIT_CONST) { |
| 3518 // Perform an initialization check for const {this} variables. | 3515 // Perform an initialization check for const {this} variables. |
| 3519 // Note that the {this} variable is the only const variable being able | 3516 // Note that the {this} variable is the only const variable being able |
| 3520 // to trigger bind operations outside the TDZ, via {super} calls. | 3517 // to trigger bind operations outside the TDZ, via {super} calls. |
| 3521 Node* current = environment()->Lookup(variable); | 3518 Node* current = environment()->Lookup(variable); |
| 3522 if (current->op() != the_hole->op() && variable->is_this()) { | 3519 if (current->op() != the_hole->op() && variable->is_this()) { |
| 3523 value = BuildHoleCheckElseThrow(current, variable, value, bailout_id); | 3520 value = BuildHoleCheckElseThrow(current, variable, value, bailout_id); |
| 3524 } | 3521 } |
| 3525 } else if (mode == CONST && op != Token::INIT_CONST) { | 3522 } else if (mode == CONST && op != Token::INIT_CONST) { |
| 3526 // Assignment to const is exception in all modes. | 3523 // Assignment to const is exception in all modes. |
| 3527 Node* current = environment()->Lookup(variable); | 3524 Node* current = environment()->Lookup(variable); |
| 3528 if (current->op() == the_hole->op()) { | 3525 if (current->op() == the_hole->op()) { |
| 3529 return BuildThrowReferenceError(variable, bailout_id); | 3526 return BuildThrowReferenceError(variable, bailout_id); |
| 3530 } else if (value->opcode() == IrOpcode::kPhi) { | 3527 } else if (current->opcode() == IrOpcode::kPhi) { |
| 3531 BuildHoleCheckThenThrow(current, variable, value, bailout_id); | 3528 BuildHoleCheckThenThrow(current, variable, value, bailout_id); |
| 3532 } | 3529 } |
| 3533 return BuildThrowConstAssignError(bailout_id); | 3530 return BuildThrowConstAssignError(bailout_id); |
| 3534 } | 3531 } |
| 3535 environment()->Bind(variable, value); | 3532 environment()->Bind(variable, value); |
| 3536 return value; | 3533 return value; |
| 3537 case VariableLocation::CONTEXT: { | 3534 case VariableLocation::CONTEXT: { |
| 3538 // Context variable (potentially up the context chain). | 3535 // Context variable (potentially up the context chain). |
| 3539 int depth = current_scope()->ContextChainLength(variable->scope()); | 3536 int depth = current_scope()->ContextChainLength(variable->scope()); |
| 3540 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { | 3537 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4300 // Phi does not exist yet, introduce one. | 4297 // Phi does not exist yet, introduce one. |
| 4301 value = NewPhi(inputs, value, control); | 4298 value = NewPhi(inputs, value, control); |
| 4302 value->ReplaceInput(inputs - 1, other); | 4299 value->ReplaceInput(inputs - 1, other); |
| 4303 } | 4300 } |
| 4304 return value; | 4301 return value; |
| 4305 } | 4302 } |
| 4306 | 4303 |
| 4307 } // namespace compiler | 4304 } // namespace compiler |
| 4308 } // namespace internal | 4305 } // namespace internal |
| 4309 } // namespace v8 | 4306 } // namespace v8 |
| OLD | NEW |