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