OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); | 1126 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); |
1127 __ bind(&exit); | 1127 __ bind(&exit); |
1128 decrement_loop_depth(); | 1128 decrement_loop_depth(); |
1129 } | 1129 } |
1130 | 1130 |
1131 | 1131 |
1132 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, | 1132 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, |
1133 FeedbackVectorSlot slot) { | 1133 FeedbackVectorSlot slot) { |
1134 DCHECK(NeedsHomeObject(initializer)); | 1134 DCHECK(NeedsHomeObject(initializer)); |
1135 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); | 1135 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); |
1136 __ mov(StoreDescriptor::NameRegister(), | |
1137 Operand(isolate()->factory()->home_object_symbol())); | |
1138 __ LoadP(StoreDescriptor::ValueRegister(), | 1136 __ LoadP(StoreDescriptor::ValueRegister(), |
1139 MemOperand(sp, offset * kPointerSize)); | 1137 MemOperand(sp, offset * kPointerSize)); |
1140 EmitLoadStoreICSlot(slot); | 1138 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); |
1141 CallStoreIC(); | |
1142 } | 1139 } |
1143 | 1140 |
1144 | 1141 |
1145 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer, | 1142 void FullCodeGenerator::EmitSetHomeObjectAccumulator(Expression* initializer, |
1146 int offset, | 1143 int offset, |
1147 FeedbackVectorSlot slot) { | 1144 FeedbackVectorSlot slot) { |
1148 DCHECK(NeedsHomeObject(initializer)); | 1145 DCHECK(NeedsHomeObject(initializer)); |
1149 __ Move(StoreDescriptor::ReceiverRegister(), r3); | 1146 __ Move(StoreDescriptor::ReceiverRegister(), r3); |
1150 __ mov(StoreDescriptor::NameRegister(), | |
1151 Operand(isolate()->factory()->home_object_symbol())); | |
1152 __ LoadP(StoreDescriptor::ValueRegister(), | 1147 __ LoadP(StoreDescriptor::ValueRegister(), |
1153 MemOperand(sp, offset * kPointerSize)); | 1148 MemOperand(sp, offset * kPointerSize)); |
1154 EmitLoadStoreICSlot(slot); | 1149 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); |
1155 CallStoreIC(); | |
1156 } | 1150 } |
1157 | 1151 |
1158 | 1152 |
1159 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, | 1153 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, |
1160 TypeofMode typeof_mode, | 1154 TypeofMode typeof_mode, |
1161 Label* slow) { | 1155 Label* slow) { |
1162 Register current = cp; | 1156 Register current = cp; |
1163 Register next = r4; | 1157 Register next = r4; |
1164 Register temp = r5; | 1158 Register temp = r5; |
1165 | 1159 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1374 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
1381 // Fall through. | 1375 // Fall through. |
1382 case ObjectLiteral::Property::COMPUTED: | 1376 case ObjectLiteral::Property::COMPUTED: |
1383 // It is safe to use [[Put]] here because the boilerplate already | 1377 // It is safe to use [[Put]] here because the boilerplate already |
1384 // contains computed properties with an uninitialized value. | 1378 // contains computed properties with an uninitialized value. |
1385 if (key->IsStringLiteral()) { | 1379 if (key->IsStringLiteral()) { |
1386 DCHECK(key->IsPropertyName()); | 1380 DCHECK(key->IsPropertyName()); |
1387 if (property->emit_store()) { | 1381 if (property->emit_store()) { |
1388 VisitForAccumulatorValue(value); | 1382 VisitForAccumulatorValue(value); |
1389 DCHECK(StoreDescriptor::ValueRegister().is(r3)); | 1383 DCHECK(StoreDescriptor::ValueRegister().is(r3)); |
1390 __ mov(StoreDescriptor::NameRegister(), Operand(key->value())); | |
1391 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); | 1384 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); |
1392 EmitLoadStoreICSlot(property->GetSlot(0)); | 1385 CallStoreIC(property->GetSlot(0), key->value()); |
1393 CallStoreIC(); | |
1394 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); | 1386 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); |
1395 | 1387 |
1396 if (NeedsHomeObject(value)) { | 1388 if (NeedsHomeObject(value)) { |
1397 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); | 1389 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); |
1398 } | 1390 } |
1399 } else { | 1391 } else { |
1400 VisitForEffect(value); | 1392 VisitForEffect(value); |
1401 } | 1393 } |
1402 break; | 1394 break; |
1403 } | 1395 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 | 1571 |
1580 if (!result_saved) { | 1572 if (!result_saved) { |
1581 PushOperand(r3); | 1573 PushOperand(r3); |
1582 result_saved = true; | 1574 result_saved = true; |
1583 } | 1575 } |
1584 VisitForAccumulatorValue(subexpr); | 1576 VisitForAccumulatorValue(subexpr); |
1585 | 1577 |
1586 __ LoadSmiLiteral(StoreDescriptor::NameRegister(), | 1578 __ LoadSmiLiteral(StoreDescriptor::NameRegister(), |
1587 Smi::FromInt(array_index)); | 1579 Smi::FromInt(array_index)); |
1588 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 1580 __ LoadP(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
1589 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1581 CallKeyedStoreIC(expr->LiteralFeedbackSlot()); |
1590 CallKeyedStoreIC(); | |
1591 | 1582 |
1592 PrepareForBailoutForId(expr->GetIdForElement(array_index), | 1583 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
1593 BailoutState::NO_REGISTERS); | 1584 BailoutState::NO_REGISTERS); |
1594 } | 1585 } |
1595 | 1586 |
1596 if (result_saved) { | 1587 if (result_saved) { |
1597 context()->PlugTOS(); | 1588 context()->PlugTOS(); |
1598 } else { | 1589 } else { |
1599 context()->Plug(r3); | 1590 context()->Plug(r3); |
1600 } | 1591 } |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 Variable* var = expr->AsVariableProxy()->var(); | 2047 Variable* var = expr->AsVariableProxy()->var(); |
2057 EffectContext context(this); | 2048 EffectContext context(this); |
2058 EmitVariableAssignment(var, Token::ASSIGN, slot); | 2049 EmitVariableAssignment(var, Token::ASSIGN, slot); |
2059 break; | 2050 break; |
2060 } | 2051 } |
2061 case NAMED_PROPERTY: { | 2052 case NAMED_PROPERTY: { |
2062 PushOperand(r3); // Preserve value. | 2053 PushOperand(r3); // Preserve value. |
2063 VisitForAccumulatorValue(prop->obj()); | 2054 VisitForAccumulatorValue(prop->obj()); |
2064 __ Move(StoreDescriptor::ReceiverRegister(), r3); | 2055 __ Move(StoreDescriptor::ReceiverRegister(), r3); |
2065 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. | 2056 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
2066 __ mov(StoreDescriptor::NameRegister(), | 2057 CallStoreIC(slot, prop->key()->AsLiteral()->value()); |
2067 Operand(prop->key()->AsLiteral()->value())); | |
2068 EmitLoadStoreICSlot(slot); | |
2069 CallStoreIC(); | |
2070 break; | 2058 break; |
2071 } | 2059 } |
2072 case NAMED_SUPER_PROPERTY: { | 2060 case NAMED_SUPER_PROPERTY: { |
2073 PushOperand(r3); | 2061 PushOperand(r3); |
2074 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); | 2062 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2075 VisitForAccumulatorValue( | 2063 VisitForAccumulatorValue( |
2076 prop->obj()->AsSuperPropertyReference()->home_object()); | 2064 prop->obj()->AsSuperPropertyReference()->home_object()); |
2077 // stack: value, this; r3: home_object | 2065 // stack: value, this; r3: home_object |
2078 Register scratch = r5; | 2066 Register scratch = r5; |
2079 Register scratch2 = r6; | 2067 Register scratch2 = r6; |
(...skipping 26 matching lines...) Expand all Loading... |
2106 EmitKeyedSuperPropertyStore(prop); | 2094 EmitKeyedSuperPropertyStore(prop); |
2107 break; | 2095 break; |
2108 } | 2096 } |
2109 case KEYED_PROPERTY: { | 2097 case KEYED_PROPERTY: { |
2110 PushOperand(r3); // Preserve value. | 2098 PushOperand(r3); // Preserve value. |
2111 VisitForStackValue(prop->obj()); | 2099 VisitForStackValue(prop->obj()); |
2112 VisitForAccumulatorValue(prop->key()); | 2100 VisitForAccumulatorValue(prop->key()); |
2113 __ Move(StoreDescriptor::NameRegister(), r3); | 2101 __ Move(StoreDescriptor::NameRegister(), r3); |
2114 PopOperands(StoreDescriptor::ValueRegister(), | 2102 PopOperands(StoreDescriptor::ValueRegister(), |
2115 StoreDescriptor::ReceiverRegister()); | 2103 StoreDescriptor::ReceiverRegister()); |
2116 EmitLoadStoreICSlot(slot); | 2104 CallKeyedStoreIC(slot); |
2117 CallKeyedStoreIC(); | |
2118 break; | 2105 break; |
2119 } | 2106 } |
2120 } | 2107 } |
2121 context()->Plug(r3); | 2108 context()->Plug(r3); |
2122 } | 2109 } |
2123 | 2110 |
2124 | 2111 |
2125 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( | 2112 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
2126 Variable* var, MemOperand location) { | 2113 Variable* var, MemOperand location) { |
2127 __ StoreP(result_register(), location, r0); | 2114 __ StoreP(result_register(), location, r0); |
2128 if (var->IsContextSlot()) { | 2115 if (var->IsContextSlot()) { |
2129 // RecordWrite may destroy all its register arguments. | 2116 // RecordWrite may destroy all its register arguments. |
2130 __ mr(r6, result_register()); | 2117 __ mr(r6, result_register()); |
2131 int offset = Context::SlotOffset(var->index()); | 2118 int offset = Context::SlotOffset(var->index()); |
2132 __ RecordWriteContextSlot(r4, offset, r6, r5, kLRHasBeenSaved, | 2119 __ RecordWriteContextSlot(r4, offset, r6, r5, kLRHasBeenSaved, |
2133 kDontSaveFPRegs); | 2120 kDontSaveFPRegs); |
2134 } | 2121 } |
2135 } | 2122 } |
2136 | 2123 |
2137 | 2124 |
2138 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2125 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2139 FeedbackVectorSlot slot) { | 2126 FeedbackVectorSlot slot) { |
2140 if (var->IsUnallocated()) { | 2127 if (var->IsUnallocated()) { |
2141 // Global var, const, or let. | 2128 // Global var, const, or let. |
2142 __ mov(StoreDescriptor::NameRegister(), Operand(var->name())); | |
2143 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 2129 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
2144 EmitLoadStoreICSlot(slot); | 2130 CallStoreIC(slot, var->name()); |
2145 CallStoreIC(); | |
2146 | 2131 |
2147 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { | 2132 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
2148 DCHECK(!var->IsLookupSlot()); | 2133 DCHECK(!var->IsLookupSlot()); |
2149 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2134 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2150 MemOperand location = VarOperand(var, r4); | 2135 MemOperand location = VarOperand(var, r4); |
2151 // Perform an initialization check for lexically declared variables. | 2136 // Perform an initialization check for lexically declared variables. |
2152 if (var->binding_needs_init()) { | 2137 if (var->binding_needs_init()) { |
2153 Label assign; | 2138 Label assign; |
2154 __ LoadP(r6, location); | 2139 __ LoadP(r6, location); |
2155 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); | 2140 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2203 } | 2188 } |
2204 } | 2189 } |
2205 | 2190 |
2206 | 2191 |
2207 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2192 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2208 // Assignment to a property, using a named store IC. | 2193 // Assignment to a property, using a named store IC. |
2209 Property* prop = expr->target()->AsProperty(); | 2194 Property* prop = expr->target()->AsProperty(); |
2210 DCHECK(prop != NULL); | 2195 DCHECK(prop != NULL); |
2211 DCHECK(prop->key()->IsLiteral()); | 2196 DCHECK(prop->key()->IsLiteral()); |
2212 | 2197 |
2213 __ mov(StoreDescriptor::NameRegister(), | |
2214 Operand(prop->key()->AsLiteral()->value())); | |
2215 PopOperand(StoreDescriptor::ReceiverRegister()); | 2198 PopOperand(StoreDescriptor::ReceiverRegister()); |
2216 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2199 CallStoreIC(expr->AssignmentSlot(), prop->key()->AsLiteral()->value()); |
2217 CallStoreIC(); | |
2218 | 2200 |
2219 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 2201 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
2220 context()->Plug(r3); | 2202 context()->Plug(r3); |
2221 } | 2203 } |
2222 | 2204 |
2223 | 2205 |
2224 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { | 2206 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { |
2225 // Assignment to named property of super. | 2207 // Assignment to named property of super. |
2226 // r3 : value | 2208 // r3 : value |
2227 // stack : receiver ('this'), home_object | 2209 // stack : receiver ('this'), home_object |
(...skipping 21 matching lines...) Expand all Loading... |
2249 : Runtime::kStoreKeyedToSuper_Sloppy)); | 2231 : Runtime::kStoreKeyedToSuper_Sloppy)); |
2250 } | 2232 } |
2251 | 2233 |
2252 | 2234 |
2253 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2235 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2254 // Assignment to a property, using a keyed store IC. | 2236 // Assignment to a property, using a keyed store IC. |
2255 PopOperands(StoreDescriptor::ReceiverRegister(), | 2237 PopOperands(StoreDescriptor::ReceiverRegister(), |
2256 StoreDescriptor::NameRegister()); | 2238 StoreDescriptor::NameRegister()); |
2257 DCHECK(StoreDescriptor::ValueRegister().is(r3)); | 2239 DCHECK(StoreDescriptor::ValueRegister().is(r3)); |
2258 | 2240 |
2259 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2241 CallKeyedStoreIC(expr->AssignmentSlot()); |
2260 CallKeyedStoreIC(); | |
2261 | 2242 |
2262 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 2243 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
2263 context()->Plug(r3); | 2244 context()->Plug(r3); |
2264 } | 2245 } |
2265 | 2246 |
2266 | 2247 |
2267 void FullCodeGenerator::CallIC(Handle<Code> code, TypeFeedbackId ast_id) { | 2248 void FullCodeGenerator::CallIC(Handle<Code> code, TypeFeedbackId ast_id) { |
2268 ic_total_count_++; | 2249 ic_total_count_++; |
2269 __ Call(code, RelocInfo::CODE_TARGET, ast_id); | 2250 __ Call(code, RelocInfo::CODE_TARGET, ast_id); |
2270 } | 2251 } |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3294 } | 3275 } |
3295 } else { | 3276 } else { |
3296 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3277 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3297 Token::ASSIGN, expr->CountSlot()); | 3278 Token::ASSIGN, expr->CountSlot()); |
3298 PrepareForBailoutForId(expr->AssignmentId(), | 3279 PrepareForBailoutForId(expr->AssignmentId(), |
3299 BailoutState::TOS_REGISTER); | 3280 BailoutState::TOS_REGISTER); |
3300 context()->Plug(r3); | 3281 context()->Plug(r3); |
3301 } | 3282 } |
3302 break; | 3283 break; |
3303 case NAMED_PROPERTY: { | 3284 case NAMED_PROPERTY: { |
3304 __ mov(StoreDescriptor::NameRegister(), | |
3305 Operand(prop->key()->AsLiteral()->value())); | |
3306 PopOperand(StoreDescriptor::ReceiverRegister()); | 3285 PopOperand(StoreDescriptor::ReceiverRegister()); |
3307 EmitLoadStoreICSlot(expr->CountSlot()); | 3286 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); |
3308 CallStoreIC(); | |
3309 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 3287 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3310 if (expr->is_postfix()) { | 3288 if (expr->is_postfix()) { |
3311 if (!context()->IsEffect()) { | 3289 if (!context()->IsEffect()) { |
3312 context()->PlugTOS(); | 3290 context()->PlugTOS(); |
3313 } | 3291 } |
3314 } else { | 3292 } else { |
3315 context()->Plug(r3); | 3293 context()->Plug(r3); |
3316 } | 3294 } |
3317 break; | 3295 break; |
3318 } | 3296 } |
(...skipping 17 matching lines...) Expand all Loading... |
3336 context()->PlugTOS(); | 3314 context()->PlugTOS(); |
3337 } | 3315 } |
3338 } else { | 3316 } else { |
3339 context()->Plug(r3); | 3317 context()->Plug(r3); |
3340 } | 3318 } |
3341 break; | 3319 break; |
3342 } | 3320 } |
3343 case KEYED_PROPERTY: { | 3321 case KEYED_PROPERTY: { |
3344 PopOperands(StoreDescriptor::ReceiverRegister(), | 3322 PopOperands(StoreDescriptor::ReceiverRegister(), |
3345 StoreDescriptor::NameRegister()); | 3323 StoreDescriptor::NameRegister()); |
3346 EmitLoadStoreICSlot(expr->CountSlot()); | 3324 CallKeyedStoreIC(expr->CountSlot()); |
3347 CallKeyedStoreIC(); | |
3348 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 3325 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3349 if (expr->is_postfix()) { | 3326 if (expr->is_postfix()) { |
3350 if (!context()->IsEffect()) { | 3327 if (!context()->IsEffect()) { |
3351 context()->PlugTOS(); | 3328 context()->PlugTOS(); |
3352 } | 3329 } |
3353 } else { | 3330 } else { |
3354 context()->Plug(r3); | 3331 context()->Plug(r3); |
3355 } | 3332 } |
3356 break; | 3333 break; |
3357 } | 3334 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3715 | 3692 |
3716 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); | 3693 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); |
3717 | 3694 |
3718 DCHECK(interrupt_address == | 3695 DCHECK(interrupt_address == |
3719 isolate->builtins()->OnStackReplacement()->entry()); | 3696 isolate->builtins()->OnStackReplacement()->entry()); |
3720 return ON_STACK_REPLACEMENT; | 3697 return ON_STACK_REPLACEMENT; |
3721 } | 3698 } |
3722 } // namespace internal | 3699 } // namespace internal |
3723 } // namespace v8 | 3700 } // namespace v8 |
3724 #endif // V8_TARGET_ARCH_PPC | 3701 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |