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

Side by Side Diff: src/full-codegen/arm/full-codegen-arm.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/crankshaft/hydrogen.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.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_ARM 5 #if V8_TARGET_ARCH_ARM
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 2573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 2584
2585 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2585 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2586 FeedbackVectorSlot slot) { 2586 FeedbackVectorSlot slot) {
2587 if (var->IsUnallocated()) { 2587 if (var->IsUnallocated()) {
2588 // Global var, const, or let. 2588 // Global var, const, or let.
2589 __ mov(StoreDescriptor::NameRegister(), Operand(var->name())); 2589 __ mov(StoreDescriptor::NameRegister(), Operand(var->name()));
2590 __ ldr(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); 2590 __ ldr(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
2591 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 2591 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
2592 CallStoreIC(); 2592 CallStoreIC();
2593 2593
2594 } else if (var->mode() == LET && op != Token::INIT_LET) { 2594 } else if (var->mode() == LET && op != Token::INIT) {
2595 // Non-initializing assignment to let variable needs a write barrier. 2595 // Non-initializing assignment to let variable needs a write barrier.
2596 DCHECK(!var->IsLookupSlot()); 2596 DCHECK(!var->IsLookupSlot());
2597 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2597 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2598 Label assign; 2598 Label assign;
2599 MemOperand location = VarOperand(var, r1); 2599 MemOperand location = VarOperand(var, r1);
2600 __ ldr(r3, location); 2600 __ ldr(r3, location);
2601 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); 2601 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex);
2602 __ b(ne, &assign); 2602 __ b(ne, &assign);
2603 __ mov(r3, Operand(var->name())); 2603 __ mov(r3, Operand(var->name()));
2604 __ push(r3); 2604 __ push(r3);
2605 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2605 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2606 // Perform the assignment. 2606 // Perform the assignment.
2607 __ bind(&assign); 2607 __ bind(&assign);
2608 EmitStoreToStackLocalOrContextSlot(var, location); 2608 EmitStoreToStackLocalOrContextSlot(var, location);
2609 2609
2610 } else if (var->mode() == CONST && op != Token::INIT_CONST) { 2610 } else if (var->mode() == CONST && op != Token::INIT) {
2611 // Assignment to const variable needs a write barrier. 2611 // Assignment to const variable needs a write barrier.
2612 DCHECK(!var->IsLookupSlot()); 2612 DCHECK(!var->IsLookupSlot());
2613 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2613 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2614 Label const_error; 2614 Label const_error;
2615 MemOperand location = VarOperand(var, r1); 2615 MemOperand location = VarOperand(var, r1);
2616 __ ldr(r3, location); 2616 __ ldr(r3, location);
2617 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); 2617 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex);
2618 __ b(ne, &const_error); 2618 __ b(ne, &const_error);
2619 __ mov(r3, Operand(var->name())); 2619 __ mov(r3, Operand(var->name()));
2620 __ push(r3); 2620 __ push(r3);
2621 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2621 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2622 __ bind(&const_error); 2622 __ bind(&const_error);
2623 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2623 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2624 2624
2625 } else if (var->is_this() && op == Token::INIT_CONST) { 2625 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) {
2626 // Initializing assignment to const {this} needs a write barrier. 2626 // Initializing assignment to const {this} needs a write barrier.
2627 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2627 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2628 Label uninitialized_this; 2628 Label uninitialized_this;
2629 MemOperand location = VarOperand(var, r1); 2629 MemOperand location = VarOperand(var, r1);
2630 __ ldr(r3, location); 2630 __ ldr(r3, location);
2631 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); 2631 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex);
2632 __ b(eq, &uninitialized_this); 2632 __ b(eq, &uninitialized_this);
2633 __ mov(r0, Operand(var->name())); 2633 __ mov(r0, Operand(var->name()));
2634 __ Push(r0); 2634 __ Push(r0);
2635 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2635 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2636 __ bind(&uninitialized_this); 2636 __ bind(&uninitialized_this);
2637 EmitStoreToStackLocalOrContextSlot(var, location); 2637 EmitStoreToStackLocalOrContextSlot(var, location);
2638 2638
2639 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2639 } else if (!var->is_const_mode() ||
2640 (var->mode() == CONST && op == Token::INIT)) {
2640 if (var->IsLookupSlot()) { 2641 if (var->IsLookupSlot()) {
2641 // Assignment to var. 2642 // Assignment to var.
2642 __ push(r0); // Value. 2643 __ push(r0); // Value.
2643 __ mov(r1, Operand(var->name())); 2644 __ mov(r1, Operand(var->name()));
2644 __ mov(r0, Operand(Smi::FromInt(language_mode()))); 2645 __ mov(r0, Operand(Smi::FromInt(language_mode())));
2645 __ Push(cp, r1, r0); // Context, name, language mode. 2646 __ Push(cp, r1, r0); // Context, name, language mode.
2646 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2647 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2647 } else { 2648 } else {
2648 // Assignment to var or initializing assignment to let/const in harmony 2649 // Assignment to var or initializing assignment to let/const in harmony
2649 // mode. 2650 // mode.
2650 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); 2651 DCHECK((var->IsStackAllocated() || var->IsContextSlot()));
2651 MemOperand location = VarOperand(var, r1); 2652 MemOperand location = VarOperand(var, r1);
2652 if (generate_debug_code_ && op == Token::INIT_LET) { 2653 if (generate_debug_code_ && var->mode() == LET && op == Token::INIT) {
2653 // Check for an uninitialized let binding. 2654 // Check for an uninitialized let binding.
2654 __ ldr(r2, location); 2655 __ ldr(r2, location);
2655 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); 2656 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex);
2656 __ Check(eq, kLetBindingReInitialization); 2657 __ Check(eq, kLetBindingReInitialization);
2657 } 2658 }
2658 EmitStoreToStackLocalOrContextSlot(var, location); 2659 EmitStoreToStackLocalOrContextSlot(var, location);
2659 } 2660 }
2660 2661
2661 } else if (op == Token::INIT_CONST_LEGACY) { 2662 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) {
2662 // Const initializers need a write barrier. 2663 // Const initializers need a write barrier.
2663 DCHECK(var->mode() == CONST_LEGACY);
2664 DCHECK(!var->IsParameter()); // No const parameters. 2664 DCHECK(!var->IsParameter()); // No const parameters.
2665 if (var->IsLookupSlot()) { 2665 if (var->IsLookupSlot()) {
2666 __ push(r0); 2666 __ push(r0);
2667 __ mov(r0, Operand(var->name())); 2667 __ mov(r0, Operand(var->name()));
2668 __ Push(cp, r0); // Context and name. 2668 __ Push(cp, r0); // Context and name.
2669 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); 2669 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2670 } else { 2670 } else {
2671 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2671 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2672 Label skip; 2672 Label skip;
2673 MemOperand location = VarOperand(var, r1); 2673 MemOperand location = VarOperand(var, r1);
2674 __ ldr(r2, location); 2674 __ ldr(r2, location);
2675 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); 2675 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex);
2676 __ b(ne, &skip); 2676 __ b(ne, &skip);
2677 EmitStoreToStackLocalOrContextSlot(var, location); 2677 EmitStoreToStackLocalOrContextSlot(var, location);
2678 __ bind(&skip); 2678 __ bind(&skip);
2679 } 2679 }
2680 2680
2681 } else { 2681 } else {
2682 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY); 2682 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
2683 if (is_strict(language_mode())) { 2683 if (is_strict(language_mode())) {
2684 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2684 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2685 } 2685 }
2686 // Silently ignore store in sloppy mode. 2686 // Silently ignore store in sloppy mode.
2687 } 2687 }
2688 } 2688 }
2689 2689
2690 2690
2691 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2691 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2692 // Assignment to a property, using a named store IC. 2692 // Assignment to a property, using a named store IC.
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after
5091 DCHECK(interrupt_address == 5091 DCHECK(interrupt_address ==
5092 isolate->builtins()->OsrAfterStackCheck()->entry()); 5092 isolate->builtins()->OsrAfterStackCheck()->entry());
5093 return OSR_AFTER_STACK_CHECK; 5093 return OSR_AFTER_STACK_CHECK;
5094 } 5094 }
5095 5095
5096 5096
5097 } // namespace internal 5097 } // namespace internal
5098 } // namespace v8 5098 } // namespace v8
5099 5099
5100 #endif // V8_TARGET_ARCH_ARM 5100 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698