OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 break; | 1434 break; |
1435 } | 1435 } |
1436 | 1436 |
1437 case VariableLocation::PARAMETER: | 1437 case VariableLocation::PARAMETER: |
1438 case VariableLocation::LOCAL: | 1438 case VariableLocation::LOCAL: |
1439 case VariableLocation::CONTEXT: { | 1439 case VariableLocation::CONTEXT: { |
1440 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1440 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
1441 Comment cmnt(masm_, var->IsContextSlot() | 1441 Comment cmnt(masm_, var->IsContextSlot() |
1442 ? "Context variable" | 1442 ? "Context variable" |
1443 : "Stack variable"); | 1443 : "Stack variable"); |
1444 if (var->binding_needs_init()) { | 1444 if (NeedsHoleCheckForLoad(proxy)) { |
1445 // var->scope() may be NULL when the proxy is located in eval code and | 1445 // Let and const need a read barrier. |
1446 // refers to a potential outside binding. Currently those bindings are | 1446 GetVar(x0, var); |
1447 // always looked up dynamically, i.e. in that case | 1447 Label done; |
1448 // var->location() == LOOKUP. | 1448 __ JumpIfNotRoot(x0, Heap::kTheHoleValueRootIndex, &done); |
1449 // always holds. | 1449 if (var->mode() == LET || var->mode() == CONST) { |
1450 DCHECK(var->scope() != NULL); | 1450 // Throw a reference error when using an uninitialized let/const |
1451 | 1451 // binding in harmony mode. |
1452 // Check if the binding really needs an initialization check. The check | 1452 __ Mov(x0, Operand(var->name())); |
1453 // can be skipped in the following situation: we have a LET or CONST | 1453 __ Push(x0); |
1454 // binding in harmony mode, both the Variable and the VariableProxy have | 1454 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
1455 // the same declaration scope (i.e. they are both in global code, in the | 1455 __ Bind(&done); |
1456 // same function or in the same eval code) and the VariableProxy is in | |
1457 // the source physically located after the initializer of the variable. | |
1458 // | |
1459 // We cannot skip any initialization checks for CONST in non-harmony | |
1460 // mode because const variables may be declared but never initialized: | |
1461 // if (false) { const x; }; var y = x; | |
1462 // | |
1463 // The condition on the declaration scopes is a conservative check for | |
1464 // nested functions that access a binding and are called before the | |
1465 // binding is initialized: | |
1466 // function() { f(); let x = 1; function f() { x = 2; } } | |
1467 // | |
1468 bool skip_init_check; | |
1469 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | |
1470 skip_init_check = false; | |
1471 } else if (var->is_this()) { | |
1472 CHECK(info_->has_literal() && | |
1473 (info_->literal()->kind() & kSubclassConstructor) != 0); | |
1474 // TODO(dslomov): implement 'this' hole check elimination. | |
1475 skip_init_check = false; | |
1476 } else { | 1456 } else { |
1477 // Check that we always have valid source position. | 1457 // Uninitialized legacy const bindings are unholed. |
1478 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1458 DCHECK(var->mode() == CONST_LEGACY); |
1479 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1459 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); |
1480 skip_init_check = var->mode() != CONST_LEGACY && | 1460 __ Bind(&done); |
1481 var->initializer_position() < proxy->position(); | |
1482 } | 1461 } |
1483 | 1462 context()->Plug(x0); |
1484 if (!skip_init_check) { | 1463 break; |
1485 // Let and const need a read barrier. | |
1486 GetVar(x0, var); | |
1487 Label done; | |
1488 __ JumpIfNotRoot(x0, Heap::kTheHoleValueRootIndex, &done); | |
1489 if (var->mode() == LET || var->mode() == CONST) { | |
1490 // Throw a reference error when using an uninitialized let/const | |
1491 // binding in harmony mode. | |
1492 __ Mov(x0, Operand(var->name())); | |
1493 __ Push(x0); | |
1494 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
1495 __ Bind(&done); | |
1496 } else { | |
1497 // Uninitalized const bindings outside of harmony mode are unholed. | |
1498 DCHECK(var->mode() == CONST_LEGACY); | |
1499 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); | |
1500 __ Bind(&done); | |
1501 } | |
1502 context()->Plug(x0); | |
1503 break; | |
1504 } | |
1505 } | 1464 } |
1506 context()->Plug(var); | 1465 context()->Plug(var); |
1507 break; | 1466 break; |
1508 } | 1467 } |
1509 | 1468 |
1510 case VariableLocation::LOOKUP: { | 1469 case VariableLocation::LOOKUP: { |
1511 Label done, slow; | 1470 Label done, slow; |
1512 // Generate code for loading from variables potentially shadowed by | 1471 // Generate code for loading from variables potentially shadowed by |
1513 // eval-introduced variables. | 1472 // eval-introduced variables. |
1514 EmitDynamicLookupFastCase(proxy, typeof_mode, &slow, &done); | 1473 EmitDynamicLookupFastCase(proxy, typeof_mode, &slow, &done); |
(...skipping 3852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 } | 5326 } |
5368 | 5327 |
5369 return INTERRUPT; | 5328 return INTERRUPT; |
5370 } | 5329 } |
5371 | 5330 |
5372 | 5331 |
5373 } // namespace internal | 5332 } // namespace internal |
5374 } // namespace v8 | 5333 } // namespace v8 |
5375 | 5334 |
5376 #endif // V8_TARGET_ARCH_ARM64 | 5335 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |