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

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

Issue 397573002: X87: Clean up and update const / var (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@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
« no previous file with comments | « no previous file | 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_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 __ push(Immediate(Smi::FromInt(attr))); 794 __ push(Immediate(Smi::FromInt(attr)));
795 // Push initial value, if any. 795 // Push initial value, if any.
796 // Note: For variables we must not push an initial value (such as 796 // Note: For variables we must not push an initial value (such as
797 // 'undefined') because we may have a (legal) redeclaration and we 797 // 'undefined') because we may have a (legal) redeclaration and we
798 // must not destroy the current value. 798 // must not destroy the current value.
799 if (hole_init) { 799 if (hole_init) {
800 __ push(Immediate(isolate()->factory()->the_hole_value())); 800 __ push(Immediate(isolate()->factory()->the_hole_value()));
801 } else { 801 } else {
802 __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value. 802 __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value.
803 } 803 }
804 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 804 __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
805 break; 805 break;
806 } 806 }
807 } 807 }
808 } 808 }
809 809
810 810
811 void FullCodeGenerator::VisitFunctionDeclaration( 811 void FullCodeGenerator::VisitFunctionDeclaration(
812 FunctionDeclaration* declaration) { 812 FunctionDeclaration* declaration) {
813 VariableProxy* proxy = declaration->proxy(); 813 VariableProxy* proxy = declaration->proxy();
814 Variable* variable = proxy->var(); 814 Variable* variable = proxy->var();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); 846 PrepareForBailoutForId(proxy->id(), NO_REGISTERS);
847 break; 847 break;
848 } 848 }
849 849
850 case Variable::LOOKUP: { 850 case Variable::LOOKUP: {
851 Comment cmnt(masm_, "[ FunctionDeclaration"); 851 Comment cmnt(masm_, "[ FunctionDeclaration");
852 __ push(esi); 852 __ push(esi);
853 __ push(Immediate(variable->name())); 853 __ push(Immediate(variable->name()));
854 __ push(Immediate(Smi::FromInt(NONE))); 854 __ push(Immediate(Smi::FromInt(NONE)));
855 VisitForStackValue(declaration->fun()); 855 VisitForStackValue(declaration->fun());
856 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 856 __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
857 break; 857 break;
858 } 858 }
859 } 859 }
860 } 860 }
861 861
862 862
863 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { 863 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
864 Variable* variable = declaration->proxy()->var(); 864 Variable* variable = declaration->proxy()->var();
865 ASSERT(variable->location() == Variable::CONTEXT); 865 ASSERT(variable->location() == Variable::CONTEXT);
866 ASSERT(variable->interface()->IsFrozen()); 866 ASSERT(variable->interface()->IsFrozen());
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 Variable* var, MemOperand location) { 2372 Variable* var, MemOperand location) {
2373 __ mov(location, eax); 2373 __ mov(location, eax);
2374 if (var->IsContextSlot()) { 2374 if (var->IsContextSlot()) {
2375 __ mov(edx, eax); 2375 __ mov(edx, eax);
2376 int offset = Context::SlotOffset(var->index()); 2376 int offset = Context::SlotOffset(var->index());
2377 __ RecordWriteContextSlot(ecx, offset, edx, ebx); 2377 __ RecordWriteContextSlot(ecx, offset, edx, ebx);
2378 } 2378 }
2379 } 2379 }
2380 2380
2381 2381
2382 void FullCodeGenerator::EmitCallStoreContextSlot(
2383 Handle<String> name, StrictMode strict_mode) {
2384 __ push(eax); // Value.
2385 __ push(esi); // Context.
2386 __ push(Immediate(name));
2387 __ push(Immediate(Smi::FromInt(strict_mode)));
2388 __ CallRuntime(Runtime::kStoreContextSlot, 4);
2389 }
2390
2391
2392 void FullCodeGenerator::EmitVariableAssignment(Variable* var, 2382 void FullCodeGenerator::EmitVariableAssignment(Variable* var,
2393 Token::Value op) { 2383 Token::Value op) {
2394 if (var->IsUnallocated()) { 2384 if (var->IsUnallocated()) {
2395 // Global var, const, or let. 2385 // Global var, const, or let.
2396 __ mov(StoreIC::NameRegister(), var->name()); 2386 __ mov(StoreIC::NameRegister(), var->name());
2397 __ mov(StoreIC::ReceiverRegister(), GlobalObjectOperand()); 2387 __ mov(StoreIC::ReceiverRegister(), GlobalObjectOperand());
2398 CallStoreIC(); 2388 CallStoreIC();
2399 2389
2400 } else if (op == Token::INIT_CONST_LEGACY) { 2390 } else if (op == Token::INIT_CONST_LEGACY) {
2401 // Const initializers need a write barrier. 2391 // Const initializers need a write barrier.
2402 ASSERT(!var->IsParameter()); // No const parameters. 2392 ASSERT(!var->IsParameter()); // No const parameters.
2403 if (var->IsLookupSlot()) { 2393 if (var->IsLookupSlot()) {
2404 __ push(eax); 2394 __ push(eax);
2405 __ push(esi); 2395 __ push(esi);
2406 __ push(Immediate(var->name())); 2396 __ push(Immediate(var->name()));
2407 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); 2397 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3);
2408 } else { 2398 } else {
2409 ASSERT(var->IsStackLocal() || var->IsContextSlot()); 2399 ASSERT(var->IsStackLocal() || var->IsContextSlot());
2410 Label skip; 2400 Label skip;
2411 MemOperand location = VarOperand(var, ecx); 2401 MemOperand location = VarOperand(var, ecx);
2412 __ mov(edx, location); 2402 __ mov(edx, location);
2413 __ cmp(edx, isolate()->factory()->the_hole_value()); 2403 __ cmp(edx, isolate()->factory()->the_hole_value());
2414 __ j(not_equal, &skip, Label::kNear); 2404 __ j(not_equal, &skip, Label::kNear);
2415 EmitStoreToStackLocalOrContextSlot(var, location); 2405 EmitStoreToStackLocalOrContextSlot(var, location);
2416 __ bind(&skip); 2406 __ bind(&skip);
2417 } 2407 }
2418 2408
2419 } else if (var->mode() == LET && op != Token::INIT_LET) { 2409 } else if (var->mode() == LET && op != Token::INIT_LET) {
2420 // Non-initializing assignment to let variable needs a write barrier. 2410 // Non-initializing assignment to let variable needs a write barrier.
2421 if (var->IsLookupSlot()) { 2411 ASSERT(!var->IsLookupSlot());
2422 EmitCallStoreContextSlot(var->name(), strict_mode()); 2412 ASSERT(var->IsStackAllocated() || var->IsContextSlot());
2423 } else { 2413 Label assign;
2424 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); 2414 MemOperand location = VarOperand(var, ecx);
2425 Label assign; 2415 __ mov(edx, location);
2426 MemOperand location = VarOperand(var, ecx); 2416 __ cmp(edx, isolate()->factory()->the_hole_value());
2427 __ mov(edx, location); 2417 __ j(not_equal, &assign, Label::kNear);
2428 __ cmp(edx, isolate()->factory()->the_hole_value()); 2418 __ push(Immediate(var->name()));
2429 __ j(not_equal, &assign, Label::kNear); 2419 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2430 __ push(Immediate(var->name())); 2420 __ bind(&assign);
2431 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2421 EmitStoreToStackLocalOrContextSlot(var, location);
2432 __ bind(&assign);
2433 EmitStoreToStackLocalOrContextSlot(var, location);
2434 }
2435 2422
2436 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { 2423 } else if (!var->is_const_mode() || op == Token::INIT_CONST) {
2437 // Assignment to var or initializing assignment to let/const
2438 // in harmony mode.
2439 if (var->IsLookupSlot()) { 2424 if (var->IsLookupSlot()) {
2440 EmitCallStoreContextSlot(var->name(), strict_mode()); 2425 // Assignment to var.
2426 __ push(eax); // Value.
2427 __ push(esi); // Context.
2428 __ push(Immediate(var->name()));
2429 __ push(Immediate(Smi::FromInt(strict_mode())));
2430 __ CallRuntime(Runtime::kStoreLookupSlot, 4);
2441 } else { 2431 } else {
2432 // Assignment to var or initializing assignment to let/const in harmony
2433 // mode.
2442 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); 2434 ASSERT(var->IsStackAllocated() || var->IsContextSlot());
2443 MemOperand location = VarOperand(var, ecx); 2435 MemOperand location = VarOperand(var, ecx);
2444 if (generate_debug_code_ && op == Token::INIT_LET) { 2436 if (generate_debug_code_ && op == Token::INIT_LET) {
2445 // Check for an uninitialized let binding. 2437 // Check for an uninitialized let binding.
2446 __ mov(edx, location); 2438 __ mov(edx, location);
2447 __ cmp(edx, isolate()->factory()->the_hole_value()); 2439 __ cmp(edx, isolate()->factory()->the_hole_value());
2448 __ Check(equal, kLetBindingReInitialization); 2440 __ Check(equal, kLetBindingReInitialization);
2449 } 2441 }
2450 EmitStoreToStackLocalOrContextSlot(var, location); 2442 EmitStoreToStackLocalOrContextSlot(var, location);
2451 } 2443 }
(...skipping 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after
4797 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4789 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4798 Assembler::target_address_at(call_target_address, 4790 Assembler::target_address_at(call_target_address,
4799 unoptimized_code)); 4791 unoptimized_code));
4800 return OSR_AFTER_STACK_CHECK; 4792 return OSR_AFTER_STACK_CHECK;
4801 } 4793 }
4802 4794
4803 4795
4804 } } // namespace v8::internal 4796 } } // namespace v8::internal
4805 4797
4806 #endif // V8_TARGET_ARCH_X87 4798 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698