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

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

Issue 389373004: MIPS: This CL simplifies var / const by ensuring the behavior is consistent in itself, and with reg… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // 'undefined') because we may have a (legal) redeclaration and we 849 // 'undefined') because we may have a (legal) redeclaration and we
850 // must not destroy the current value. 850 // must not destroy the current value.
851 if (hole_init) { 851 if (hole_init) {
852 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex); 852 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex);
853 __ Push(cp, a2, a1, a0); 853 __ Push(cp, a2, a1, a0);
854 } else { 854 } else {
855 ASSERT(Smi::FromInt(0) == 0); 855 ASSERT(Smi::FromInt(0) == 0);
856 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value. 856 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value.
857 __ Push(cp, a2, a1, a0); 857 __ Push(cp, a2, a1, a0);
858 } 858 }
859 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 859 __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
860 break; 860 break;
861 } 861 }
862 } 862 }
863 } 863 }
864 864
865 865
866 void FullCodeGenerator::VisitFunctionDeclaration( 866 void FullCodeGenerator::VisitFunctionDeclaration(
867 FunctionDeclaration* declaration) { 867 FunctionDeclaration* declaration) {
868 VariableProxy* proxy = declaration->proxy(); 868 VariableProxy* proxy = declaration->proxy();
869 Variable* variable = proxy->var(); 869 Variable* variable = proxy->var();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 break; 905 break;
906 } 906 }
907 907
908 case Variable::LOOKUP: { 908 case Variable::LOOKUP: {
909 Comment cmnt(masm_, "[ FunctionDeclaration"); 909 Comment cmnt(masm_, "[ FunctionDeclaration");
910 __ li(a2, Operand(variable->name())); 910 __ li(a2, Operand(variable->name()));
911 __ li(a1, Operand(Smi::FromInt(NONE))); 911 __ li(a1, Operand(Smi::FromInt(NONE)));
912 __ Push(cp, a2, a1); 912 __ Push(cp, a2, a1);
913 // Push initial value for function declaration. 913 // Push initial value for function declaration.
914 VisitForStackValue(declaration->fun()); 914 VisitForStackValue(declaration->fun());
915 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 915 __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
916 break; 916 break;
917 } 917 }
918 } 918 }
919 } 919 }
920 920
921 921
922 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { 922 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
923 Variable* variable = declaration->proxy()->var(); 923 Variable* variable = declaration->proxy()->var();
924 ASSERT(variable->location() == Variable::CONTEXT); 924 ASSERT(variable->location() == Variable::CONTEXT);
925 ASSERT(variable->interface()->IsFrozen()); 925 ASSERT(variable->interface()->IsFrozen());
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 if (var->IsContextSlot()) { 2445 if (var->IsContextSlot()) {
2446 // RecordWrite may destroy all its register arguments. 2446 // RecordWrite may destroy all its register arguments.
2447 __ Move(a3, result_register()); 2447 __ Move(a3, result_register());
2448 int offset = Context::SlotOffset(var->index()); 2448 int offset = Context::SlotOffset(var->index());
2449 __ RecordWriteContextSlot( 2449 __ RecordWriteContextSlot(
2450 a1, offset, a3, a2, kRAHasBeenSaved, kDontSaveFPRegs); 2450 a1, offset, a3, a2, kRAHasBeenSaved, kDontSaveFPRegs);
2451 } 2451 }
2452 } 2452 }
2453 2453
2454 2454
2455 void FullCodeGenerator::EmitCallStoreContextSlot(
2456 Handle<String> name, StrictMode strict_mode) {
2457 __ li(a1, Operand(name));
2458 __ li(a0, Operand(Smi::FromInt(strict_mode)));
2459 __ Push(v0, cp, a1, a0); // Value, context, name, strict mode.
2460 __ CallRuntime(Runtime::kStoreContextSlot, 4);
2461 }
2462
2463
2464 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) { 2455 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op) {
2465 if (var->IsUnallocated()) { 2456 if (var->IsUnallocated()) {
2466 // Global var, const, or let. 2457 // Global var, const, or let.
2467 __ mov(StoreIC::ValueRegister(), result_register()); 2458 __ mov(StoreIC::ValueRegister(), result_register());
2468 __ li(StoreIC::NameRegister(), Operand(var->name())); 2459 __ li(StoreIC::NameRegister(), Operand(var->name()));
2469 __ lw(StoreIC::ReceiverRegister(), GlobalObjectOperand()); 2460 __ lw(StoreIC::ReceiverRegister(), GlobalObjectOperand());
2470 CallStoreIC(); 2461 CallStoreIC();
2471 2462
2472 } else if (op == Token::INIT_CONST_LEGACY) { 2463 } else if (op == Token::INIT_CONST_LEGACY) {
2473 // Const initializers need a write barrier. 2464 // Const initializers need a write barrier.
2474 ASSERT(!var->IsParameter()); // No const parameters. 2465 ASSERT(!var->IsParameter()); // No const parameters.
2475 if (var->IsLookupSlot()) { 2466 if (var->IsLookupSlot()) {
2476 __ li(a0, Operand(var->name())); 2467 __ li(a0, Operand(var->name()));
2477 __ Push(v0, cp, a0); // Context and name. 2468 __ Push(v0, cp, a0); // Context and name.
2478 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); 2469 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2479 } else { 2470 } else {
2480 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); 2471 ASSERT(var->IsStackAllocated() || var->IsContextSlot());
2481 Label skip; 2472 Label skip;
2482 MemOperand location = VarOperand(var, a1); 2473 MemOperand location = VarOperand(var, a1);
2483 __ lw(a2, location); 2474 __ lw(a2, location);
2484 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2475 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2485 __ Branch(&skip, ne, a2, Operand(at)); 2476 __ Branch(&skip, ne, a2, Operand(at));
2486 EmitStoreToStackLocalOrContextSlot(var, location); 2477 EmitStoreToStackLocalOrContextSlot(var, location);
2487 __ bind(&skip); 2478 __ bind(&skip);
2488 } 2479 }
2489 2480
2490 } else if (var->mode() == LET && op != Token::INIT_LET) { 2481 } else if (var->mode() == LET && op != Token::INIT_LET) {
2491 // Non-initializing assignment to let variable needs a write barrier. 2482 // Non-initializing assignment to let variable needs a write barrier.
2492 if (var->IsLookupSlot()) { 2483 ASSERT(!var->IsLookupSlot());
2493 EmitCallStoreContextSlot(var->name(), strict_mode()); 2484 ASSERT(var->IsStackAllocated() || var->IsContextSlot());
2494 } else { 2485 Label assign;
2495 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); 2486 MemOperand location = VarOperand(var, a1);
2496 Label assign; 2487 __ lw(a3, location);
2497 MemOperand location = VarOperand(var, a1); 2488 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2498 __ lw(a3, location); 2489 __ Branch(&assign, ne, a3, Operand(t0));
2499 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2490 __ li(a3, Operand(var->name()));
2500 __ Branch(&assign, ne, a3, Operand(t0)); 2491 __ push(a3);
2501 __ li(a3, Operand(var->name())); 2492 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2502 __ push(a3); 2493 // Perform the assignment.
2503 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2494 __ bind(&assign);
2504 // Perform the assignment. 2495 EmitStoreToStackLocalOrContextSlot(var, location);
2505 __ bind(&assign);
2506 EmitStoreToStackLocalOrContextSlot(var, location);
2507 }
2508 2496
2509 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2497 } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
2510 // Assignment to var or initializing assignment to let/const
2511 // in harmony mode.
2512 if (var->IsLookupSlot()) { 2498 if (var->IsLookupSlot()) {
2513 EmitCallStoreContextSlot(var->name(), strict_mode()); 2499 ASSERT(op == Token::ASSIGN || op == Token::INIT_VAR ||
2500 op == Token::ASSIGN_ADD);
2501 // Assignment to var.
2502 __ li(a1, Operand(var->name()));
2503 __ li(a0, Operand(Smi::FromInt(strict_mode())));
2504 __ Push(v0, cp, a1, a0); // Value, context, name, strict mode.
2505 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2514 } else { 2506 } else {
2507 // Assignment to var or initializing assignment to let/const in harmony
2508 // mode.
2515 ASSERT((var->IsStackAllocated() || var->IsContextSlot())); 2509 ASSERT((var->IsStackAllocated() || var->IsContextSlot()));
2516 MemOperand location = VarOperand(var, a1); 2510 MemOperand location = VarOperand(var, a1);
2517 if (generate_debug_code_ && op == Token::INIT_LET) { 2511 if (generate_debug_code_ && op == Token::INIT_LET) {
2518 // Check for an uninitialized let binding. 2512 // Check for an uninitialized let binding.
2519 __ lw(a2, location); 2513 __ lw(a2, location);
2520 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2514 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
2521 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0)); 2515 __ Check(eq, kLetBindingReInitialization, a2, Operand(t0));
2522 } 2516 }
2523 EmitStoreToStackLocalOrContextSlot(var, location); 2517 EmitStoreToStackLocalOrContextSlot(var, location);
2524 } 2518 }
(...skipping 2337 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 Assembler::target_address_at(pc_immediate_load_address)) == 4856 Assembler::target_address_at(pc_immediate_load_address)) ==
4863 reinterpret_cast<uint32_t>( 4857 reinterpret_cast<uint32_t>(
4864 isolate->builtins()->OsrAfterStackCheck()->entry())); 4858 isolate->builtins()->OsrAfterStackCheck()->entry()));
4865 return OSR_AFTER_STACK_CHECK; 4859 return OSR_AFTER_STACK_CHECK;
4866 } 4860 }
4867 4861
4868 4862
4869 } } // namespace v8::internal 4863 } } // namespace v8::internal
4870 4864
4871 #endif // V8_TARGET_ARCH_MIPS 4865 #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