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

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

Issue 983693003: MIPS: Fix exception for assignment to uninitialised const. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/mips/full-codegen-mips.cc ('k') | no next file » | 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 } 2697 }
2698 2698
2699 2699
2700 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) { 2700 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) {
2701 if (var->IsUnallocated()) { 2701 if (var->IsUnallocated()) {
2702 // Global var, const, or let. 2702 // Global var, const, or let.
2703 __ mov(StoreDescriptor::ValueRegister(), result_register()); 2703 __ mov(StoreDescriptor::ValueRegister(), result_register());
2704 __ li(StoreDescriptor::NameRegister(), Operand(var->name())); 2704 __ li(StoreDescriptor::NameRegister(), Operand(var->name()));
2705 __ ld(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); 2705 __ ld(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
2706 CallStoreIC(); 2706 CallStoreIC();
2707 } else if (op == Token::INIT_CONST_LEGACY) {
2708 // Const initializers need a write barrier.
2709 DCHECK(!var->IsParameter()); // No const parameters.
2710 if (var->IsLookupSlot()) {
2711 __ li(a0, Operand(var->name()));
2712 __ Push(v0, cp, a0); // Context and name.
2713 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2714 } else {
2715 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2716 Label skip;
2717 MemOperand location = VarOperand(var, a1);
2718 __ ld(a2, location);
2719 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2720 __ Branch(&skip, ne, a2, Operand(at));
2721 EmitStoreToStackLocalOrContextSlot(var, location);
2722 __ bind(&skip);
2723 }
2724 2707
2725 } else if (var->mode() == LET && op != Token::INIT_LET) { 2708 } else if (var->mode() == LET && op != Token::INIT_LET) {
2726 // Non-initializing assignment to let variable needs a write barrier. 2709 // Non-initializing assignment to let variable needs a write barrier.
2727 DCHECK(!var->IsLookupSlot()); 2710 DCHECK(!var->IsLookupSlot());
2728 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2711 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2729 Label assign; 2712 Label assign;
2730 MemOperand location = VarOperand(var, a1); 2713 MemOperand location = VarOperand(var, a1);
2731 __ ld(a3, location); 2714 __ ld(a3, location);
2732 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); 2715 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex);
2733 __ Branch(&assign, ne, a3, Operand(a4)); 2716 __ Branch(&assign, ne, a3, Operand(a4));
2734 __ li(a3, Operand(var->name())); 2717 __ li(a3, Operand(var->name()));
2735 __ push(a3); 2718 __ push(a3);
2736 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2719 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2737 // Perform the assignment. 2720 // Perform the assignment.
2738 __ bind(&assign); 2721 __ bind(&assign);
2739 EmitStoreToStackLocalOrContextSlot(var, location); 2722 EmitStoreToStackLocalOrContextSlot(var, location);
2723
2724 } else if (var->mode() == CONST && op != Token::INIT_CONST) {
2725 // Assignment to const variable needs a write barrier.
2726 DCHECK(!var->IsLookupSlot());
2727 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2728 Label const_error;
2729 MemOperand location = VarOperand(var, a1);
2730 __ ld(a3, location);
2731 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2732 __ Branch(&const_error, ne, a3, Operand(at));
2733 __ li(a3, Operand(var->name()));
2734 __ push(a3);
2735 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2736 __ bind(&const_error);
2737 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2738
2740 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2739 } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
2741 if (var->IsLookupSlot()) { 2740 if (var->IsLookupSlot()) {
2742 // Assignment to var. 2741 // Assignment to var.
2743 __ li(a4, Operand(var->name())); 2742 __ li(a4, Operand(var->name()));
2744 __ li(a3, Operand(Smi::FromInt(language_mode()))); 2743 __ li(a3, Operand(Smi::FromInt(language_mode())));
2745 // jssp[0] : language mode. 2744 // jssp[0] : language mode.
2746 // jssp[8] : name. 2745 // jssp[8] : name.
2747 // jssp[16] : context. 2746 // jssp[16] : context.
2748 // jssp[24] : value. 2747 // jssp[24] : value.
2749 __ Push(v0, cp, a4, a3); 2748 __ Push(v0, cp, a4, a3);
2750 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2749 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2751 } else { 2750 } else {
2752 // Assignment to var or initializing assignment to let/const in harmony 2751 // Assignment to var or initializing assignment to let/const in harmony
2753 // mode. 2752 // mode.
2754 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); 2753 DCHECK((var->IsStackAllocated() || var->IsContextSlot()));
2755 MemOperand location = VarOperand(var, a1); 2754 MemOperand location = VarOperand(var, a1);
2756 if (generate_debug_code_ && op == Token::INIT_LET) { 2755 if (generate_debug_code_ && op == Token::INIT_LET) {
2757 // Check for an uninitialized let binding. 2756 // Check for an uninitialized let binding.
2758 __ ld(a2, location); 2757 __ ld(a2, location);
2759 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); 2758 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex);
2760 __ Check(eq, kLetBindingReInitialization, a2, Operand(a4)); 2759 __ Check(eq, kLetBindingReInitialization, a2, Operand(a4));
2761 } 2760 }
2762 EmitStoreToStackLocalOrContextSlot(var, location); 2761 EmitStoreToStackLocalOrContextSlot(var, location);
2763 } 2762 }
2764 } else if (IsSignallingAssignmentToConst(var, op, language_mode())) { 2763
2765 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2764 } else if (op == Token::INIT_CONST_LEGACY) {
2765 // Const initializers need a write barrier.
2766 DCHECK(!var->IsParameter()); // No const parameters.
2767 if (var->IsLookupSlot()) {
2768 __ li(a0, Operand(var->name()));
2769 __ Push(v0, cp, a0); // Context and name.
2770 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2771 } else {
2772 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2773 Label skip;
2774 MemOperand location = VarOperand(var, a1);
2775 __ ld(a2, location);
2776 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2777 __ Branch(&skip, ne, a2, Operand(at));
2778 EmitStoreToStackLocalOrContextSlot(var, location);
2779 __ bind(&skip);
2780 }
2781
2782 } else {
2783 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY);
2784 if (is_strict(language_mode())) {
2785 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2786 }
2787 // Silently ignore store in sloppy mode.
2766 } 2788 }
2767 } 2789 }
2768 2790
2769 2791
2770 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2792 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2771 // Assignment to a property, using a named store IC. 2793 // Assignment to a property, using a named store IC.
2772 Property* prop = expr->target()->AsProperty(); 2794 Property* prop = expr->target()->AsProperty();
2773 DCHECK(prop != NULL); 2795 DCHECK(prop != NULL);
2774 DCHECK(prop->key()->IsLiteral()); 2796 DCHECK(prop->key()->IsLiteral());
2775 2797
(...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after
5451 Assembler::target_address_at(pc_immediate_load_address)) == 5473 Assembler::target_address_at(pc_immediate_load_address)) ==
5452 reinterpret_cast<uint64_t>( 5474 reinterpret_cast<uint64_t>(
5453 isolate->builtins()->OsrAfterStackCheck()->entry())); 5475 isolate->builtins()->OsrAfterStackCheck()->entry()));
5454 return OSR_AFTER_STACK_CHECK; 5476 return OSR_AFTER_STACK_CHECK;
5455 } 5477 }
5456 5478
5457 5479
5458 } } // namespace v8::internal 5480 } } // namespace v8::internal
5459 5481
5460 #endif // V8_TARGET_ARCH_MIPS64 5482 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698