| OLD | NEW | 
|---|
| 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_X64 | 7 #if V8_TARGET_ARCH_X64 | 
| 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 817       __ Push(Smi::FromInt(attr)); | 817       __ Push(Smi::FromInt(attr)); | 
| 818       // Push initial value, if any. | 818       // Push initial value, if any. | 
| 819       // Note: For variables we must not push an initial value (such as | 819       // Note: For variables we must not push an initial value (such as | 
| 820       // 'undefined') because we may have a (legal) redeclaration and we | 820       // 'undefined') because we may have a (legal) redeclaration and we | 
| 821       // must not destroy the current value. | 821       // must not destroy the current value. | 
| 822       if (hole_init) { | 822       if (hole_init) { | 
| 823         __ PushRoot(Heap::kTheHoleValueRootIndex); | 823         __ PushRoot(Heap::kTheHoleValueRootIndex); | 
| 824       } else { | 824       } else { | 
| 825         __ Push(Smi::FromInt(0));  // Indicates no initial value. | 825         __ Push(Smi::FromInt(0));  // Indicates no initial value. | 
| 826       } | 826       } | 
| 827       __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 827       __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 
| 828       break; | 828       break; | 
| 829     } | 829     } | 
| 830   } | 830   } | 
| 831 } | 831 } | 
| 832 | 832 | 
| 833 | 833 | 
| 834 void FullCodeGenerator::VisitFunctionDeclaration( | 834 void FullCodeGenerator::VisitFunctionDeclaration( | 
| 835     FunctionDeclaration* declaration) { | 835     FunctionDeclaration* declaration) { | 
| 836   VariableProxy* proxy = declaration->proxy(); | 836   VariableProxy* proxy = declaration->proxy(); | 
| 837   Variable* variable = proxy->var(); | 837   Variable* variable = proxy->var(); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 871       PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 871       PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 
| 872       break; | 872       break; | 
| 873     } | 873     } | 
| 874 | 874 | 
| 875     case Variable::LOOKUP: { | 875     case Variable::LOOKUP: { | 
| 876       Comment cmnt(masm_, "[ FunctionDeclaration"); | 876       Comment cmnt(masm_, "[ FunctionDeclaration"); | 
| 877       __ Push(rsi); | 877       __ Push(rsi); | 
| 878       __ Push(variable->name()); | 878       __ Push(variable->name()); | 
| 879       __ Push(Smi::FromInt(NONE)); | 879       __ Push(Smi::FromInt(NONE)); | 
| 880       VisitForStackValue(declaration->fun()); | 880       VisitForStackValue(declaration->fun()); | 
| 881       __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 881       __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 
| 882       break; | 882       break; | 
| 883     } | 883     } | 
| 884   } | 884   } | 
| 885 } | 885 } | 
| 886 | 886 | 
| 887 | 887 | 
| 888 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 888 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 
| 889   Variable* variable = declaration->proxy()->var(); | 889   Variable* variable = declaration->proxy()->var(); | 
| 890   ASSERT(variable->location() == Variable::CONTEXT); | 890   ASSERT(variable->location() == Variable::CONTEXT); | 
| 891   ASSERT(variable->interface()->IsFrozen()); | 891   ASSERT(variable->interface()->IsFrozen()); | 
| (...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2375     Variable* var, MemOperand location) { | 2375     Variable* var, MemOperand location) { | 
| 2376   __ movp(location, rax); | 2376   __ movp(location, rax); | 
| 2377   if (var->IsContextSlot()) { | 2377   if (var->IsContextSlot()) { | 
| 2378     __ movp(rdx, rax); | 2378     __ movp(rdx, rax); | 
| 2379     __ RecordWriteContextSlot( | 2379     __ RecordWriteContextSlot( | 
| 2380         rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs); | 2380         rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs); | 
| 2381   } | 2381   } | 
| 2382 } | 2382 } | 
| 2383 | 2383 | 
| 2384 | 2384 | 
| 2385 void FullCodeGenerator::EmitCallStoreContextSlot( |  | 
| 2386     Handle<String> name, StrictMode strict_mode) { |  | 
| 2387   __ Push(rax);  // Value. |  | 
| 2388   __ Push(rsi);  // Context. |  | 
| 2389   __ Push(name); |  | 
| 2390   __ Push(Smi::FromInt(strict_mode)); |  | 
| 2391   __ CallRuntime(Runtime::kStoreContextSlot, 4); |  | 
| 2392 } |  | 
| 2393 |  | 
| 2394 |  | 
| 2395 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 2385 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 
| 2396                                                Token::Value op) { | 2386                                                Token::Value op) { | 
| 2397   if (var->IsUnallocated()) { | 2387   if (var->IsUnallocated()) { | 
| 2398     // Global var, const, or let. | 2388     // Global var, const, or let. | 
| 2399     __ Move(rcx, var->name()); | 2389     __ Move(rcx, var->name()); | 
| 2400     __ movp(rdx, GlobalObjectOperand()); | 2390     __ movp(rdx, GlobalObjectOperand()); | 
| 2401     CallStoreIC(); | 2391     CallStoreIC(); | 
| 2402 | 2392 | 
| 2403   } else if (op == Token::INIT_CONST_LEGACY) { | 2393   } else if (op == Token::INIT_CONST_LEGACY) { | 
| 2404     // Const initializers need a write barrier. | 2394     // Const initializers need a write barrier. | 
| 2405     ASSERT(!var->IsParameter());  // No const parameters. | 2395     ASSERT(!var->IsParameter());  // No const parameters. | 
| 2406     if (var->IsLookupSlot()) { | 2396     if (var->IsLookupSlot()) { | 
| 2407       __ Push(rax); | 2397       __ Push(rax); | 
| 2408       __ Push(rsi); | 2398       __ Push(rsi); | 
| 2409       __ Push(var->name()); | 2399       __ Push(var->name()); | 
| 2410       __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 2400       __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); | 
| 2411     } else { | 2401     } else { | 
| 2412       ASSERT(var->IsStackLocal() || var->IsContextSlot()); | 2402       ASSERT(var->IsStackLocal() || var->IsContextSlot()); | 
| 2413       Label skip; | 2403       Label skip; | 
| 2414       MemOperand location = VarOperand(var, rcx); | 2404       MemOperand location = VarOperand(var, rcx); | 
| 2415       __ movp(rdx, location); | 2405       __ movp(rdx, location); | 
| 2416       __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2406       __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 
| 2417       __ j(not_equal, &skip); | 2407       __ j(not_equal, &skip); | 
| 2418       EmitStoreToStackLocalOrContextSlot(var, location); | 2408       EmitStoreToStackLocalOrContextSlot(var, location); | 
| 2419       __ bind(&skip); | 2409       __ bind(&skip); | 
| 2420     } | 2410     } | 
| 2421 | 2411 | 
| 2422   } else if (var->mode() == LET && op != Token::INIT_LET) { | 2412   } else if (var->mode() == LET && op != Token::INIT_LET) { | 
| 2423     // Non-initializing assignment to let variable needs a write barrier. | 2413     // Non-initializing assignment to let variable needs a write barrier. | 
| 2424     if (var->IsLookupSlot()) { | 2414     ASSERT(!var->IsLookupSlot()); | 
| 2425       EmitCallStoreContextSlot(var->name(), strict_mode()); | 2415     ASSERT(var->IsStackAllocated() || var->IsContextSlot()); | 
| 2426     } else { | 2416     Label assign; | 
| 2427       ASSERT(var->IsStackAllocated() || var->IsContextSlot()); | 2417     MemOperand location = VarOperand(var, rcx); | 
| 2428       Label assign; | 2418     __ movp(rdx, location); | 
| 2429       MemOperand location = VarOperand(var, rcx); | 2419     __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 
| 2430       __ movp(rdx, location); | 2420     __ j(not_equal, &assign, Label::kNear); | 
| 2431       __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2421     __ Push(var->name()); | 
| 2432       __ j(not_equal, &assign, Label::kNear); | 2422     __ CallRuntime(Runtime::kThrowReferenceError, 1); | 
| 2433       __ Push(var->name()); | 2423     __ bind(&assign); | 
| 2434       __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2424     EmitStoreToStackLocalOrContextSlot(var, location); | 
| 2435       __ bind(&assign); |  | 
| 2436       EmitStoreToStackLocalOrContextSlot(var, location); |  | 
| 2437     } |  | 
| 2438 | 2425 | 
| 2439   } else if (!var->is_const_mode() || op == Token::INIT_CONST) { | 2426   } else if (!var->is_const_mode() || op == Token::INIT_CONST) { | 
| 2440     // Assignment to var or initializing assignment to let/const |  | 
| 2441     // in harmony mode. |  | 
| 2442     if (var->IsLookupSlot()) { | 2427     if (var->IsLookupSlot()) { | 
| 2443       EmitCallStoreContextSlot(var->name(), strict_mode()); | 2428       ASSERT(op == Token::ASSIGN || op == Token::INIT_VAR || | 
|  | 2429              op == Token::ASSIGN_ADD); | 
|  | 2430       // Assignment to var. | 
|  | 2431       __ Push(rax);  // Value. | 
|  | 2432       __ Push(rsi);  // Context. | 
|  | 2433       __ Push(var->name()); | 
|  | 2434       __ Push(Smi::FromInt(strict_mode())); | 
|  | 2435       __ CallRuntime(Runtime::kStoreLookupSlot, 4); | 
| 2444     } else { | 2436     } else { | 
|  | 2437       // Assignment to var or initializing assignment to let/const in harmony | 
|  | 2438       // mode. | 
| 2445       ASSERT(var->IsStackAllocated() || var->IsContextSlot()); | 2439       ASSERT(var->IsStackAllocated() || var->IsContextSlot()); | 
| 2446       MemOperand location = VarOperand(var, rcx); | 2440       MemOperand location = VarOperand(var, rcx); | 
| 2447       if (generate_debug_code_ && op == Token::INIT_LET) { | 2441       if (generate_debug_code_ && op == Token::INIT_LET) { | 
| 2448         // Check for an uninitialized let binding. | 2442         // Check for an uninitialized let binding. | 
| 2449         __ movp(rdx, location); | 2443         __ movp(rdx, location); | 
| 2450         __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2444         __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 
| 2451         __ Check(equal, kLetBindingReInitialization); | 2445         __ Check(equal, kLetBindingReInitialization); | 
| 2452       } | 2446       } | 
| 2453       EmitStoreToStackLocalOrContextSlot(var, location); | 2447       EmitStoreToStackLocalOrContextSlot(var, location); | 
| 2454     } | 2448     } | 
| (...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4812   ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4806   ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 
| 4813             Assembler::target_address_at(call_target_address, | 4807             Assembler::target_address_at(call_target_address, | 
| 4814                                          unoptimized_code)); | 4808                                          unoptimized_code)); | 
| 4815   return OSR_AFTER_STACK_CHECK; | 4809   return OSR_AFTER_STACK_CHECK; | 
| 4816 } | 4810 } | 
| 4817 | 4811 | 
| 4818 | 4812 | 
| 4819 } }  // namespace v8::internal | 4813 } }  // namespace v8::internal | 
| 4820 | 4814 | 
| 4821 #endif  // V8_TARGET_ARCH_X64 | 4815 #endif  // V8_TARGET_ARCH_X64 | 
| OLD | NEW | 
|---|