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