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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
(...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2487 | 2487 |
2488 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2488 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2489 FeedbackVectorSlot slot) { | 2489 FeedbackVectorSlot slot) { |
2490 if (var->IsUnallocated()) { | 2490 if (var->IsUnallocated()) { |
2491 // Global var, const, or let. | 2491 // Global var, const, or let. |
2492 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2492 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2493 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2493 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2494 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2494 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2495 CallStoreIC(); | 2495 CallStoreIC(); |
2496 | 2496 |
2497 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2497 } else if (var->mode() == LET && op != Token::INIT) { |
2498 // Non-initializing assignment to let variable needs a write barrier. | 2498 // Non-initializing assignment to let variable needs a write barrier. |
2499 DCHECK(!var->IsLookupSlot()); | 2499 DCHECK(!var->IsLookupSlot()); |
2500 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2500 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2501 Label assign; | 2501 Label assign; |
2502 MemOperand location = VarOperand(var, ecx); | 2502 MemOperand location = VarOperand(var, ecx); |
2503 __ mov(edx, location); | 2503 __ mov(edx, location); |
2504 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2504 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2505 __ j(not_equal, &assign, Label::kNear); | 2505 __ j(not_equal, &assign, Label::kNear); |
2506 __ push(Immediate(var->name())); | 2506 __ push(Immediate(var->name())); |
2507 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2507 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
2508 __ bind(&assign); | 2508 __ bind(&assign); |
2509 EmitStoreToStackLocalOrContextSlot(var, location); | 2509 EmitStoreToStackLocalOrContextSlot(var, location); |
2510 | 2510 |
2511 } else if (var->mode() == CONST && op != Token::INIT_CONST) { | 2511 } else if (var->mode() == CONST && op != Token::INIT) { |
2512 // Assignment to const variable needs a write barrier. | 2512 // Assignment to const variable needs a write barrier. |
2513 DCHECK(!var->IsLookupSlot()); | 2513 DCHECK(!var->IsLookupSlot()); |
2514 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2514 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2515 Label const_error; | 2515 Label const_error; |
2516 MemOperand location = VarOperand(var, ecx); | 2516 MemOperand location = VarOperand(var, ecx); |
2517 __ mov(edx, location); | 2517 __ mov(edx, location); |
2518 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2518 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2519 __ j(not_equal, &const_error, Label::kNear); | 2519 __ j(not_equal, &const_error, Label::kNear); |
2520 __ push(Immediate(var->name())); | 2520 __ push(Immediate(var->name())); |
2521 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2521 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
2522 __ bind(&const_error); | 2522 __ bind(&const_error); |
2523 __ CallRuntime(Runtime::kThrowConstAssignError, 0); | 2523 __ CallRuntime(Runtime::kThrowConstAssignError, 0); |
2524 | 2524 |
2525 } else if (var->is_this() && op == Token::INIT_CONST) { | 2525 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { |
2526 // Initializing assignment to const {this} needs a write barrier. | 2526 // Initializing assignment to const {this} needs a write barrier. |
2527 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2527 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2528 Label uninitialized_this; | 2528 Label uninitialized_this; |
2529 MemOperand location = VarOperand(var, ecx); | 2529 MemOperand location = VarOperand(var, ecx); |
2530 __ mov(edx, location); | 2530 __ mov(edx, location); |
2531 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2531 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2532 __ j(equal, &uninitialized_this); | 2532 __ j(equal, &uninitialized_this); |
2533 __ push(Immediate(var->name())); | 2533 __ push(Immediate(var->name())); |
2534 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2534 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
2535 __ bind(&uninitialized_this); | 2535 __ bind(&uninitialized_this); |
2536 EmitStoreToStackLocalOrContextSlot(var, location); | 2536 EmitStoreToStackLocalOrContextSlot(var, location); |
2537 | 2537 |
2538 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { | 2538 } else if (!var->is_const_mode() || |
| 2539 (var->mode() == CONST && op == Token::INIT)) { |
2539 if (var->IsLookupSlot()) { | 2540 if (var->IsLookupSlot()) { |
2540 // Assignment to var. | 2541 // Assignment to var. |
2541 __ push(eax); // Value. | 2542 __ push(eax); // Value. |
2542 __ push(esi); // Context. | 2543 __ push(esi); // Context. |
2543 __ push(Immediate(var->name())); | 2544 __ push(Immediate(var->name())); |
2544 __ push(Immediate(Smi::FromInt(language_mode()))); | 2545 __ push(Immediate(Smi::FromInt(language_mode()))); |
2545 __ CallRuntime(Runtime::kStoreLookupSlot, 4); | 2546 __ CallRuntime(Runtime::kStoreLookupSlot, 4); |
2546 } else { | 2547 } else { |
2547 // Assignment to var or initializing assignment to let/const in harmony | 2548 // Assignment to var or initializing assignment to let/const in harmony |
2548 // mode. | 2549 // mode. |
2549 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2550 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2550 MemOperand location = VarOperand(var, ecx); | 2551 MemOperand location = VarOperand(var, ecx); |
2551 if (generate_debug_code_ && op == Token::INIT_LET) { | 2552 if (generate_debug_code_ && var->mode() == LET && op == Token::INIT) { |
2552 // Check for an uninitialized let binding. | 2553 // Check for an uninitialized let binding. |
2553 __ mov(edx, location); | 2554 __ mov(edx, location); |
2554 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2555 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2555 __ Check(equal, kLetBindingReInitialization); | 2556 __ Check(equal, kLetBindingReInitialization); |
2556 } | 2557 } |
2557 EmitStoreToStackLocalOrContextSlot(var, location); | 2558 EmitStoreToStackLocalOrContextSlot(var, location); |
2558 } | 2559 } |
2559 | 2560 |
2560 } else if (op == Token::INIT_CONST_LEGACY) { | 2561 } else if (var->mode() == CONST_LEGACY && op == Token::INIT) { |
2561 // Const initializers need a write barrier. | 2562 // Const initializers need a write barrier. |
2562 DCHECK(var->mode() == CONST_LEGACY); | |
2563 DCHECK(!var->IsParameter()); // No const parameters. | 2563 DCHECK(!var->IsParameter()); // No const parameters. |
2564 if (var->IsLookupSlot()) { | 2564 if (var->IsLookupSlot()) { |
2565 __ push(eax); | 2565 __ push(eax); |
2566 __ push(esi); | 2566 __ push(esi); |
2567 __ push(Immediate(var->name())); | 2567 __ push(Immediate(var->name())); |
2568 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); | 2568 __ CallRuntime(Runtime::kInitializeLegacyConstLookupSlot, 3); |
2569 } else { | 2569 } else { |
2570 DCHECK(var->IsStackLocal() || var->IsContextSlot()); | 2570 DCHECK(var->IsStackLocal() || var->IsContextSlot()); |
2571 Label skip; | 2571 Label skip; |
2572 MemOperand location = VarOperand(var, ecx); | 2572 MemOperand location = VarOperand(var, ecx); |
2573 __ mov(edx, location); | 2573 __ mov(edx, location); |
2574 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2574 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2575 __ j(not_equal, &skip, Label::kNear); | 2575 __ j(not_equal, &skip, Label::kNear); |
2576 EmitStoreToStackLocalOrContextSlot(var, location); | 2576 EmitStoreToStackLocalOrContextSlot(var, location); |
2577 __ bind(&skip); | 2577 __ bind(&skip); |
2578 } | 2578 } |
2579 | 2579 |
2580 } else { | 2580 } else { |
2581 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT_CONST_LEGACY); | 2581 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); |
2582 if (is_strict(language_mode())) { | 2582 if (is_strict(language_mode())) { |
2583 __ CallRuntime(Runtime::kThrowConstAssignError, 0); | 2583 __ CallRuntime(Runtime::kThrowConstAssignError, 0); |
2584 } | 2584 } |
2585 // Silently ignore store in sloppy mode. | 2585 // Silently ignore store in sloppy mode. |
2586 } | 2586 } |
2587 } | 2587 } |
2588 | 2588 |
2589 | 2589 |
2590 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2590 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2591 // Assignment to a property, using a named store IC. | 2591 // Assignment to a property, using a named store IC. |
(...skipping 2368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4960 Assembler::target_address_at(call_target_address, | 4960 Assembler::target_address_at(call_target_address, |
4961 unoptimized_code)); | 4961 unoptimized_code)); |
4962 return OSR_AFTER_STACK_CHECK; | 4962 return OSR_AFTER_STACK_CHECK; |
4963 } | 4963 } |
4964 | 4964 |
4965 | 4965 |
4966 } // namespace internal | 4966 } // namespace internal |
4967 } // namespace v8 | 4967 } // namespace v8 |
4968 | 4968 |
4969 #endif // V8_TARGET_ARCH_IA32 | 4969 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |