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

Side by Side Diff: src/full-codegen/mips/full-codegen-mips.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
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_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 context()->Plug(v0); 1444 context()->Plug(v0);
1445 break; 1445 break;
1446 } 1446 }
1447 1447
1448 case VariableLocation::PARAMETER: 1448 case VariableLocation::PARAMETER:
1449 case VariableLocation::LOCAL: 1449 case VariableLocation::LOCAL:
1450 case VariableLocation::CONTEXT: { 1450 case VariableLocation::CONTEXT: {
1451 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); 1451 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1452 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" 1452 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
1453 : "[ Stack variable"); 1453 : "[ Stack variable");
1454 if (var->binding_needs_init()) { 1454 if (NeedsHoleCheckForLoad(proxy)) {
1455 // var->scope() may be NULL when the proxy is located in eval code and 1455 // Let and const need a read barrier.
1456 // refers to a potential outside binding. Currently those bindings are 1456 GetVar(v0, var);
1457 // always looked up dynamically, i.e. in that case 1457 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1458 // var->location() == LOOKUP. 1458 __ subu(at, v0, at); // Sub as compare: at == 0 on eq.
1459 // always holds. 1459 if (var->mode() == LET || var->mode() == CONST) {
1460 DCHECK(var->scope() != NULL); 1460 // Throw a reference error when using an uninitialized let/const
1461 1461 // binding in harmony mode.
1462 // Check if the binding really needs an initialization check. The check 1462 Label done;
1463 // can be skipped in the following situation: we have a LET or CONST 1463 __ Branch(&done, ne, at, Operand(zero_reg));
1464 // binding in harmony mode, both the Variable and the VariableProxy have 1464 __ li(a0, Operand(var->name()));
1465 // the same declaration scope (i.e. they are both in global code, in the 1465 __ push(a0);
1466 // same function or in the same eval code) and the VariableProxy is in 1466 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1467 // the source physically located after the initializer of the variable. 1467 __ bind(&done);
1468 //
1469 // We cannot skip any initialization checks for CONST in non-harmony
1470 // mode because const variables may be declared but never initialized:
1471 // if (false) { const x; }; var y = x;
1472 //
1473 // The condition on the declaration scopes is a conservative check for
1474 // nested functions that access a binding and are called before the
1475 // binding is initialized:
1476 // function() { f(); let x = 1; function f() { x = 2; } }
1477 //
1478 bool skip_init_check;
1479 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) {
1480 skip_init_check = false;
1481 } else if (var->is_this()) {
1482 CHECK(info_->has_literal() &&
1483 (info_->literal()->kind() & kSubclassConstructor) != 0);
1484 // TODO(dslomov): implement 'this' hole check elimination.
1485 skip_init_check = false;
1486 } else { 1468 } else {
1487 // Check that we always have valid source position. 1469 // Uninitialized legacy const bindings are unholed.
1488 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); 1470 DCHECK(var->mode() == CONST_LEGACY);
1489 DCHECK(proxy->position() != RelocInfo::kNoPosition); 1471 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1490 skip_init_check = var->mode() != CONST_LEGACY && 1472 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole.
1491 var->initializer_position() < proxy->position();
1492 } 1473 }
1493 1474 context()->Plug(v0);
1494 if (!skip_init_check) { 1475 break;
1495 // Let and const need a read barrier.
1496 GetVar(v0, var);
1497 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
1498 __ subu(at, v0, at); // Sub as compare: at == 0 on eq.
1499 if (var->mode() == LET || var->mode() == CONST) {
1500 // Throw a reference error when using an uninitialized let/const
1501 // binding in harmony mode.
1502 Label done;
1503 __ Branch(&done, ne, at, Operand(zero_reg));
1504 __ li(a0, Operand(var->name()));
1505 __ push(a0);
1506 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1507 __ bind(&done);
1508 } else {
1509 // Uninitalized const bindings outside of harmony mode are unholed.
1510 DCHECK(var->mode() == CONST_LEGACY);
1511 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1512 __ Movz(v0, a0, at); // Conditional move: Undefined if TheHole.
1513 }
1514 context()->Plug(v0);
1515 break;
1516 }
1517 } 1476 }
1518 context()->Plug(var); 1477 context()->Plug(var);
1519 break; 1478 break;
1520 } 1479 }
1521 1480
1522 case VariableLocation::LOOKUP: { 1481 case VariableLocation::LOOKUP: {
1523 Comment cmnt(masm_, "[ Lookup variable"); 1482 Comment cmnt(masm_, "[ Lookup variable");
1524 Label done, slow; 1483 Label done, slow;
1525 // Generate code for loading from variables potentially shadowed 1484 // Generate code for loading from variables potentially shadowed
1526 // by eval-introduced variables. 1485 // by eval-introduced variables.
(...skipping 3817 matching lines...) Expand 10 before | Expand all | Expand 10 after
5344 reinterpret_cast<uint32_t>( 5303 reinterpret_cast<uint32_t>(
5345 isolate->builtins()->OsrAfterStackCheck()->entry())); 5304 isolate->builtins()->OsrAfterStackCheck()->entry()));
5346 return OSR_AFTER_STACK_CHECK; 5305 return OSR_AFTER_STACK_CHECK;
5347 } 5306 }
5348 5307
5349 5308
5350 } // namespace internal 5309 } // namespace internal
5351 } // namespace v8 5310 } // namespace v8
5352 5311
5353 #endif // V8_TARGET_ARCH_MIPS 5312 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698