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

Side by Side Diff: src/mips/full-codegen-mips.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 | « no previous file | src/mips64/full-codegen-mips64.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 2700
2701 2701
2702 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) { 2702 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) {
2703 if (var->IsUnallocated()) { 2703 if (var->IsUnallocated()) {
2704 // Global var, const, or let. 2704 // Global var, const, or let.
2705 __ mov(StoreDescriptor::ValueRegister(), result_register()); 2705 __ mov(StoreDescriptor::ValueRegister(), result_register());
2706 __ li(StoreDescriptor::NameRegister(), Operand(var->name())); 2706 __ li(StoreDescriptor::NameRegister(), Operand(var->name()));
2707 __ lw(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); 2707 __ lw(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
2708 CallStoreIC(); 2708 CallStoreIC();
2709 2709
2710 } else if (op == Token::INIT_CONST_LEGACY) {
2711 // Const initializers need a write barrier.
2712 DCHECK(!var->IsParameter()); // No const parameters.
2713 if (var->IsLookupSlot()) {
2714 __ li(a0, Operand(var->name()));
2715 __ Push(v0, cp, a0); // Context and name.
2716 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2717 } else {
2718 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2719 Label skip;
2720 MemOperand location = VarOperand(var, a1);
2721 __ lw(a2, location);
2722 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2723 __ Branch(&skip, ne, a2, Operand(at));
2724 EmitStoreToStackLocalOrContextSlot(var, location);
2725 __ bind(&skip);
2726 }
2727
2728 } else if (var->mode() == LET && op != Token::INIT_LET) { 2710 } else if (var->mode() == LET && op != Token::INIT_LET) {
2729 // Non-initializing assignment to let variable needs a write barrier. 2711 // Non-initializing assignment to let variable needs a write barrier.
2730 DCHECK(!var->IsLookupSlot()); 2712 DCHECK(!var->IsLookupSlot());
2731 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2713 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2732 Label assign; 2714 Label assign;
2733 MemOperand location = VarOperand(var, a1); 2715 MemOperand location = VarOperand(var, a1);
2734 __ lw(a3, location); 2716 __ lw(a3, location);
2735 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2717 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2736 __ Branch(&assign, ne, a3, Operand(t0)); 2718 __ Branch(&assign, ne, a3, Operand(t0));
2737 __ li(a3, Operand(var->name())); 2719 __ li(a3, Operand(var->name()));
2738 __ push(a3); 2720 __ push(a3);
2739 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2721 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2740 // Perform the assignment. 2722 // Perform the assignment.
2741 __ bind(&assign); 2723 __ bind(&assign);
2742 EmitStoreToStackLocalOrContextSlot(var, location); 2724 EmitStoreToStackLocalOrContextSlot(var, location);
2725
2726 } else if (var->mode() == CONST && op != Token::INIT_CONST) {
2727 // Assignment to const variable needs a write barrier.
2728 DCHECK(!var->IsLookupSlot());
2729 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2730 Label const_error;
2731 MemOperand location = VarOperand(var, a1);
2732 __ lw(a3, location);
2733 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2734 __ Branch(&const_error, ne, a3, Operand(at));
2735 __ li(a3, Operand(var->name()));
2736 __ push(a3);
2737 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2738 __ bind(&const_error);
2739 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2740
2743 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2741 } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
2744 if (var->IsLookupSlot()) { 2742 if (var->IsLookupSlot()) {
2745 // Assignment to var. 2743 // Assignment to var.
2746 __ li(a1, Operand(var->name())); 2744 __ li(a1, Operand(var->name()));
2747 __ li(a0, Operand(Smi::FromInt(language_mode()))); 2745 __ li(a0, Operand(Smi::FromInt(language_mode())));
2748 __ Push(v0, cp, a1, a0); // Value, context, name, language mode. 2746 __ Push(v0, cp, a1, a0); // Value, context, name, language mode.
2749 __ CallRuntime(Runtime::kStoreLookupSlot, 4); 2747 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2750 } else { 2748 } else {
2751 // Assignment to var or initializing assignment to let/const in harmony 2749 // Assignment to var or initializing assignment to let/const in harmony
2752 // mode. 2750 // mode.
2753 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); 2751 DCHECK((var->IsStackAllocated() || var->IsContextSlot()));
2754 MemOperand location = VarOperand(var, a1); 2752 MemOperand location = VarOperand(var, a1);
2755 if (generate_debug_code_ && op == Token::INIT_LET) { 2753 if (generate_debug_code_ && op == Token::INIT_LET) {
2756 // Check for an uninitialized let binding. 2754 // Check for an uninitialized let binding.
2757 __ lw(a2, location); 2755 __ lw(a2, location);
2758 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2756 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2759 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0)); 2757 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0));
2760 } 2758 }
2761 EmitStoreToStackLocalOrContextSlot(var, location); 2759 EmitStoreToStackLocalOrContextSlot(var, location);
2762 } 2760 }
2763 } else if (IsSignallingAssignmentToConst(var, op, language_mode())) { 2761
2764 __ CallRuntime(Runtime::kThrowConstAssignError, 0); 2762 } else if (op == Token::INIT_CONST_LEGACY) {
2763 // Const initializers need a write barrier.
2764 DCHECK(!var->IsParameter()); // No const parameters.
2765 if (var->IsLookupSlot()) {
2766 __ li(a0, Operand(var->name()));
2767 __ Push(v0, cp, a0); // Context and name.
2768 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2769 } else {
2770 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2771 Label skip;
2772 MemOperand location = VarOperand(var, a1);
2773 __ lw(a2, location);
2774 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2775 __ Branch(&skip, ne, a2, Operand(at));
2776 EmitStoreToStackLocalOrContextSlot(var, location);
2777 __ bind(&skip);
2778 }
2779
2780 } else {
2781 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY);
2782 if (is_strict(language_mode())) {
2783 __ CallRuntime(Runtime::kThrowConstAssignError, 0);
2784 }
2785 // Silently ignore store in sloppy mode.
2765 } 2786 }
2766 } 2787 }
2767 2788
2768 2789
2769 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2790 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2770 // Assignment to a property, using a named store IC. 2791 // Assignment to a property, using a named store IC.
2771 Property* prop = expr->target()->AsProperty(); 2792 Property* prop = expr->target()->AsProperty();
2772 DCHECK(prop != NULL); 2793 DCHECK(prop != NULL);
2773 DCHECK(prop->key()->IsLiteral()); 2794 DCHECK(prop->key()->IsLiteral());
2774 2795
(...skipping 2670 matching lines...) Expand 10 before | Expand all | Expand 10 after
5445 Assembler::target_address_at(pc_immediate_load_address)) == 5466 Assembler::target_address_at(pc_immediate_load_address)) ==
5446 reinterpret_cast<uint32_t>( 5467 reinterpret_cast<uint32_t>(
5447 isolate->builtins()->OsrAfterStackCheck()->entry())); 5468 isolate->builtins()->OsrAfterStackCheck()->entry()));
5448 return OSR_AFTER_STACK_CHECK; 5469 return OSR_AFTER_STACK_CHECK;
5449 } 5470 }
5450 5471
5451 5472
5452 } } // namespace v8::internal 5473 } } // namespace v8::internal
5453 5474
5454 #endif // V8_TARGET_ARCH_MIPS 5475 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | src/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698