OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, | 1401 Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, |
1402 NOT_IN_LOOP, | 1402 NOT_IN_LOOP, |
1403 MONOMORPHIC); | 1403 MONOMORPHIC); |
1404 StubCache::GenerateProbe(masm, flags, rdx, rcx, rbx, no_reg); | 1404 StubCache::GenerateProbe(masm, flags, rdx, rcx, rbx, no_reg); |
1405 | 1405 |
1406 // Cache miss: Jump to runtime. | 1406 // Cache miss: Jump to runtime. |
1407 GenerateMiss(masm); | 1407 GenerateMiss(masm); |
1408 } | 1408 } |
1409 | 1409 |
1410 | 1410 |
| 1411 void StoreIC::GenerateArrayLength(MacroAssembler* masm) { |
| 1412 // ----------- S t a t e ------------- |
| 1413 // -- rax : value |
| 1414 // -- rcx : name |
| 1415 // -- rdx : receiver |
| 1416 // -- rsp[0] : return address |
| 1417 // ----------------------------------- |
| 1418 // |
| 1419 // This accepts as a receiver anything JSObject::SetElementsLength accepts |
| 1420 // (currently anything except for external and pixel arrays which means |
| 1421 // anything with elements of FixedArray type.), but currently is restricted |
| 1422 // to JSArray. |
| 1423 // Value must be a number, but only smis are accepted as the most common case. |
| 1424 |
| 1425 Label miss; |
| 1426 |
| 1427 Register receiver = rdx; |
| 1428 Register value = rax; |
| 1429 Register scratch = rbx; |
| 1430 |
| 1431 // Check that the receiver isn't a smi. |
| 1432 __ JumpIfSmi(receiver, &miss); |
| 1433 |
| 1434 // Check that the object is a JS array. |
| 1435 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); |
| 1436 __ j(not_equal, &miss); |
| 1437 |
| 1438 // Check that elements are FixedArray. |
| 1439 __ movq(scratch, FieldOperand(receiver, JSArray::kElementsOffset)); |
| 1440 __ CmpObjectType(scratch, FIXED_ARRAY_TYPE, scratch); |
| 1441 __ j(not_equal, &miss); |
| 1442 |
| 1443 // Check that value is a smi. |
| 1444 __ JumpIfNotSmi(value, &miss); |
| 1445 |
| 1446 // Prepare tail call to StoreIC_ArrayLength. |
| 1447 __ pop(scratch); |
| 1448 __ push(receiver); |
| 1449 __ push(value); |
| 1450 __ push(scratch); // return address |
| 1451 |
| 1452 __ TailCallRuntime(ExternalReference(IC_Utility(kStoreIC_ArrayLength)), 2, 1); |
| 1453 |
| 1454 __ bind(&miss); |
| 1455 |
| 1456 GenerateMiss(masm); |
| 1457 } |
| 1458 |
| 1459 |
1411 #undef __ | 1460 #undef __ |
1412 | 1461 |
1413 | 1462 |
1414 } } // namespace v8::internal | 1463 } } // namespace v8::internal |
OLD | NEW |