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

Side by Side Diff: src/full-codegen/ia32/full-codegen-ia32.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/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.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_IA32 5 #if V8_TARGET_ARCH_IA32
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 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 context()->Plug(eax); 1377 context()->Plug(eax);
1378 break; 1378 break;
1379 } 1379 }
1380 1380
1381 case VariableLocation::PARAMETER: 1381 case VariableLocation::PARAMETER:
1382 case VariableLocation::LOCAL: 1382 case VariableLocation::LOCAL:
1383 case VariableLocation::CONTEXT: { 1383 case VariableLocation::CONTEXT: {
1384 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); 1384 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1385 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" 1385 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
1386 : "[ Stack variable"); 1386 : "[ Stack variable");
1387 if (var->binding_needs_init()) {
1388 // var->scope() may be NULL when the proxy is located in eval code and
1389 // refers to a potential outside binding. Currently those bindings are
1390 // always looked up dynamically, i.e. in that case
1391 // var->location() == LOOKUP.
1392 // always holds.
1393 DCHECK(var->scope() != NULL);
1394 1387
1395 // Check if the binding really needs an initialization check. The check 1388 if (NeedsHoleCheckForLoad(proxy)) {
1396 // can be skipped in the following situation: we have a LET or CONST 1389 // Let and const need a read barrier.
1397 // binding in harmony mode, both the Variable and the VariableProxy have 1390 Label done;
1398 // the same declaration scope (i.e. they are both in global code, in the 1391 GetVar(eax, var);
1399 // same function or in the same eval code) and the VariableProxy is in 1392 __ cmp(eax, isolate()->factory()->the_hole_value());
1400 // the source physically located after the initializer of the variable. 1393 __ j(not_equal, &done, Label::kNear);
1401 // 1394 if (var->mode() == LET || var->mode() == CONST) {
1402 // We cannot skip any initialization checks for CONST in non-harmony 1395 // Throw a reference error when using an uninitialized let/const
1403 // mode because const variables may be declared but never initialized: 1396 // binding in harmony mode.
1404 // if (false) { const x; }; var y = x; 1397 __ push(Immediate(var->name()));
1405 // 1398 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1406 // The condition on the declaration scopes is a conservative check for
1407 // nested functions that access a binding and are called before the
1408 // binding is initialized:
1409 // function() { f(); let x = 1; function f() { x = 2; } }
1410 //
1411 bool skip_init_check;
1412 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) {
1413 skip_init_check = false;
1414 } else if (var->is_this()) {
1415 CHECK(literal() != nullptr &&
1416 (literal()->kind() & kSubclassConstructor) != 0);
1417 // TODO(dslomov): implement 'this' hole check elimination.
1418 skip_init_check = false;
1419 } else { 1399 } else {
1420 // Check that we always have valid source position. 1400 // Uninitialized legacy const bindings are unholed.
1421 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); 1401 DCHECK(var->mode() == CONST_LEGACY);
1422 DCHECK(proxy->position() != RelocInfo::kNoPosition); 1402 __ mov(eax, isolate()->factory()->undefined_value());
1423 skip_init_check = var->mode() != CONST_LEGACY &&
1424 var->initializer_position() < proxy->position();
1425 } 1403 }
1426 1404 __ bind(&done);
1427 if (!skip_init_check) { 1405 context()->Plug(eax);
1428 // Let and const need a read barrier. 1406 break;
1429 Label done;
1430 GetVar(eax, var);
1431 __ cmp(eax, isolate()->factory()->the_hole_value());
1432 __ j(not_equal, &done, Label::kNear);
1433 if (var->mode() == LET || var->mode() == CONST) {
1434 // Throw a reference error when using an uninitialized let/const
1435 // binding in harmony mode.
1436 __ push(Immediate(var->name()));
1437 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1438 } else {
1439 // Uninitalized const bindings outside of harmony mode are unholed.
1440 DCHECK(var->mode() == CONST_LEGACY);
1441 __ mov(eax, isolate()->factory()->undefined_value());
1442 }
1443 __ bind(&done);
1444 context()->Plug(eax);
1445 break;
1446 }
1447 } 1407 }
1448 context()->Plug(var); 1408 context()->Plug(var);
1449 break; 1409 break;
1450 } 1410 }
1451 1411
1452 case VariableLocation::LOOKUP: { 1412 case VariableLocation::LOOKUP: {
1453 Comment cmnt(masm_, "[ Lookup variable"); 1413 Comment cmnt(masm_, "[ Lookup variable");
1454 Label done, slow; 1414 Label done, slow;
1455 // Generate code for loading from variables potentially shadowed 1415 // Generate code for loading from variables potentially shadowed
1456 // by eval-introduced variables. 1416 // by eval-introduced variables.
(...skipping 3799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5256 Assembler::target_address_at(call_target_address, 5216 Assembler::target_address_at(call_target_address,
5257 unoptimized_code)); 5217 unoptimized_code));
5258 return OSR_AFTER_STACK_CHECK; 5218 return OSR_AFTER_STACK_CHECK;
5259 } 5219 }
5260 5220
5261 5221
5262 } // namespace internal 5222 } // namespace internal
5263 } // namespace v8 5223 } // namespace v8
5264 5224
5265 #endif // V8_TARGET_ARCH_IA32 5225 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698