Chromium Code Reviews| 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 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2069 | 2069 |
| 2070 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2070 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
| 2071 FeedbackVectorSlot slot) { | 2071 FeedbackVectorSlot slot) { |
| 2072 if (var->IsUnallocated()) { | 2072 if (var->IsUnallocated()) { |
| 2073 // Global var, const, or let. | 2073 // Global var, const, or let. |
| 2074 __ Move(StoreDescriptor::NameRegister(), var->name()); | 2074 __ Move(StoreDescriptor::NameRegister(), var->name()); |
| 2075 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 2075 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
| 2076 EmitLoadStoreICSlot(slot); | 2076 EmitLoadStoreICSlot(slot); |
| 2077 CallStoreIC(); | 2077 CallStoreIC(); |
| 2078 | 2078 |
| 2079 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { | 2079 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
|
Toon Verwaest
2016/08/18 07:05:26
probably the same explicit control flow was used h
adamk
2016/08/18 18:40:18
Sort of. It wasn't as explicit (due to the fact th
| |
| 2080 DCHECK(!var->IsLookupSlot()); | 2080 DCHECK(!var->IsLookupSlot()); |
| 2081 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2081 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 2082 MemOperand location = VarOperand(var, rcx); | 2082 MemOperand location = VarOperand(var, rcx); |
| 2083 // Perform an initialization check for lexically declared variables. | 2083 // Perform an initialization check for lexically declared variables. |
| 2084 if (var->binding_needs_init()) { | 2084 if (var->binding_needs_init()) { |
| 2085 Label assign; | 2085 Label assign; |
| 2086 __ movp(rdx, location); | 2086 __ movp(rdx, location); |
| 2087 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2087 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
| 2088 __ j(not_equal, &assign, Label::kNear); | 2088 __ j(not_equal, &assign, Label::kNear); |
| 2089 __ Push(var->name()); | 2089 __ Push(var->name()); |
| 2090 __ CallRuntime(Runtime::kThrowReferenceError); | 2090 __ CallRuntime(Runtime::kThrowReferenceError); |
| 2091 __ bind(&assign); | 2091 __ bind(&assign); |
| 2092 } | 2092 } |
| 2093 if (var->mode() == CONST) { | 2093 if (var->mode() != CONST) { |
| 2094 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 2095 } else if (var->throw_on_const_assignment(language_mode())) { | |
| 2094 __ CallRuntime(Runtime::kThrowConstAssignError); | 2096 __ CallRuntime(Runtime::kThrowConstAssignError); |
| 2095 } else { | |
| 2096 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 2097 } | 2097 } |
| 2098 | 2098 |
| 2099 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { | 2099 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { |
| 2100 // Initializing assignment to const {this} needs a write barrier. | 2100 // Initializing assignment to const {this} needs a write barrier. |
| 2101 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2101 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 2102 Label uninitialized_this; | 2102 Label uninitialized_this; |
| 2103 MemOperand location = VarOperand(var, rcx); | 2103 MemOperand location = VarOperand(var, rcx); |
| 2104 __ movp(rdx, location); | 2104 __ movp(rdx, location); |
| 2105 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2105 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
| 2106 __ j(equal, &uninitialized_this); | 2106 __ j(equal, &uninitialized_this); |
| 2107 __ Push(var->name()); | 2107 __ Push(var->name()); |
| 2108 __ CallRuntime(Runtime::kThrowReferenceError); | 2108 __ CallRuntime(Runtime::kThrowReferenceError); |
| 2109 __ bind(&uninitialized_this); | 2109 __ bind(&uninitialized_this); |
| 2110 EmitStoreToStackLocalOrContextSlot(var, location); | 2110 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2111 | 2111 |
| 2112 } else if (!var->is_const_mode() || op == Token::INIT) { | 2112 } else { |
| 2113 DCHECK(var->mode() != CONST || op == Token::INIT); | |
| 2113 if (var->IsLookupSlot()) { | 2114 if (var->IsLookupSlot()) { |
| 2114 // Assignment to var. | 2115 // Assignment to var. |
| 2115 __ Push(var->name()); | 2116 __ Push(var->name()); |
| 2116 __ Push(rax); | 2117 __ Push(rax); |
| 2117 __ CallRuntime(is_strict(language_mode()) | 2118 __ CallRuntime(is_strict(language_mode()) |
| 2118 ? Runtime::kStoreLookupSlot_Strict | 2119 ? Runtime::kStoreLookupSlot_Strict |
| 2119 : Runtime::kStoreLookupSlot_Sloppy); | 2120 : Runtime::kStoreLookupSlot_Sloppy); |
| 2120 } else { | 2121 } else { |
| 2121 // Assignment to var or initializing assignment to let/const in harmony | 2122 // Assignment to var or initializing assignment to let/const in harmony |
| 2122 // mode. | 2123 // mode. |
| 2123 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2124 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 2124 MemOperand location = VarOperand(var, rcx); | 2125 MemOperand location = VarOperand(var, rcx); |
| 2125 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { | 2126 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { |
| 2126 // Check for an uninitialized let binding. | 2127 // Check for an uninitialized let binding. |
| 2127 __ movp(rdx, location); | 2128 __ movp(rdx, location); |
| 2128 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2129 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
| 2129 __ Check(equal, kLetBindingReInitialization); | 2130 __ Check(equal, kLetBindingReInitialization); |
| 2130 } | 2131 } |
| 2131 EmitStoreToStackLocalOrContextSlot(var, location); | 2132 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2132 } | 2133 } |
| 2133 | |
| 2134 } else { | |
| 2135 DCHECK(var->mode() == CONST_LEGACY && op != Token::INIT); | |
| 2136 if (is_strict(language_mode())) { | |
| 2137 __ CallRuntime(Runtime::kThrowConstAssignError); | |
| 2138 } | |
| 2139 // Silently ignore store in sloppy mode. | |
| 2140 } | 2134 } |
| 2141 } | 2135 } |
| 2142 | 2136 |
| 2143 | 2137 |
| 2144 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2138 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 2145 // Assignment to a property, using a named store IC. | 2139 // Assignment to a property, using a named store IC. |
| 2146 Property* prop = expr->target()->AsProperty(); | 2140 Property* prop = expr->target()->AsProperty(); |
| 2147 DCHECK(prop != NULL); | 2141 DCHECK(prop != NULL); |
| 2148 DCHECK(prop->key()->IsLiteral()); | 2142 DCHECK(prop->key()->IsLiteral()); |
| 2149 | 2143 |
| (...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3662 DCHECK_EQ( | 3656 DCHECK_EQ( |
| 3663 isolate->builtins()->OnStackReplacement()->entry(), | 3657 isolate->builtins()->OnStackReplacement()->entry(), |
| 3664 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3658 Assembler::target_address_at(call_target_address, unoptimized_code)); |
| 3665 return ON_STACK_REPLACEMENT; | 3659 return ON_STACK_REPLACEMENT; |
| 3666 } | 3660 } |
| 3667 | 3661 |
| 3668 } // namespace internal | 3662 } // namespace internal |
| 3669 } // namespace v8 | 3663 } // namespace v8 |
| 3670 | 3664 |
| 3671 #endif // V8_TARGET_ARCH_X64 | 3665 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |