| 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 context()->Plug(r3); | 1411 context()->Plug(r3); |
| 1412 break; | 1412 break; |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 case VariableLocation::PARAMETER: | 1415 case VariableLocation::PARAMETER: |
| 1416 case VariableLocation::LOCAL: | 1416 case VariableLocation::LOCAL: |
| 1417 case VariableLocation::CONTEXT: { | 1417 case VariableLocation::CONTEXT: { |
| 1418 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1418 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
| 1419 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1419 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
| 1420 : "[ Stack variable"); | 1420 : "[ Stack variable"); |
| 1421 if (var->binding_needs_init()) { | 1421 if (NeedsHoleCheckForLoad(proxy)) { |
| 1422 // var->scope() may be NULL when the proxy is located in eval code and | 1422 Label done; |
| 1423 // refers to a potential outside binding. Currently those bindings are | 1423 // Let and const need a read barrier. |
| 1424 // always looked up dynamically, i.e. in that case | 1424 GetVar(r3, var); |
| 1425 // var->location() == LOOKUP. | 1425 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1426 // always holds. | 1426 __ bne(&done); |
| 1427 DCHECK(var->scope() != NULL); | 1427 if (var->mode() == LET || var->mode() == CONST) { |
| 1428 | 1428 // Throw a reference error when using an uninitialized let/const |
| 1429 // Check if the binding really needs an initialization check. The check | 1429 // binding in harmony mode. |
| 1430 // can be skipped in the following situation: we have a LET or CONST | 1430 __ mov(r3, Operand(var->name())); |
| 1431 // binding in harmony mode, both the Variable and the VariableProxy have | 1431 __ push(r3); |
| 1432 // the same declaration scope (i.e. they are both in global code, in the | 1432 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 1433 // same function or in the same eval code) and the VariableProxy is in | |
| 1434 // the source physically located after the initializer of the variable. | |
| 1435 // | |
| 1436 // We cannot skip any initialization checks for CONST in non-harmony | |
| 1437 // mode because const variables may be declared but never initialized: | |
| 1438 // if (false) { const x; }; var y = x; | |
| 1439 // | |
| 1440 // The condition on the declaration scopes is a conservative check for | |
| 1441 // nested functions that access a binding and are called before the | |
| 1442 // binding is initialized: | |
| 1443 // function() { f(); let x = 1; function f() { x = 2; } } | |
| 1444 // | |
| 1445 bool skip_init_check; | |
| 1446 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | |
| 1447 skip_init_check = false; | |
| 1448 } else if (var->is_this()) { | |
| 1449 CHECK(info_->has_literal() && | |
| 1450 (info_->literal()->kind() & kSubclassConstructor) != 0); | |
| 1451 // TODO(dslomov): implement 'this' hole check elimination. | |
| 1452 skip_init_check = false; | |
| 1453 } else { | 1433 } else { |
| 1454 // Check that we always have valid source position. | 1434 // Uninitialized legacy const bindings are unholed. |
| 1455 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1435 DCHECK(var->mode() == CONST_LEGACY); |
| 1456 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1436 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
| 1457 skip_init_check = var->mode() != CONST_LEGACY && | |
| 1458 var->initializer_position() < proxy->position(); | |
| 1459 } | 1437 } |
| 1460 | 1438 __ bind(&done); |
| 1461 if (!skip_init_check) { | 1439 context()->Plug(r3); |
| 1462 Label done; | 1440 break; |
| 1463 // Let and const need a read barrier. | |
| 1464 GetVar(r3, var); | |
| 1465 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | |
| 1466 __ bne(&done); | |
| 1467 if (var->mode() == LET || var->mode() == CONST) { | |
| 1468 // Throw a reference error when using an uninitialized let/const | |
| 1469 // binding in harmony mode. | |
| 1470 __ mov(r3, Operand(var->name())); | |
| 1471 __ push(r3); | |
| 1472 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
| 1473 } else { | |
| 1474 // Uninitalized const bindings outside of harmony mode are unholed. | |
| 1475 DCHECK(var->mode() == CONST_LEGACY); | |
| 1476 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); | |
| 1477 } | |
| 1478 __ bind(&done); | |
| 1479 context()->Plug(r3); | |
| 1480 break; | |
| 1481 } | |
| 1482 } | 1441 } |
| 1483 context()->Plug(var); | 1442 context()->Plug(var); |
| 1484 break; | 1443 break; |
| 1485 } | 1444 } |
| 1486 | 1445 |
| 1487 case VariableLocation::LOOKUP: { | 1446 case VariableLocation::LOOKUP: { |
| 1488 Comment cmnt(masm_, "[ Lookup variable"); | 1447 Comment cmnt(masm_, "[ Lookup variable"); |
| 1489 Label done, slow; | 1448 Label done, slow; |
| 1490 // Generate code for loading from variables potentially shadowed | 1449 // Generate code for loading from variables potentially shadowed |
| 1491 // by eval-introduced variables. | 1450 // by eval-introduced variables. |
| (...skipping 3832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5324 return ON_STACK_REPLACEMENT; | 5283 return ON_STACK_REPLACEMENT; |
| 5325 } | 5284 } |
| 5326 | 5285 |
| 5327 DCHECK(interrupt_address == | 5286 DCHECK(interrupt_address == |
| 5328 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5287 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5329 return OSR_AFTER_STACK_CHECK; | 5288 return OSR_AFTER_STACK_CHECK; |
| 5330 } | 5289 } |
| 5331 } // namespace internal | 5290 } // namespace internal |
| 5332 } // namespace v8 | 5291 } // namespace v8 |
| 5333 #endif // V8_TARGET_ARCH_PPC | 5292 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |