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

Side by Side Diff: src/full-codegen/mips/full-codegen-mips.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
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 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2578 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2579 FeedbackVectorSlot slot) { 2579 FeedbackVectorSlot slot) {
2580 if (var->IsUnallocated()) { 2580 if (var->IsUnallocated()) {
2581 // Global var, const, or let. 2581 // Global var, const, or let.
2582 __ mov(StoreDescriptor::ValueRegister(), result_register()); 2582 __ mov(StoreDescriptor::ValueRegister(), result_register());
2583 __ li(StoreDescriptor::NameRegister(), Operand(var->name())); 2583 __ li(StoreDescriptor::NameRegister(), Operand(var->name()));
2584 __ lw(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); 2584 __ lw(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
2585 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 2585 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
2586 CallStoreIC(); 2586 CallStoreIC();
2587 2587
2588 } else if (var->mode() == LET && op != Token::INIT_LET) { 2588 } else if (var->mode() == LET && op != Token::INIT) {
2589 // Non-initializing assignment to let variable needs a write barrier. 2589 // Non-initializing assignment to let variable needs a write barrier.
2590 DCHECK(!var->IsLookupSlot()); 2590 DCHECK(!var->IsLookupSlot());
2591 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2591 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2592 Label assign; 2592 Label assign;
2593 MemOperand location = VarOperand(var, a1); 2593 MemOperand location = VarOperand(var, a1);
2594 __ lw(a3, location); 2594 __ lw(a3, location);
2595 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2595 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2596 __ Branch(&assign, ne, a3, Operand(t0)); 2596 __ Branch(&assign, ne, a3, Operand(t0));
2597 __ li(a3, Operand(var->name())); 2597 __ li(a3, Operand(var->name()));
2598 __ push(a3); 2598 __ push(a3);
2599 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2599 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2600 // Perform the assignment. 2600 // Perform the assignment.
2601 __ bind(&assign); 2601 __ bind(&assign);
2602 EmitStoreToStackLocalOrContextSlot(var, location); 2602 EmitStoreToStackLocalOrContextSlot(var, location);
2603 2603
2604 } else if (var->mode() == CONST && op != Token::INIT_CONST) { 2604 } else if (var->mode() == CONST && op != Token::INIT) {
2605 // Assignment to const variable needs a write barrier. 2605 // Assignment to const variable needs a write barrier.
2606 DCHECK(!var->IsLookupSlot()); 2606 DCHECK(!var->IsLookupSlot());
2607 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2607 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2608 Label const_error; 2608 Label const_error;
2609 MemOperand location = VarOperand(var, a1); 2609 MemOperand location = VarOperand(var, a1);
2610 __ lw(a3, location); 2610 __ lw(a3, location);
2611 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2611 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2612 __ Branch(&const_error, ne, a3, Operand(at)); 2612 __ Branch(&const_error, ne, a3, Operand(at));
2613 __ li(a3, Operand(var->name())); 2613 __ li(a3, Operand(var->name()));
2614 __ push(a3); 2614 __ push(a3);
2615 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2615 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2616 __ bind(&const_error); 2616 __ bind(&const_error);
2617 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2617 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2618 2618
2619 } else if (var->is_this() && op == Token::INIT_CONST) { 2619 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) {
2620 // Initializing assignment to const {this} needs a write barrier. 2620 // Initializing assignment to const {this} needs a write barrier.
2621 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2621 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2622 Label uninitialized_this; 2622 Label uninitialized_this;
2623 MemOperand location = VarOperand(var, a1); 2623 MemOperand location = VarOperand(var, a1);
2624 __ lw(a3, location); 2624 __ lw(a3, location);
2625 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2625 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2626 __ Branch(&uninitialized_this, eq, a3, Operand(at)); 2626 __ Branch(&uninitialized_this, eq, a3, Operand(at));
2627 __ li(a0, Operand(var->name())); 2627 __ li(a0, Operand(var->name()));
2628 __ Push(a0); 2628 __ Push(a0);
2629 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2629 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2630 __ bind(&uninitialized_this); 2630 __ bind(&uninitialized_this);
2631 EmitStoreToStackLocalOrContextSlot(var, location); 2631 EmitStoreToStackLocalOrContextSlot(var, location);
2632 2632
2633 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2633 } else if (!var->is_const_mode() ||
2634 (var->mode() == CONST && op == Token::INIT)) {
2634 if (var->IsLookupSlot()) { 2635 if (var->IsLookupSlot()) {
2635 // Assignment to var. 2636 // Assignment to var.
2636 __ li(a1, Operand(var->name())); 2637 __ li(a1, Operand(var->name()));
2637 __ li(a0, Operand(Smi::FromInt(language_mode()))); 2638 __ li(a0, Operand(Smi::FromInt(language_mode())));
2638 __ Push(v0, cp, a1, a0); // Value, context, name, language mode. 2639 __ Push(v0, cp, a1, a0); // Value, context, name, language mode.
2639 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2640 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2640 } else { 2641 } else {
2641 // Assignment to var or initializing assignment to let/const in harmony 2642 // Assignment to var or initializing assignment to let/const in harmony
2642 // mode. 2643 // mode.
2643 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); 2644 DCHECK((var->IsStackAllocated() || var->IsContextSlot()));
2644 MemOperand location = VarOperand(var, a1); 2645 MemOperand location = VarOperand(var, a1);
2645 if (generate_debug_code_ && op == Token::INIT_LET) { 2646 if (generate_debug_code_ && var->mode() == LET && op == Token::INIT) {
2646 // Check for an uninitialized let binding. 2647 // Check for an uninitialized let binding.
2647 __ lw(a2, location); 2648 __ lw(a2, location);
2648 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2649 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2649 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0)); 2650 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0));
2650 } 2651 }
2651 EmitStoreToStackLocalOrContextSlot(var, location); 2652 EmitStoreToStackLocalOrContextSlot(var, location);
2652 } 2653 }
2653 2654
2654 } else if (op == Token::INIT_CONST_LEGACY) { 2655 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) {
2655 // Const initializers need a write barrier. 2656 // Const initializers need a write barrier.
2656 DCHECK(!var->IsParameter()); // No const parameters. 2657 DCHECK(!var->IsParameter()); // No const parameters.
2657 if (var->IsLookupSlot()) { 2658 if (var->IsLookupSlot()) {
2658 __ li(a0, Operand(var->name())); 2659 __ li(a0, Operand(var->name()));
2659 __ Push(v0, cp, a0); // Context and name. 2660 __ Push(v0, cp, a0); // Context and name.
2660 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); 2661 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2661 } else { 2662 } else {
2662 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2663 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2663 Label skip; 2664 Label skip;
2664 MemOperand location = VarOperand(var, a1); 2665 MemOperand location = VarOperand(var, a1);
2665 __ lw(a2, location); 2666 __ lw(a2, location);
2666 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2667 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2667 __ Branch(&skip, ne, a2, Operand(at)); 2668 __ Branch(&skip, ne, a2, Operand(at));
2668 EmitStoreToStackLocalOrContextSlot(var, location); 2669 EmitStoreToStackLocalOrContextSlot(var, location);
2669 __ bind(&skip); 2670 __ bind(&skip);
2670 } 2671 }
2671 2672
2672 } else { 2673 } else {
2673 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY); 2674 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT);
2674 if (is_strict(language_mode())) { 2675 if (is_strict(language_mode())) {
2675 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2676 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2676 } 2677 }
2677 // Silently ignore store in sloppy mode. 2678 // Silently ignore store in sloppy mode.
2678 } 2679 }
2679 } 2680 }
2680 2681
2681 2682
2682 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2683 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2683 // Assignment to a property, using a named store IC. 2684 // Assignment to a property, using a named store IC.
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
5055 reinterpret_cast<uint32_t>( 5056 reinterpret_cast<uint32_t>(
5056 isolate->builtins()->OsrAfterStackCheck()->entry())); 5057 isolate->builtins()->OsrAfterStackCheck()->entry()));
5057 return OSR_AFTER_STACK_CHECK; 5058 return OSR_AFTER_STACK_CHECK;
5058 } 5059 }
5059 5060
5060 5061
5061 } // namespace internal 5062 } // namespace internal
5062 } // namespace v8 5063 } // namespace v8
5063 5064
5064 #endif // V8_TARGET_ARCH_MIPS 5065 #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