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

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

Issue 2361393005: Reland 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/x64/full-codegen-x64.cc ('k') | no next file » | 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_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/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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); 1077 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS);
1078 __ bind(&exit); 1078 __ bind(&exit);
1079 decrement_loop_depth(); 1079 decrement_loop_depth();
1080 } 1080 }
1081 1081
1082 1082
1083 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, 1083 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
1084 FeedbackVectorSlot slot) { 1084 FeedbackVectorSlot slot) {
1085 DCHECK(NeedsHomeObject(initializer)); 1085 DCHECK(NeedsHomeObject(initializer));
1086 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); 1086 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1087 __ mov(StoreDescriptor::NameRegister(),
1088 Immediate(isolate()->factory()->home_object_symbol()));
1089 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize)); 1087 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize));
1090 EmitLoadStoreICSlot(slot); 1088 CallStoreIC(slot, isolate()->factory()->home_object_symbol());
1091 CallStoreIC();
1092 } 1089 }
1093 1090
1094 1091
1095 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer, 1092 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer,
1096 int offset, 1093 int offset,
1097 FeedbackVectorSlot slot) { 1094 FeedbackVectorSlot slot) {
1098 DCHECK(NeedsHomeObject(initializer)); 1095 DCHECK(NeedsHomeObject(initializer));
1099 __ mov(StoreDescriptor::ReceiverRegister(), eax); 1096 __ mov(StoreDescriptor::ReceiverRegister(), eax);
1100 __ mov(StoreDescriptor::NameRegister(),
1101 Immediate(isolate()->factory()->home_object_symbol()));
1102 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize)); 1097 __ mov(StoreDescriptor::ValueRegister(), Operand(esp, offset * kPointerSize));
1103 EmitLoadStoreICSlot(slot); 1098 CallStoreIC(slot, isolate()->factory()->home_object_symbol());
1104 CallStoreIC();
1105 } 1099 }
1106 1100
1107 1101
1108 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, 1102 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
1109 TypeofMode typeof_mode, 1103 TypeofMode typeof_mode,
1110 Label* slow) { 1104 Label* slow) {
1111 Register context = esi; 1105 Register context = esi;
1112 Register temp = edx; 1106 Register temp = edx;
1113 1107
1114 int to_check = scope()->ContextChainLengthUntilOutermostSloppyEval(); 1108 int to_check = scope()->ContextChainLengthUntilOutermostSloppyEval();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 1323 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
1330 // Fall through. 1324 // Fall through.
1331 case ObjectLiteral::Property::COMPUTED: 1325 case ObjectLiteral::Property::COMPUTED:
1332 // It is safe to use [[Put]] here because the boilerplate already 1326 // It is safe to use [[Put]] here because the boilerplate already
1333 // contains computed properties with an uninitialized value. 1327 // contains computed properties with an uninitialized value.
1334 if (key->IsStringLiteral()) { 1328 if (key->IsStringLiteral()) {
1335 DCHECK(key->IsPropertyName()); 1329 DCHECK(key->IsPropertyName());
1336 if (property->emit_store()) { 1330 if (property->emit_store()) {
1337 VisitForAccumulatorValue(value); 1331 VisitForAccumulatorValue(value);
1338 DCHECK(StoreDescriptor::ValueRegister().is(eax)); 1332 DCHECK(StoreDescriptor::ValueRegister().is(eax));
1339 __ mov(StoreDescriptor::NameRegister(), Immediate(key->value()));
1340 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); 1333 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1341 EmitLoadStoreICSlot(property->GetSlot(0)); 1334 CallStoreIC(property->GetSlot(0), key->value());
1342 CallStoreIC();
1343 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); 1335 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS);
1344 if (NeedsHomeObject(value)) { 1336 if (NeedsHomeObject(value)) {
1345 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); 1337 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1));
1346 } 1338 }
1347 } else { 1339 } else {
1348 VisitForEffect(value); 1340 VisitForEffect(value);
1349 } 1341 }
1350 break; 1342 break;
1351 } 1343 }
1352 PushOperand(Operand(esp, 0)); // Duplicate receiver. 1344 PushOperand(Operand(esp, 0)); // Duplicate receiver.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 1515
1524 if (!result_saved) { 1516 if (!result_saved) {
1525 PushOperand(eax); // array literal. 1517 PushOperand(eax); // array literal.
1526 result_saved = true; 1518 result_saved = true;
1527 } 1519 }
1528 VisitForAccumulatorValue(subexpr); 1520 VisitForAccumulatorValue(subexpr);
1529 1521
1530 __ mov(StoreDescriptor::NameRegister(), 1522 __ mov(StoreDescriptor::NameRegister(),
1531 Immediate(Smi::FromInt(array_index))); 1523 Immediate(Smi::FromInt(array_index)));
1532 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); 1524 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0));
1533 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); 1525 CallKeyedStoreIC(expr->LiteralFeedbackSlot());
1534 CallKeyedStoreIC();
1535 PrepareForBailoutForId(expr->GetIdForElement(array_index), 1526 PrepareForBailoutForId(expr->GetIdForElement(array_index),
1536 BailoutState::NO_REGISTERS); 1527 BailoutState::NO_REGISTERS);
1537 } 1528 }
1538 1529
1539 if (result_saved) { 1530 if (result_saved) {
1540 context()->PlugTOS(); 1531 context()->PlugTOS();
1541 } else { 1532 } else {
1542 context()->Plug(eax); 1533 context()->Plug(eax);
1543 } 1534 }
1544 } 1535 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 Variable* var = expr->AsVariableProxy()->var(); 1938 Variable* var = expr->AsVariableProxy()->var();
1948 EffectContext context(this); 1939 EffectContext context(this);
1949 EmitVariableAssignment(var, Token::ASSIGN, slot); 1940 EmitVariableAssignment(var, Token::ASSIGN, slot);
1950 break; 1941 break;
1951 } 1942 }
1952 case NAMED_PROPERTY: { 1943 case NAMED_PROPERTY: {
1953 PushOperand(eax); // Preserve value. 1944 PushOperand(eax); // Preserve value.
1954 VisitForAccumulatorValue(prop->obj()); 1945 VisitForAccumulatorValue(prop->obj());
1955 __ Move(StoreDescriptor::ReceiverRegister(), eax); 1946 __ Move(StoreDescriptor::ReceiverRegister(), eax);
1956 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 1947 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
1957 __ mov(StoreDescriptor::NameRegister(), 1948 CallStoreIC(slot, prop->key()->AsLiteral()->value());
1958 prop->key()->AsLiteral()->value());
1959 EmitLoadStoreICSlot(slot);
1960 CallStoreIC();
1961 break; 1949 break;
1962 } 1950 }
1963 case NAMED_SUPER_PROPERTY: { 1951 case NAMED_SUPER_PROPERTY: {
1964 PushOperand(eax); 1952 PushOperand(eax);
1965 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 1953 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
1966 VisitForAccumulatorValue( 1954 VisitForAccumulatorValue(
1967 prop->obj()->AsSuperPropertyReference()->home_object()); 1955 prop->obj()->AsSuperPropertyReference()->home_object());
1968 // stack: value, this; eax: home_object 1956 // stack: value, this; eax: home_object
1969 Register scratch = ecx; 1957 Register scratch = ecx;
1970 Register scratch2 = edx; 1958 Register scratch2 = edx;
(...skipping 26 matching lines...) Expand all
1997 EmitKeyedSuperPropertyStore(prop); 1985 EmitKeyedSuperPropertyStore(prop);
1998 break; 1986 break;
1999 } 1987 }
2000 case KEYED_PROPERTY: { 1988 case KEYED_PROPERTY: {
2001 PushOperand(eax); // Preserve value. 1989 PushOperand(eax); // Preserve value.
2002 VisitForStackValue(prop->obj()); 1990 VisitForStackValue(prop->obj());
2003 VisitForAccumulatorValue(prop->key()); 1991 VisitForAccumulatorValue(prop->key());
2004 __ Move(StoreDescriptor::NameRegister(), eax); 1992 __ Move(StoreDescriptor::NameRegister(), eax);
2005 PopOperand(StoreDescriptor::ReceiverRegister()); // Receiver. 1993 PopOperand(StoreDescriptor::ReceiverRegister()); // Receiver.
2006 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 1994 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
2007 EmitLoadStoreICSlot(slot); 1995 CallKeyedStoreIC(slot);
2008 CallKeyedStoreIC();
2009 break; 1996 break;
2010 } 1997 }
2011 } 1998 }
2012 context()->Plug(eax); 1999 context()->Plug(eax);
2013 } 2000 }
2014 2001
2015 2002
2016 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( 2003 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
2017 Variable* var, MemOperand location) { 2004 Variable* var, MemOperand location) {
2018 __ mov(location, eax); 2005 __ mov(location, eax);
2019 if (var->IsContextSlot()) { 2006 if (var->IsContextSlot()) {
2020 __ mov(edx, eax); 2007 __ mov(edx, eax);
2021 int offset = Context::SlotOffset(var->index()); 2008 int offset = Context::SlotOffset(var->index());
2022 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); 2009 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs);
2023 } 2010 }
2024 } 2011 }
2025 2012
2026 2013
2027 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2014 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2028 FeedbackVectorSlot slot) { 2015 FeedbackVectorSlot slot) {
2029 if (var->IsUnallocated()) { 2016 if (var->IsUnallocated()) {
2030 // Global var, const, or let. 2017 // Global var, const, or let.
2031 __ mov(StoreDescriptor::NameRegister(), var->name());
2032 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); 2018 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand());
2033 __ mov(StoreDescriptor::ReceiverRegister(), 2019 __ mov(StoreDescriptor::ReceiverRegister(),
2034 ContextOperand(StoreDescriptor::ReceiverRegister(), 2020 ContextOperand(StoreDescriptor::ReceiverRegister(),
2035 Context::EXTENSION_INDEX)); 2021 Context::EXTENSION_INDEX));
2036 EmitLoadStoreICSlot(slot); 2022 CallStoreIC(slot, var->name());
2037 CallStoreIC();
2038 2023
2039 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { 2024 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) {
2040 DCHECK(!var->IsLookupSlot()); 2025 DCHECK(!var->IsLookupSlot());
2041 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2026 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2042 MemOperand location = VarOperand(var, ecx); 2027 MemOperand location = VarOperand(var, ecx);
2043 // Perform an initialization check for lexically declared variables. 2028 // Perform an initialization check for lexically declared variables.
2044 if (var->binding_needs_init()) { 2029 if (var->binding_needs_init()) {
2045 Label assign; 2030 Label assign;
2046 __ mov(edx, location); 2031 __ mov(edx, location);
2047 __ cmp(edx, isolate()->factory()->the_hole_value()); 2032 __ cmp(edx, isolate()->factory()->the_hole_value());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 2080
2096 2081
2097 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2082 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2098 // Assignment to a property, using a named store IC. 2083 // Assignment to a property, using a named store IC.
2099 // eax : value 2084 // eax : value
2100 // esp[0] : receiver 2085 // esp[0] : receiver
2101 Property* prop = expr->target()->AsProperty(); 2086 Property* prop = expr->target()->AsProperty();
2102 DCHECK(prop != NULL); 2087 DCHECK(prop != NULL);
2103 DCHECK(prop->key()->IsLiteral()); 2088 DCHECK(prop->key()->IsLiteral());
2104 2089
2105 __ mov(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value());
2106 PopOperand(StoreDescriptor::ReceiverRegister()); 2090 PopOperand(StoreDescriptor::ReceiverRegister());
2107 EmitLoadStoreICSlot(expr->AssignmentSlot()); 2091 CallStoreIC(expr->AssignmentSlot(), prop->key()->AsLiteral()->value());
2108 CallStoreIC();
2109 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2092 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2110 context()->Plug(eax); 2093 context()->Plug(eax);
2111 } 2094 }
2112 2095
2113 2096
2114 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { 2097 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
2115 // Assignment to named property of super. 2098 // Assignment to named property of super.
2116 // eax : value 2099 // eax : value
2117 // stack : receiver ('this'), home_object 2100 // stack : receiver ('this'), home_object
2118 DCHECK(prop != NULL); 2101 DCHECK(prop != NULL);
(...skipping 22 matching lines...) Expand all
2141 2124
2142 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { 2125 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
2143 // Assignment to a property, using a keyed store IC. 2126 // Assignment to a property, using a keyed store IC.
2144 // eax : value 2127 // eax : value
2145 // esp[0] : key 2128 // esp[0] : key
2146 // esp[kPointerSize] : receiver 2129 // esp[kPointerSize] : receiver
2147 2130
2148 PopOperand(StoreDescriptor::NameRegister()); // Key. 2131 PopOperand(StoreDescriptor::NameRegister()); // Key.
2149 PopOperand(StoreDescriptor::ReceiverRegister()); 2132 PopOperand(StoreDescriptor::ReceiverRegister());
2150 DCHECK(StoreDescriptor::ValueRegister().is(eax)); 2133 DCHECK(StoreDescriptor::ValueRegister().is(eax));
2151 EmitLoadStoreICSlot(expr->AssignmentSlot()); 2134 CallKeyedStoreIC(expr->AssignmentSlot());
2152 CallKeyedStoreIC();
2153 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2135 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2154 context()->Plug(eax); 2136 context()->Plug(eax);
2155 } 2137 }
2156 2138
2157 2139
2158 void FullCodeGenerator::CallIC(Handle<Code> code, 2140 void FullCodeGenerator::CallIC(Handle<Code> code,
2159 TypeFeedbackId ast_id) { 2141 TypeFeedbackId ast_id) {
2160 ic_total_count_++; 2142 ic_total_count_++;
2161 __ call(code, RelocInfo::CODE_TARGET, ast_id); 2143 __ call(code, RelocInfo::CODE_TARGET, ast_id);
2162 } 2144 }
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 } else { 3169 } else {
3188 // Perform the assignment as if via '='. 3170 // Perform the assignment as if via '='.
3189 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3171 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3190 Token::ASSIGN, expr->CountSlot()); 3172 Token::ASSIGN, expr->CountSlot());
3191 PrepareForBailoutForId(expr->AssignmentId(), 3173 PrepareForBailoutForId(expr->AssignmentId(),
3192 BailoutState::TOS_REGISTER); 3174 BailoutState::TOS_REGISTER);
3193 context()->Plug(eax); 3175 context()->Plug(eax);
3194 } 3176 }
3195 break; 3177 break;
3196 case NAMED_PROPERTY: { 3178 case NAMED_PROPERTY: {
3197 __ mov(StoreDescriptor::NameRegister(),
3198 prop->key()->AsLiteral()->value());
3199 PopOperand(StoreDescriptor::ReceiverRegister()); 3179 PopOperand(StoreDescriptor::ReceiverRegister());
3200 EmitLoadStoreICSlot(expr->CountSlot()); 3180 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value());
3201 CallStoreIC();
3202 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3181 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3203 if (expr->is_postfix()) { 3182 if (expr->is_postfix()) {
3204 if (!context()->IsEffect()) { 3183 if (!context()->IsEffect()) {
3205 context()->PlugTOS(); 3184 context()->PlugTOS();
3206 } 3185 }
3207 } else { 3186 } else {
3208 context()->Plug(eax); 3187 context()->Plug(eax);
3209 } 3188 }
3210 break; 3189 break;
3211 } 3190 }
(...skipping 17 matching lines...) Expand all
3229 context()->PlugTOS(); 3208 context()->PlugTOS();
3230 } 3209 }
3231 } else { 3210 } else {
3232 context()->Plug(eax); 3211 context()->Plug(eax);
3233 } 3212 }
3234 break; 3213 break;
3235 } 3214 }
3236 case KEYED_PROPERTY: { 3215 case KEYED_PROPERTY: {
3237 PopOperand(StoreDescriptor::NameRegister()); 3216 PopOperand(StoreDescriptor::NameRegister());
3238 PopOperand(StoreDescriptor::ReceiverRegister()); 3217 PopOperand(StoreDescriptor::ReceiverRegister());
3239 EmitLoadStoreICSlot(expr->CountSlot()); 3218 CallKeyedStoreIC(expr->CountSlot());
3240 CallKeyedStoreIC();
3241 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3219 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3242 if (expr->is_postfix()) { 3220 if (expr->is_postfix()) {
3243 // Result is on the stack 3221 // Result is on the stack
3244 if (!context()->IsEffect()) { 3222 if (!context()->IsEffect()) {
3245 context()->PlugTOS(); 3223 context()->PlugTOS();
3246 } 3224 }
3247 } else { 3225 } else {
3248 context()->Plug(eax); 3226 context()->Plug(eax);
3249 } 3227 }
3250 break; 3228 break;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3613 isolate->builtins()->OnStackReplacement()->entry(), 3591 isolate->builtins()->OnStackReplacement()->entry(),
3614 Assembler::target_address_at(call_target_address, unoptimized_code)); 3592 Assembler::target_address_at(call_target_address, unoptimized_code));
3615 return ON_STACK_REPLACEMENT; 3593 return ON_STACK_REPLACEMENT;
3616 } 3594 }
3617 3595
3618 3596
3619 } // namespace internal 3597 } // namespace internal
3620 } // namespace v8 3598 } // namespace v8
3621 3599
3622 #endif // V8_TARGET_ARCH_X87 3600 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/full-codegen/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698