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

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

Issue 2363513003: [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
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_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); 1156 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS);
1157 __ bind(&exit); 1157 __ bind(&exit);
1158 decrement_loop_depth(); 1158 decrement_loop_depth();
1159 } 1159 }
1160 1160
1161 1161
1162 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, 1162 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset,
1163 FeedbackVectorSlot slot) { 1163 FeedbackVectorSlot slot) {
1164 DCHECK(NeedsHomeObject(initializer)); 1164 DCHECK(NeedsHomeObject(initializer));
1165 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); 1165 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
1166 __ li(StoreDescriptor::NameRegister(),
1167 Operand(isolate()->factory()->home_object_symbol()));
1168 __ lw(StoreDescriptor::ValueRegister(), 1166 __ lw(StoreDescriptor::ValueRegister(),
1169 MemOperand(sp, offset * kPointerSize)); 1167 MemOperand(sp, offset * kPointerSize));
1170 EmitLoadStoreICSlot(slot); 1168 CallStoreIC(slot, isolate()->factory()->home_object_symbol());
1171 CallStoreIC();
1172 } 1169 }
1173 1170
1174 1171
1175 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer, 1172 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer,
1176 int offset, 1173 int offset,
1177 FeedbackVectorSlot slot) { 1174 FeedbackVectorSlot slot) {
1178 DCHECK(NeedsHomeObject(initializer)); 1175 DCHECK(NeedsHomeObject(initializer));
1179 __ Move(StoreDescriptor::ReceiverRegister(), v0); 1176 __ Move(StoreDescriptor::ReceiverRegister(), v0);
1180 __ li(StoreDescriptor::NameRegister(),
1181 Operand(isolate()->factory()->home_object_symbol()));
1182 __ lw(StoreDescriptor::ValueRegister(), 1177 __ lw(StoreDescriptor::ValueRegister(),
1183 MemOperand(sp, offset * kPointerSize)); 1178 MemOperand(sp, offset * kPointerSize));
1184 EmitLoadStoreICSlot(slot); 1179 CallStoreIC(slot, isolate()->factory()->home_object_symbol());
1185 CallStoreIC();
1186 } 1180 }
1187 1181
1188 1182
1189 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, 1183 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
1190 TypeofMode typeof_mode, 1184 TypeofMode typeof_mode,
1191 Label* slow) { 1185 Label* slow) {
1192 Register current = cp; 1186 Register current = cp;
1193 Register next = a1; 1187 Register next = a1;
1194 Register temp = a2; 1188 Register temp = a2;
1195 1189
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 // Fall through. 1406 // Fall through.
1413 case ObjectLiteral::Property::COMPUTED: 1407 case ObjectLiteral::Property::COMPUTED:
1414 // It is safe to use [[Put]] here because the boilerplate already 1408 // It is safe to use [[Put]] here because the boilerplate already
1415 // contains computed properties with an uninitialized value. 1409 // contains computed properties with an uninitialized value.
1416 if (key->IsStringLiteral()) { 1410 if (key->IsStringLiteral()) {
1417 DCHECK(key->IsPropertyName()); 1411 DCHECK(key->IsPropertyName());
1418 if (property->emit_store()) { 1412 if (property->emit_store()) {
1419 VisitForAccumulatorValue(value); 1413 VisitForAccumulatorValue(value);
1420 __ mov(StoreDescriptor::ValueRegister(), result_register()); 1414 __ mov(StoreDescriptor::ValueRegister(), result_register());
1421 DCHECK(StoreDescriptor::ValueRegister().is(a0)); 1415 DCHECK(StoreDescriptor::ValueRegister().is(a0));
1422 __ li(StoreDescriptor::NameRegister(), Operand(key->value()));
1423 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); 1416 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
1424 EmitLoadStoreICSlot(property->GetSlot(0)); 1417 CallStoreIC(property->GetSlot(0), key->value());
1425 CallStoreIC();
1426 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); 1418 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS);
1427 1419
1428 if (NeedsHomeObject(value)) { 1420 if (NeedsHomeObject(value)) {
1429 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); 1421 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1));
1430 } 1422 }
1431 } else { 1423 } else {
1432 VisitForEffect(value); 1424 VisitForEffect(value);
1433 } 1425 }
1434 break; 1426 break;
1435 } 1427 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 if (!result_saved) { 1605 if (!result_saved) {
1614 PushOperand(v0); // array literal 1606 PushOperand(v0); // array literal
1615 result_saved = true; 1607 result_saved = true;
1616 } 1608 }
1617 1609
1618 VisitForAccumulatorValue(subexpr); 1610 VisitForAccumulatorValue(subexpr);
1619 1611
1620 __ li(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); 1612 __ li(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index)));
1621 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); 1613 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0));
1622 __ mov(StoreDescriptor::ValueRegister(), result_register()); 1614 __ mov(StoreDescriptor::ValueRegister(), result_register());
1623 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); 1615 CallKeyedStoreIC(expr->LiteralFeedbackSlot());
1624 CallKeyedStoreIC();
1625 1616
1626 PrepareForBailoutForId(expr->GetIdForElement(array_index), 1617 PrepareForBailoutForId(expr->GetIdForElement(array_index),
1627 BailoutState::NO_REGISTERS); 1618 BailoutState::NO_REGISTERS);
1628 } 1619 }
1629 1620
1630 if (result_saved) { 1621 if (result_saved) {
1631 context()->PlugTOS(); 1622 context()->PlugTOS();
1632 } else { 1623 } else {
1633 context()->Plug(v0); 1624 context()->Plug(v0);
1634 } 1625 }
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 Variable* var = expr->AsVariableProxy()->var(); 2044 Variable* var = expr->AsVariableProxy()->var();
2054 EffectContext context(this); 2045 EffectContext context(this);
2055 EmitVariableAssignment(var, Token::ASSIGN, slot); 2046 EmitVariableAssignment(var, Token::ASSIGN, slot);
2056 break; 2047 break;
2057 } 2048 }
2058 case NAMED_PROPERTY: { 2049 case NAMED_PROPERTY: {
2059 PushOperand(result_register()); // Preserve value. 2050 PushOperand(result_register()); // Preserve value.
2060 VisitForAccumulatorValue(prop->obj()); 2051 VisitForAccumulatorValue(prop->obj());
2061 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); 2052 __ mov(StoreDescriptor::ReceiverRegister(), result_register());
2062 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 2053 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
2063 __ li(StoreDescriptor::NameRegister(), 2054 CallStoreIC(slot, prop->key()->AsLiteral()->value());
2064 Operand(prop->key()->AsLiteral()->value()));
2065 EmitLoadStoreICSlot(slot);
2066 CallStoreIC();
2067 break; 2055 break;
2068 } 2056 }
2069 case NAMED_SUPER_PROPERTY: { 2057 case NAMED_SUPER_PROPERTY: {
2070 PushOperand(v0); 2058 PushOperand(v0);
2071 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 2059 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
2072 VisitForAccumulatorValue( 2060 VisitForAccumulatorValue(
2073 prop->obj()->AsSuperPropertyReference()->home_object()); 2061 prop->obj()->AsSuperPropertyReference()->home_object());
2074 // stack: value, this; v0: home_object 2062 // stack: value, this; v0: home_object
2075 Register scratch = a2; 2063 Register scratch = a2;
2076 Register scratch2 = a3; 2064 Register scratch2 = a3;
(...skipping 26 matching lines...) Expand all
2103 EmitKeyedSuperPropertyStore(prop); 2091 EmitKeyedSuperPropertyStore(prop);
2104 break; 2092 break;
2105 } 2093 }
2106 case KEYED_PROPERTY: { 2094 case KEYED_PROPERTY: {
2107 PushOperand(result_register()); // Preserve value. 2095 PushOperand(result_register()); // Preserve value.
2108 VisitForStackValue(prop->obj()); 2096 VisitForStackValue(prop->obj());
2109 VisitForAccumulatorValue(prop->key()); 2097 VisitForAccumulatorValue(prop->key());
2110 __ mov(StoreDescriptor::NameRegister(), result_register()); 2098 __ mov(StoreDescriptor::NameRegister(), result_register());
2111 PopOperands(StoreDescriptor::ValueRegister(), 2099 PopOperands(StoreDescriptor::ValueRegister(),
2112 StoreDescriptor::ReceiverRegister()); 2100 StoreDescriptor::ReceiverRegister());
2113 EmitLoadStoreICSlot(slot); 2101 CallKeyedStoreIC(slot);
2114 CallKeyedStoreIC();
2115 break; 2102 break;
2116 } 2103 }
2117 } 2104 }
2118 context()->Plug(v0); 2105 context()->Plug(v0);
2119 } 2106 }
2120 2107
2121 2108
2122 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( 2109 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
2123 Variable* var, MemOperand location) { 2110 Variable* var, MemOperand location) {
2124 __ sw(result_register(), location); 2111 __ sw(result_register(), location);
2125 if (var->IsContextSlot()) { 2112 if (var->IsContextSlot()) {
2126 // RecordWrite may destroy all its register arguments. 2113 // RecordWrite may destroy all its register arguments.
2127 __ Move(a3, result_register()); 2114 __ Move(a3, result_register());
2128 int offset = Context::SlotOffset(var->index()); 2115 int offset = Context::SlotOffset(var->index());
2129 __ RecordWriteContextSlot( 2116 __ RecordWriteContextSlot(
2130 a1, offset, a3, a2, kRAHasBeenSaved, kDontSaveFPRegs); 2117 a1, offset, a3, a2, kRAHasBeenSaved, kDontSaveFPRegs);
2131 } 2118 }
2132 } 2119 }
2133 2120
2134 2121
2135 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2122 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2136 FeedbackVectorSlot slot) { 2123 FeedbackVectorSlot slot) {
2137 if (var->IsUnallocated()) { 2124 if (var->IsUnallocated()) {
2138 // Global var, const, or let. 2125 // Global var, const, or let.
2139 __ mov(StoreDescriptor::ValueRegister(), result_register()); 2126 __ mov(StoreDescriptor::ValueRegister(), result_register());
2140 __ li(StoreDescriptor::NameRegister(), Operand(var->name()));
2141 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); 2127 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister());
2142 EmitLoadStoreICSlot(slot); 2128 CallStoreIC(slot, var->name());
2143 CallStoreIC();
2144 2129
2145 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { 2130 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) {
2146 DCHECK(!var->IsLookupSlot()); 2131 DCHECK(!var->IsLookupSlot());
2147 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2132 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2148 MemOperand location = VarOperand(var, a1); 2133 MemOperand location = VarOperand(var, a1);
2149 // Perform an initialization check for lexically declared variables. 2134 // Perform an initialization check for lexically declared variables.
2150 if (var->binding_needs_init()) { 2135 if (var->binding_needs_init()) {
2151 Label assign; 2136 Label assign;
2152 __ lw(a3, location); 2137 __ lw(a3, location);
2153 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); 2138 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 } 2187 }
2203 2188
2204 2189
2205 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2190 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2206 // Assignment to a property, using a named store IC. 2191 // Assignment to a property, using a named store IC.
2207 Property* prop = expr->target()->AsProperty(); 2192 Property* prop = expr->target()->AsProperty();
2208 DCHECK(prop != NULL); 2193 DCHECK(prop != NULL);
2209 DCHECK(prop->key()->IsLiteral()); 2194 DCHECK(prop->key()->IsLiteral());
2210 2195
2211 __ mov(StoreDescriptor::ValueRegister(), result_register()); 2196 __ mov(StoreDescriptor::ValueRegister(), result_register());
2212 __ li(StoreDescriptor::NameRegister(),
2213 Operand(prop->key()->AsLiteral()->value()));
2214 PopOperand(StoreDescriptor::ReceiverRegister()); 2197 PopOperand(StoreDescriptor::ReceiverRegister());
2215 EmitLoadStoreICSlot(expr->AssignmentSlot()); 2198 CallStoreIC(expr->AssignmentSlot(), prop->key()->AsLiteral()->value());
2216 CallStoreIC();
2217 2199
2218 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2200 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2219 context()->Plug(v0); 2201 context()->Plug(v0);
2220 } 2202 }
2221 2203
2222 2204
2223 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { 2205 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
2224 // Assignment to named property of super. 2206 // Assignment to named property of super.
2225 // v0 : value 2207 // v0 : value
2226 // stack : receiver ('this'), home_object 2208 // stack : receiver ('this'), home_object
(...skipping 27 matching lines...) Expand all
2254 // Call keyed store IC. 2236 // Call keyed store IC.
2255 // The arguments are: 2237 // The arguments are:
2256 // - a0 is the value, 2238 // - a0 is the value,
2257 // - a1 is the key, 2239 // - a1 is the key,
2258 // - a2 is the receiver. 2240 // - a2 is the receiver.
2259 __ mov(StoreDescriptor::ValueRegister(), result_register()); 2241 __ mov(StoreDescriptor::ValueRegister(), result_register());
2260 PopOperands(StoreDescriptor::ReceiverRegister(), 2242 PopOperands(StoreDescriptor::ReceiverRegister(),
2261 StoreDescriptor::NameRegister()); 2243 StoreDescriptor::NameRegister());
2262 DCHECK(StoreDescriptor::ValueRegister().is(a0)); 2244 DCHECK(StoreDescriptor::ValueRegister().is(a0));
2263 2245
2264 EmitLoadStoreICSlot(expr->AssignmentSlot()); 2246 CallKeyedStoreIC(expr->AssignmentSlot());
2265 CallKeyedStoreIC();
2266 2247
2267 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 2248 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
2268 context()->Plug(v0); 2249 context()->Plug(v0);
2269 } 2250 }
2270 2251
2271 2252
2272 void FullCodeGenerator::CallIC(Handle<Code> code, 2253 void FullCodeGenerator::CallIC(Handle<Code> code,
2273 TypeFeedbackId id) { 2254 TypeFeedbackId id) {
2274 ic_total_count_++; 2255 ic_total_count_++;
2275 __ Call(code, RelocInfo::CODE_TARGET, id); 2256 __ Call(code, RelocInfo::CODE_TARGET, id);
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 } else { 3284 } else {
3304 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3285 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3305 Token::ASSIGN, expr->CountSlot()); 3286 Token::ASSIGN, expr->CountSlot());
3306 PrepareForBailoutForId(expr->AssignmentId(), 3287 PrepareForBailoutForId(expr->AssignmentId(),
3307 BailoutState::TOS_REGISTER); 3288 BailoutState::TOS_REGISTER);
3308 context()->Plug(v0); 3289 context()->Plug(v0);
3309 } 3290 }
3310 break; 3291 break;
3311 case NAMED_PROPERTY: { 3292 case NAMED_PROPERTY: {
3312 __ mov(StoreDescriptor::ValueRegister(), result_register()); 3293 __ mov(StoreDescriptor::ValueRegister(), result_register());
3313 __ li(StoreDescriptor::NameRegister(),
3314 Operand(prop->key()->AsLiteral()->value()));
3315 PopOperand(StoreDescriptor::ReceiverRegister()); 3294 PopOperand(StoreDescriptor::ReceiverRegister());
3316 EmitLoadStoreICSlot(expr->CountSlot()); 3295 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value());
3317 CallStoreIC();
3318 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3296 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3319 if (expr->is_postfix()) { 3297 if (expr->is_postfix()) {
3320 if (!context()->IsEffect()) { 3298 if (!context()->IsEffect()) {
3321 context()->PlugTOS(); 3299 context()->PlugTOS();
3322 } 3300 }
3323 } else { 3301 } else {
3324 context()->Plug(v0); 3302 context()->Plug(v0);
3325 } 3303 }
3326 break; 3304 break;
3327 } 3305 }
(...skipping 18 matching lines...) Expand all
3346 } 3324 }
3347 } else { 3325 } else {
3348 context()->Plug(v0); 3326 context()->Plug(v0);
3349 } 3327 }
3350 break; 3328 break;
3351 } 3329 }
3352 case KEYED_PROPERTY: { 3330 case KEYED_PROPERTY: {
3353 __ mov(StoreDescriptor::ValueRegister(), result_register()); 3331 __ mov(StoreDescriptor::ValueRegister(), result_register());
3354 PopOperands(StoreDescriptor::ReceiverRegister(), 3332 PopOperands(StoreDescriptor::ReceiverRegister(),
3355 StoreDescriptor::NameRegister()); 3333 StoreDescriptor::NameRegister());
3356 EmitLoadStoreICSlot(expr->CountSlot()); 3334 CallKeyedStoreIC(expr->CountSlot());
3357 CallKeyedStoreIC();
3358 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3335 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3359 if (expr->is_postfix()) { 3336 if (expr->is_postfix()) {
3360 if (!context()->IsEffect()) { 3337 if (!context()->IsEffect()) {
3361 context()->PlugTOS(); 3338 context()->PlugTOS();
3362 } 3339 }
3363 } else { 3340 } else {
3364 context()->Plug(v0); 3341 context()->Plug(v0);
3365 } 3342 }
3366 break; 3343 break;
3367 } 3344 }
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
3732 reinterpret_cast<uint32_t>( 3709 reinterpret_cast<uint32_t>(
3733 isolate->builtins()->OnStackReplacement()->entry())); 3710 isolate->builtins()->OnStackReplacement()->entry()));
3734 return ON_STACK_REPLACEMENT; 3711 return ON_STACK_REPLACEMENT;
3735 } 3712 }
3736 3713
3737 3714
3738 } // namespace internal 3715 } // namespace internal
3739 } // namespace v8 3716 } // namespace v8
3740 3717
3741 #endif // V8_TARGET_ARCH_MIPS 3718 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698