Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: src/full-codegen/mips64/full-codegen-mips64.cc

Issue 1312613003: Ensure hole checks take place in switch statement scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename function and add sloppy mode tests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 context()->Plug(v0); 1441 context()->Plug(v0);
1442 break; 1442 break;
1443 } 1443 }
1444 1444
1445 case VariableLocation::PARAMETER: 1445 case VariableLocation::PARAMETER:
1446 case VariableLocation::LOCAL: 1446 case VariableLocation::LOCAL:
1447 case VariableLocation::CONTEXT: { 1447 case VariableLocation::CONTEXT: {
1448 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); 1448 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1449 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" 1449 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
1450 : "[ Stack variable"); 1450 : "[ Stack variable");
1451 if (var->binding_needs_init()) { 1451 if (NeedsHoleCheckForLoad(proxy)) {
1452 // var->scope() may be NULL when the proxy is located in eval code and 1452 // Let and const need a read barrier.
1453 // refers to a potential outside binding. Currently those bindings are 1453 GetVar(v0, var);
1454 // always looked up dynamically, i.e. in that case 1454 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1455 // var->location() == LOOKUP. 1455 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq.
1456 // always holds. 1456 if (var->mode() == LET || var->mode() == CONST) {
1457 DCHECK(var->scope() != NULL); 1457 // Throw a reference error when using an uninitialized let/const
1458 1458 // binding in harmony mode.
1459 // Check if the binding really needs an initialization check. The check 1459 Label done;
1460 // can be skipped in the following situation: we have a LET or CONST 1460 __ Branch(&done, ne, at, Operand(zero_reg));
1461 // binding in harmony mode, both the Variable and the VariableProxy have 1461 __ li(a0, Operand(var->name()));
1462 // the same declaration scope (i.e. they are both in global code, in the 1462 __ push(a0);
1463 // same function or in the same eval code) and the VariableProxy is in 1463 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1464 // the source physically located after the initializer of the variable. 1464 __ bind(&done);
1465 //
1466 // We cannot skip any initialization checks for CONST in non-harmony
1467 // mode because const variables may be declared but never initialized:
1468 // if (false) { const x; }; var y = x;
1469 //
1470 // The condition on the declaration scopes is a conservative check for
1471 // nested functions that access a binding and are called before the
1472 // binding is initialized:
1473 // function() { f(); let x = 1; function f() { x = 2; } }
1474 //
1475 bool skip_init_check;
1476 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) {
1477 skip_init_check = false;
1478 } else if (var->is_this()) {
1479 CHECK(info_->has_literal() &&
1480 (info_->literal()->kind() & kSubclassConstructor) != 0);
1481 // TODO(dslomov): implement 'this' hole check elimination.
1482 skip_init_check = false;
1483 } else { 1465 } else {
1484 // Check that we always have valid source position. 1466 // Uninitialized legacy const bindings are unholed.
1485 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); 1467 DCHECK(var->mode() == CONST_LEGACY);
1486 DCHECK(proxy->position() != RelocInfo::kNoPosition); 1468 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1487 skip_init_check = var->mode() != CONST_LEGACY && 1469 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole.
1488 var->initializer_position() < proxy->position();
1489 } 1470 }
1490 1471 context()->Plug(v0);
1491 if (!skip_init_check) { 1472 break;
1492 // Let and const need a read barrier.
1493 GetVar(v0, var);
1494 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1495 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq.
1496 if (var->mode() == LET || var->mode() == CONST) {
1497 // Throw a reference error when using an uninitialized let/const
1498 // binding in harmony mode.
1499 Label done;
1500 __ Branch(&done, ne, at, Operand(zero_reg));
1501 __ li(a0, Operand(var->name()));
1502 __ push(a0);
1503 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1504 __ bind(&done);
1505 } else {
1506 // Uninitalized const bindings outside of harmony mode are unholed.
1507 DCHECK(var->mode() == CONST_LEGACY);
1508 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1509 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole.
1510 }
1511 context()->Plug(v0);
1512 break;
1513 }
1514 } 1473 }
1515 context()->Plug(var); 1474 context()->Plug(var);
1516 break; 1475 break;
1517 } 1476 }
1518 1477
1519 case VariableLocation::LOOKUP: { 1478 case VariableLocation::LOOKUP: {
1520 Comment cmnt(masm_, "[ Lookup variable"); 1479 Comment cmnt(masm_, "[ Lookup variable");
1521 Label done, slow; 1480 Label done, slow;
1522 // Generate code for loading from variables potentially shadowed 1481 // Generate code for loading from variables potentially shadowed
1523 // by eval-introduced variables. 1482 // by eval-introduced variables.
(...skipping 3826 matching lines...) Expand 10 before | Expand all | Expand 10 after
5350 reinterpret_cast<uint64_t>( 5309 reinterpret_cast<uint64_t>(
5351 isolate->builtins()->OsrAfterStackCheck()->entry())); 5310 isolate->builtins()->OsrAfterStackCheck()->entry()));
5352 return OSR_AFTER_STACK_CHECK; 5311 return OSR_AFTER_STACK_CHECK;
5353 } 5312 }
5354 5313
5355 5314
5356 } // namespace internal 5315 } // namespace internal
5357 } // namespace v8 5316 } // namespace v8
5358 5317
5359 #endif // V8_TARGET_ARCH_MIPS64 5318 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698