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/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 // Perform an initialization check for lexically declared variables. | 2060 // Perform an initialization check for lexically declared variables. |
2061 if (var->binding_needs_init()) { | 2061 if (var->binding_needs_init()) { |
2062 Label assign; | 2062 Label assign; |
2063 __ mov(edx, location); | 2063 __ mov(edx, location); |
2064 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2064 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2065 __ j(not_equal, &assign, Label::kNear); | 2065 __ j(not_equal, &assign, Label::kNear); |
2066 __ push(Immediate(var->name())); | 2066 __ push(Immediate(var->name())); |
2067 __ CallRuntime(Runtime::kThrowReferenceError); | 2067 __ CallRuntime(Runtime::kThrowReferenceError); |
2068 __ bind(&assign); | 2068 __ bind(&assign); |
2069 } | 2069 } |
2070 if (var->mode() == CONST) { | 2070 if (var->mode() != CONST) { |
| 2071 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2072 } else if (var->throw_on_const_assignment(language_mode())) { |
2071 __ CallRuntime(Runtime::kThrowConstAssignError); | 2073 __ CallRuntime(Runtime::kThrowConstAssignError); |
2072 } else { | |
2073 EmitStoreToStackLocalOrContextSlot(var, location); | |
2074 } | 2074 } |
2075 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { | 2075 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { |
2076 // Initializing assignment to const {this} needs a write barrier. | 2076 // Initializing assignment to const {this} needs a write barrier. |
2077 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2077 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2078 Label uninitialized_this; | 2078 Label uninitialized_this; |
2079 MemOperand location = VarOperand(var, ecx); | 2079 MemOperand location = VarOperand(var, ecx); |
2080 __ mov(edx, location); | 2080 __ mov(edx, location); |
2081 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2081 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2082 __ j(equal, &uninitialized_this); | 2082 __ j(equal, &uninitialized_this); |
2083 __ push(Immediate(var->name())); | 2083 __ push(Immediate(var->name())); |
2084 __ CallRuntime(Runtime::kThrowReferenceError); | 2084 __ CallRuntime(Runtime::kThrowReferenceError); |
2085 __ bind(&uninitialized_this); | 2085 __ bind(&uninitialized_this); |
2086 EmitStoreToStackLocalOrContextSlot(var, location); | 2086 EmitStoreToStackLocalOrContextSlot(var, location); |
2087 | 2087 |
2088 } else if (!var->is_const_mode() || op == Token::INIT) { | 2088 } else { |
| 2089 DCHECK(var->mode() != CONST || op == Token::INIT); |
2089 if (var->IsLookupSlot()) { | 2090 if (var->IsLookupSlot()) { |
2090 // Assignment to var. | 2091 // Assignment to var. |
2091 __ Push(Immediate(var->name())); | 2092 __ Push(Immediate(var->name())); |
2092 __ Push(eax); | 2093 __ Push(eax); |
2093 __ CallRuntime(is_strict(language_mode()) | 2094 __ CallRuntime(is_strict(language_mode()) |
2094 ? Runtime::kStoreLookupSlot_Strict | 2095 ? Runtime::kStoreLookupSlot_Strict |
2095 : Runtime::kStoreLookupSlot_Sloppy); | 2096 : Runtime::kStoreLookupSlot_Sloppy); |
2096 } else { | 2097 } else { |
2097 // Assignment to var or initializing assignment to let/const in harmony | 2098 // Assignment to var or initializing assignment to let/const in harmony |
2098 // mode. | 2099 // mode. |
2099 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2100 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2100 MemOperand location = VarOperand(var, ecx); | 2101 MemOperand location = VarOperand(var, ecx); |
2101 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { | 2102 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { |
2102 // Check for an uninitialized let binding. | 2103 // Check for an uninitialized let binding. |
2103 __ mov(edx, location); | 2104 __ mov(edx, location); |
2104 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2105 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2105 __ Check(equal, kLetBindingReInitialization); | 2106 __ Check(equal, kLetBindingReInitialization); |
2106 } | 2107 } |
2107 EmitStoreToStackLocalOrContextSlot(var, location); | 2108 EmitStoreToStackLocalOrContextSlot(var, location); |
2108 } | 2109 } |
2109 | |
2110 } else { | |
2111 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); | |
2112 if (is_strict(language_mode())) { | |
2113 __ CallRuntime(Runtime::kThrowConstAssignError); | |
2114 } | |
2115 // Silently ignore store in sloppy mode. | |
2116 } | 2110 } |
2117 } | 2111 } |
2118 | 2112 |
2119 | 2113 |
2120 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2114 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2121 // Assignment to a property, using a named store IC. | 2115 // Assignment to a property, using a named store IC. |
2122 // eax : value | 2116 // eax : value |
2123 // esp[0] : receiver | 2117 // esp[0] : receiver |
2124 Property* prop = expr->target()->AsProperty(); | 2118 Property* prop = expr->target()->AsProperty(); |
2125 DCHECK(prop != NULL); | 2119 DCHECK(prop != NULL); |
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3640 isolate->builtins()->OnStackReplacement()->entry(), | 3634 isolate->builtins()->OnStackReplacement()->entry(), |
3641 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3635 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3642 return ON_STACK_REPLACEMENT; | 3636 return ON_STACK_REPLACEMENT; |
3643 } | 3637 } |
3644 | 3638 |
3645 | 3639 |
3646 } // namespace internal | 3640 } // namespace internal |
3647 } // namespace v8 | 3641 } // namespace v8 |
3648 | 3642 |
3649 #endif // V8_TARGET_ARCH_X87 | 3643 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |