OLD | NEW |
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 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 __ CallStub(&stub); | 1217 __ CallStub(&stub); |
1218 RestoreContext(); | 1218 RestoreContext(); |
1219 } | 1219 } |
1220 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); | 1220 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1221 | 1221 |
1222 // If result_saved is true the result is on top of the stack. If | 1222 // If result_saved is true the result is on top of the stack. If |
1223 // result_saved is false the result is in v0. | 1223 // result_saved is false the result is in v0. |
1224 bool result_saved = false; | 1224 bool result_saved = false; |
1225 | 1225 |
1226 AccessorTable accessor_table(zone()); | 1226 AccessorTable accessor_table(zone()); |
1227 int property_index = 0; | 1227 for (int i = 0; i < expr->properties()->length(); i++) { |
1228 for (; property_index < expr->properties()->length(); property_index++) { | 1228 ObjectLiteral::Property* property = expr->properties()->at(i); |
1229 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1229 DCHECK(!property->is_computed_name()); |
1230 if (property->is_computed_name()) break; | |
1231 if (property->IsCompileTimeValue()) continue; | 1230 if (property->IsCompileTimeValue()) continue; |
1232 | 1231 |
1233 Literal* key = property->key()->AsLiteral(); | 1232 Literal* key = property->key()->AsLiteral(); |
1234 Expression* value = property->value(); | 1233 Expression* value = property->value(); |
1235 if (!result_saved) { | 1234 if (!result_saved) { |
1236 PushOperand(v0); // Save result on stack. | 1235 PushOperand(v0); // Save result on stack. |
1237 result_saved = true; | 1236 result_saved = true; |
1238 } | 1237 } |
1239 switch (property->kind()) { | 1238 switch (property->kind()) { |
1240 case ObjectLiteral::Property::CONSTANT: | 1239 case ObjectLiteral::Property::CONSTANT: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 DropOperands(3); | 1278 DropOperands(3); |
1280 } | 1279 } |
1281 break; | 1280 break; |
1282 case ObjectLiteral::Property::PROTOTYPE: | 1281 case ObjectLiteral::Property::PROTOTYPE: |
1283 // Duplicate receiver on stack. | 1282 // Duplicate receiver on stack. |
1284 __ lw(a0, MemOperand(sp)); | 1283 __ lw(a0, MemOperand(sp)); |
1285 PushOperand(a0); | 1284 PushOperand(a0); |
1286 VisitForStackValue(value); | 1285 VisitForStackValue(value); |
1287 DCHECK(property->emit_store()); | 1286 DCHECK(property->emit_store()); |
1288 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1287 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
1289 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1288 PrepareForBailoutForId(expr->GetIdForPropertySet(i), |
1290 BailoutState::NO_REGISTERS); | 1289 BailoutState::NO_REGISTERS); |
1291 break; | 1290 break; |
1292 case ObjectLiteral::Property::GETTER: | 1291 case ObjectLiteral::Property::GETTER: |
1293 if (property->emit_store()) { | 1292 if (property->emit_store()) { |
1294 AccessorTable::Iterator it = accessor_table.lookup(key); | 1293 AccessorTable::Iterator it = accessor_table.lookup(key); |
1295 it->second->bailout_id = expr->GetIdForPropertySet(property_index); | 1294 it->second->bailout_id = expr->GetIdForPropertySet(i); |
1296 it->second->getter = property; | 1295 it->second->getter = property; |
1297 } | 1296 } |
1298 break; | 1297 break; |
1299 case ObjectLiteral::Property::SETTER: | 1298 case ObjectLiteral::Property::SETTER: |
1300 if (property->emit_store()) { | 1299 if (property->emit_store()) { |
1301 AccessorTable::Iterator it = accessor_table.lookup(key); | 1300 AccessorTable::Iterator it = accessor_table.lookup(key); |
1302 it->second->bailout_id = expr->GetIdForPropertySet(property_index); | 1301 it->second->bailout_id = expr->GetIdForPropertySet(i); |
1303 it->second->setter = property; | 1302 it->second->setter = property; |
1304 } | 1303 } |
1305 break; | 1304 break; |
1306 } | 1305 } |
1307 } | 1306 } |
1308 | 1307 |
1309 // Emit code to define accessors, using only a single call to the runtime for | 1308 // Emit code to define accessors, using only a single call to the runtime for |
1310 // each pair of corresponding getters and setters. | 1309 // each pair of corresponding getters and setters. |
1311 for (AccessorTable::Iterator it = accessor_table.begin(); | 1310 for (AccessorTable::Iterator it = accessor_table.begin(); |
1312 it != accessor_table.end(); | 1311 it != accessor_table.end(); |
1313 ++it) { | 1312 ++it) { |
1314 __ lw(a0, MemOperand(sp)); // Duplicate receiver. | 1313 __ lw(a0, MemOperand(sp)); // Duplicate receiver. |
1315 PushOperand(a0); | 1314 PushOperand(a0); |
1316 VisitForStackValue(it->first); | 1315 VisitForStackValue(it->first); |
1317 EmitAccessor(it->second->getter); | 1316 EmitAccessor(it->second->getter); |
1318 EmitAccessor(it->second->setter); | 1317 EmitAccessor(it->second->setter); |
1319 __ li(a0, Operand(Smi::FromInt(NONE))); | 1318 __ li(a0, Operand(Smi::FromInt(NONE))); |
1320 PushOperand(a0); | 1319 PushOperand(a0); |
1321 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); | 1320 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); |
1322 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); | 1321 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); |
1323 } | 1322 } |
1324 | 1323 |
1325 // Object literals have two parts. The "static" part on the left contains no | |
1326 // computed property names, and so we can compute its map ahead of time; see | |
1327 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part | |
1328 // starts with the first computed property name, and continues with all | |
1329 // properties to its right. All the code from above initializes the static | |
1330 // component of the object literal, and arranges for the map of the result to | |
1331 // reflect the static order in which the keys appear. For the dynamic | |
1332 // properties, we compile them into a series of "SetOwnProperty" runtime | |
1333 // calls. This will preserve insertion order. | |
1334 for (; property_index < expr->properties()->length(); property_index++) { | |
1335 ObjectLiteral::Property* property = expr->properties()->at(property_index); | |
1336 | |
1337 Expression* value = property->value(); | |
1338 if (!result_saved) { | |
1339 PushOperand(v0); // Save result on the stack | |
1340 result_saved = true; | |
1341 } | |
1342 | |
1343 __ lw(a0, MemOperand(sp)); // Duplicate receiver. | |
1344 PushOperand(a0); | |
1345 | |
1346 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | |
1347 DCHECK(!property->is_computed_name()); | |
1348 VisitForStackValue(value); | |
1349 DCHECK(property->emit_store()); | |
1350 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | |
1351 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | |
1352 BailoutState::NO_REGISTERS); | |
1353 } else { | |
1354 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); | |
1355 VisitForStackValue(value); | |
1356 if (NeedsHomeObject(value)) { | |
1357 EmitSetHomeObject(value, 2, property->GetSlot()); | |
1358 } | |
1359 | |
1360 switch (property->kind()) { | |
1361 case ObjectLiteral::Property::CONSTANT: | |
1362 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | |
1363 case ObjectLiteral::Property::COMPUTED: | |
1364 case ObjectLiteral::Property::PROTOTYPE: | |
1365 UNREACHABLE(); | |
1366 break; | |
1367 | |
1368 case ObjectLiteral::Property::GETTER: | |
1369 PushOperand(Smi::FromInt(NONE)); | |
1370 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); | |
1371 break; | |
1372 | |
1373 case ObjectLiteral::Property::SETTER: | |
1374 PushOperand(Smi::FromInt(NONE)); | |
1375 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); | |
1376 break; | |
1377 } | |
1378 } | |
1379 } | |
1380 | |
1381 if (result_saved) { | 1324 if (result_saved) { |
1382 context()->PlugTOS(); | 1325 context()->PlugTOS(); |
1383 } else { | 1326 } else { |
1384 context()->Plug(v0); | 1327 context()->Plug(v0); |
1385 } | 1328 } |
1386 } | 1329 } |
1387 | 1330 |
1388 | 1331 |
1389 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1332 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
1390 Comment cmnt(masm_, "[ ArrayLiteral"); | 1333 Comment cmnt(masm_, "[ ArrayLiteral"); |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3149 reinterpret_cast<uint32_t>( | 3092 reinterpret_cast<uint32_t>( |
3150 isolate->builtins()->OnStackReplacement()->entry())); | 3093 isolate->builtins()->OnStackReplacement()->entry())); |
3151 return ON_STACK_REPLACEMENT; | 3094 return ON_STACK_REPLACEMENT; |
3152 } | 3095 } |
3153 | 3096 |
3154 | 3097 |
3155 } // namespace internal | 3098 } // namespace internal |
3156 } // namespace v8 | 3099 } // namespace v8 |
3157 | 3100 |
3158 #endif // V8_TARGET_ARCH_MIPS | 3101 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |