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

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

Issue 1431873006: Use a single Token::INIT for all variable initialization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm, simplify fvar code Created 5 years, 1 month 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/debug/debug.h" 10 #include "src/debug/debug.h"
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 2480
2481 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2481 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2482 FeedbackVectorSlot slot) { 2482 FeedbackVectorSlot slot) {
2483 if (var->IsUnallocated()) { 2483 if (var->IsUnallocated()) {
2484 // Global var, const, or let. 2484 // Global var, const, or let.
2485 __ Move(StoreDescriptor::NameRegister(), var->name()); 2485 __ Move(StoreDescriptor::NameRegister(), var->name());
2486 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); 2486 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
2487 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 2487 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
2488 CallStoreIC(); 2488 CallStoreIC();
2489 2489
2490 } else if (var->mode() == LET && op != Token::INIT_LET) { 2490 } else if (var->mode() == LET && op != Token::INIT) {
2491 // Non-initializing assignment to let variable needs a write barrier. 2491 // Non-initializing assignment to let variable needs a write barrier.
2492 DCHECK(!var->IsLookupSlot()); 2492 DCHECK(!var->IsLookupSlot());
2493 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2493 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2494 Label assign; 2494 Label assign;
2495 MemOperand location = VarOperand(var, rcx); 2495 MemOperand location = VarOperand(var, rcx);
2496 __ movp(rdx, location); 2496 __ movp(rdx, location);
2497 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2497 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2498 __ j(not_equal, &assign, Label::kNear); 2498 __ j(not_equal, &assign, Label::kNear);
2499 __ Push(var->name()); 2499 __ Push(var->name());
2500 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2500 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2501 __ bind(&assign); 2501 __ bind(&assign);
2502 EmitStoreToStackLocalOrContextSlot(var, location); 2502 EmitStoreToStackLocalOrContextSlot(var, location);
2503 2503
2504 } else if (var->mode() == CONST && op != Token::INIT_CONST) { 2504 } else if (var->mode() == CONST && op != Token::INIT) {
2505 // Assignment to const variable needs a write barrier. 2505 // Assignment to const variable needs a write barrier.
2506 DCHECK(!var->IsLookupSlot()); 2506 DCHECK(!var->IsLookupSlot());
2507 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2507 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2508 Label const_error; 2508 Label const_error;
2509 MemOperand location = VarOperand(var, rcx); 2509 MemOperand location = VarOperand(var, rcx);
2510 __ movp(rdx, location); 2510 __ movp(rdx, location);
2511 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2511 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2512 __ j(not_equal, &const_error, Label::kNear); 2512 __ j(not_equal, &const_error, Label::kNear);
2513 __ Push(var->name()); 2513 __ Push(var->name());
2514 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2514 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2515 __ bind(&const_error); 2515 __ bind(&const_error);
2516 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2516 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2517 2517
2518 } else if (var->is_this() && op == Token::INIT_CONST) { 2518 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) {
2519 // Initializing assignment to const {this} needs a write barrier. 2519 // Initializing assignment to const {this} needs a write barrier.
2520 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2520 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2521 Label uninitialized_this; 2521 Label uninitialized_this;
2522 MemOperand location = VarOperand(var, rcx); 2522 MemOperand location = VarOperand(var, rcx);
2523 __ movp(rdx, location); 2523 __ movp(rdx, location);
2524 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2524 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2525 __ j(equal, &uninitialized_this); 2525 __ j(equal, &uninitialized_this);
2526 __ Push(var->name()); 2526 __ Push(var->name());
2527 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2527 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2528 __ bind(&uninitialized_this); 2528 __ bind(&uninitialized_this);
2529 EmitStoreToStackLocalOrContextSlot(var, location); 2529 EmitStoreToStackLocalOrContextSlot(var, location);
2530 2530
2531 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2531 } else if (!var->is_const_mode() ||
2532 (var->mode() == CONST && op == Token::INIT)) {
2532 if (var->IsLookupSlot()) { 2533 if (var->IsLookupSlot()) {
2533 // Assignment to var. 2534 // Assignment to var.
2534 __ Push(rax); // Value. 2535 __ Push(rax); // Value.
2535 __ Push(rsi); // Context. 2536 __ Push(rsi); // Context.
2536 __ Push(var->name()); 2537 __ Push(var->name());
2537 __ Push(Smi::FromInt(language_mode())); 2538 __ Push(Smi::FromInt(language_mode()));
2538 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2539 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2539 } else { 2540 } else {
2540 // Assignment to var or initializing assignment to let/const in harmony 2541 // Assignment to var or initializing assignment to let/const in harmony
2541 // mode. 2542 // mode.
2542 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2543 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2543 MemOperand location = VarOperand(var, rcx); 2544 MemOperand location = VarOperand(var, rcx);
2544 if (generate_debug_code_ && op == Token::INIT_LET) { 2545 if (generate_debug_code_ && var->mode() == LET && op == Token::INIT) {
2545 // Check for an uninitialized let binding. 2546 // Check for an uninitialized let binding.
2546 __ movp(rdx, location); 2547 __ movp(rdx, location);
2547 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2548 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2548 __ Check(equal, kLetBindingReInitialization); 2549 __ Check(equal, kLetBindingReInitialization);
2549 } 2550 }
2550 EmitStoreToStackLocalOrContextSlot(var, location); 2551 EmitStoreToStackLocalOrContextSlot(var, location);
2551 } 2552 }
2552 2553
2553 } else if (op == Token::INIT_CONST_LEGACY) { 2554 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) {
2554 // Const initializers need a write barrier. 2555 // Const initializers need a write barrier.
2555 DCHECK(var->mode() == CONST_LEGACY);
2556 DCHECK(!var->IsParameter()); // No const parameters. 2556 DCHECK(!var->IsParameter()); // No const parameters.
2557 if (var->IsLookupSlot()) { 2557 if (var->IsLookupSlot()) {
2558 __ Push(rax); 2558 __ Push(rax);
2559 __ Push(rsi); 2559 __ Push(rsi);
2560 __ Push(var->name()); 2560 __ Push(var->name());
2561 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); 2561 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2562 } else { 2562 } else {
2563 DCHECK(var->IsStackLocal() || var->IsContextSlot()); 2563 DCHECK(var->IsStackLocal() || var->IsContextSlot());
2564 Label skip; 2564 Label skip;
2565 MemOperand location = VarOperand(var, rcx); 2565 MemOperand location = VarOperand(var, rcx);
2566 __ movp(rdx, location); 2566 __ movp(rdx, location);
2567 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2567 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2568 __ j(not_equal, &skip); 2568 __ j(not_equal, &skip);
2569 EmitStoreToStackLocalOrContextSlot(var, location); 2569 EmitStoreToStackLocalOrContextSlot(var, location);
2570 __ bind(&skip); 2570 __ bind(&skip);
2571 } 2571 }
2572 2572
2573 } else { 2573 } else {
2574 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY); 2574 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
2575 if (is_strict(language_mode())) { 2575 if (is_strict(language_mode())) {
2576 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2576 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2577 } 2577 }
2578 // Silently ignore store in sloppy mode. 2578 // Silently ignore store in sloppy mode.
2579 } 2579 }
2580 } 2580 }
2581 2581
2582 2582
2583 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2583 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2584 // Assignment to a property, using a named store IC. 2584 // Assignment to a property, using a named store IC.
(...skipping 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after
4976 Assembler::target_address_at(call_target_address, 4976 Assembler::target_address_at(call_target_address,
4977 unoptimized_code)); 4977 unoptimized_code));
4978 return OSR_AFTER_STACK_CHECK; 4978 return OSR_AFTER_STACK_CHECK;
4979 } 4979 }
4980 4980
4981 4981
4982 } // namespace internal 4982 } // namespace internal
4983 } // namespace v8 4983 } // namespace v8
4984 4984
4985 #endif // V8_TARGET_ARCH_X64 4985 #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