Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: src/full-codegen/ia32/full-codegen-ia32.cc

Issue 2363123002: Revert of [fullcodegen] Refactor code that calls store ICs. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/full-codegen/full-codegen.h" 7 #include "src/full-codegen/full-codegen.h"
8 #include "src/ast/compile-time-value.h" 8 #include "src/ast/compile-time-value.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); 1085 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS);
1086 __ bind(&exit); 1086 __ bind(&exit);
1087 decrement_loop_depth(); 1087 decrement_loop_depth();
1088 } 1088 }
1089 1089
1090 1090
1091 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, 1091 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
1092 FeedbackVectorSlot slot) { 1092 FeedbackVectorSlot slot) {
1093 DCHECK(NeedsHomeObject(initializer)); 1093 DCHECK(NeedsHomeObject(initializer));
1094 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); 1094 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1095 __ mov(StoreDescriptor::NameRegister(),
1096 Immediate(isolate()->factory()->home_object_symbol()));
1095 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize)); 1097 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize));
1096 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); 1098 EmitLoadStoreICSlot(slot);
1099 CallStoreIC();
1097 } 1100 }
1098 1101
1099 1102
1100 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer, 1103 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer,
1101 int offset, 1104 int offset,
1102 FeedbackVectorSlot slot) { 1105 FeedbackVectorSlot slot) {
1103 DCHECK(NeedsHomeObject(initializer)); 1106 DCHECK(NeedsHomeObject(initializer));
1104 __ mov(StoreDescriptor::ReceiverRegister(), eax); 1107 __ mov(StoreDescriptor::ReceiverRegister(), eax);
1108 __ mov(StoreDescriptor::NameRegister(),
1109 Immediate(isolate()->factory()->home_object_symbol()));
1105 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize)); 1110 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize));
1106 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); 1111 EmitLoadStoreICSlot(slot);
1112 CallStoreIC();
1107 } 1113 }
1108 1114
1109 1115
1110 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, 1116 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
1111 TypeofMode typeof_mode, 1117 TypeofMode typeof_mode,
1112 Label* slow) { 1118 Label* slow) {
1113 Register context = esi; 1119 Register context = esi;
1114 Register temp = edx; 1120 Register temp = edx;
1115 1121
1116 int to_check = scope()->ContextChainLengthUntilOutermostSloppyEval(); 1122 int to_check = scope()->ContextChainLengthUntilOutermostSloppyEval();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 1337 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
1332 // Fall through. 1338 // Fall through.
1333 case ObjectLiteral::Property::COMPUTED: 1339 case ObjectLiteral::Property::COMPUTED:
1334 // It is safe to use [[Put]] here because the boilerplate already 1340 // It is safe to use [[Put]] here because the boilerplate already
1335 // contains computed properties with an uninitialized value. 1341 // contains computed properties with an uninitialized value.
1336 if (key->IsStringLiteral()) { 1342 if (key->IsStringLiteral()) {
1337 DCHECK(key->IsPropertyName()); 1343 DCHECK(key->IsPropertyName());
1338 if (property->emit_store()) { 1344 if (property->emit_store()) {
1339 VisitForAccumulatorValue(value); 1345 VisitForAccumulatorValue(value);
1340 DCHECK(StoreDescriptor::ValueRegister().is(eax)); 1346 DCHECK(StoreDescriptor::ValueRegister().is(eax));
1347 __ mov(StoreDescriptor::NameRegister(), Immediate(key->value()));
1341 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); 1348 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1342 CallStoreIC(property->GetSlot(0), key->value()); 1349 EmitLoadStoreICSlot(property->GetSlot(0));
1350 CallStoreIC();
1343 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); 1351 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS);
1344 if (NeedsHomeObject(value)) { 1352 if (NeedsHomeObject(value)) {
1345 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); 1353 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1));
1346 } 1354 }
1347 } else { 1355 } else {
1348 VisitForEffect(value); 1356 VisitForEffect(value);
1349 } 1357 }
1350 break; 1358 break;
1351 } 1359 }
1352 PushOperand(Operand(esp, 0)); // Duplicate receiver. 1360 PushOperand(Operand(esp, 0)); // Duplicate receiver.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 1531
1524 if (!result_saved) { 1532 if (!result_saved) {
1525 PushOperand(eax); // array literal. 1533 PushOperand(eax); // array literal.
1526 result_saved = true; 1534 result_saved = true;
1527 } 1535 }
1528 VisitForAccumulatorValue(subexpr); 1536 VisitForAccumulatorValue(subexpr);
1529 1537
1530 __ mov(StoreDescriptor::NameRegister(), 1538 __ mov(StoreDescriptor::NameRegister(),
1531 Immediate(Smi::FromInt(array_index))); 1539 Immediate(Smi::FromInt(array_index)));
1532 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); 1540 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1533 CallKeyedStoreIC(expr->LiteralFeedbackSlot()); 1541 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot());
1542 CallKeyedStoreIC();
1534 PrepareForBailoutForId(expr->GetIdForElement(array_index), 1543 PrepareForBailoutForId(expr->GetIdForElement(array_index),
1535 BailoutState::NO_REGISTERS); 1544 BailoutState::NO_REGISTERS);
1536 } 1545 }
1537 1546
1538 if (result_saved) { 1547 if (result_saved) {
1539 context()->PlugTOS(); 1548 context()->PlugTOS();
1540 } else { 1549 } else {
1541 context()->Plug(eax); 1550 context()->Plug(eax);
1542 } 1551 }
1543 } 1552 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 Variable* var = expr->AsVariableProxy()->var(); 1955 Variable* var = expr->AsVariableProxy()->var();
1947 EffectContext context(this); 1956 EffectContext context(this);
1948 EmitVariableAssignment(var, Token::ASSIGN, slot); 1957 EmitVariableAssignment(var, Token::ASSIGN, slot);
1949 break; 1958 break;
1950 } 1959 }
1951 case NAMED_PROPERTY: { 1960 case NAMED_PROPERTY: {
1952 PushOperand(eax); // Preserve value. 1961 PushOperand(eax); // Preserve value.
1953 VisitForAccumulatorValue(prop->obj()); 1962 VisitForAccumulatorValue(prop->obj());
1954 __ Move(StoreDescriptor::ReceiverRegister(), eax); 1963 __ Move(StoreDescriptor::ReceiverRegister(), eax);
1955 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 1964 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
1956 CallStoreIC(slot, prop->key()->AsLiteral()->value()); 1965 __ mov(StoreDescriptor::NameRegister(),
1966 prop->key()->AsLiteral()->value());
1967 EmitLoadStoreICSlot(slot);
1968 CallStoreIC();
1957 break; 1969 break;
1958 } 1970 }
1959 case NAMED_SUPER_PROPERTY: { 1971 case NAMED_SUPER_PROPERTY: {
1960 PushOperand(eax); 1972 PushOperand(eax);
1961 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 1973 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
1962 VisitForAccumulatorValue( 1974 VisitForAccumulatorValue(
1963 prop->obj()->AsSuperPropertyReference()->home_object()); 1975 prop->obj()->AsSuperPropertyReference()->home_object());
1964 // stack: value, this; eax: home_object 1976 // stack: value, this; eax: home_object
1965 Register scratch = ecx; 1977 Register scratch = ecx;
1966 Register scratch2 = edx; 1978 Register scratch2 = edx;
(...skipping 26 matching lines...) Expand all
1993 EmitKeyedSuperPropertyStore(prop); 2005 EmitKeyedSuperPropertyStore(prop);
1994 break; 2006 break;
1995 } 2007 }
1996 case KEYED_PROPERTY: { 2008 case KEYED_PROPERTY: {
1997 PushOperand(eax); // Preserve value. 2009 PushOperand(eax); // Preserve value.
1998 VisitForStackValue(prop->obj()); 2010 VisitForStackValue(prop->obj());
1999 VisitForAccumulatorValue(prop->key()); 2011 VisitForAccumulatorValue(prop->key());
2000 __ Move(StoreDescriptor::NameRegister(), eax); 2012 __ Move(StoreDescriptor::NameRegister(), eax);
2001 PopOperand(StoreDescriptor::ReceiverRegister()); // Receiver. 2013 PopOperand(StoreDescriptor::ReceiverRegister()); // Receiver.
2002 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 2014 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
2003 CallKeyedStoreIC(slot); 2015 EmitLoadStoreICSlot(slot);
2016 CallKeyedStoreIC();
2004 break; 2017 break;
2005 } 2018 }
2006 } 2019 }
2007 context()->Plug(eax); 2020 context()->Plug(eax);
2008 } 2021 }
2009 2022
2010 2023
2011 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( 2024 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
2012 Variable* var, MemOperand location) { 2025 Variable* var, MemOperand location) {
2013 __ mov(location, eax); 2026 __ mov(location, eax);
2014 if (var->IsContextSlot()) { 2027 if (var->IsContextSlot()) {
2015 __ mov(edx, eax); 2028 __ mov(edx, eax);
2016 int offset = Context::SlotOffset(var->index()); 2029 int offset = Context::SlotOffset(var->index());
2017 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); 2030 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs);
2018 } 2031 }
2019 } 2032 }
2020 2033
2021 2034
2022 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2035 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2023 FeedbackVectorSlot slot) { 2036 FeedbackVectorSlot slot) {
2024 if (var->IsUnallocated()) { 2037 if (var->IsUnallocated()) {
2025 // Global var, const, or let. 2038 // Global var, const, or let.
2039 __ mov(StoreDescriptor::NameRegister(), var->name());
2026 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); 2040 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand());
2027 __ mov(StoreDescriptor::ReceiverRegister(), 2041 __ mov(StoreDescriptor::ReceiverRegister(),
2028 ContextOperand(StoreDescriptor::ReceiverRegister(), 2042 ContextOperand(StoreDescriptor::ReceiverRegister(),
2029 Context::EXTENSION_INDEX)); 2043 Context::EXTENSION_INDEX));
2030 CallStoreIC(slot, var->name()); 2044 EmitLoadStoreICSlot(slot);
2045 CallStoreIC();
2031 2046
2032 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { 2047 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) {
2033 DCHECK(!var->IsLookupSlot()); 2048 DCHECK(!var->IsLookupSlot());
2034 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2049 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2035 MemOperand location = VarOperand(var, ecx); 2050 MemOperand location = VarOperand(var, ecx);
2036 // Perform an initialization check for lexically declared variables. 2051 // Perform an initialization check for lexically declared variables.
2037 if (var->binding_needs_init()) { 2052 if (var->binding_needs_init()) {
2038 Label assign; 2053 Label assign;
2039 __ mov(edx, location); 2054 __ mov(edx, location);
2040 __ cmp(edx, isolate()->factory()->the_hole_value()); 2055 __ cmp(edx, isolate()->factory()->the_hole_value());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 2103
2089 2104
2090 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2105 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2091 // Assignment to a property, using a named store IC. 2106 // Assignment to a property, using a named store IC.
2092 // eax : value 2107 // eax : value
2093 // esp[0] : receiver 2108 // esp[0] : receiver
2094 Property* prop = expr->target()->AsProperty(); 2109 Property* prop = expr->target()->AsProperty();
2095 DCHECK(prop != NULL); 2110 DCHECK(prop != NULL);
2096 DCHECK(prop->key()->IsLiteral()); 2111 DCHECK(prop->key()->IsLiteral());
2097 2112
2113 __ mov(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value());
2098 PopOperand(StoreDescriptor::ReceiverRegister()); 2114 PopOperand(StoreDescriptor::ReceiverRegister());
2099 CallStoreIC(expr->AssignmentSlot(), prop->key()->AsLiteral()->value()); 2115 EmitLoadStoreICSlot(expr->AssignmentSlot());
2116 CallStoreIC();
2100 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2117 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2101 context()->Plug(eax); 2118 context()->Plug(eax);
2102 } 2119 }
2103 2120
2104 2121
2105 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { 2122 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
2106 // Assignment to named property of super. 2123 // Assignment to named property of super.
2107 // eax : value 2124 // eax : value
2108 // stack : receiver ('this'), home_object 2125 // stack : receiver ('this'), home_object
2109 DCHECK(prop != NULL); 2126 DCHECK(prop != NULL);
(...skipping 22 matching lines...) Expand all
2132 2149
2133 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { 2150 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
2134 // Assignment to a property, using a keyed store IC. 2151 // Assignment to a property, using a keyed store IC.
2135 // eax : value 2152 // eax : value
2136 // esp[0] : key 2153 // esp[0] : key
2137 // esp[kPointerSize] : receiver 2154 // esp[kPointerSize] : receiver
2138 2155
2139 PopOperand(StoreDescriptor::NameRegister()); // Key. 2156 PopOperand(StoreDescriptor::NameRegister()); // Key.
2140 PopOperand(StoreDescriptor::ReceiverRegister()); 2157 PopOperand(StoreDescriptor::ReceiverRegister());
2141 DCHECK(StoreDescriptor::ValueRegister().is(eax)); 2158 DCHECK(StoreDescriptor::ValueRegister().is(eax));
2142 CallKeyedStoreIC(expr->AssignmentSlot()); 2159 EmitLoadStoreICSlot(expr->AssignmentSlot());
2160 CallKeyedStoreIC();
2143 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2161 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2144 context()->Plug(eax); 2162 context()->Plug(eax);
2145 } 2163 }
2146 2164
2147 2165
2148 void FullCodeGenerator::CallIC(Handle<Code> code, 2166 void FullCodeGenerator::CallIC(Handle<Code> code,
2149 TypeFeedbackId ast_id) { 2167 TypeFeedbackId ast_id) {
2150 ic_total_count_++; 2168 ic_total_count_++;
2151 __ call(code, RelocInfo::CODE_TARGET, ast_id); 2169 __ call(code, RelocInfo::CODE_TARGET, ast_id);
2152 } 2170 }
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 } else { 3195 } else {
3178 // Perform the assignment as if via '='. 3196 // Perform the assignment as if via '='.
3179 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3197 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3180 Token::ASSIGN, expr->CountSlot()); 3198 Token::ASSIGN, expr->CountSlot());
3181 PrepareForBailoutForId(expr->AssignmentId(), 3199 PrepareForBailoutForId(expr->AssignmentId(),
3182 BailoutState::TOS_REGISTER); 3200 BailoutState::TOS_REGISTER);
3183 context()->Plug(eax); 3201 context()->Plug(eax);
3184 } 3202 }
3185 break; 3203 break;
3186 case NAMED_PROPERTY: { 3204 case NAMED_PROPERTY: {
3205 __ mov(StoreDescriptor::NameRegister(),
3206 prop->key()->AsLiteral()->value());
3187 PopOperand(StoreDescriptor::ReceiverRegister()); 3207 PopOperand(StoreDescriptor::ReceiverRegister());
3188 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); 3208 EmitLoadStoreICSlot(expr->CountSlot());
3209 CallStoreIC();
3189 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3210 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3190 if (expr->is_postfix()) { 3211 if (expr->is_postfix()) {
3191 if (!context()->IsEffect()) { 3212 if (!context()->IsEffect()) {
3192 context()->PlugTOS(); 3213 context()->PlugTOS();
3193 } 3214 }
3194 } else { 3215 } else {
3195 context()->Plug(eax); 3216 context()->Plug(eax);
3196 } 3217 }
3197 break; 3218 break;
3198 } 3219 }
(...skipping 17 matching lines...) Expand all
3216 context()->PlugTOS(); 3237 context()->PlugTOS();
3217 } 3238 }
3218 } else { 3239 } else {
3219 context()->Plug(eax); 3240 context()->Plug(eax);
3220 } 3241 }
3221 break; 3242 break;
3222 } 3243 }
3223 case KEYED_PROPERTY: { 3244 case KEYED_PROPERTY: {
3224 PopOperand(StoreDescriptor::NameRegister()); 3245 PopOperand(StoreDescriptor::NameRegister());
3225 PopOperand(StoreDescriptor::ReceiverRegister()); 3246 PopOperand(StoreDescriptor::ReceiverRegister());
3226 CallKeyedStoreIC(expr->CountSlot()); 3247 EmitLoadStoreICSlot(expr->CountSlot());
3248 CallKeyedStoreIC();
3227 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3249 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3228 if (expr->is_postfix()) { 3250 if (expr->is_postfix()) {
3229 // Result is on the stack 3251 // Result is on the stack
3230 if (!context()->IsEffect()) { 3252 if (!context()->IsEffect()) {
3231 context()->PlugTOS(); 3253 context()->PlugTOS();
3232 } 3254 }
3233 } else { 3255 } else {
3234 context()->Plug(eax); 3256 context()->Plug(eax);
3235 } 3257 }
3236 break; 3258 break;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3599 isolate->builtins()->OnStackReplacement()->entry(), 3621 isolate->builtins()->OnStackReplacement()->entry(),
3600 Assembler::target_address_at(call_target_address, unoptimized_code)); 3622 Assembler::target_address_at(call_target_address, unoptimized_code));
3601 return ON_STACK_REPLACEMENT; 3623 return ON_STACK_REPLACEMENT;
3602 } 3624 }
3603 3625
3604 3626
3605 } // namespace internal 3627 } // namespace internal
3606 } // namespace v8 3628 } // namespace v8
3607 3629
3608 #endif // V8_TARGET_ARCH_IA32 3630 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698