| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 context()->Plug(r0); | 1447 context()->Plug(r0); |
| 1448 break; | 1448 break; |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 case VariableLocation::PARAMETER: | 1451 case VariableLocation::PARAMETER: |
| 1452 case VariableLocation::LOCAL: | 1452 case VariableLocation::LOCAL: |
| 1453 case VariableLocation::CONTEXT: { | 1453 case VariableLocation::CONTEXT: { |
| 1454 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1454 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
| 1455 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1455 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
| 1456 : "[ Stack variable"); | 1456 : "[ Stack variable"); |
| 1457 if (var->binding_needs_init()) { | 1457 if (NeedsHoleCheckForLoad(proxy)) { |
| 1458 // var->scope() may be NULL when the proxy is located in eval code and | 1458 // Let and const need a read barrier. |
| 1459 // refers to a potential outside binding. Currently those bindings are | 1459 GetVar(r0, var); |
| 1460 // always looked up dynamically, i.e. in that case | 1460 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
| 1461 // var->location() == LOOKUP. | 1461 if (var->mode() == LET || var->mode() == CONST) { |
| 1462 // always holds. | 1462 // Throw a reference error when using an uninitialized let/const |
| 1463 DCHECK(var->scope() != NULL); | 1463 // binding in harmony mode. |
| 1464 | 1464 Label done; |
| 1465 // Check if the binding really needs an initialization check. The check | 1465 __ b(ne, &done); |
| 1466 // can be skipped in the following situation: we have a LET or CONST | 1466 __ mov(r0, Operand(var->name())); |
| 1467 // binding in harmony mode, both the Variable and the VariableProxy have | 1467 __ push(r0); |
| 1468 // the same declaration scope (i.e. they are both in global code, in the | 1468 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 1469 // same function or in the same eval code) and the VariableProxy is in | 1469 __ bind(&done); |
| 1470 // the source physically located after the initializer of the variable. | |
| 1471 // | |
| 1472 // We cannot skip any initialization checks for CONST in non-harmony | |
| 1473 // mode because const variables may be declared but never initialized: | |
| 1474 // if (false) { const x; }; var y = x; | |
| 1475 // | |
| 1476 // The condition on the declaration scopes is a conservative check for | |
| 1477 // nested functions that access a binding and are called before the | |
| 1478 // binding is initialized: | |
| 1479 // function() { f(); let x = 1; function f() { x = 2; } } | |
| 1480 // | |
| 1481 bool skip_init_check; | |
| 1482 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | |
| 1483 skip_init_check = false; | |
| 1484 } else if (var->is_this()) { | |
| 1485 CHECK(info_->has_literal() && | |
| 1486 (info_->literal()->kind() & kSubclassConstructor) != 0); | |
| 1487 // TODO(dslomov): implement 'this' hole check elimination. | |
| 1488 skip_init_check = false; | |
| 1489 } else { | 1470 } else { |
| 1490 // Check that we always have valid source position. | 1471 // Uninitialized legacy const bindings are unholed. |
| 1491 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1472 DCHECK(var->mode() == CONST_LEGACY); |
| 1492 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1473 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); |
| 1493 skip_init_check = var->mode() != CONST_LEGACY && | |
| 1494 var->initializer_position() < proxy->position(); | |
| 1495 } | 1474 } |
| 1496 | 1475 context()->Plug(r0); |
| 1497 if (!skip_init_check) { | 1476 break; |
| 1498 // Let and const need a read barrier. | |
| 1499 GetVar(r0, var); | |
| 1500 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | |
| 1501 if (var->mode() == LET || var->mode() == CONST) { | |
| 1502 // Throw a reference error when using an uninitialized let/const | |
| 1503 // binding in harmony mode. | |
| 1504 Label done; | |
| 1505 __ b(ne, &done); | |
| 1506 __ mov(r0, Operand(var->name())); | |
| 1507 __ push(r0); | |
| 1508 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
| 1509 __ bind(&done); | |
| 1510 } else { | |
| 1511 // Uninitalized const bindings outside of harmony mode are unholed. | |
| 1512 DCHECK(var->mode() == CONST_LEGACY); | |
| 1513 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | |
| 1514 } | |
| 1515 context()->Plug(r0); | |
| 1516 break; | |
| 1517 } | |
| 1518 } | 1477 } |
| 1519 context()->Plug(var); | 1478 context()->Plug(var); |
| 1520 break; | 1479 break; |
| 1521 } | 1480 } |
| 1522 | 1481 |
| 1523 case VariableLocation::LOOKUP: { | 1482 case VariableLocation::LOOKUP: { |
| 1524 Comment cmnt(masm_, "[ Lookup variable"); | 1483 Comment cmnt(masm_, "[ Lookup variable"); |
| 1525 Label done, slow; | 1484 Label done, slow; |
| 1526 // Generate code for loading from variables potentially shadowed | 1485 // Generate code for loading from variables potentially shadowed |
| 1527 // by eval-introduced variables. | 1486 // by eval-introduced variables. |
| (...skipping 3849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5377 DCHECK(interrupt_address == | 5336 DCHECK(interrupt_address == |
| 5378 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5337 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5379 return OSR_AFTER_STACK_CHECK; | 5338 return OSR_AFTER_STACK_CHECK; |
| 5380 } | 5339 } |
| 5381 | 5340 |
| 5382 | 5341 |
| 5383 } // namespace internal | 5342 } // namespace internal |
| 5384 } // namespace v8 | 5343 } // namespace v8 |
| 5385 | 5344 |
| 5386 #endif // V8_TARGET_ARCH_ARM | 5345 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |