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

Side by Side Diff: src/full-codegen/x64/full-codegen-x64.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/ppc/full-codegen-ppc.cc ('k') | src/full-codegen/x87/full-codegen-x87.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_X64 5 #if V8_TARGET_ARCH_X64
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 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 context()->Plug(rax); 1406 context()->Plug(rax);
1407 break; 1407 break;
1408 } 1408 }
1409 1409
1410 case VariableLocation::PARAMETER: 1410 case VariableLocation::PARAMETER:
1411 case VariableLocation::LOCAL: 1411 case VariableLocation::LOCAL:
1412 case VariableLocation::CONTEXT: { 1412 case VariableLocation::CONTEXT: {
1413 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); 1413 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1414 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" 1414 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot"
1415 : "[ Stack slot"); 1415 : "[ Stack slot");
1416 if (var->binding_needs_init()) { 1416 if (NeedsHoleCheckForLoad(proxy)) {
1417 // var->scope() may be NULL when the proxy is located in eval code and 1417 // Let and const need a read barrier.
1418 // refers to a potential outside binding. Currently those bindings are 1418 Label done;
1419 // always looked up dynamically, i.e. in that case 1419 GetVar(rax, var);
1420 // var->location() == LOOKUP. 1420 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
1421 // always holds. 1421 __ j(not_equal, &done, Label::kNear);
1422 DCHECK(var->scope() != NULL); 1422 if (var->mode() == LET || var->mode() == CONST) {
1423 1423 // Throw a reference error when using an uninitialized let/const
1424 // Check if the binding really needs an initialization check. The check 1424 // binding in harmony mode.
1425 // can be skipped in the following situation: we have a LET or CONST 1425 __ Push(var->name());
1426 // binding in harmony mode, both the Variable and the VariableProxy have 1426 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1427 // the same declaration scope (i.e. they are both in global code, in the
1428 // same function or in the same eval code) and the VariableProxy is in
1429 // the source physically located after the initializer of the variable.
1430 //
1431 // We cannot skip any initialization checks for CONST in non-harmony
1432 // mode because const variables may be declared but never initialized:
1433 // if (false) { const x; }; var y = x;
1434 //
1435 // The condition on the declaration scopes is a conservative check for
1436 // nested functions that access a binding and are called before the
1437 // binding is initialized:
1438 // function() { f(); let x = 1; function f() { x = 2; } }
1439 //
1440 bool skip_init_check;
1441 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) {
1442 skip_init_check = false;
1443 } else if (var->is_this()) {
1444 CHECK(info_->has_literal() &&
1445 (info_->literal()->kind() & kSubclassConstructor) != 0);
1446 // TODO(dslomov): implement 'this' hole check elimination.
1447 skip_init_check = false;
1448 } else { 1427 } else {
1449 // Check that we always have valid source position. 1428 // Uninitialized legacy const bindings are unholed.
1450 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); 1429 DCHECK(var->mode() == CONST_LEGACY);
1451 DCHECK(proxy->position() != RelocInfo::kNoPosition); 1430 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
1452 skip_init_check = var->mode() != CONST_LEGACY &&
1453 var->initializer_position() < proxy->position();
1454 } 1431 }
1455 1432 __ bind(&done);
1456 if (!skip_init_check) { 1433 context()->Plug(rax);
1457 // Let and const need a read barrier. 1434 break;
1458 Label done;
1459 GetVar(rax, var);
1460 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
1461 __ j(not_equal, &done, Label::kNear);
1462 if (var->mode() == LET || var->mode() == CONST) {
1463 // Throw a reference error when using an uninitialized let/const
1464 // binding in harmony mode.
1465 __ Push(var->name());
1466 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1467 } else {
1468 // Uninitalized const bindings outside of harmony mode are unholed.
1469 DCHECK(var->mode() == CONST_LEGACY);
1470 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
1471 }
1472 __ bind(&done);
1473 context()->Plug(rax);
1474 break;
1475 }
1476 } 1435 }
1477 context()->Plug(var); 1436 context()->Plug(var);
1478 break; 1437 break;
1479 } 1438 }
1480 1439
1481 case VariableLocation::LOOKUP: { 1440 case VariableLocation::LOOKUP: {
1482 Comment cmnt(masm_, "[ Lookup slot"); 1441 Comment cmnt(masm_, "[ Lookup slot");
1483 Label done, slow; 1442 Label done, slow;
1484 // Generate code for loading from variables potentially shadowed 1443 // Generate code for loading from variables potentially shadowed
1485 // by eval-introduced variables. 1444 // by eval-introduced variables.
(...skipping 3780 matching lines...) Expand 10 before | Expand all | Expand 10 after
5266 Assembler::target_address_at(call_target_address, 5225 Assembler::target_address_at(call_target_address,
5267 unoptimized_code)); 5226 unoptimized_code));
5268 return OSR_AFTER_STACK_CHECK; 5227 return OSR_AFTER_STACK_CHECK;
5269 } 5228 }
5270 5229
5271 5230
5272 } // namespace internal 5231 } // namespace internal
5273 } // namespace v8 5232 } // namespace v8
5274 5233
5275 #endif // V8_TARGET_ARCH_X64 5234 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698