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

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

Issue 2361393005: Reland of [fullcodegen] Refactor code that calls store ICs. (Closed)
Patch Set: Created 4 years, 2 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/s390/full-codegen-s390.cc ('k') | src/full-codegen/x87/full-codegen-x87.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_X64 5 #if V8_TARGET_ARCH_X64
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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); 1112 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS);
1113 __ bind(&exit); 1113 __ bind(&exit);
1114 decrement_loop_depth(); 1114 decrement_loop_depth();
1115 } 1115 }
1116 1116
1117 1117
1118 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, 1118 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
1119 FeedbackVectorSlot slot) { 1119 FeedbackVectorSlot slot) {
1120 DCHECK(NeedsHomeObject(initializer)); 1120 DCHECK(NeedsHomeObject(initializer));
1121 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); 1121 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0));
1122 __ Move(StoreDescriptor::NameRegister(),
1123 isolate()->factory()->home_object_symbol());
1124 __ movp(StoreDescriptor::ValueRegister(), 1122 __ movp(StoreDescriptor::ValueRegister(),
1125 Operand(rsp, offset * kPointerSize)); 1123 Operand(rsp, offset * kPointerSize));
1126 EmitLoadStoreICSlot(slot); 1124 CallStoreIC(slot, isolate()->factory()->home_object_symbol());
1127 CallStoreIC();
1128 } 1125 }
1129 1126
1130 1127
1131 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer, 1128 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer,
1132 int offset, 1129 int offset,
1133 FeedbackVectorSlot slot) { 1130 FeedbackVectorSlot slot) {
1134 DCHECK(NeedsHomeObject(initializer)); 1131 DCHECK(NeedsHomeObject(initializer));
1135 __ movp(StoreDescriptor::ReceiverRegister(), rax); 1132 __ movp(StoreDescriptor::ReceiverRegister(), rax);
1136 __ Move(StoreDescriptor::NameRegister(),
1137 isolate()->factory()->home_object_symbol());
1138 __ movp(StoreDescriptor::ValueRegister(), 1133 __ movp(StoreDescriptor::ValueRegister(),
1139 Operand(rsp, offset * kPointerSize)); 1134 Operand(rsp, offset * kPointerSize));
1140 EmitLoadStoreICSlot(slot); 1135 CallStoreIC(slot, isolate()->factory()->home_object_symbol());
1141 CallStoreIC();
1142 } 1136 }
1143 1137
1144 1138
1145 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, 1139 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
1146 TypeofMode typeof_mode, 1140 TypeofMode typeof_mode,
1147 Label* slow) { 1141 Label* slow) {
1148 Register context = rsi; 1142 Register context = rsi;
1149 Register temp = rdx; 1143 Register temp = rdx;
1150 1144
1151 int to_check = scope()->ContextChainLengthUntilOutermostSloppyEval(); 1145 int to_check = scope()->ContextChainLengthUntilOutermostSloppyEval();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 1360 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
1367 // Fall through. 1361 // Fall through.
1368 case ObjectLiteral::Property::COMPUTED: 1362 case ObjectLiteral::Property::COMPUTED:
1369 // It is safe to use [[Put]] here because the boilerplate already 1363 // It is safe to use [[Put]] here because the boilerplate already
1370 // contains computed properties with an uninitialized value. 1364 // contains computed properties with an uninitialized value.
1371 if (key->IsStringLiteral()) { 1365 if (key->IsStringLiteral()) {
1372 DCHECK(key->IsPropertyName()); 1366 DCHECK(key->IsPropertyName());
1373 if (property->emit_store()) { 1367 if (property->emit_store()) {
1374 VisitForAccumulatorValue(value); 1368 VisitForAccumulatorValue(value);
1375 DCHECK(StoreDescriptor::ValueRegister().is(rax)); 1369 DCHECK(StoreDescriptor::ValueRegister().is(rax));
1376 __ Move(StoreDescriptor::NameRegister(), key->value());
1377 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); 1370 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0));
1378 EmitLoadStoreICSlot(property->GetSlot(0)); 1371 CallStoreIC(property->GetSlot(0), key->value());
1379 CallStoreIC();
1380 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); 1372 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS);
1381 1373
1382 if (NeedsHomeObject(value)) { 1374 if (NeedsHomeObject(value)) {
1383 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); 1375 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1));
1384 } 1376 }
1385 } else { 1377 } else {
1386 VisitForEffect(value); 1378 VisitForEffect(value);
1387 } 1379 }
1388 break; 1380 break;
1389 } 1381 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1550 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1559 1551
1560 if (!result_saved) { 1552 if (!result_saved) {
1561 PushOperand(rax); // array literal 1553 PushOperand(rax); // array literal
1562 result_saved = true; 1554 result_saved = true;
1563 } 1555 }
1564 VisitForAccumulatorValue(subexpr); 1556 VisitForAccumulatorValue(subexpr);
1565 1557
1566 __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); 1558 __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index));
1567 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); 1559 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0));
1568 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); 1560 CallKeyedStoreIC(expr->LiteralFeedbackSlot());
1569 CallKeyedStoreIC();
1570 1561
1571 PrepareForBailoutForId(expr->GetIdForElement(array_index), 1562 PrepareForBailoutForId(expr->GetIdForElement(array_index),
1572 BailoutState::NO_REGISTERS); 1563 BailoutState::NO_REGISTERS);
1573 } 1564 }
1574 1565
1575 if (result_saved) { 1566 if (result_saved) {
1576 context()->PlugTOS(); 1567 context()->PlugTOS();
1577 } else { 1568 } else {
1578 context()->Plug(rax); 1569 context()->Plug(rax);
1579 } 1570 }
(...skipping 367 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(rax); // Preserve value. 1944 PushOperand(rax); // Preserve value.
1954 VisitForAccumulatorValue(prop->obj()); 1945 VisitForAccumulatorValue(prop->obj());
1955 __ Move(StoreDescriptor::ReceiverRegister(), rax); 1946 __ Move(StoreDescriptor::ReceiverRegister(), rax);
1956 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 1947 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
1957 __ Move(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(rax); 1952 PushOperand(rax);
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; rax: home_object 1956 // stack: value, this; rax: home_object
1969 Register scratch = rcx; 1957 Register scratch = rcx;
1970 Register scratch2 = rdx; 1958 Register scratch2 = rdx;
(...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(rax); // Preserve value. 1989 PushOperand(rax); // Preserve value.
2002 VisitForStackValue(prop->obj()); 1990 VisitForStackValue(prop->obj());
2003 VisitForAccumulatorValue(prop->key()); 1991 VisitForAccumulatorValue(prop->key());
2004 __ Move(StoreDescriptor::NameRegister(), rax); 1992 __ Move(StoreDescriptor::NameRegister(), rax);
2005 PopOperand(StoreDescriptor::ReceiverRegister()); 1993 PopOperand(StoreDescriptor::ReceiverRegister());
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(rax); 1999 context()->Plug(rax);
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 __ movp(location, rax); 2005 __ movp(location, rax);
2019 if (var->IsContextSlot()) { 2006 if (var->IsContextSlot()) {
2020 __ movp(rdx, rax); 2007 __ movp(rdx, rax);
2021 __ RecordWriteContextSlot( 2008 __ RecordWriteContextSlot(
2022 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs); 2009 rcx, Context::SlotOffset(var->index()), rdx, rbx, 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 __ Move(StoreDescriptor::NameRegister(), var->name());
2032 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); 2018 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister());
2033 EmitLoadStoreICSlot(slot); 2019 CallStoreIC(slot, var->name());
2034 CallStoreIC();
2035 2020
2036 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { 2021 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) {
2037 DCHECK(!var->IsLookupSlot()); 2022 DCHECK(!var->IsLookupSlot());
2038 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2023 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2039 MemOperand location = VarOperand(var, rcx); 2024 MemOperand location = VarOperand(var, rcx);
2040 // Perform an initialization check for lexically declared variables. 2025 // Perform an initialization check for lexically declared variables.
2041 if (var->binding_needs_init()) { 2026 if (var->binding_needs_init()) {
2042 Label assign; 2027 Label assign;
2043 __ movp(rdx, location); 2028 __ movp(rdx, location);
2044 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2029 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 } 2076 }
2092 } 2077 }
2093 2078
2094 2079
2095 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2080 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2096 // Assignment to a property, using a named store IC. 2081 // Assignment to a property, using a named store IC.
2097 Property* prop = expr->target()->AsProperty(); 2082 Property* prop = expr->target()->AsProperty();
2098 DCHECK(prop != NULL); 2083 DCHECK(prop != NULL);
2099 DCHECK(prop->key()->IsLiteral()); 2084 DCHECK(prop->key()->IsLiteral());
2100 2085
2101 __ Move(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value());
2102 PopOperand(StoreDescriptor::ReceiverRegister()); 2086 PopOperand(StoreDescriptor::ReceiverRegister());
2103 EmitLoadStoreICSlot(expr->AssignmentSlot()); 2087 CallStoreIC(expr->AssignmentSlot(), prop->key()->AsLiteral()->value());
2104 CallStoreIC();
2105 2088
2106 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2089 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2107 context()->Plug(rax); 2090 context()->Plug(rax);
2108 } 2091 }
2109 2092
2110 2093
2111 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { 2094 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
2112 // Assignment to named property of super. 2095 // Assignment to named property of super.
2113 // rax : value 2096 // rax : value
2114 // stack : receiver ('this'), home_object 2097 // stack : receiver ('this'), home_object
(...skipping 20 matching lines...) Expand all
2135 ? Runtime::kStoreKeyedToSuper_Strict 2118 ? Runtime::kStoreKeyedToSuper_Strict
2136 : Runtime::kStoreKeyedToSuper_Sloppy); 2119 : Runtime::kStoreKeyedToSuper_Sloppy);
2137 } 2120 }
2138 2121
2139 2122
2140 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { 2123 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
2141 // Assignment to a property, using a keyed store IC. 2124 // Assignment to a property, using a keyed store IC.
2142 PopOperand(StoreDescriptor::NameRegister()); // Key. 2125 PopOperand(StoreDescriptor::NameRegister()); // Key.
2143 PopOperand(StoreDescriptor::ReceiverRegister()); 2126 PopOperand(StoreDescriptor::ReceiverRegister());
2144 DCHECK(StoreDescriptor::ValueRegister().is(rax)); 2127 DCHECK(StoreDescriptor::ValueRegister().is(rax));
2145 EmitLoadStoreICSlot(expr->AssignmentSlot()); 2128 CallKeyedStoreIC(expr->AssignmentSlot());
2146 CallKeyedStoreIC();
2147 2129
2148 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2130 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2149 context()->Plug(rax); 2131 context()->Plug(rax);
2150 } 2132 }
2151 2133
2152 2134
2153 void FullCodeGenerator::CallIC(Handle<Code> code, 2135 void FullCodeGenerator::CallIC(Handle<Code> code,
2154 TypeFeedbackId ast_id) { 2136 TypeFeedbackId ast_id) {
2155 ic_total_count_++; 2137 ic_total_count_++;
2156 __ call(code, RelocInfo::CODE_TARGET, ast_id); 2138 __ call(code, RelocInfo::CODE_TARGET, ast_id);
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 } else { 3166 } else {
3185 // Perform the assignment as if via '='. 3167 // Perform the assignment as if via '='.
3186 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3168 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3187 Token::ASSIGN, expr->CountSlot()); 3169 Token::ASSIGN, expr->CountSlot());
3188 PrepareForBailoutForId(expr->AssignmentId(), 3170 PrepareForBailoutForId(expr->AssignmentId(),
3189 BailoutState::TOS_REGISTER); 3171 BailoutState::TOS_REGISTER);
3190 context()->Plug(rax); 3172 context()->Plug(rax);
3191 } 3173 }
3192 break; 3174 break;
3193 case NAMED_PROPERTY: { 3175 case NAMED_PROPERTY: {
3194 __ Move(StoreDescriptor::NameRegister(),
3195 prop->key()->AsLiteral()->value());
3196 PopOperand(StoreDescriptor::ReceiverRegister()); 3176 PopOperand(StoreDescriptor::ReceiverRegister());
3197 EmitLoadStoreICSlot(expr->CountSlot()); 3177 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value());
3198 CallStoreIC();
3199 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3178 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3200 if (expr->is_postfix()) { 3179 if (expr->is_postfix()) {
3201 if (!context()->IsEffect()) { 3180 if (!context()->IsEffect()) {
3202 context()->PlugTOS(); 3181 context()->PlugTOS();
3203 } 3182 }
3204 } else { 3183 } else {
3205 context()->Plug(rax); 3184 context()->Plug(rax);
3206 } 3185 }
3207 break; 3186 break;
3208 } 3187 }
(...skipping 17 matching lines...) Expand all
3226 context()->PlugTOS(); 3205 context()->PlugTOS();
3227 } 3206 }
3228 } else { 3207 } else {
3229 context()->Plug(rax); 3208 context()->Plug(rax);
3230 } 3209 }
3231 break; 3210 break;
3232 } 3211 }
3233 case KEYED_PROPERTY: { 3212 case KEYED_PROPERTY: {
3234 PopOperand(StoreDescriptor::NameRegister()); 3213 PopOperand(StoreDescriptor::NameRegister());
3235 PopOperand(StoreDescriptor::ReceiverRegister()); 3214 PopOperand(StoreDescriptor::ReceiverRegister());
3236 EmitLoadStoreICSlot(expr->CountSlot()); 3215 CallKeyedStoreIC(expr->CountSlot());
3237 CallKeyedStoreIC();
3238 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3216 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3239 if (expr->is_postfix()) { 3217 if (expr->is_postfix()) {
3240 if (!context()->IsEffect()) { 3218 if (!context()->IsEffect()) {
3241 context()->PlugTOS(); 3219 context()->PlugTOS();
3242 } 3220 }
3243 } else { 3221 } else {
3244 context()->Plug(rax); 3222 context()->Plug(rax);
3245 } 3223 }
3246 break; 3224 break;
3247 } 3225 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 DCHECK_EQ( 3587 DCHECK_EQ(
3610 isolate->builtins()->OnStackReplacement()->entry(), 3588 isolate->builtins()->OnStackReplacement()->entry(),
3611 Assembler::target_address_at(call_target_address, unoptimized_code)); 3589 Assembler::target_address_at(call_target_address, unoptimized_code));
3612 return ON_STACK_REPLACEMENT; 3590 return ON_STACK_REPLACEMENT;
3613 } 3591 }
3614 3592
3615 } // namespace internal 3593 } // namespace internal
3616 } // namespace v8 3594 } // namespace v8
3617 3595
3618 #endif // V8_TARGET_ARCH_X64 3596 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/s390/full-codegen-s390.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698