OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 // rsp[16] : argument argc - 1 | 1191 // rsp[16] : argument argc - 1 |
1192 // ... | 1192 // ... |
1193 // rsp[argc * 8] : argument 1 | 1193 // rsp[argc * 8] : argument 1 |
1194 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1194 // rsp[(argc + 1) * 8] : argument 0 = receiver |
1195 // ----------------------------------- | 1195 // ----------------------------------- |
1196 | 1196 |
1197 GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss, Code::kNoExtraICState); | 1197 GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss, Code::kNoExtraICState); |
1198 } | 1198 } |
1199 | 1199 |
1200 | 1200 |
| 1201 static Operand GenerateMappedArgumentsLookup(MacroAssembler* masm, |
| 1202 Register object, |
| 1203 Register key, |
| 1204 Register scratch1, |
| 1205 Register scratch2, |
| 1206 Register scratch3, |
| 1207 Label* unmapped_case, |
| 1208 Label* slow_case) { |
| 1209 Heap* heap = masm->isolate()->heap(); |
| 1210 |
| 1211 // Check that the receiver isn't a smi. |
| 1212 __ JumpIfSmi(object, slow_case); |
| 1213 |
| 1214 // Check that the key is a positive smi. |
| 1215 Condition check = masm->CheckNonNegativeSmi(key); |
| 1216 __ j(NegateCondition(check), slow_case); |
| 1217 |
| 1218 // Load the elements into scratch1 and check its map. If not, jump |
| 1219 // to the unmapped lookup with the parameter map in scratch1. |
| 1220 Handle<Map> arguments_map(heap->non_strict_arguments_elements_map()); |
| 1221 __ movq(scratch1, FieldOperand(object, JSObject::kElementsOffset)); |
| 1222 __ CheckMap(scratch1, arguments_map, slow_case, DONT_DO_SMI_CHECK); |
| 1223 |
| 1224 // Check if element is in the range of mapped arguments. |
| 1225 __ movq(scratch2, FieldOperand(scratch1, FixedArray::kLengthOffset)); |
| 1226 __ SmiSubConstant(scratch2, scratch2, Smi::FromInt(2)); |
| 1227 __ cmpq(key, scratch2); |
| 1228 __ j(greater_equal, unmapped_case); |
| 1229 |
| 1230 // Load element index and check whether it is the hole. |
| 1231 const int kHeaderSize = FixedArray::kHeaderSize + 2 * kPointerSize; |
| 1232 __ SmiToInteger64(scratch3, key); |
| 1233 __ movq(scratch2, FieldOperand(scratch1, |
| 1234 scratch3, |
| 1235 times_pointer_size, |
| 1236 kHeaderSize)); |
| 1237 __ CompareRoot(scratch2, Heap::kTheHoleValueRootIndex); |
| 1238 __ j(equal, unmapped_case); |
| 1239 |
| 1240 // Load value from context and return it. We can reuse scratch1 because |
| 1241 // we do not jump to the unmapped lookup (which requires the parameter |
| 1242 // map in scratch1). |
| 1243 __ movq(scratch1, FieldOperand(scratch1, FixedArray::kHeaderSize)); |
| 1244 __ SmiToInteger64(scratch3, scratch2); |
| 1245 return FieldOperand(scratch1, |
| 1246 scratch3, |
| 1247 times_pointer_size, |
| 1248 Context::kHeaderSize); |
| 1249 } |
| 1250 |
| 1251 |
| 1252 static Operand GenerateUnmappedArgumentsLookup(MacroAssembler* masm, |
| 1253 Register key, |
| 1254 Register parameter_map, |
| 1255 Register scratch, |
| 1256 Label* slow_case) { |
| 1257 // Element is in arguments backing store, which is referenced by the |
| 1258 // second element of the parameter_map. The parameter_map register |
| 1259 // must be loaded with the parameter map of the arguments object and is |
| 1260 // overwritten. |
| 1261 const int kBackingStoreOffset = FixedArray::kHeaderSize + kPointerSize; |
| 1262 Register backing_store = parameter_map; |
| 1263 __ movq(backing_store, FieldOperand(parameter_map, kBackingStoreOffset)); |
| 1264 __ movq(scratch, FieldOperand(backing_store, FixedArray::kLengthOffset)); |
| 1265 __ cmpq(key, scratch); |
| 1266 __ j(greater_equal, slow_case); |
| 1267 __ SmiToInteger64(scratch, key); |
| 1268 return FieldOperand(backing_store, |
| 1269 scratch, |
| 1270 times_pointer_size, |
| 1271 FixedArray::kHeaderSize); |
| 1272 } |
| 1273 |
| 1274 |
| 1275 void KeyedLoadIC::GenerateNonStrictArguments(MacroAssembler* masm) { |
| 1276 // ----------- S t a t e ------------- |
| 1277 // -- rax : key |
| 1278 // -- rdx : receiver |
| 1279 // -- rsp[0] : return address |
| 1280 // ----------------------------------- |
| 1281 Label slow, notin; |
| 1282 Operand mapped_location = |
| 1283 GenerateMappedArgumentsLookup( |
| 1284 masm, rdx, rax, rbx, rcx, rdi, ¬in, &slow); |
| 1285 __ movq(rax, mapped_location); |
| 1286 __ Ret(); |
| 1287 __ bind(¬in); |
| 1288 // The unmapped lookup expects that the parameter map is in rbx. |
| 1289 Operand unmapped_location = |
| 1290 GenerateUnmappedArgumentsLookup(masm, rax, rbx, rcx, &slow); |
| 1291 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); |
| 1292 __ j(equal, &slow); |
| 1293 __ movq(rax, unmapped_location); |
| 1294 __ Ret(); |
| 1295 __ bind(&slow); |
| 1296 GenerateMiss(masm, false); |
| 1297 } |
| 1298 |
| 1299 |
| 1300 void KeyedStoreIC::GenerateNonStrictArguments(MacroAssembler* masm) { |
| 1301 // ----------- S t a t e ------------- |
| 1302 // -- rax : value |
| 1303 // -- rcx : key |
| 1304 // -- rdx : receiver |
| 1305 // -- rsp[0] : return address |
| 1306 // ----------------------------------- |
| 1307 Label slow, notin; |
| 1308 Operand mapped_location = GenerateMappedArgumentsLookup( |
| 1309 masm, rdx, rcx, rbx, rdi, r8, ¬in, &slow); |
| 1310 __ movq(mapped_location, rax); |
| 1311 __ Ret(); |
| 1312 __ bind(¬in); |
| 1313 // The unmapped lookup expects that the parameter map is in rbx. |
| 1314 Operand unmapped_location = |
| 1315 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rdi, &slow); |
| 1316 __ movq(unmapped_location, rax); |
| 1317 __ Ret(); |
| 1318 __ bind(&slow); |
| 1319 GenerateMiss(masm, false); |
| 1320 } |
| 1321 |
| 1322 |
| 1323 void KeyedCallIC::GenerateNonStrictArguments(MacroAssembler* masm, |
| 1324 int argc) { |
| 1325 // ----------- S t a t e ------------- |
| 1326 // rcx : function name |
| 1327 // rsp[0] : return address |
| 1328 // rsp[8] : argument argc |
| 1329 // rsp[16] : argument argc - 1 |
| 1330 // ... |
| 1331 // rsp[argc * 8] : argument 1 |
| 1332 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 1333 // ----------------------------------- |
| 1334 Label slow, notin; |
| 1335 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 1336 Operand mapped_location = GenerateMappedArgumentsLookup( |
| 1337 masm, rdx, rcx, rbx, rax, r8, ¬in, &slow); |
| 1338 __ movq(rdi, mapped_location); |
| 1339 GenerateFunctionTailCall(masm, argc, &slow); |
| 1340 __ bind(¬in); |
| 1341 // The unmapped lookup expects that the parameter map is in rbx. |
| 1342 Operand unmapped_location = |
| 1343 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow); |
| 1344 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); |
| 1345 __ j(equal, &slow); |
| 1346 __ movq(rdi, unmapped_location); |
| 1347 GenerateFunctionTailCall(masm, argc, &slow); |
| 1348 __ bind(&slow); |
| 1349 GenerateMiss(masm, argc); |
| 1350 } |
| 1351 |
| 1352 |
1201 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { | 1353 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
1202 // ----------- S t a t e ------------- | 1354 // ----------- S t a t e ------------- |
1203 // -- rax : receiver | 1355 // -- rax : receiver |
1204 // -- rcx : name | 1356 // -- rcx : name |
1205 // -- rsp[0] : return address | 1357 // -- rsp[0] : return address |
1206 // ----------------------------------- | 1358 // ----------------------------------- |
1207 | 1359 |
1208 // Probe the stub cache. | 1360 // Probe the stub cache. |
1209 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, | 1361 Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, |
1210 NOT_IN_LOOP, | 1362 NOT_IN_LOOP, |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1753 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
1602 ? not_zero | 1754 ? not_zero |
1603 : zero; | 1755 : zero; |
1604 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1756 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1605 } | 1757 } |
1606 | 1758 |
1607 | 1759 |
1608 } } // namespace v8::internal | 1760 } } // namespace v8::internal |
1609 | 1761 |
1610 #endif // V8_TARGET_ARCH_X64 | 1762 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |