| 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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 __ CallStub(&stub); | 1189 __ CallStub(&stub); |
| 1190 RestoreContext(); | 1190 RestoreContext(); |
| 1191 } | 1191 } |
| 1192 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); | 1192 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
| 1193 | 1193 |
| 1194 // If result_saved is true the result is on top of the stack. If | 1194 // If result_saved is true the result is on top of the stack. If |
| 1195 // result_saved is false the result is in r3. | 1195 // result_saved is false the result is in r3. |
| 1196 bool result_saved = false; | 1196 bool result_saved = false; |
| 1197 | 1197 |
| 1198 AccessorTable accessor_table(zone()); | 1198 AccessorTable accessor_table(zone()); |
| 1199 int property_index = 0; | 1199 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1200 for (; property_index < expr->properties()->length(); property_index++) { | 1200 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1201 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1201 DCHECK(!property->is_computed_name()); |
| 1202 if (property->is_computed_name()) break; | |
| 1203 if (property->IsCompileTimeValue()) continue; | 1202 if (property->IsCompileTimeValue()) continue; |
| 1204 | 1203 |
| 1205 Literal* key = property->key()->AsLiteral(); | 1204 Literal* key = property->key()->AsLiteral(); |
| 1206 Expression* value = property->value(); | 1205 Expression* value = property->value(); |
| 1207 if (!result_saved) { | 1206 if (!result_saved) { |
| 1208 PushOperand(r3); // Save result on stack | 1207 PushOperand(r3); // Save result on stack |
| 1209 result_saved = true; | 1208 result_saved = true; |
| 1210 } | 1209 } |
| 1211 switch (property->kind()) { | 1210 switch (property->kind()) { |
| 1212 case ObjectLiteral::Property::CONSTANT: | 1211 case ObjectLiteral::Property::CONSTANT: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 DropOperands(3); | 1249 DropOperands(3); |
| 1251 } | 1250 } |
| 1252 break; | 1251 break; |
| 1253 case ObjectLiteral::Property::PROTOTYPE: | 1252 case ObjectLiteral::Property::PROTOTYPE: |
| 1254 // Duplicate receiver on stack. | 1253 // Duplicate receiver on stack. |
| 1255 __ LoadP(r3, MemOperand(sp)); | 1254 __ LoadP(r3, MemOperand(sp)); |
| 1256 PushOperand(r3); | 1255 PushOperand(r3); |
| 1257 VisitForStackValue(value); | 1256 VisitForStackValue(value); |
| 1258 DCHECK(property->emit_store()); | 1257 DCHECK(property->emit_store()); |
| 1259 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1258 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
| 1260 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1259 PrepareForBailoutForId(expr->GetIdForPropertySet(i), |
| 1261 BailoutState::NO_REGISTERS); | 1260 BailoutState::NO_REGISTERS); |
| 1262 break; | 1261 break; |
| 1263 case ObjectLiteral::Property::GETTER: | 1262 case ObjectLiteral::Property::GETTER: |
| 1264 if (property->emit_store()) { | 1263 if (property->emit_store()) { |
| 1265 AccessorTable::Iterator it = accessor_table.lookup(key); | 1264 AccessorTable::Iterator it = accessor_table.lookup(key); |
| 1266 it->second->bailout_id = expr->GetIdForPropertySet(property_index); | 1265 it->second->bailout_id = expr->GetIdForPropertySet(i); |
| 1267 it->second->getter = property; | 1266 it->second->getter = property; |
| 1268 } | 1267 } |
| 1269 break; | 1268 break; |
| 1270 case ObjectLiteral::Property::SETTER: | 1269 case ObjectLiteral::Property::SETTER: |
| 1271 if (property->emit_store()) { | 1270 if (property->emit_store()) { |
| 1272 AccessorTable::Iterator it = accessor_table.lookup(key); | 1271 AccessorTable::Iterator it = accessor_table.lookup(key); |
| 1273 it->second->bailout_id = expr->GetIdForPropertySet(property_index); | 1272 it->second->bailout_id = expr->GetIdForPropertySet(i); |
| 1274 it->second->setter = property; | 1273 it->second->setter = property; |
| 1275 } | 1274 } |
| 1276 break; | 1275 break; |
| 1277 } | 1276 } |
| 1278 } | 1277 } |
| 1279 | 1278 |
| 1280 // Emit code to define accessors, using only a single call to the runtime for | 1279 // Emit code to define accessors, using only a single call to the runtime for |
| 1281 // each pair of corresponding getters and setters. | 1280 // each pair of corresponding getters and setters. |
| 1282 for (AccessorTable::Iterator it = accessor_table.begin(); | 1281 for (AccessorTable::Iterator it = accessor_table.begin(); |
| 1283 it != accessor_table.end(); ++it) { | 1282 it != accessor_table.end(); ++it) { |
| 1284 __ LoadP(r3, MemOperand(sp)); // Duplicate receiver. | 1283 __ LoadP(r3, MemOperand(sp)); // Duplicate receiver. |
| 1285 PushOperand(r3); | 1284 PushOperand(r3); |
| 1286 VisitForStackValue(it->first); | 1285 VisitForStackValue(it->first); |
| 1287 EmitAccessor(it->second->getter); | 1286 EmitAccessor(it->second->getter); |
| 1288 EmitAccessor(it->second->setter); | 1287 EmitAccessor(it->second->setter); |
| 1289 __ LoadSmiLiteral(r3, Smi::FromInt(NONE)); | 1288 __ LoadSmiLiteral(r3, Smi::FromInt(NONE)); |
| 1290 PushOperand(r3); | 1289 PushOperand(r3); |
| 1291 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); | 1290 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); |
| 1292 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); | 1291 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); |
| 1293 } | 1292 } |
| 1294 | 1293 |
| 1295 // Object literals have two parts. The "static" part on the left contains no | |
| 1296 // computed property names, and so we can compute its map ahead of time; see | |
| 1297 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part | |
| 1298 // starts with the first computed property name, and continues with all | |
| 1299 // properties to its right. All the code from above initializes the static | |
| 1300 // component of the object literal, and arranges for the map of the result to | |
| 1301 // reflect the static order in which the keys appear. For the dynamic | |
| 1302 // properties, we compile them into a series of "SetOwnProperty" runtime | |
| 1303 // calls. This will preserve insertion order. | |
| 1304 for (; property_index < expr->properties()->length(); property_index++) { | |
| 1305 ObjectLiteral::Property* property = expr->properties()->at(property_index); | |
| 1306 | |
| 1307 Expression* value = property->value(); | |
| 1308 if (!result_saved) { | |
| 1309 PushOperand(r3); // Save result on the stack | |
| 1310 result_saved = true; | |
| 1311 } | |
| 1312 | |
| 1313 __ LoadP(r3, MemOperand(sp)); // Duplicate receiver. | |
| 1314 PushOperand(r3); | |
| 1315 | |
| 1316 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | |
| 1317 DCHECK(!property->is_computed_name()); | |
| 1318 VisitForStackValue(value); | |
| 1319 DCHECK(property->emit_store()); | |
| 1320 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | |
| 1321 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | |
| 1322 BailoutState::NO_REGISTERS); | |
| 1323 } else { | |
| 1324 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); | |
| 1325 VisitForStackValue(value); | |
| 1326 if (NeedsHomeObject(value)) { | |
| 1327 EmitSetHomeObject(value, 2, property->GetSlot()); | |
| 1328 } | |
| 1329 | |
| 1330 switch (property->kind()) { | |
| 1331 case ObjectLiteral::Property::CONSTANT: | |
| 1332 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | |
| 1333 case ObjectLiteral::Property::COMPUTED: | |
| 1334 case ObjectLiteral::Property::PROTOTYPE: | |
| 1335 UNREACHABLE(); | |
| 1336 break; | |
| 1337 | |
| 1338 case ObjectLiteral::Property::GETTER: | |
| 1339 PushOperand(Smi::FromInt(NONE)); | |
| 1340 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); | |
| 1341 break; | |
| 1342 | |
| 1343 case ObjectLiteral::Property::SETTER: | |
| 1344 PushOperand(Smi::FromInt(NONE)); | |
| 1345 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); | |
| 1346 break; | |
| 1347 } | |
| 1348 } | |
| 1349 } | |
| 1350 | |
| 1351 if (result_saved) { | 1294 if (result_saved) { |
| 1352 context()->PlugTOS(); | 1295 context()->PlugTOS(); |
| 1353 } else { | 1296 } else { |
| 1354 context()->Plug(r3); | 1297 context()->Plug(r3); |
| 1355 } | 1298 } |
| 1356 } | 1299 } |
| 1357 | 1300 |
| 1358 | 1301 |
| 1359 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1302 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1360 Comment cmnt(masm_, "[ ArrayLiteral"); | 1303 Comment cmnt(masm_, "[ ArrayLiteral"); |
| (...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 | 3073 |
| 3131 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); | 3074 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); |
| 3132 | 3075 |
| 3133 DCHECK(interrupt_address == | 3076 DCHECK(interrupt_address == |
| 3134 isolate->builtins()->OnStackReplacement()->entry()); | 3077 isolate->builtins()->OnStackReplacement()->entry()); |
| 3135 return ON_STACK_REPLACEMENT; | 3078 return ON_STACK_REPLACEMENT; |
| 3136 } | 3079 } |
| 3137 } // namespace internal | 3080 } // namespace internal |
| 3138 } // namespace v8 | 3081 } // namespace v8 |
| 3139 #endif // V8_TARGET_ARCH_PPC | 3082 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |